CN109298853A - A kind of message treatment method, device, electronic equipment and storage medium - Google Patents
A kind of message treatment method, device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN109298853A CN109298853A CN201811051114.3A CN201811051114A CN109298853A CN 109298853 A CN109298853 A CN 109298853A CN 201811051114 A CN201811051114 A CN 201811051114A CN 109298853 A CN109298853 A CN 109298853A
- Authority
- CN
- China
- Prior art keywords
- protocol interface
- protocol
- functional module
- message
- module
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 149
- 238000012545 processing Methods 0.000 claims abstract description 77
- OKTJSMMVPCPJKN-UHFFFAOYSA-N Carbon Chemical compound [C] OKTJSMMVPCPJKN-UHFFFAOYSA-N 0.000 claims abstract description 51
- 229910052799 carbon Inorganic materials 0.000 claims abstract description 51
- 230000006870 function Effects 0.000 claims description 100
- 230000015654 memory Effects 0.000 claims description 20
- 238000004590 computer program Methods 0.000 claims description 4
- 230000008878 coupling Effects 0.000 abstract description 14
- 238000010168 coupling process Methods 0.000 abstract description 14
- 238000005859 coupling reaction Methods 0.000 abstract description 14
- 238000011161 development Methods 0.000 abstract description 9
- 238000013461 design Methods 0.000 description 10
- 238000010586 diagram Methods 0.000 description 8
- 230000004048 modification Effects 0.000 description 8
- 238000012986 modification Methods 0.000 description 8
- 239000011800 void material Substances 0.000 description 7
- 230000005540 biological transmission Effects 0.000 description 6
- 230000008859 change Effects 0.000 description 6
- 230000008569 process Effects 0.000 description 4
- 230000001960 triggered effect Effects 0.000 description 3
- 235000010627 Phaseolus vulgaris Nutrition 0.000 description 2
- 244000046052 Phaseolus vulgaris Species 0.000 description 2
- 230000007547 defect Effects 0.000 description 2
- 230000006872 improvement Effects 0.000 description 2
- 230000009471 action Effects 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 238000004040 coloring Methods 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 238000010276 construction Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 230000005611 electricity Effects 0.000 description 1
- 238000003672 processing method Methods 0.000 description 1
- 230000009467 reduction Effects 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/20—Software design
- G06F8/24—Object-oriented
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/31—Programming languages or programming paradigms
- G06F8/315—Object-oriented languages
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/34—Graphical or visual programming
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computing Systems (AREA)
- Computer And Data Communications (AREA)
Abstract
The embodiment of the invention discloses a kind of message treatment method, device, electronic equipment and storage mediums, which comprises establishes the first protocol interface, first protocol interface is made to have the protocol method for Message Processing;First functional module inherits first protocol interface and makes carbon copies the protocol method in first protocol interface;Second protocol interface is established, and establishes the adduction relationship between the second protocol interface and first protocol interface;Second functional module inherits the second protocol interface and makes carbon copies the adduction relationship in the second protocol interface;When third functional module receives message, call the second protocol interface to trigger the protocol method made carbon copies in first functional module by second functional module, to handle the message.By using above-mentioned technical proposal, it may be implemented to reduce the degree of coupling between each module, while reducing the degree of transitivity of message, greatly improve development efficiency.
Description
Technical field
The present embodiments relate to technical field of software development more particularly to a kind of message treatment method, device electronics to set
Standby and storage medium.
Background technique
In software development and design, MVC (Model-View-Controller, model-view-control structure) frame is generallyd use
Frame carries out exploitation design to specific software, wherein model layer is responsible for the work such as the generation of message, collection, and view layer is responsible for being based on
The message carries out page presentation work, and control layer is responsible for the transmission work of message, that is, is responsible for message being transmitted to view layer.
The message is finally transferred in view layer for page presentation, and the change eventually by the view layer page is disappeared
Expense is fallen.To the treatment process of the message in traditional scheme are as follows: will be described by a series of distribution operation by messaging bus
Message is transmitted to view layer, carries out the processing operations such as parsing and page presentation to message again by view layer.But traditional scheme
Have following defects that messaging bus occupies the development of a large number of services code, and message needs could quilt by multistage circulation
It is transmitted to view layer, significantly reduces the development efficiency of code.There is a kind of improvement project in view of the foregoing drawbacks, specifically: it is logical
It crosses and establishes the adduction relationship between control layer and view layer and the adduction relationship between model layer and control layer, work as model layer
When receiving message, the operation of the Message Processing in view layer is directly triggered by calling control layer, realizes the processing to message,
So that the message no longer needs to be finally reached view layer by repeatedly distributing, reduce the degree of transitivity of message, without
Redevelopment is used for the messaging bus of message distribution, improves the development efficiency of code.
But there are another defects for above-mentioned improvement project: there are chain-types between model layer, control layer and view layer
Adduction relationship, successively quote, cause the code degree of coupling between each layer very high, and as the increase of business function will lead to
The maintainable of code is deteriorated.
Summary of the invention
The embodiment of the present invention provides a kind of message treatment method, device, electronic equipment and storage medium, passes through the method
The degree of coupling between each module can be reduced, the maintainability and scalability of service code are improved, while reducing the biography of message
Successive number reduces the complexity of message transmission, greatly improves development efficiency.
In a first aspect, the embodiment of the invention provides a kind of message treatment methods, which comprises
The first protocol interface is established, makes first protocol interface that there is the protocol method for Message Processing;
First functional module inherits first protocol interface and makes carbon copies the protocol method in first protocol interface, with
First functional module is set to have the function of service logic identical with the protocol method;
Second protocol interface is established, and establishes the pass of the reference between the second protocol interface and first protocol interface
System, to realize the protocol method in first protocol interface by the second protocol interface;
Second functional module inherits the second protocol interface and makes carbon copies the adduction relationship in the second protocol interface, with
Make the protocol method in the first protocol interface described in second Implement of Function Module;
When third functional module receives message, call the second protocol interface by second functional module
The protocol method made carbon copies in first functional module is triggered, to handle the message.
Further, described to establish the first protocol interface, make first protocol interface that there is the association for Message Processing
View method, comprising:
Define the first protocol interface;
Message processing function is defined in first protocol interface;
Wherein, the type of first protocol interface is publicly-owned type, and the type of the message processing function is publicly-owned class
Type, so that the message processing function is called by other classes.
Further, described to establish second protocol interface, and establish the second protocol interface and connect with first agreement
Adduction relationship between mouthful, to realize the protocol method in first protocol interface by the second protocol interface, comprising:
Define second protocol interface;
Function identical with the message processing function title is defined in the second protocol interface;
In the second protocol interface using the corresponding constructed fuction of the second functional module class to the Message Processing
Function initializes, to realize the protocol method in first protocol interface by the second protocol interface.
Further, described to utilize the corresponding constructed fuction pair of the second functional module class in the second protocol interface
The message processing function initializes, comprising:
Work as using the corresponding constructed fuction of the second functional module class in the second protocol interface to second function
When energy module class is initialized, the first functional module class of initialized completion is passed into the second functional module class
Object;
Alternatively, in the second protocol interface to the first function inside the corresponding constructed fuction of the second functional module class
Energy module class initializes.
Further, described when third functional module receives message, call the second protocol interface to pass through
It states the second functional module and triggers the protocol method made carbon copies in first functional module, before handling the message, the side
Method further include:
A second protocol interface object is defined in the corresponding class of the third functional module;
The second protocol interface object is carried out in the constructed fuction of the corresponding class of the third functional module initial
Change, so that the third functional module has the permission for calling the second protocol interface.
Further, described after third functional module receives message, call the second protocol interface to pass through
Before second functional module triggers the protocol method made carbon copies in first functional module, the method also includes:
Convert the message to data object corresponding with the parameter type of the message processing function.
Second aspect, the embodiment of the invention provides a kind of message processing apparatus, described device includes:
First establishes module, for establishing the first protocol interface, has first protocol interface for Message Processing
Protocol method;
First inherits module, inherits first protocol interface for the first functional module and makes carbon copies first agreement and connects
Protocol method in mouthful, so that first functional module has the function of service logic identical with the protocol method;
Second establishes module, for establishing second protocol interface, and establishes the second protocol interface and first association
The adduction relationship between interface is discussed, to realize the protocol method in first protocol interface by the second protocol interface;
Second inherits module, inherits the second protocol interface for the second functional module and makes carbon copies the second protocol and connects
Adduction relationship in mouthful, so that the protocol method in the first protocol interface described in second Implement of Function Module;
Calling module, for calling the second protocol interface to pass through when third functional module receives message
It states the second functional module and triggers the protocol method made carbon copies in first functional module, to handle the message.
The third aspect the embodiment of the invention provides a kind of electronic equipment, including memory, processor and is stored in storage
On device and the computer program that can run on a processor, the processor realizes such as above-mentioned the when executing the computer program
Message treatment method described in one side.
Fourth aspect, the embodiment of the invention provides a kind of storage medium comprising computer executable instructions, the meters
Calculation machine executable instruction realizes the message treatment method as described in above-mentioned first aspect when being executed as computer processor.
A kind of message treatment method provided in an embodiment of the present invention calls the first function by the first protocol interface of design
That makes carbon copies in module class is used to handle the protocol method of message, calls the second functional module class by design second protocol interface
The protocol method of middle manifolding, and the adduction relationship between second protocol interface and the first protocol interface is established, when third function
When module receives message, call the protocol method made carbon copies in the second functional module class to trigger first by second protocol interface
Protocol method in protocol interface, it is final to realize the agreement side for being used to handle message called and made carbon copies in the first functional module class
Method realizes the degree of coupling reduced between each module, improves the maintainability and scalability of service code, while reducing message
Degree of transitivity, reduce the complexity of message transmission, improve the purpose of code development efficiency.
Detailed description of the invention
To describe the technical solutions in the embodiments of the present invention more clearly, institute in being described below to the embodiment of the present invention
Attached drawing to be used is needed to be briefly described, it should be apparent that, the accompanying drawings in the following description is only some implementations of the invention
Example, for those of ordinary skill in the art, without creative efforts, can also implement according to the present invention
The content of example and these attached drawings obtain other attached drawings.
Fig. 1 is a kind of message treatment method flow diagram that the embodiment of the present invention one provides;
Fig. 2 is a kind of message treatment method flow diagram provided by Embodiment 2 of the present invention;
Fig. 3 is a kind of message processing apparatus structural schematic diagram that the embodiment of the present invention three provides;
Fig. 4 is the structural schematic diagram for a kind of electronic equipment that the embodiment of the present invention four provides.
Specific embodiment
To keep the technical problems solved, the adopted technical scheme and the technical effect achieved by the invention clearer, below
It will the technical scheme of the embodiment of the invention will be described in further detail in conjunction with attached drawing, it is clear that described embodiment is only
It is a part of the embodiment of the present invention, instead of all the embodiments.Based on the embodiments of the present invention, those skilled in the art exist
Every other embodiment obtained under the premise of creative work is not made, shall fall within the protection scope of the present invention.
Embodiment one
Fig. 1 is a kind of message treatment method flow diagram that the embodiment of the present invention one provides.Disappear disclosed in the present embodiment
Cease processing method be applied to android system in, can be executed by message processing apparatus, wherein the device can by software and/
Or hardware realization, and it is typically integrated in the android system for being equipped with the internal application software comprising multiple separate functional blocks
Equipment in, such as Android phone etc..Referring specifically to shown in Fig. 1, this method comprises the following steps:
110, the first protocol interface is established, makes first protocol interface that there is the protocol method for Message Processing.
Wherein, message described in the present embodiment can specifically refer to that the input of user or system are patrolled according to specific business
The message for collecting automatic trigger, in software development, it will usually special functional module is set and is used to receive message, the institute received
It is processed in specific functional module to state message needs, to realize specific service logic.Therefore, to described in traditional scheme
The treatment process of message includes: that first method is finally to transmit the message by message reception module by repeatedly transmitting
To message processing module, the needs of message described in this method are repeatedly transmitted, and lead to the code development quantitative change for message transmission
Greatly;Another method be by the adduction relationship established between each functional module so that the message by each functional module it
Between it is mutual calling be disposed off, in this method between each functional module have stronger adduction relationship, the degree of coupling is higher so that
The maintainable of service code is deteriorated.Therefore, it in order to reduce the reference each other between each functional module, dependence, reduces each
The degree of coupling between functional module, this embodiment introduces protocol interfaces, and the service logic for being used to handle message is transplanted to association
Interface is discussed, corresponding message processing function module is by inheriting the protocol interface and making carbon copies in the protocol interface for handling
The service logic of message realizes message processing function module to the processing function of message;When other functional modules need to quote
When message processing function module handles message, then the place to message directly can be realized by quoting the protocol interface
Function is managed, reduces the adduction relationship between each functional module, reduces the degree of coupling between each functional module.
The present embodiment is explained so that the message is " message of modification page layout background color " as an example.The message by
Message receiver module is received, and carries out page layout background according to the message by view controller module control view layer module
The modification of color simultaneously carries out page presentation, i.e., the described message finally needs to be handled by view layer module, to realize view layer
Module is according to the purpose of the message modification page layout background color.In traditional scheme, the view controller module and the view
There is adduction relationship between figure layer module, between the message receiver module and the view controller module there is reference to close
System, when message receiver module receives message, directly by calling view controller module to trigger the view layer module
In power function for handling message the message is handled.In order to decouple view controller module and the view layer
Adduction relationship between module, the present embodiment devise the first protocol interface.
Illustratively, described to establish the first protocol interface, make first protocol interface that there is the association for Message Processing
View method, comprising:
Define the first protocol interface;
Message processing function is defined in first protocol interface;
Wherein, the type of first protocol interface is publicly-owned type, and the type of the message processing function is publicly-owned class
Type, so that the message processing function is called by other classes.
Wherein, the first protocol interface is defined, and at the message of the first protocol interface definition " modification page layout background color "
Manage the definition method of function specifically:
Public Interface MyControllerToView{
public void onReceiveChangeBgColor(ColorBean color)
}
Entitled " MyControllerToView " of first protocol interface is used for Message Processing in first protocol interface
Protocol method be entitled " onReceiveChangeBgColor " message processing function, the type of message processing function is
Publicly-owned type, so that the message processing function can be called by other classes.The return value of the message processing function is
One void type, that is, empty return function, the parameter information of the message processing function is the number of ColorBean type
According to color, wherein the data color of ColorBean type is the message for being ultimately transferred to view layer module, view layer module
The update and modification to page layout background color can be realized using the message processing function " onReceiveChangeBgColor "
Operation.Message processing function described in view layer module " onReceiveChangeBgColor " is the common letter of a public
Number, then the message processing function can be called by view class object, when the message processing function is called just
The colouring information of view layer can be changed, that is, modify the background color of the page.In message processing function
Further by calling color.getColor () method to change to obtain needs in " onReceiveChangeBgColor "
Color colour information BgColor, then by view.setBackgroundColor (BgColor) method in view class come
Modify the Background color information of the page.Message processing function " onReceiveChangeBgColor " should be present in view layer
The corresponding view class of module, but in order to reduce the adduction relationship between each functional module, by will be at message in the present embodiment
Reason function " onReceiveChangeBgColor " is defined in the first protocol interface, when other function module needs to quote view
When message processing function in layer module, then can directly it be realized by quoting first protocol interface, while in order to guarantee
The logic function that view layer module has Message Processing is stated, then the view layer module is by inheriting first protocol interface simultaneously
The message processing function made carbon copies in first protocol interface is realized.
120, the first functional module inherits first protocol interface and makes carbon copies the agreement side in first protocol interface
Method, so that first functional module has the function of service logic identical with the protocol method.
Wherein, functional module refers to the module for realizing certain specific functions in applied software development.The first function mould
Block can be but not limited to any module in message reception module, view controller module and view layer module.The present embodiment
It is explained so that first functional module is view layer module as an example, the view layer module according to message for carrying out
Page modification and displaying operation.
Specifically, view layer module inherits described the by the method for " implements MyControllerToView "
One protocol interface simultaneously makes carbon copies the protocol method in first protocol interface, by inheriting first protocol interface and making carbon copies institute
The protocol method in the first protocol interface is stated, view layer module is then provided with business identical with the protocol method function and patrols
Volume, other function module then realizes the agreement called and made carbon copies in the view layer module by quoting first protocol interface
The purpose of method is bridged to quote between the view layer module and other function module by first protocol interface and be closed
System, reduces the direct adduction relationship between each functional module, reduces the degree of coupling between each functional module.
130, second protocol interface is established, and establishes drawing between the second protocol interface and first protocol interface
With relationship, to realize the protocol method in first protocol interface by the second protocol interface.
Wherein, the reference that the second protocol interface is used to decouple between other function module and the second functional module is closed
System, has adduction relationship between second functional module and first functional module, second functional module can be
But any module being not limited in message reception module, view controller module and view layer module, the present embodiment is with described
Two functional modules be view controller module for be explained.The view controller module is one to viewstate
The logic unit controlled is mainly used for controlling viewstate, such as control change view page color, change view
The progress etc. of progress bar in figure, i.e. view controller module are used to control the side of some Message Processings of view layer module view
Method, that is to say, that view controller module is can to control view layer module view, and this control is in service code layer
The embodiment in face is by holding view layer mould in the inside of view controller module class (class name is known as MyViewController)
Block view's constructs using relationship.The implementation method for the view controller module for specifically holding view layer module is to regard
Initialization or the view to view layer module class are realized in the constructed fuction of figure controller module class MyViewController
Layer module class holds operation.In order to reduce the degree of coupling between each functional module, the present embodiment is by view controller module pair
The relationship of holding of view layer module is transplanted in the second protocol interface, that is, establishes the second protocol interface and described first
Adduction relationship between protocol interface.
The second protocol interface is specifically used for the reference between decoupling message receiver module and view controller module
Relationship.The purpose for establishing second protocol interface will should be present in the second functional module (i.e. view controller module)
Service logic migrates to the second protocol interface, to reduce the coupling between other function module and second functional module
Degree.In the present embodiment, due to having adduction relationship between view controller module and the view layer module, in order to
It reduces the degree of coupling between view controller module and view layer module and does not influence related service in the view layer module
The adduction relationship between the second protocol interface and first protocol interface is established in the execution of logic, to pass through described the
Two protocol interfaces realize the protocol method in first protocol interface.Since the view layer module is inherited and has been made carbon copies described
Protocol method in first protocol interface, therefore work as protocol method in first protocol interface and be performed, then in the view
Figure layer inside modules realize the protocol method.
Illustratively, described to establish second protocol interface, and establish the second protocol interface and connect with first agreement
Adduction relationship between mouthful, to realize the protocol method in first protocol interface by the second protocol interface, comprising:
Define second protocol interface;
Function identical with the message processing function title is defined in the second protocol interface;
In the second protocol interface using the corresponding constructed fuction of the second functional module class to the Message Processing
Function initializes, to realize the protocol method in first protocol interface by the second protocol interface.
Second protocol interface is defined, and identical with the message processing function title in second protocol interface definition
Function, specifically:
Public interface IMsgToController{
public void onReceiveChangeBgColor(ColorBean color)
}
Wherein, the function name that entitled " IMsgToController " of the second protocol interface is defined is
" onReceiveChangeBgColor ", it is identical as the message processing function title defined in the first protocol interface.
Illustratively, described to utilize the corresponding constructed fuction pair of the second functional module class in the second protocol interface
The message processing function initializes, comprising:
Work as using the corresponding constructed fuction of the second functional module class in the second protocol interface to second function
When energy module class is initialized, the first functional module class of initialized completion is passed into the second functional module class
Object;
Alternatively, in the second protocol interface to the first function inside the corresponding constructed fuction of the second functional module class
Energy module class initializes.
Specifically, utilizing the corresponding constructed fuction pair of the view controller module class by two methods as follows
The message processing function initializes:
public void MyViewController()
public void MyViewController(View view)
Wherein, " MyViewController " is the class name of view controller module, the construction letter of above-mentioned not parameter
Number public void MyViewController () be need the inside of constructed fuction to the class of view layer module view into
The constructed fuction public void MyViewController (View view) of row initialization operation, parameter is by one
The view layer module class that initialization operation has been completed passes to view controller module MyViewController object.This two
The final target of kind building method is the application relationship for making the second protocol interface hold first protocol interface.
140, the second functional module inherits the second protocol interface and makes carbon copies the pass of the reference in the second protocol interface
System, so that the protocol method in the first protocol interface described in second Implement of Function Module.
In order to keep view controller module to the control action of view layer module, in order to make view controller module according to
So has the protocol method in the second protocol interface, view controller module is by inheriting the second protocol interface and answering
The adduction relationship write in the second protocol interface is realized.
Specifically, described in method succession of the view controller module by " implements IMsgToController "
Second protocol interface simultaneously makes carbon copies the adduction relationship in the second protocol interface, by inheriting the second protocol interface and making carbon copies
Adduction relationship in the second protocol interface, view controller module are then provided with identical as the second protocol interface function
Service logic, other function module then realizes by quoting the second protocol interface and calls the view controller module
The purpose of the protocol method of middle manifolding bridges the view controller module and other function by the second protocol interface
Adduction relationship between module reduces the direct adduction relationship between each functional module, reduces between each functional module
The degree of coupling.
150, when third functional module receives message, call the second protocol interface by second function
Module triggers the protocol method made carbon copies in first functional module, to handle the message.
Wherein, the third functional module specifically can be the message receiver module for receiving message.When described
When two protocol interfaces are called, then realize to call in the view controller module and make carbon copies protocol method, pass through the view
The protocol method made carbon copies in controller module triggers the message processing function in first protocol interface, and then realizes pair
The calling for the message processing function made carbon copies in the view layer module.
A kind of message treatment method provided in this embodiment calls the first functional module by the first protocol interface of design
That makes carbon copies in class is used to handle the protocol method of message, is called by design second protocol interface multiple in the second functional module class
The protocol method write, and the adduction relationship between second protocol interface and the first protocol interface is established, when third functional module
When receiving message, call the protocol method made carbon copies in the second functional module class to trigger the first agreement by second protocol interface
Protocol method in interface, it is final to realize the protocol method for being used to handle message for calling and making carbon copies in the first functional module class, in fact
Show the degree of coupling between each module of reduction, improved the maintainability and scalability of service code, while reducing the biography of message
Successive number reduces the complexity of message transmission, improves the purpose of code development efficiency.
Embodiment two
Fig. 2 is a kind of message treatment method flow diagram provided by Embodiment 2 of the present invention.In the base of above-described embodiment
On plinth, this gives above-mentioned steps 150 " when third functional module receives message, the second protocol to be called to connect
Mouth is to trigger the protocol method made carbon copies in first functional module by second functional module, to handle the message "
Realization process.Referring specifically to shown in Fig. 2, this method comprises the following steps:
210, the first protocol interface is established, makes first protocol interface that there is the protocol method for Message Processing.
220, the first functional module inherits first protocol interface and makes carbon copies the agreement side in first protocol interface
Method, so that first functional module has the function of service logic identical with the protocol method.
230, second protocol interface is established, and establishes drawing between the second protocol interface and first protocol interface
With relationship, to realize the protocol method in first protocol interface by the second protocol interface.
240, the second functional module inherits the second protocol interface and makes carbon copies the pass of the reference in the second protocol interface
System, so that the protocol method in the first protocol interface described in second Implement of Function Module.
250, a second protocol interface object is defined in the corresponding class of the third functional module, described the
The second protocol interface object is initialized in the constructed fuction of the corresponding class of three functional modules, so that the third function
It can permission of the module with the calling second protocol interface.
Wherein, the second protocol interface object is global variable, so that other objects can be called it, in institute
It states and defines a global variable ImsgToController in the corresponding class MsgReceiver of third functional module specifically:
private IMsgToController mIMsgToController。
To mIMsgToController object in the constructed fuction of the corresponding class MsgReceiver of third functional module
It initializes, specific initial method is by calling mIMsgToController=new
MyViewController () is realized, is disappeared by above-mentioned steps in the corresponding class MsgReceiver reception of third functional module
It the place of breath then can be directly by calling the mIMsgToControll in second protocol interface object mIMsgToController
Er.onReceiveChangeBgColor (color) realizes processing of the view layer module to message.It is connect by designing second protocol
Mouth IMsgToController is multiple in the second functional module (i.e. view controller module class MyViewController) to call
The message processing function onReceiveChangeBgColor write.Message receiver module has been decoupled by this design
Strongly reference relationship between MsgReceiver and view controller module MyViewController, improves each functional module
Between independence.
260, when message receiver receives message, the parameter with the message processing function is converted the message to
The corresponding data object of type.
For example, the message is converted into first after message receiver receives the message for changing page layout background color
Bean object, i.e., the described message processing function onReceiveChangeBgColor (ColorBean required for view is shown
Color the data object of parameter type ColorBean required for).
270, call the second protocol interface to trigger in first functional module by second functional module
The protocol method of manifolding, to handle the message.
After the message is converted into bean object required for view is shown, directly by calling second protocol interface pair
As the mIMsgToController.onReceiveChangeBgColor (color) in mIMsgToController realizes view
Processing of the figure layer module to message, at this time view controller module will automatic trigger view layer module manifolding the modification page back
The function onReceiveChangeBgColor of scape color, view layer module are achieved that the modification process of color.By multiple
The design method of protocol interface has decoupled the direct adduction relationship between each functional module, has improved between each functional module
Independence.
A kind of message treatment method provided in this embodiment, it is global by being defined in the corresponding class of message receiver module
Second protocol interface object, and to the second protocol interface pair in the constructed fuction of the corresponding class of message receiver module
As initializing, realizing can be directly by calling second protocol to connect on the ground that message receiver module receives message
The mode of mouth object calls message processing function, realizes the processing to message, and has decoupled the pass of the reference between each functional module
System improves the maintainability of service code especially when service logic increases.
Embodiment three
Fig. 3 is a kind of message processing apparatus structural schematic diagram that the embodiment of the present invention three provides.It is shown in Figure 3, it is described
Device include: first establish module 310, first inherit module 320, second establish module 330, second inherit module 340 and adjust
With module 350;
Wherein, first module 310 is established, for establishing the first protocol interface, there is first protocol interface and be used for
The protocol method of Message Processing;
First inherits module 320, inherits first protocol interface for the first functional module and makes carbon copies first association
The protocol method in interface is discussed, so that first functional module has the function of service logic identical with the protocol method;
Second establishes module 330, for establishing second protocol interface, and establishes the second protocol interface and described first
Adduction relationship between protocol interface, to realize the agreement side in first protocol interface by the second protocol interface
Method;
Second inherits module 340, inherits the second protocol interface for the second functional module and makes carbon copies second association
The adduction relationship in interface is discussed, so that the protocol method in the first protocol interface described in second Implement of Function Module;
Calling module 350, for calling the second protocol interface to pass through when third functional module receives message
Second functional module triggers the protocol method made carbon copies in first functional module, to handle the message.
Message processing apparatus provided in this embodiment is called in the first functional module class by the first protocol interface of design
Manifolding for handling the protocol method of message, called by design second protocol interface and to be made carbon copies in the second functional module class
Protocol method, and the adduction relationship between second protocol interface and the first protocol interface is established, when third functional module receives
When to message, call the protocol method made carbon copies in the second functional module class to trigger the first protocol interface by second protocol interface
In protocol method, it is final realize call made carbon copies in the first functional module class for handling the protocol method of message, realize
The degree of coupling between each module is reduced, the maintainability and scalability of service code are improved, while reducing the transmitting time of message
Number reduces the complexity of message transmission, improves the purpose of code development efficiency.
Example IV
Fig. 4 is the structural schematic diagram for a kind of electronic equipment that the embodiment of the present invention four provides.As shown in figure 4, the electronics is set
It is standby to include: processor 670, memory 671 and be stored in the computer journey that run on memory 671 and on processor 670
Sequence;Wherein, the quantity of processor 670 can be one or more, in Fig. 4 by taking a processor 670 as an example;Processor 670 is held
The message treatment method as described in above-described embodiment one is realized when the row computer program.As shown in figure 4, the electronics is set
Standby can also include input unit 672 and output device 673.Processor 670, memory 671, input unit 672 and output dress
Setting 673 can be connected by bus or other modes, in Fig. 4 for being connected by bus.
Memory 671 is used as a kind of computer readable storage medium, can be used for storing software program, journey can be performed in computer
Sequence and module, if message processing apparatus/module in the embodiment of the present invention is (for example, first establishes module 310 and second and establish mould
Block 320 etc.).Software program, instruction and the module that processor 670 is stored in memory 671 by operation, thereby executing electricity
The various function application and Message Processing of sub- equipment, that is, realize above-mentioned message treatment method.
Memory 671 can mainly include storing program area and storage data area, wherein storing program area can store operation system
Application program needed for system, at least one function;Storage data area, which can be stored, uses created data etc. according to terminal.This
Outside, memory 671 may include high-speed random access memory, can also include nonvolatile memory, for example, at least one
Disk memory, flush memory device or other non-volatile solid state memory parts.In some instances, memory 671 can be into one
Step includes the memory remotely located relative to processor 670, these remote memories can be set by network connection to electronics
Standby/storage medium.The example of above-mentioned network include but is not limited to internet, intranet, local area network, mobile radio communication and its
Combination.
Input unit 672 can be used for receiving the number or character information of input, and generates and set with the user of electronic equipment
It sets and the related key signals of function control inputs.Output device 673 may include that display screen etc. shows equipment.
Embodiment five
The embodiment of the present invention five also provides a kind of storage medium comprising computer executable instructions, and the computer can be held
Row instruction is used to execute a kind of message treatment method when being executed by computer processor, this method comprises:
The first protocol interface is established, makes first protocol interface that there is the protocol method for Message Processing;
First functional module inherits first protocol interface and makes carbon copies the protocol method in first protocol interface, with
First functional module is set to have the function of service logic identical with the protocol method;
Second protocol interface is established, and establishes the pass of the reference between the second protocol interface and first protocol interface
System, to realize the protocol method in first protocol interface by the second protocol interface;
Second functional module inherits the second protocol interface and makes carbon copies the adduction relationship in the second protocol interface, with
Make the protocol method in the first protocol interface described in second Implement of Function Module;
When third functional module receives message, call the second protocol interface by second functional module
The protocol method made carbon copies in first functional module is triggered, to handle the message.
Certainly, a kind of storage medium comprising computer executable instructions, computer provided by the embodiment of the present invention
The method operation that executable instruction is not limited to the described above, can also be performed Message Processing provided by any embodiment of the invention
Relevant operation.
By the description above with respect to embodiment, it is apparent to those skilled in the art that, the present invention
It can be realized by software and required common hardware, naturally it is also possible to which by hardware realization, but in many cases, the former is more
Good embodiment.Based on this understanding, technical solution of the present invention substantially in other words contributes to the prior art
Part can be embodied in the form of software products, which can store in computer readable storage medium
In, floppy disk, read-only memory (Read-Only Memory, ROM), random access memory (Random such as computer
Access Memory, RAM), flash memory (FLASH), hard disk or CD etc., including some instructions are with so that a computer is set
Standby (can be personal computer, storage medium or the network equipment etc.) executes described in each embodiment of the present invention.
Note that the above is only a better embodiment of the present invention and the applied technical principle.It will be appreciated by those skilled in the art that
The invention is not limited to the specific embodiments described herein, be able to carry out for a person skilled in the art it is various it is apparent variation,
It readjusts and substitutes without departing from protection scope of the present invention.Therefore, although being carried out by above embodiments to the present invention
It is described in further detail, but the present invention is not limited to the above embodiments only, without departing from the inventive concept, also
It may include more other equivalent embodiments, and the scope of the invention is determined by the scope of the appended claims.
Claims (10)
1. a kind of message treatment method characterized by comprising
The first protocol interface is established, makes first protocol interface that there is the protocol method for Message Processing;
First functional module inherits first protocol interface and makes carbon copies the protocol method in first protocol interface, so that institute
Stating the first functional module has the function of service logic identical with the protocol method;
Second protocol interface is established, and establishes the adduction relationship between the second protocol interface and first protocol interface,
To realize the protocol method in first protocol interface by the second protocol interface;
Second functional module inherits the second protocol interface and makes carbon copies the adduction relationship in the second protocol interface, so that institute
State the protocol method in the first protocol interface described in the second Implement of Function Module;
When third functional module receives message, the second protocol interface is called to trigger by second functional module
The protocol method made carbon copies in first functional module, to handle the message.
2. making first agreement the method according to claim 1, wherein described establish the first protocol interface
Interface has the protocol method for Message Processing, comprising:
Define the first protocol interface;
Message processing function is defined in first protocol interface;
Wherein, the type of first protocol interface is publicly-owned type, and the type of the message processing function is publicly-owned type, with
It is called the message processing function by other classes.
3. according to the method described in claim 2, it is characterized in that, described establish second protocol interface, and establishing described second
Adduction relationship between protocol interface and first protocol interface, to realize first association by the second protocol interface
Discuss the protocol method in interface, comprising:
Define second protocol interface;
Function identical with the message processing function title is defined in the second protocol interface;
In the second protocol interface using the corresponding constructed fuction of the second functional module class to the message processing function
It initializes, to realize the protocol method in first protocol interface by the second protocol interface.
4. according to the method described in claim 3, it is characterized in that, described utilize second function in the second protocol interface
The corresponding constructed fuction of energy module class initializes the message processing function, comprising:
Work as using the corresponding constructed fuction of the second functional module class in the second protocol interface to the second function mould
When block class is initialized, the first functional module class of initialized completion is passed to pair of the second functional module class
As;
Alternatively, in the second protocol interface to the first function mould inside the corresponding constructed fuction of the second functional module class
Block class initializes.
5. according to the method described in claim 3, it is characterized in that, described when third functional module receives message, calling
The second protocol interface to trigger the protocol method made carbon copies in first functional module by second functional module, with
Before handling the message, the method also includes:
A second protocol interface object is defined in the corresponding class of the third functional module;
The second protocol interface object is initialized in the constructed fuction of the corresponding class of the third functional module, with
Make the third functional module that there is the permission for calling the second protocol interface.
6. according to the method described in claim 5, it is characterized in that, the second protocol interface object is global variable.
7. according to the method described in claim 2, it is characterized in that, described after third functional module receives message, tune
With the second protocol interface to trigger the protocol method made carbon copies in first functional module by second functional module
Before, the method also includes:
Convert the message to data object corresponding with the parameter type of the message processing function.
8. a kind of message processing apparatus, which is characterized in that described device includes:
First establishes module, for establishing the first protocol interface, first protocol interface is made to have the association for Message Processing
View method;
First inherits module, inherits first protocol interface for the first functional module and makes carbon copies in first protocol interface
Protocol method so that first functional module has the function of service logic identical with the protocol method;
Second establishes module, for establishing second protocol interface, and establishes the second protocol interface and connects with first agreement
Adduction relationship between mouthful, to realize the protocol method in first protocol interface by the second protocol interface;
Second inherits module, inherits the second protocol interface for the second functional module and makes carbon copies in the second protocol interface
Adduction relationship so that the protocol method in the first protocol interface described in second Implement of Function Module;
Calling module, for when third functional module receives message, calling the second protocol interface by described the
Two functional modules trigger the protocol method made carbon copies in first functional module, to handle the message.
9. a kind of electronic equipment including memory, processor and stores the calculating that can be run on a memory and on a processor
Machine program, which is characterized in that the processor is realized as described in any one of claim 1-7 when executing the computer program
Message treatment method.
10. a kind of storage medium comprising computer executable instructions, the computer executable instructions are by computer disposal
Such as message treatment method of any of claims 1-7 is realized when device executes.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811051114.3A CN109298853A (en) | 2018-09-10 | 2018-09-10 | A kind of message treatment method, device, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811051114.3A CN109298853A (en) | 2018-09-10 | 2018-09-10 | A kind of message treatment method, device, electronic equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN109298853A true CN109298853A (en) | 2019-02-01 |
Family
ID=65166532
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811051114.3A Pending CN109298853A (en) | 2018-09-10 | 2018-09-10 | A kind of message treatment method, device, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109298853A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110597647A (en) * | 2019-09-16 | 2019-12-20 | 五八有限公司 | Message interception method and device, electronic equipment and storage medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20090319985A1 (en) * | 2008-06-23 | 2009-12-24 | Chengdu Huawei Symantec Technologies Co., Ltd. | Method, system and apparatus for acquiring interface |
CN107220129A (en) * | 2017-04-14 | 2017-09-29 | 武汉斗鱼网络科技有限公司 | Communication means and system between a kind of software module |
CN107391119A (en) * | 2017-06-30 | 2017-11-24 | 武汉斗鱼网络科技有限公司 | A kind of horizontal/vertical screen implementation method and device |
CN107463380A (en) * | 2017-08-01 | 2017-12-12 | 武汉斗鱼网络科技有限公司 | Message treatment method, device and electronic equipment |
-
2018
- 2018-09-10 CN CN201811051114.3A patent/CN109298853A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20090319985A1 (en) * | 2008-06-23 | 2009-12-24 | Chengdu Huawei Symantec Technologies Co., Ltd. | Method, system and apparatus for acquiring interface |
CN107220129A (en) * | 2017-04-14 | 2017-09-29 | 武汉斗鱼网络科技有限公司 | Communication means and system between a kind of software module |
CN107391119A (en) * | 2017-06-30 | 2017-11-24 | 武汉斗鱼网络科技有限公司 | A kind of horizontal/vertical screen implementation method and device |
CN107463380A (en) * | 2017-08-01 | 2017-12-12 | 武汉斗鱼网络科技有限公司 | Message treatment method, device and electronic equipment |
Non-Patent Citations (1)
Title |
---|
SNSPORTS: ""android module解耦组件化总体概述"", 《HTTPS://WWW.JIANSHU.COM/P/E03255A23083》 * |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110597647A (en) * | 2019-09-16 | 2019-12-20 | 五八有限公司 | Message interception method and device, electronic equipment and storage medium |
CN110597647B (en) * | 2019-09-16 | 2021-05-28 | 五八有限公司 | Message interception method and device, electronic equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108200170A (en) | Message treatment method, device and readable storage medium storing program for executing | |
CN109361550A (en) | The method, device and equipment of network equipments configuration management | |
CN108062230A (en) | Serial port transparent transmission and program updating system and method in Internet range | |
CN109032815A (en) | Information interacting method, device, equipment and storage medium between functional module | |
CN108023808A (en) | message distributing method and device in application program | |
US20160253304A1 (en) | Method for controlling access to electronic documents based on stateless communication | |
CN107770269B (en) | A kind of service response method and its terminal | |
CN110012002A (en) | Message parsing method, device and server, computer readable storage medium | |
WO2011137788A1 (en) | Device management method, middleware, and machine-to-machine communication platform, device and system | |
CN103176789A (en) | Method and system used for realizing function extension of open platform | |
CN1973282A (en) | System and method for managing a change to a cluster configuration | |
CN107562415A (en) | A kind of paster functional framework implementation method and equipment | |
CN102012812B (en) | Device and method for implementing application resource sharing | |
CN108306844A (en) | Telecommunication by Application Programming Interface and long-range programming | |
CN109343983A (en) | Information interacting method, device, equipment and storage medium between functional module | |
CN101615116B (en) | Method, device and system for acquiring interface | |
CN109298853A (en) | A kind of message treatment method, device, electronic equipment and storage medium | |
CN107766127A (en) | Transaction message processing method, device, equipment and system | |
CN109144750A (en) | A kind of message treatment method, device, electronic equipment and storage medium | |
CN110324722A (en) | The acquisition methods, device of data, equipment and storage medium in direct broadcasting room | |
CN109388388A (en) | Information interacting method, device, equipment and storage medium between functional module | |
TW501024B (en) | Method and apparatus for customizing and forwarding parameters in a network processor | |
CN107526644A (en) | A kind of interprocess communication system, method, computer-readable recording medium and storage control | |
CN103150162B (en) | Improve the method for embedded software code degree of share | |
CN109062620A (en) | Android frame animation executes method, apparatus, terminal and readable medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20190201 |