CN103838615A - Strategy execution method, strategy execution device and strategy execution system - Google Patents
Strategy execution method, strategy execution device and strategy execution system Download PDFInfo
- Publication number
- CN103838615A CN103838615A CN201410072394.1A CN201410072394A CN103838615A CN 103838615 A CN103838615 A CN 103838615A CN 201410072394 A CN201410072394 A CN 201410072394A CN 103838615 A CN103838615 A CN 103838615A
- Authority
- CN
- China
- Prior art keywords
- observer
- response policy
- scheduled event
- mark
- control device
- 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.)
- Granted
Links
Images
Landscapes
- Stored Programmes (AREA)
Abstract
The invention discloses a strategy execution method, a strategy execution device and a strategy execution system and belongs to the field of computers. The method includes: receiving identifications of preset events and strategy parameters corresponding to the preset events; inquiring response strategies according to corresponding relation between preset identifications and response strategies of the preset events; sending execution notifications to observer devices corresponding to the response strategies, and enabling the observer devices to execute the response strategies according to the strategy parameters. Due to the facts that after the identifications of the preset events and the strategy parameters corresponding to the preset events are received, the corresponding response strategies are inquired, the strategy parameters and the response strategies are sent to the observer devices, and the observer devices execute the response strategies according to the strategy parameters, problems of complex code structures of the observer devices and system cost increase in the prior art are resolved, and improvement of system performance and readability and maintainability of observer codes are achieved.
Description
Technical field
The present invention relates to computer realm, particularly a kind of policy execution method, Apparatus and system.
Background technology
Observer Pattern is the one of software design pattern.Under Observer Pattern, observed person's device is corresponding to one or more observer's devices, and in the time of observed person's device generation scheduled event, observer's device can be carried out corresponding response policy according to this scheduled event.
Taking Android system as example, under existing Observer Pattern, observer's device is registered to control device, in the time of observed person's device generation scheduled event, sends mark and the correlation parameter of this scheduled event to control device.Control device receives after the mark and correlation parameter of this scheduled event, by Intent, the mark of this scheduled event and correlation parameter is passed to observer's device.Observer's device is inquired about corresponding response policy according to the mark of this scheduled event, and carries out this response policy according to this correlation parameter.
Realizing in process of the present invention, inventor finds that prior art at least exists following problem:
Under existing Observer Pattern, first, transmit data and need to carry out the process of serializing and unserializing by Intent, and the certain system overhead of this process need consumption affects system performance; Secondly, observer's device need to be inquired about corresponding response policy according to the mark of scheduled event, thereby causes the code structure of observer's device more complicated, affects the readable and maintainable of code.
Summary of the invention
In prior art, to transmit data by Intent and need to carry out the increase system overhead that the process of serializing and unserializing causes in order to solve, affect the problem of system performance and observer's device and need to inquire about according to the mark of scheduled event the code structure complexity of observer's device that corresponding response policy causes, impact readability and maintainable problem, the embodiment of the present invention provides a kind of policy execution method, Apparatus and system.Described technical scheme is as follows:
On the one hand, provide the policy execution method under a kind of Observer Pattern, for control device, described method comprises:
Receive mark and the policing parameter corresponding with described scheduled event of scheduled event;
Inquire about described response policy according to the corresponding relation between mark and the response policy of the described scheduled event of setting up in advance;
Send and carry out notice to observer's device corresponding to described response policy, in described execution notice, include described policing parameter and described response policy, described execution notice is used to indicate described observer's device and carries out described response policy according to described policing parameter.
Before the mark of described reception scheduled event and the policing parameter corresponding with described scheduled event, comprising:
Receive the registration request that described observer's device sends;
Travel through by Java reflex mechanism in the source code of described observer's device, comprise can implementation strategy;
Detect described can implementation strategy whether the Java that should have predefined type note;
If testing result is described can implementation strategy correspondence have the Java of described predefined type to explain, can implementation strategy be retrieved as described response policy by described, and from the attribute of described can implementation strategy corresponding Java note, obtains the mark of described scheduled event;
Set up the corresponding relation between mark and the described response policy of described scheduled event.
Described method also comprises:
Receive the request of cancelling that described observer's device sends;
Corresponding relation between the mark of described scheduled event and described response policy is deleted.
On the other hand, provide the policy execution method under a kind of Observer Pattern, for observer's device, described method comprises:
The execution notice that receiving control device sends, includes policing parameter and the response policy corresponding with described observer's device in described execution notice; Described execution notice is mark and the described policing parameter of described control device reception scheduled event, and inquires according to the corresponding relation between mark and the described response policy of the described scheduled event of setting up in advance the notice sending after described response policy;
Carry out described response policy according to described policing parameter.
Before the execution notice that described receiving control device sends, also comprise:
Send registration request to described control device, described registration request be used to indicate in described control device travels through described observer's device source code by Java reflex mechanism, comprise can implementation strategy, and can implementation strategy correspondence have after the Java note of described predefined type described in detecting, can implementation strategy be retrieved as described response policy by described, and obtain the mark of described scheduled event the attribute of explaining from described can implementation strategy corresponding Java, and set up the corresponding relation between mark and the described response policy of described scheduled event.
Described method also comprises:
Send to described control device the request of cancelling, described in cancel request and be used to indicate described control device by the corresponding relation deletion between the mark of described scheduled event and described response policy.
On the one hand, provide the control device under a kind of Observer Pattern again, described device comprises:
The first receiver module, for receiving the mark of scheduled event and the policing parameter corresponding with described scheduled event;
Enquiry module, for inquiring about described response policy according to the corresponding relation between mark and the response policy of the described scheduled event of setting up in advance;
Notice sending module, for sending and carry out notice to observer's device corresponding to described response policy, in described execution notice, include described policing parameter and described response policy, described execution notice is used to indicate described observer's device and carries out described response policy according to described policing parameter.
Described device comprises:
Registration request receiver module, before receiving the mark and the policing parameter corresponding with described scheduled event of scheduled event at described the first receiver module, receives the registration request that described observer's device sends;
Spider module, can implementation strategy for what travel through by Java reflex mechanism that the source code of described observer's device comprises;
Whether detection module, can implementation strategy explain the Java that should have predefined type for detection of described;
The first acquisition module, if can implementation strategy correspondence have the Java of described predefined type to explain described in for the testing result of described detection module being, can implementation strategy be retrieved as described response policy by described;
The second acquisition module if be described can implementation strategy correspondence have the Java of described predefined type to explain for the testing result of described detection module, obtains the mark of described scheduled event from the described attribute of can Java corresponding to implementation strategy explaining;
Set up module, for setting up the corresponding relation between mark and the described response policy of described scheduled event.
Described device also comprises:
Cancel request receiving module, the request of cancelling sending for receiving described observer's device;
Removing module, for deleting the corresponding relation between the mark of described scheduled event and described response policy.
Another aspect, provides the observer under a kind of Observer Pattern device, and described device comprises:
Notice receiver module, the execution sending for receiving control device notice, includes policing parameter and the response policy corresponding with described observer's device in described execution notice; Described execution notice is mark and the described policing parameter of described control device reception scheduled event, and inquires according to the corresponding relation between mark and the described response policy of the described scheduled event of setting up in advance the notice sending after described response policy;
Execution module, for carrying out described response policy according to described policing parameter.
Described device also comprises:
Registration request sending module, before the execution notice sending at described notice receiver module receiving control device, send registration request to described control device, described registration request be used to indicate in described control device travels through described observer's device source code by Java reflex mechanism, comprise can implementation strategy, and can implementation strategy correspondence have after the Java note of described predefined type described in detecting, can implementation strategy be retrieved as described response policy by described, and the attribute of explaining from described can implementation strategy corresponding Java, obtain the mark of described scheduled event, and set up the corresponding relation between mark and the described response policy of described scheduled event.
Described device also comprises:
Cancel request sending module, for sending to described control device the request of cancelling, described in cancel request and be used to indicate described control device by the corresponding relation deletion between the mark of described scheduled event and described response policy.
Another aspect, provides the system of the strategy execution under a kind of Observer Pattern, and described system comprises:
Control device as above and observer's device.
The beneficial effect that the technical scheme that the embodiment of the present invention provides is brought is:
By receiving after the mark and the policing parameter corresponding with this scheduled event of scheduled event, inquire about this response policy according to the corresponding relation between mark and the response policy of this scheduled event of setting up in advance, and send the execution notice that includes this policing parameter and this response policy to observer's device corresponding to this response policy, carry out this response policy by observer's device according to this policing parameter, do not need to transmit data by Intent, do not need observer's device to inquire about corresponding response policy according to the mark of scheduled event yet, solve the problem that increases the problem of system overhead and the code structure complexity of observer's device in prior art, reach and improve system performance and observer's code readability and maintainable effect.
Brief description of the drawings
In order to be illustrated more clearly in the technical scheme in the embodiment of the present invention, below the accompanying drawing of required use during embodiment is described is briefly described, apparently, accompanying drawing in the following describes is only some embodiments of the present invention, for those of ordinary skill in the art, do not paying under the prerequisite of creative work, can also obtain according to these accompanying drawings other accompanying drawing.
Fig. 1 is the method flow diagram of the policy execution method that provides of one embodiment of the invention;
Fig. 2 is the method flow diagram of the policy execution method that provides of another embodiment of the present invention;
Fig. 3 is the method flow diagram of the policy execution method that provides of one embodiment of the invention;
Fig. 4 is the method flow diagram of the policy execution method that provides of another embodiment of the present invention;
Fig. 5 is the method flow diagram of the policy execution method that provides of one embodiment of the invention;
Fig. 6 is the structure drawing of device of the control device that provides of one embodiment of the invention;
Fig. 7 is the structure drawing of device of the control device that provides of another embodiment of the present invention;
Fig. 8 is the structure drawing of device of observer's device of providing of one embodiment of the invention;
Fig. 9 is the structure drawing of device of observer's device of providing of another embodiment of the present invention;
Figure 10 is the system pie graph of the strategy execution system that provides of one embodiment of the invention.
Embodiment
For making the object, technical solutions and advantages of the present invention clearer, below in conjunction with accompanying drawing, embodiment of the present invention is described further in detail.
Please refer to Fig. 1, it shows the method flow diagram of the policy execution method that one embodiment of the invention provides.This policy execution method is for the control device under Observer Pattern.This policy execution method can comprise:
In sum, the policy execution method that the embodiment of the present invention provides, by receiving after the mark and the policing parameter corresponding with this scheduled event of scheduled event, inquire about this response policy according to the corresponding relation between mark and the response policy of this scheduled event of setting up in advance, and send the execution notice that includes this policing parameter and this response policy to observer's device corresponding to this response policy, carry out this response policy by observer's device according to this policing parameter, do not need to transmit data by Intent, do not need observer's device to inquire about corresponding response policy according to the mark of scheduled event yet, solve the problem that increases the problem of system overhead and the code structure complexity of observer's device in prior art, reach and improve system performance and observer's code readability and maintainable effect.
Please refer to Fig. 2, it shows the method flow diagram of the policy execution method that another embodiment of the present invention provides.This policy execution method is for the control device under Observer Pattern.Be designed to example with the control device under this Observer Pattern and observer's device based on Java language, this policy execution method can comprise:
Under Observer Pattern, observer's device, before carrying out corresponding response policy according to scheduled event, first needs to send registration request to control device and registers.
Be designed to example with observer's device based on Java language, developer can write executable strategy in the source code of observer's device, be called again method (Method), these methods (Method) can be in the time that observer's device moves, and the source code that is traveled through this observer's device by Java reflex mechanism by other program obtains.
And Java note is the another kind of special mechanism in Java, it can make in Java source code not only to comprise functional code, can also add metadata.In Java source code, Java explains with the form of "@explains name " and exists.In the time of exploitation observer device, by observer's device, the response policy under Observer Pattern writes source code with the form of method (Method) to developer, and the mark of scheduled event corresponding this response policy is write in the attribute of note of the predefined type that this response policy is corresponding.
Control device is receiving after the registration request of observer's device transmission, can travel through comprise in the source code of this observer's device all by Java reflex mechanism can implementation strategy, and detect these and can implementation strategy whether the Java that should have predefined type be explained, detect whether this note name of can Java corresponding to implementation strategy explaining is the note name of being scheduled to.
Please refer to code snippet as follows:
Wherein, NotificationID is the note name of being scheduled to, onSampleID is can implementation strategy, control device get can implementation strategy onSampleID after, corresponding note of explaining NotificationID by name detected, this onSampleID is retrieved as to this response policy, and the metadata comprising in the attribute of@NotificationID is retrieved as to the mark of the scheduled event that this response policy is corresponding.
Concrete, control device can be by the mark corresponding stored of this response policy and this observer's device, sets up the corresponding relation between the mark of mark, this response policy and this observer's device of this scheduled event simultaneously.
Wherein, this scheduled event is the event of observed person's device, and observed person is set to send to control device mark and the policing parameter corresponding to this scheduled event of this scheduled event in the time there is this scheduled event.
Wherein, this response policy is the object reference of can observed person's device directly carrying out, and observer's device receives after this execution notice, can directly carry out this response policy according to this policing parameter.
Taking this observed person's device as downloading process, observer's device is show process, the download that scheduled event has been file, this scheduled event be designated 1, this policing parameter is the memory address of the file downloaded, and this response policy is to show that the file in this memory address is example.First show process initiates registration to control device, control device obtains mark and this response policy of this scheduled event from the source code of show process by Java emission mechanism, and set up the mark of mark, this response policy and this show process of this scheduled event, such as the corresponding relation between the interface IP address of this show process.After downloading process has been downloaded certain file, send the mark 1 of this scheduled event and the memory address of this file to control device, after control device inquires this response policy and is the file showing in this memory address according to the mark 1 of this scheduled event, the interface IP address that the memory address of this file and this response policy is sent to this show process, show process shows this file according to this memory address.In the time that show process no longer needs to show the file that downloading process downloaded, can send and cancel request to control device, control device be inquired about the corresponding relation between the mark of mark, this response policy and this show process of this scheduled event and is deleted according to the mark of this show process.
In sum, the policy execution method that the embodiment of the present invention provides, by receiving after the mark and the policing parameter corresponding with this scheduled event of scheduled event, inquire about this response policy according to the corresponding relation between mark and the response policy of this scheduled event of setting up in advance, and send the execution notice that includes this policing parameter and this response policy to observer's device corresponding to this response policy, carry out this response policy by observer's device according to this policing parameter, it is the object reference that control device can directly call observer's device, observer's device no longer needs to judge whether voluntarily to carry out this response policy according to the mark of this scheduled event, thereby reach the code structure of simplifying observer's device, improve code readability and maintainable effect.
In addition, the policy execution method that the embodiment of the present invention provides, can directly policing parameter and response policy be sent to observer's device, do not need data to carry out serializing, solve the problem that increases the increase system overhead that the serializing of data causes in prior art, reached the effect that improves system performance.
Please refer to Fig. 3, it shows the method flow diagram of the policy execution method that one embodiment of the invention provides.This policy execution method is for the observer's device under Observer Pattern.This policy execution method can comprise:
In sum, the policy execution method that the embodiment of the present invention provides, mark and this policing parameter by receiving control device at reception scheduled event, and inquire according to the corresponding relation between mark and this response policy of this scheduled event of setting up in advance the notice sending after this response policy, and carry out this response policy according to this policing parameter, do not need to transmit data by Intent, do not need observer's device to inquire about corresponding response policy according to the mark of scheduled event yet, solve the problem that increases the problem of system overhead and the code structure complexity of observer's device in prior art, reach and improve system performance and observer's code readability and maintainable effect.
Please refer to Fig. 4, it shows the method flow diagram of the policy execution method that another embodiment of the present invention provides.This policy execution method is for the observer's device under Observer Pattern.Be designed to example with the control device under this Observer Pattern and observer's device based on Java language, this policy execution method can comprise:
This registration request be used to indicate in this control device travels through this observer's device source code by Java reflex mechanism, comprise can implementation strategy, and detect this can implementation strategy to after should having the Java of this predefined type to explain, this can implementation strategy be retrieved as to this response policy, and obtain the mark of this scheduled event the attribute of explaining from this can implementation strategy corresponding Java, and set up the corresponding relation between mark and this response policy of this scheduled event.
Wherein, this control device obtains mark and this response policy of this scheduled event by Java reflex mechanism, and the concrete steps of setting up the corresponding relation between mark and this response policy of this scheduled event please refer to middle step 204 embodiment illustrated in fig. 2 to the description under step 208, repeat no more herein.
Wherein, this execution notice is mark and this policing parameter of this control device reception scheduled event, and inquires according to the corresponding relation between mark and this response policy of this scheduled event of setting up in advance the notice sending after this response policy.
Wherein, this response policy is the object reference of can observed person's device directly carrying out, and observer's device receives after this execution notice, can directly carry out this response policy according to this policing parameter.
This is cancelled request and is used to indicate this control device by the corresponding relation deletion between the mark of this scheduled event and this response policy.
Taking this observed person's device as downloading process, observer's device is show process, the download that scheduled event has been file, this scheduled event be designated 1, this policing parameter is the memory address of the file downloaded, and this response policy is to show that the file in this memory address is example.First show process initiates registration to control device, control device obtains mark and this response policy of this scheduled event from the source code of show process, and set up the mark of mark, this response policy and this show process of this scheduled event, such as the corresponding relation between the interface IP address of this show process.Control device is follow-up to be received after the mark 1 of this scheduled event and the memory address of the file that download apparatus is downloaded of download apparatus transmission, and after inquiring this response policy and be the file showing in this memory address according to the mark 1 of this scheduled event, the interface IP address that the memory address of this file and this response policy is sent to this show process, show process shows this file according to this memory address.In the time that show process no longer needs to show the file that downloading process downloaded, can send and cancel request to control device, control device be inquired about the corresponding relation between the mark of mark, this response policy and this show process of this scheduled event and is deleted according to the mark of this show process.
In sum, the policy execution method that the embodiment of the present invention provides, mark and this policing parameter by receiving control device at reception scheduled event, and inquire according to the corresponding relation between mark and this response policy of this scheduled event of setting up in advance the notice sending after this response policy, and carry out this response policy according to this policing parameter, do not need to transmit data by Intent, do not need observer's device to inquire about corresponding response policy according to the mark of scheduled event yet, solve the problem that increases the problem of system overhead and the code structure complexity of observer's device in prior art, reach and improve system performance and observer's code readability and maintainable effect.
Please refer to Fig. 5, it shows the method flow diagram of the policy execution method that one embodiment of the invention provides.This policy execution method is for tactful executive system under Observer Pattern, and this system comprises observer's device and control device.Be designed to example with the control device under this Observer Pattern and observer's device based on Java language, this policy execution method can comprise:
Step 502, observer's device sends registration request to control device;
Under Observer Pattern, observer's device, before carrying out corresponding response policy according to scheduled event, first needs to send registration request to control device and registers.
Step 504, control device travel through by Java reflex mechanism in the source code of this observer's device, comprise can implementation strategy, detect this and can implementation strategy whether the Java that should have predefined type be explained;
Be designed to example with observer's device based on Java language, developer can write executable strategy in the source code of observer's device, be called again method (Method), these methods (Method) can be in the time that observer's device moves, and the source code that is traveled through this observer's device by Java reflex mechanism by other program obtains.
And Java note is the another kind of special mechanism in Java, it can make in Java source code not only to comprise functional code, can also add metadata.In Java source code, Java explains with the form of "@explains name " and exists.In the time of exploitation observer device, by observer's device, the response policy under Observer Pattern writes source code with the form of method (Method) to developer, and the mark of scheduled event corresponding this response policy is write in the attribute of note of the predefined type that this response policy is corresponding.
Control device is receiving after the registration request of observer's device transmission, can travel through comprise in the source code of this observer's device all by Java reflex mechanism can implementation strategy, and detect these and can implementation strategy whether the Java that should have predefined type be explained, detect whether this note name of can Java corresponding to implementation strategy explaining is the note name of being scheduled to.
Step 506, if being this, testing result can the Java that should have this predefined type be explained implementation strategy, control device can implementation strategy be retrieved as this response policy by this, and the attribute of explaining from this can implementation strategy corresponding Java, obtains the mark of this scheduled event;
Please refer to code snippet as follows:
Wherein, NotificationID is the note name of being scheduled to, onSampleID is can implementation strategy, control device get can implementation strategy onSampleID after, corresponding note of explaining NotificationID by name detected, this onSampleID is retrieved as to this response policy, and the metadata comprising in the attribute of@NotificationID is retrieved as to the mark of the scheduled event that this response policy is corresponding.
Step 508, control device is set up the corresponding relation between mark and this response policy of this scheduled event;
Concrete, control device can be by the mark corresponding stored of this response policy and this observer's device, sets up the corresponding relation between the mark of mark, this response policy and this observer's device of this scheduled event simultaneously.
Step 510, control device receives the mark of this scheduled event and the policing parameter corresponding with this scheduled event;
Wherein, this scheduled event is the event of observed person's device, and observed person is set to send to control device mark and the policing parameter corresponding to this scheduled event of this scheduled event in the time there is this scheduled event.
Step 512, control device is inquired about this response policy according to the corresponding relation between the mark of this scheduled event and response policy, and sends and carry out notice to this observer's device;
In this execution notice, include this policing parameter and this response policy.
Step 514, observer's device is carried out this response policy according to this policing parameter;
Wherein, this response policy is the object reference of can observed person's device directly carrying out, and observer's device receives after this execution notice, can directly carry out this response policy according to this policing parameter.
Step 516, observer's device sends to this control device the request of cancelling;
In the time that observer's device is no longer carried out corresponding response policy according to scheduled event, can send the request of cancelling to control device.
Step 518, control device is deleted the corresponding relation between the mark of this scheduled event and this response policy.
Taking this observed person's device as downloading process, observer's device is show process, the download that scheduled event has been file, this scheduled event be designated 1, this policing parameter is the memory address of the file downloaded, and this response policy is to show that the file in this memory address is example.First show process initiates registration to control device, control device obtains mark and this response policy of this scheduled event from the source code of show process by Java emission mechanism, and set up the mark of mark, this response policy and this show process of this scheduled event, such as the corresponding relation between the interface IP address of this show process.After downloading process has been downloaded certain file, send the mark 1 of this scheduled event and the memory address of this file to control device, after control device inquires this response policy and is the file showing in this memory address according to the mark 1 of this scheduled event, the interface IP address that the memory address of this file and this response policy is sent to this show process, show process shows this file according to this memory address.In the time that show process no longer needs to show the file that downloading process downloaded, can send and cancel request to control device, control device be inquired about the corresponding relation between the mark of mark, this response policy and this show process of this scheduled event and is deleted according to the mark of this show process.
In sum, the policy execution method that the embodiment of the present invention provides, control device is receiving after the mark and the policing parameter corresponding with this scheduled event of scheduled event, inquire about this response policy according to the corresponding relation between mark and the response policy of this scheduled event of setting up in advance, and send the execution notice that includes this policing parameter and this response policy to observer's device corresponding to this response policy, carry out this response policy by observer's device according to this policing parameter, it is the object reference that control device can directly call observer's device, observer's device no longer needs to judge whether voluntarily to carry out this response policy according to the mark of this scheduled event, thereby reach the code structure of simplifying observer's device, improve code readability and maintainable effect.
In addition, the policy execution method that the embodiment of the present invention provides, control device can directly send to observer's device by policing parameter and response policy, do not need data to carry out serializing, solve the problem that increases the increase system overhead that the serializing of data causes in prior art, reached the effect that improves system performance.
Please refer to Fig. 6, it shows the structure drawing of device of the control device that one embodiment of the invention provides.This control device can be for carrying out method as shown in Figure 1 or 2 under Observer Pattern.This control device can comprise:
The first receiver module 601, for receiving the mark of scheduled event and the policing parameter corresponding with described scheduled event;
Notice sending module 603, for sending and carry out notice to observer's device corresponding to described response policy, in described execution notice, include described policing parameter and described response policy, described execution notice is used to indicate described observer's device and carries out described response policy according to described policing parameter.
In sum, the control device that the embodiment of the present invention provides, by receiving after the mark and the policing parameter corresponding with this scheduled event of scheduled event, inquire about this response policy according to the corresponding relation between mark and the response policy of this scheduled event of setting up in advance, and send the execution notice that includes this policing parameter and this response policy to observer's device corresponding to this response policy, carry out this response policy by observer's device according to this policing parameter, do not need to transmit data by Intent, do not need observer's device to inquire about corresponding response policy according to the mark of scheduled event yet, solve the problem that increases the problem of system overhead and the code structure complexity of observer's device in prior art, reach and improve system performance and observer's code readability and maintainable effect.
Please refer to Fig. 7, it shows the structure drawing of device of the control device that another embodiment of the present invention provides.This control device can be for carrying out method as shown in Figure 1 or 2 under Observer Pattern.This control device can comprise:
The first receiver module 701, for receiving the mark of scheduled event and the policing parameter corresponding with described scheduled event;
Enquiry module 702, for inquiring about described response policy according to the corresponding relation between mark and the response policy of the described scheduled event of setting up in advance;
Notice sending module 703, for sending and carry out notice to observer's device corresponding to described response policy, in described execution notice, include described policing parameter and described response policy, described execution notice is used to indicate described observer's device and carries out described response policy according to described policing parameter.
Described device also comprises:
Registration request receiver module 704, for receive the mark of scheduled event and the policing parameter corresponding with described scheduled event at described the first receiver module 701 before, receives the registration request that described observer's device sends;
Spider module 705, can implementation strategy for what travel through by Java reflex mechanism that the source code of described observer's device comprises;
Whether detection module 706, can implementation strategy explain the Java that should have predefined type for detection of described;
The first acquisition module 707, if can implementation strategy correspondence have the Java of described predefined type to explain described in for the testing result of described detection module 706 being, can implementation strategy be retrieved as described response policy by described;
The second acquisition module 708 if be described can implementation strategy correspondence have the Java of described predefined type to explain for the testing result of described detection module 706, obtains the mark of described scheduled event from the described attribute of can Java corresponding to implementation strategy explaining;
Set up module 709, for setting up the corresponding relation between mark and the described response policy of described scheduled event.
Described device also comprises:
Cancel request receiving module 710, the request of cancelling sending for receiving described observer's device;
Removing module 711, for deleting the corresponding relation between the mark of described scheduled event and described response policy.
In sum, the control device that the embodiment of the present invention provides, by receiving after the mark and the policing parameter corresponding with this scheduled event of scheduled event, inquire about this response policy according to the corresponding relation between mark and the response policy of this scheduled event of setting up in advance, and send the execution notice that includes this policing parameter and this response policy to observer's device corresponding to this response policy, carry out this response policy by observer's device according to this policing parameter, it is the object reference that control device can directly call observer's device, observer's device no longer needs to judge whether voluntarily to carry out this response policy according to the mark of this scheduled event, thereby reach the code structure of simplifying observer's device, improve code readability and maintainable effect.
In addition, the control device that the embodiment of the present invention provides, can directly policing parameter and response policy be sent to observer's device, do not need data to carry out serializing, solve the problem that increases the increase system overhead that the serializing of data causes in prior art, reached the effect that improves system performance.
Please refer to Fig. 8, it shows the structure drawing of device of observer's device that one embodiment of the invention provides.This observer's device can be for carrying out method as shown in Figure 3 or Figure 4 under Observer Pattern.This control device can comprise:
Notice receiver module 801, the execution sending for receiving control device notice, includes policing parameter and the response policy corresponding with described observer's device in described execution notice; Described execution notice is mark and the described policing parameter of described control device reception scheduled event, and inquires according to the corresponding relation between mark and the described response policy of the described scheduled event of setting up in advance the notice sending after described response policy;
Execution module 802, for carrying out described response policy according to described policing parameter.
In sum, observer's device that the embodiment of the present invention provides, mark and this policing parameter by receiving control device at reception scheduled event, and inquire according to the corresponding relation between mark and this response policy of this scheduled event of setting up in advance the notice sending after this response policy, and carry out this response policy according to this policing parameter, do not need to transmit data by Intent, do not need observer's device to inquire about corresponding response policy according to the mark of scheduled event yet, solve the problem that increases the problem of system overhead and the code structure complexity of observer's device in prior art, reach and improve system performance and observer's code readability and maintainable effect.
Please refer to Fig. 9, it shows the structure drawing of device of observer's device that another embodiment of the present invention provides.This observer's device can be for carrying out method as shown in Figure 3 or Figure 4 under Observer Pattern.This control device can comprise:
Described device also comprises:
Registration request sending module 903, before the execution notice sending at described notice receiver module 901 receiving control devices, send registration request to described control device, described registration request be used to indicate in described control device travels through described observer's device source code by Java reflex mechanism, comprise can implementation strategy, and can implementation strategy correspondence have after the Java note of described predefined type described in detecting, can implementation strategy be retrieved as described response policy by described, and the attribute of explaining from described can implementation strategy corresponding Java, obtain the mark of described scheduled event, and set up the corresponding relation between mark and the described response policy of described scheduled event.
Described device also comprises:
Cancel request sending module 904, for sending to described control device the request of cancelling, described in cancel request and be used to indicate described control device by the corresponding relation deletion between the mark of described scheduled event and described response policy.
In sum, observer's device that the embodiment of the present invention provides, mark and this policing parameter by receiving control device at reception scheduled event, and inquire according to the corresponding relation between mark and this response policy of this scheduled event of setting up in advance the notice sending after this response policy, and carry out this response policy according to this policing parameter, do not need to transmit data by Intent, do not need observer's device to inquire about corresponding response policy according to the mark of scheduled event yet, solve the problem that increases the problem of system overhead and the code structure complexity of observer's device in prior art, reach and improve system performance and observer's code readability and maintainable effect.
Please refer to Figure 10, it shows the system pie graph of the strategy execution system that one embodiment of the invention provides.This strategy execution system can be for carrying out policy execution method as shown in Figure 5 under Observer Pattern.This system can comprise:
In sum, the strategy execution system that the embodiment of the present invention provides, control device is receiving after the mark and the policing parameter corresponding with this scheduled event of scheduled event, inquire about this response policy according to the corresponding relation between mark and the response policy of this scheduled event of setting up in advance, and send the execution notice that includes this policing parameter and this response policy to observer's device corresponding to this response policy, carry out this response policy by observer's device according to this policing parameter, it is the object reference that control device can directly call observer's device, observer's device no longer needs to judge whether voluntarily to carry out this response policy according to the mark of this scheduled event, thereby reach the code structure of simplifying observer's device, improve code readability and maintainable effect.
In addition, the strategy execution system that the embodiment of the present invention provides, control device can directly send to observer's device by policing parameter and response policy, do not need data to carry out serializing, solve the problem that increases the increase system overhead that the serializing of data causes in prior art, reached the effect that improves system performance.
It should be noted that: the control device that above-described embodiment provides and observer's device are in the time carrying out response policy, only be illustrated with the division of above-mentioned each functional module, in practical application, can above-mentioned functions be distributed and completed by different functional modules as required, be divided into different functional modules by the inner structure of device, to complete all or part of function described above.In addition, the embodiment of the control device that above-described embodiment provides and observer's device and policy execution method belongs to same design, and its specific implementation process refers to embodiment of the method, repeats no more here.
The invention described above embodiment sequence number, just to describing, does not represent the quality of embodiment.
One of ordinary skill in the art will appreciate that all or part of step that realizes above-described embodiment can complete by hardware, also can carry out the hardware that instruction is relevant by program completes, described program can be stored in a kind of computer-readable recording medium, the above-mentioned storage medium of mentioning can be ROM (read-only memory), disk or CD etc.
The foregoing is only preferred embodiment of the present invention, in order to limit the present invention, within the spirit and principles in the present invention not all, any amendment of doing, be equal to replacement, improvement etc., within all should being included in protection scope of the present invention.
Claims (13)
1. the policy execution method under Observer Pattern, for control device, is characterized in that, described method comprises:
Receive mark and the policing parameter corresponding with described scheduled event of scheduled event;
Inquire about described response policy according to the corresponding relation between mark and the response policy of the described scheduled event of setting up in advance;
Send and carry out notice to observer's device corresponding to described response policy, in described execution notice, include described policing parameter and described response policy, described execution notice is used to indicate described observer's device and carries out described response policy according to described policing parameter.
2. method according to claim 1, is characterized in that, before the mark of described reception scheduled event and the policing parameter corresponding with described scheduled event, comprising:
Receive the registration request that described observer's device sends;
Travel through by Java reflex mechanism in the source code of described observer's device, comprise can implementation strategy;
Detect described can implementation strategy whether the Java that should have predefined type note;
If testing result is described can implementation strategy correspondence have the Java of described predefined type to explain, can implementation strategy be retrieved as described response policy by described, and from the attribute of described can implementation strategy corresponding Java note, obtains the mark of described scheduled event;
Set up the corresponding relation between mark and the described response policy of described scheduled event.
3. method according to claim 1, is characterized in that, described method also comprises:
Receive the request of cancelling that described observer's device sends;
Corresponding relation between the mark of described scheduled event and described response policy is deleted.
4. the policy execution method under Observer Pattern, for observer's device, is characterized in that, described method comprises:
The execution notice that receiving control device sends, includes policing parameter and the response policy corresponding with described observer's device in described execution notice; Described execution notice is mark and the described policing parameter of described control device reception scheduled event, and inquires according to the corresponding relation between mark and the described response policy of the described scheduled event of setting up in advance the notice sending after described response policy;
Carry out described response policy according to described policing parameter.
5. method according to claim 4, is characterized in that, before the execution notice that described receiving control device sends, also comprises:
Send registration request to described control device, described registration request be used to indicate in described control device travels through described observer's device source code by Java reflex mechanism, comprise can implementation strategy, and can implementation strategy correspondence have after the Java note of described predefined type described in detecting, can implementation strategy be retrieved as described response policy by described, and obtain the mark of described scheduled event the attribute of explaining from described can implementation strategy corresponding Java, and set up the corresponding relation between mark and the described response policy of described scheduled event.
6. method according to claim 4, is characterized in that, described method also comprises:
Send to described control device the request of cancelling, described in cancel request and be used to indicate described control device by the corresponding relation deletion between the mark of described scheduled event and described response policy.
7. the control device under Observer Pattern, is characterized in that, described device comprises:
The first receiver module, for receiving the mark of scheduled event and the policing parameter corresponding with described scheduled event;
Enquiry module, for inquiring about described response policy according to the corresponding relation between mark and the response policy of the described scheduled event of setting up in advance;
Notice sending module, for sending and carry out notice to observer's device corresponding to described response policy, in described execution notice, include described policing parameter and described response policy, described execution notice is used to indicate described observer's device and carries out described response policy according to described policing parameter.
8. device according to claim 7, is characterized in that, described device comprises:
Registration request receiver module, before receiving the mark and the policing parameter corresponding with described scheduled event of scheduled event at described the first receiver module, receives the registration request that described observer's device sends;
Spider module, can implementation strategy for what travel through by Java reflex mechanism that the source code of described observer's device comprises;
Whether detection module, can implementation strategy explain the Java that should have predefined type for detection of described;
The first acquisition module, if can implementation strategy correspondence have the Java of described predefined type to explain described in for the testing result of described detection module being, can implementation strategy be retrieved as described response policy by described;
The second acquisition module if be described can implementation strategy correspondence have the Java of described predefined type to explain for the testing result of described detection module, obtains the mark of described scheduled event from the described attribute of can Java corresponding to implementation strategy explaining;
Set up module, for setting up the corresponding relation between mark and the described response policy of described scheduled event.
9. device according to claim 7, is characterized in that, described device also comprises:
Cancel request receiving module, the request of cancelling sending for receiving described observer's device;
Removing module, for deleting the corresponding relation between the mark of described scheduled event and described response policy.
10. the observer's device under Observer Pattern, is characterized in that, described device comprises:
Notice receiver module, the execution sending for receiving control device notice, includes policing parameter and the response policy corresponding with described observer's device in described execution notice; Described execution notice is mark and the described policing parameter of described control device reception scheduled event, and inquires according to the corresponding relation between mark and the described response policy of the described scheduled event of setting up in advance the notice sending after described response policy;
Execution module, for carrying out described response policy according to described policing parameter.
11. devices according to claim 10, is characterized in that, described device also comprises:
Registration request sending module, before the execution notice sending at described notice receiver module receiving control device, send registration request to described control device, described registration request be used to indicate in described control device travels through described observer's device source code by Java reflex mechanism, comprise can implementation strategy, and can implementation strategy correspondence have after the Java note of described predefined type described in detecting, can implementation strategy be retrieved as described response policy by described, and the attribute of explaining from described can implementation strategy corresponding Java, obtain the mark of described scheduled event, and set up the corresponding relation between mark and the described response policy of described scheduled event.
12. devices according to claim 10, is characterized in that, described device also comprises:
Cancel request sending module, for sending to described control device the request of cancelling, described in cancel request and be used to indicate described control device by the corresponding relation deletion between the mark of described scheduled event and described response policy.
Strategy execution system under 13. 1 kinds of Observer Patterns, is characterized in that, described system comprises:
Control device as described in as arbitrary in claim 7 to 9 and as arbitrary in claim 10 to 12 as described in observer's device.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410072394.1A CN103838615B (en) | 2014-02-28 | 2014-02-28 | Strategy execution method, strategy execution device and strategy execution system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410072394.1A CN103838615B (en) | 2014-02-28 | 2014-02-28 | Strategy execution method, strategy execution device and strategy execution system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN103838615A true CN103838615A (en) | 2014-06-04 |
CN103838615B CN103838615B (en) | 2017-05-17 |
Family
ID=50802148
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410072394.1A Active CN103838615B (en) | 2014-02-28 | 2014-02-28 | Strategy execution method, strategy execution device and strategy execution system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103838615B (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107608608A (en) * | 2017-09-25 | 2018-01-19 | 浙江科澜信息技术有限公司 | A kind of information interacting method, the apparatus and system of three-dimensional graphics renderer engine |
CN108762943A (en) * | 2018-03-22 | 2018-11-06 | 武汉斗鱼网络科技有限公司 | Obtain method, terminal device and the storage medium of the internal realization process of notice |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6782541B1 (en) * | 1999-05-28 | 2004-08-24 | Avaya Technology Corp. | System and method of exchanging information between software modules |
CN101639774B (en) * | 2009-08-31 | 2012-06-27 | 腾讯科技(深圳)有限公司 | Encapsulation method of browser control part and device thereof |
US8612932B2 (en) * | 2010-04-18 | 2013-12-17 | Voxeo Corporation | Unified framework and method for call control and media control |
-
2014
- 2014-02-28 CN CN201410072394.1A patent/CN103838615B/en active Active
Non-Patent Citations (1)
Title |
---|
NUDGE: "《java学习脚印: 设计模式之观察者模式 JAVA事件委托》", 《HTTP://WWW.XUEBUYUAN.COM/1853477.HTML》 * |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107608608A (en) * | 2017-09-25 | 2018-01-19 | 浙江科澜信息技术有限公司 | A kind of information interacting method, the apparatus and system of three-dimensional graphics renderer engine |
CN107608608B (en) * | 2017-09-25 | 2021-01-26 | 浙江科澜信息技术有限公司 | Information interaction method, device and system of three-dimensional graphic rendering engine |
CN108762943A (en) * | 2018-03-22 | 2018-11-06 | 武汉斗鱼网络科技有限公司 | Obtain method, terminal device and the storage medium of the internal realization process of notice |
Also Published As
Publication number | Publication date |
---|---|
CN103838615B (en) | 2017-05-17 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9111091B2 (en) | Automatic extraction, modeling, and code mapping of application user interface display screens and components | |
US9258775B1 (en) | Location-based software updates | |
CN110096424B (en) | Test processing method and device, electronic equipment and storage medium | |
US10462261B2 (en) | System and method for configuring a data access system | |
CN105204875B (en) | The method and system of webpage calling native function | |
CN108876619B (en) | Processing method, device, equipment and medium based on block chain intelligent contract | |
CN112118318B (en) | Vehicle upgrading method, terminal device, vehicle and computer storage medium | |
US11650888B2 (en) | Workflow error handling for device driven management | |
CN104216748A (en) | Application program installation method, device and system | |
CN103984556A (en) | Map area construction device, method and monitor terminal | |
EP3313041A1 (en) | Application download method and device | |
CN104504587A (en) | Advertisement monitoring method and device, electronic apparatus | |
US20170351503A1 (en) | Method and system for installing software | |
CN106713608A (en) | Application function state modifying method and apparatus, and terminal | |
CN107193565B (en) | Method for developing native APP (application) across mobile terminals | |
US20210006643A1 (en) | Information display method, terminal, and server | |
CN107704499A (en) | A kind of page jump control method and device of application program | |
CN105988841A (en) | Update method of application program, and mobile terminal | |
CN104536752A (en) | Method and device for automatically generating APK files | |
CN106598662B (en) | Android-based application loading method and device | |
CN113760339A (en) | Vulnerability repair method and device | |
CN106201584B (en) | Version upgrading method and terminal device | |
CN103838615A (en) | Strategy execution method, strategy execution device and strategy execution system | |
CN110968147B (en) | Timer creating method and device, electronic equipment and medium | |
CN115437696B (en) | Self-adaptive configuration method and device for trusted platform |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
CB02 | Change of applicant information | ||
CB02 | Change of applicant information |
Address after: 511446 Guangzhou City, Guangdong Province, Panyu District, South Village, Huambo Business District Wanda Plaza, block B1, floor 28 Applicant after: Guangzhou Huaduo Network Technology Co., Ltd. Address before: 510655, Guangzhou, Whampoa Avenue, No. 2, creative industrial park, building 3-08, Applicant before: Guangzhou Huaduo Network Technology Co., Ltd. |
|
GR01 | Patent grant | ||
GR01 | Patent grant |