CN103838615B - Strategy execution method, strategy execution device and strategy execution system - Google Patents

Strategy execution method, strategy execution device and strategy execution system Download PDF

Info

Publication number
CN103838615B
CN103838615B CN201410072394.1A CN201410072394A CN103838615B CN 103838615 B CN103838615 B CN 103838615B CN 201410072394 A CN201410072394 A CN 201410072394A CN 103838615 B CN103838615 B CN 103838615B
Authority
CN
China
Prior art keywords
observer
mark
response policy
scheduled event
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.)
Active
Application number
CN201410072394.1A
Other languages
Chinese (zh)
Other versions
CN103838615A (en
Inventor
许铎
张旺辉
贺灏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Huaduo Network Technology Co Ltd
Original Assignee
Guangzhou Huaduo Network Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Guangzhou Huaduo Network Technology Co Ltd filed Critical Guangzhou Huaduo Network Technology Co Ltd
Priority to CN201410072394.1A priority Critical patent/CN103838615B/en
Publication of CN103838615A publication Critical patent/CN103838615A/en
Application granted granted Critical
Publication of CN103838615B publication Critical patent/CN103838615B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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

Policy execution method, apparatus and system
Technical field
The present invention relates to computer realm, more particularly to a kind of policy execution method, apparatus and system.
Background technology
Observer Pattern is one kind of software design pattern.Under Observer Pattern, observed person's device is corresponded to One or more observer's devices, when observed person's device occurs scheduled event, observer's device can be according to the predetermined thing Part performs corresponding response policy.
By taking Android system as an example, under existing Observer Pattern, observer's device is registered to control device, works as quilt When observer's device occurs scheduled event, to control device the mark and relevant parameter of the scheduled event are sent.Control device connects After receiving the mark and relevant parameter of the scheduled event, the mark and relevant parameter of the scheduled event are passed to by Intent Observer's device.Observer's device inquires about corresponding response policy according to the mark of the scheduled event, and according to the relevant parameter Perform the response policy.
During the present invention is realized, inventor has found that prior art at least has problems with:
Under existing Observer Pattern, first, transmitting data by Intent needs to carry out serializing and unserializing Process, and the process needs to consume certain overhead, affects systematic function;Secondly, observer's device is needed according to predetermined The mark of event inquires about corresponding response policy, so as to cause the code structure of observer's device more complicated, affects code It is readable and maintainable.
The content of the invention
In in order to solve prior art by Intent transmit data need carry out serialize and unserializing process and Caused increase overhead, affecting the problem and observer's device of systematic function needs to be inquired about according to the mark of scheduled event The code structure complexity of corresponding response policy and caused observer's device, affects readable and maintainable problem, originally Inventive embodiments provide a kind of policy execution method, apparatus and system.The technical scheme is as follows:
On the one hand, there is provided the policy execution method under a kind of Observer Pattern, in control device, methods described bag Include:
Receive the mark and the policing parameter corresponding with the scheduled event of scheduled event;
The response is inquired about according to the corresponding relation between the mark and response policy of the scheduled event for pre-building Strategy;
Send to the corresponding observer's device of the response policy and perform notice, described execution in notice includes the plan Parameter and the response policy are omited, the execution is notified for indicating that observer's device performs institute according to the policing parameter State response policy.
Before the mark and the policing parameter corresponding with the scheduled event for receiving scheduled event, including:
Receive the registration request that observer's device sends;
The executable strategy included in the source code that observer's device is traveled through by Java reflex mechanisms;
Detect whether the Java to there is predefined type is explained the executable strategy;
If testing result is the Java that the executable strategy correspondence has the predefined type explaining, will be described executable Strategy is retrieved as obtaining the predetermined thing in the response policy, and the attribute explained from the executable tactful corresponding Java The mark of part;
The corresponding relation set up between the mark of the scheduled event and the response policy.
Methods described also includes:
Receive the revocation request that observer's device sends;
Corresponding relation between the mark and the response policy of the scheduled event is deleted.
On the other hand, there is provided the policy execution method under a kind of Observer Pattern, in for observer's device, the side Method includes:
What receiving control device sent performs notices, it is described perform include in notice policing parameter and with the observation The corresponding response policy of person's device;It is described to perform the mark and the strategy for notifying to receive scheduled event for the control device Parameter, and according to the corresponding relation between the mark and the response policy of the scheduled event for pre-building is inquired The notice sent after response policy;
The response policy is performed according to the policing parameter.
Before the execution that the receiving control device sends is notified, also include:
Registration request is sent to the control device, the registration request is used to indicate that the control device is anti-by Java The executable strategy included in the source code for penetrating mechanism traversal observer's device, and detecting the executable strategy correspondence After the Java for having the predefined type is explained, the executable strategy is retrieved as into the response policy, and be can perform from described The mark of the scheduled event is obtained in the attribute that the corresponding Java of strategy is explained, and sets up mark and the institute of the scheduled event State the corresponding relation between response policy.
Methods described also includes:
Revocation request is sent to the control device, the revocation request will be described predetermined for indicating the control device Corresponding relation between the mark of event and the response policy is deleted.
Another further aspect, there is provided a kind of control device under Observer Pattern, described device includes:
First receiver module, for receiving the mark and the strategy ginseng corresponding with the scheduled event of scheduled event Number;
Enquiry module, for the corresponding relation between the mark and response policy according to the scheduled event for pre-building Inquire about the response policy;
Sending module is notified, for sending to the corresponding observer's device of the response policy notice, the execution are performed Include the policing parameter and the response policy in notice, the execution notify for indicate observer's device according to The policing parameter performs the response policy.
Described device includes:
Registration request receiver module, for receiving the mark of scheduled event and pre- with described in first receiver module Before determining the corresponding policing parameter of event, the registration request that observer's device sends is received;
Spider module, for the executable plan included in the source code that observer's device is traveled through by Java reflex mechanisms Slightly;
Detection module, for detecting whether the Java to there is predefined type is explained the executable strategy;
First acquisition module, if the testing result for the detection module has described pre- for the executable strategy correspondence The Java for determining type is explained, then the executable strategy is retrieved as into the response policy;
Second acquisition module, if the testing result for the detection module has described pre- for the executable strategy correspondence The Java for determining type is explained, then the mark of the scheduled event is obtained in the attribute explained from the executable tactful corresponding Java Know;
Module is set up, for setting up the corresponding relation between the mark of the scheduled event and the response policy.
Described device also includes:
Revocation request receiving module, for receiving the revocation request that observer's device sends;
Removing module, deletes for the corresponding relation between the mark and the response policy by the scheduled event.
Another aspect, there is provided a kind of observer's device under Observer Pattern, described device includes:
Receiver module is notified, for what receiving control device sent notice is performed, described execution in notice includes strategy Parameter and response policy corresponding with observer's device;Described execution notifies to receive scheduled event for the control device Mark and the policing parameter, and according to the scheduled event for pre-building mark and the response policy between Corresponding relation inquires the notice sent after the response policy;
Performing module, for performing the response policy according to the policing parameter.
Described device also includes:
Registration request sending module, the execution for sending in the notice receiver module receiving control device notifies it Before, registration request is sent to the control device, the registration request is used to indicate that the control device reflects machine by Java The executable strategy included in the source code of system traversal observer's device, and detecting the executable strategy correspondence After stating the Java notes of predefined type, the executable strategy is retrieved as into the response policy, and from the executable strategy The mark of the scheduled event is obtained in the attribute that corresponding Java is explained, and sets up the mark and the sound of the scheduled event Answer the corresponding relation between strategy.
Described device also includes:
Revocation request sending module, it is described to cancel request for indicating for sending revocation request to the control device The control device deletes the corresponding relation between the mark and the response policy of the scheduled event.
Another aspect, there is provided a kind of strategy execution system under Observer Pattern, the system includes:
Control device as above and observer's device.
The beneficial effect that technical scheme provided in an embodiment of the present invention is brought is:
By after the mark and the policing parameter corresponding with the scheduled event that receive scheduled event, according to building in advance Corresponding relation between the mark and response policy of the vertical scheduled event inquires about the response policy, and to the response policy correspondence Observer's device send include the policing parameter and the response policy perform notice, by observer's device according to the strategy Parameter performs the response policy, it is not necessary to transmit data by Intent, it is not required that observer's device is according to scheduled event The corresponding response policy of mark inquiry, solves the problems, such as the code for increasing overhead and observer's device in prior art Baroque problem, reaches and improves the readable and maintainable effect of systematic function and observer's code.
Description of the drawings
Technical scheme in order to be illustrated more clearly that the embodiment of the present invention, below will be to making needed for embodiment description Accompanying drawing is briefly described, it should be apparent that, drawings in the following description are only some embodiments of the present invention, for For those of ordinary skill in the art, on the premise of not paying creative work, can be obtaining other according to these accompanying drawings Accompanying drawing.
Fig. 1 is the method flow diagram of the policy execution method that one embodiment of the invention is provided;
Fig. 2 is the method flow diagram of the policy execution method that another embodiment of the present invention is provided;
Fig. 3 is the method flow diagram of the policy execution method that one embodiment of the invention is provided;
Fig. 4 is the method flow diagram of the policy execution method that another embodiment of the present invention is provided;
Fig. 5 is the method flow diagram of the policy execution method that one embodiment of the invention is provided;
Fig. 6 is the structure drawing of device of the control device that one embodiment of the invention is provided;
Fig. 7 is the structure drawing of device of the control device that another embodiment of the present invention is provided;
Fig. 8 is the structure drawing of device of observer's device that one embodiment of the invention is provided;
Fig. 9 is the structure drawing of device of observer's device that another embodiment of the present invention is provided;
Figure 10 is the system pie graph of the strategy execution system that one embodiment of the invention is provided.
Specific embodiment
To make the object, technical solutions and advantages of the present invention clearer, below in conjunction with accompanying drawing to embodiment party of the present invention Formula is described in further detail.
Fig. 1 is refer to, the method flow diagram of the policy execution method of one embodiment of the invention offer is provided.The plan In slightly performing the control device that method is used under Observer Pattern.The policy execution method can include:
Step 102, receives the mark and the policing parameter corresponding with the scheduled event of scheduled event;
Step 104, should according to the corresponding relation inquiry between the mark and response policy of the scheduled event for pre-building Response policy;
Step 106, sends to the corresponding observer's device of the response policy and performs notice, and the execution includes this in notifying Policing parameter and the response policy, the execution is notified for indicating that observer's device performs the response plan according to the policing parameter Slightly.
In sum, policy execution method provided in an embodiment of the present invention, by receive scheduled event mark and After the policing parameter corresponding with the scheduled event, according between the mark and response policy of the scheduled event for pre-building Corresponding relation inquires about the response policy, and includes the policing parameter to the corresponding observer's device transmission of the response policy and be somebody's turn to do Response policy performs notice, performs the response policy according to the policing parameter by observer's device, it is not necessary to by Intent Transmission data, it is not required that observer's device inquires about corresponding response policy according to the mark of scheduled event, solves existing skill Increase the problem of the problem of overhead and the code structure complexity of observer's device in art, reach raising systematic function and sight The readable and maintainable effect of the person's of examining code.
Fig. 2 is refer to, the method flow diagram of the policy execution method of another embodiment of the present invention offer is provided.The plan In slightly performing the control device that method is used under Observer Pattern.With the control device under the Observer Pattern and observer's device As a example by based on Java language design, the policy execution method can include:
Step 202, receives the registration request that observer's device sends;
Under Observer Pattern, observer's device was needed first before corresponding response policy is performed according to scheduled event Registration request is sent to control device to be registered.
Step 204, the executable strategy included in the source code that observer's device is traveled through by Java reflex mechanisms, detection Java of the executable strategy whether to there is predefined type is explained;
So that observer's device is based on Java language design as an example, developer can write in the source code of observer's device can The strategy of execution, is also called method(Method), these methods(Method)Can be in observer's plant running, by other journeys Sequence is obtained by the source code that Java reflex mechanisms travel through observer's device.
And Java notes are another kind of special mechanisms in Java, it can make not only include function in Java source codes Property realizes code, can also add metadata.In Java source codes, Java is explained in the form of "@explains name ".Opening When sending out observer's device, response policy of the developer by observer's device under Observer Pattern is in method(Method)Shape Formula writes source code, and the mark of the corresponding scheduled event of the response policy is write into the note of the corresponding predefined type of the response policy In the attribute of solution.
Control device can be somebody's turn to do after the registration request for receiving the transmission of observer's device by Java reflex mechanisms traversal The all of executable strategy included in the source code of observer's device, and detect these executable strategies whether to there is predetermined class The Java of type is explained, that is, detect whether the note name that the executable tactful corresponding Java is explained is predetermined note name.
Step 206, if testing result is the executable strategy, the Java to there is the predefined type is explained, and this can be held Row strategy is retrieved as obtaining the scheduled event in the response policy, and the attribute explained from the executable tactful corresponding Java Mark;
Refer to code snippet as follows:
Wherein, NotificationID is predetermined note name, and onSampleID is executable strategy, and control device is obtained To after executable tactful onSampleID, the entitled NotificationID of note of correspondence note is detected, then should OnSampleID is retrieved as the response policy, and the metadata included in the attribute of@NotificationID is retrieved as into the sound Answer the mark of tactful corresponding scheduled event.
Step 208, the corresponding relation set up between the mark of the scheduled event and the response policy;
Specifically, control device can store the mark of the response policy and observer's device correspondence, while building Corresponding relation between the mark of the mark, the response policy and observer's device of founding the scheduled event.
Step 210, receives the mark and the policing parameter corresponding with the scheduled event of the scheduled event;
Wherein, the scheduled event is the event that observed person's device occurs, and observed person is arranged to occurring that this is pre- The mark and the corresponding policing parameter of the scheduled event of the scheduled event are sent when determining event to control device.
Step 212, should according to the corresponding relation inquiry between the mark and response policy of the scheduled event for pre-building Response policy, and notice is performed to observer's device transmission, the execution includes the policing parameter and the response plan in notifying Slightly;
Wherein, the response policy can be the object reference that observed person's device is directly performed, and observer's device is received After the execution is notified, directly the response policy can be performed according to the policing parameter.
Step 214, receives the revocation request that observer's device sends, by the mark of the scheduled event and the response plan Corresponding relation between slightly is deleted.
With observed person's device as downloading process, observer's device is show process, and scheduled event is to complete file Download, the scheduled event is designated 1, the policing parameter is the storage address for downloading the file for completing, and the response policy is aobvious As a example by showing the file in the storage address.Show process initiates to register first to control device, and control device is launched by Java Mechanism obtains the mark of the scheduled event and the response policy from the source code of show process, and sets up the mark of the scheduled event The mark of knowledge, the response policy and the show process, such as the corresponding relation between the interface IP address of the show process.Instantly It is loaded into journey download to complete after certain file, to control device the mark 1 of the scheduled event and the storage address of this document is sent, It is to show after the file in the storage address, by this that control device inquires the response policy according to the mark 1 of the scheduled event The storage address of file and the response policy are sent to the interface IP address of the show process, and show process is aobvious according to the storage address Show this document.When show process no longer needs to show that downloading process downloads the file for completing, can send to control device and remove Pin request, control device inquires about mark, the response policy and display of the scheduled event according to the mark of the show process Corresponding relation between the mark of process is simultaneously deleted.
In sum, policy execution method provided in an embodiment of the present invention, by receive scheduled event mark and After the policing parameter corresponding with the scheduled event, according between the mark and response policy of the scheduled event for pre-building Corresponding relation inquires about the response policy, and includes the policing parameter to the corresponding observer's device transmission of the response policy and be somebody's turn to do Response policy performs notice, and perform the response policy, i.e. control device according to the policing parameter by observer's device can be straight The object reference for calling observer's device is connect, observer's device no longer needs voluntarily to judge whether according to the mark of the scheduled event The response policy is performed, so as to reach the code structure of simplified observer's device, the readable and maintainable effect of code is improved Really.
Additionally, policy execution method provided in an embodiment of the present invention, directly can send policing parameter and response policy Give observer's device, it is not necessary to which data are serialized, solve and increase caused by the serializing for increasing data in prior art The problem of adding system expense, reaches the effect for improving systematic function.
Fig. 3 is refer to, the method flow diagram of the policy execution method of one embodiment of the invention offer is provided.The plan In slightly performing observer's device that method is used under Observer Pattern.The policy execution method can include:
Step 302, what receiving control device sent performs notices, include in the execution notice policing parameter and with this The corresponding response policy of observer's device;The execution notifies the mark and the strategy ginseng for receiving scheduled event for the control device Number, and the response policy is inquired according to the corresponding relation between the mark and the response policy of the scheduled event for pre-building The notice for sending afterwards;
Step 304, according to the policing parameter response policy is performed.
In sum, policy execution method provided in an embodiment of the present invention, by receiving control device predetermined thing is being received The mark of part and the policing parameter, and according to the scheduled event for pre-building mark with it is corresponding between the response policy The notice that relational query sends to after the response policy, and the response policy is performed according to the policing parameter, it is not necessary to pass through Intent transmits data, it is not required that observer's device inquires about corresponding response policy according to the mark of scheduled event, solves Increase the problem of the problem of overhead and the code structure complexity of observer's device in prior art, reach raising systematicness Can be with the readable effect with maintainability of observer's code.
Fig. 4 is refer to, the method flow diagram of the policy execution method of another embodiment of the present invention offer is provided.The plan In slightly performing observer's device that method is used under Observer Pattern.Filled with the control device under the Observer Pattern and observer As a example by putting based on Java language design, the policy execution method can include:
Step 402, to control device registration request is sent;
The registration request is used to indicate in the source code that the control device travels through observer's device by Java reflex mechanisms Comprising executable strategy, and detect this it is executable strategy to should have the predefined type Java explain after, this can be held Row strategy is retrieved as obtaining the scheduled event in the response policy, and the attribute explained from the executable tactful corresponding Java Mark, and the corresponding relation set up between the mark of the scheduled event and the response policy.
Wherein, the control device obtains the mark and the response policy of the scheduled event by Java reflex mechanisms, and builds The concrete steps for founding the corresponding relation between the mark of the scheduled event and the response policy refer to step in embodiment illustrated in fig. 2 Description under rapid 204 to step 208, here is omitted.
Step 404, what receiving control device sent performs notices, include in the execution notice policing parameter and with sight The corresponding response policy of the person's of examining device;
Wherein, the execution notifies the mark and the policing parameter for receiving scheduled event for the control device, and according to pre- Corresponding relation between the mark of the scheduled event first set up and the response policy inquires send after the response policy logical Know.
Step 406, according to the policing parameter response policy is performed;
Wherein, the response policy can be the object reference that observed person's device is directly performed, and observer's device is received After the execution is notified, directly the response policy can be performed according to the policing parameter.
Step 408, to the control device revocation request is sent;
The revocation ask for indicate the control device by the scheduled event mark with it is corresponding between the response policy Relation is deleted.
With observed person's device as downloading process, observer's device is show process, and scheduled event is to complete file Download, the scheduled event is designated 1, the policing parameter is the storage address for downloading the file for completing, and the response policy is aobvious As a example by showing the file in the storage address.Show process initiates to register first to control device, and control device is from show process Obtain the mark and the response policy of the scheduled event in source code, and set up the mark of the scheduled event, the response policy with And the mark of the show process, such as the corresponding relation between the interface IP address of the show process.Control device is subsequently being received After the storage address of the file that the mark 1 and download apparatus of the scheduled event sent to download apparatus is downloaded, and according to this It is to show after the file in the storage address, by the storage address of this document that the mark 1 of scheduled event inquires the response policy Send with the response policy to the interface IP address of the show process, show process shows this document according to the storage address.When aobvious When showing that process no longer needs to show that downloading process downloads the file for completing, revocation request, control dress can be sent to control device Put according to the show process mark inquire about the scheduled event mark, between the response policy and the mark of the show process Corresponding relation and delete.
In sum, policy execution method provided in an embodiment of the present invention, by receiving control device predetermined thing is being received The mark of part and the policing parameter, and according to the scheduled event for pre-building mark with it is corresponding between the response policy The notice that relational query sends to after the response policy, and the response policy is performed according to the policing parameter, it is not necessary to pass through Intent transmits data, it is not required that observer's device inquires about corresponding response policy according to the mark of scheduled event, solves Increase the problem of the problem of overhead and the code structure complexity of observer's device in prior art, reach raising systematicness Can be with the readable effect with maintainability of observer's code.
Fig. 5 is refer to, the method flow diagram of the policy execution method of one embodiment of the invention offer is provided.The plan Slightly performing method is used under Observer Pattern in tactful execution system, and the system includes observer's device and control device.With this As a example by control device and observer's device under Observer Pattern is based on Java language design, the policy execution method can be wrapped Include:
Step 502, observer's device to control device sends registration request;
Under Observer Pattern, observer's device was needed first before corresponding response policy is performed according to scheduled event Registration request is sent to control device to be registered.
Step 504, control device travels through include in the source code of observer's device executable by Java reflex mechanisms Strategy, detects whether the Java to there is predefined type is explained the executable strategy;
So that observer's device is based on Java language design as an example, developer can write in the source code of observer's device can The strategy of execution, is also called method(Method), these methods(Method)Can be in observer's plant running, by other journeys Sequence is obtained by the source code that Java reflex mechanisms travel through observer's device.
And Java notes are another kind of special mechanisms in Java, it can make not only include function in Java source codes Property realizes code, can also add metadata.In Java source codes, Java is explained in the form of "@explains name ".Opening When sending out observer's device, response policy of the developer by observer's device under Observer Pattern is in method(Method)Shape Formula writes source code, and the mark of the corresponding scheduled event of the response policy is write into the note of the corresponding predefined type of the response policy In the attribute of solution.
Control device can be somebody's turn to do after the registration request for receiving the transmission of observer's device by Java reflex mechanisms traversal The all of executable strategy included in the source code of observer's device, and detect these executable strategies whether to there is predetermined class The Java of type is explained, that is, detect whether the note name that the executable tactful corresponding Java is explained is predetermined note name.
Step 506, if testing result is the executable strategy, the Java to there is the predefined type is explained, control device The executable strategy is retrieved as into the response policy, and it is pre- to obtain this from the attribute of executable tactful corresponding Java notes Determine the mark of event;
Refer to code snippet as follows:
Wherein, NotificationID is predetermined note name, and onSampleID is executable strategy, and control device is obtained To after executable tactful onSampleID, the entitled NotificationID of note of correspondence note is detected, then should OnSampleID is retrieved as the response policy, and the metadata included in the attribute of@NotificationID is retrieved as into the sound Answer the mark of tactful corresponding scheduled event.
Step 508, the corresponding relation that control device is set up between the mark of the scheduled event and the response policy;
Specifically, control device can store the mark of the response policy and observer's device correspondence, while building Corresponding relation between the mark of the mark, the response policy and observer's device of founding the scheduled event.
Step 510, control device receives the mark of the scheduled event and the policing parameter corresponding with the scheduled event;
Wherein, the scheduled event is the event that observed person's device occurs, and observed person is arranged to occurring that this is pre- The mark and the corresponding policing parameter of the scheduled event of the scheduled event are sent when determining event to control device.
Step 512, control device inquires about the sound according to the corresponding relation between the mark and response policy of the scheduled event Should be tactful, and perform notice to observer's device transmission;
The execution includes the policing parameter and the response policy in notifying.
Step 514, observer's device performs the response policy according to the policing parameter;
Wherein, the response policy can be the object reference that observed person's device is directly performed, and observer's device is received After the execution is notified, directly the response policy can be performed according to the policing parameter.
Step 516, observer's device to control device sends revocation request;
When observer's device does not perform corresponding response policy further according to scheduled event, can send to control device and remove Pin request.
Step 518, control device deletes the corresponding relation between the mark and the response policy of the scheduled event.
With observed person's device as downloading process, observer's device is show process, and scheduled event is to complete file Download, the scheduled event is designated 1, the policing parameter is the storage address for downloading the file for completing, and the response policy is aobvious As a example by showing the file in the storage address.Show process initiates to register first to control device, and control device is launched by Java Mechanism obtains the mark of the scheduled event and the response policy from the source code of show process, and sets up the mark of the scheduled event The mark of knowledge, the response policy and the show process, such as the corresponding relation between the interface IP address of the show process.Instantly It is loaded into journey download to complete after certain file, to control device the mark 1 of the scheduled event and the storage address of this document is sent, It is to show after the file in the storage address, by this that control device inquires the response policy according to the mark 1 of the scheduled event The storage address of file and the response policy are sent to the interface IP address of the show process, and show process is aobvious according to the storage address Show this document.When show process no longer needs to show that downloading process downloads the file for completing, can send to control device and remove Pin request, control device inquires about mark, the response policy and display of the scheduled event according to the mark of the show process Corresponding relation between the mark of process is simultaneously deleted.
In sum, policy execution method provided in an embodiment of the present invention, control device is receiving the mark of scheduled event And after the policing parameter corresponding with the scheduled event, according to the mark of the scheduled event for pre-building and response policy it Between corresponding relation inquire about the response policy, and send to the corresponding observer's device of the response policy and include the policing parameter Notice is performed with the response policy, perform the response policy, i.e. control device according to the policing parameter by observer's device can To directly invoke the object reference of observer's device, observer's device no longer needs voluntarily to be judged according to the mark of the scheduled event The response policy whether is performed, so as to reach the code structure of simplified observer's device, code is improved readable and maintainable Effect.
Additionally, policy execution method provided in an embodiment of the present invention, control device can directly by policing parameter and response Strategy is sent to observer's device, it is not necessary to which data are serialized, and solving increases the serializing of data in prior art The caused problem for increasing overhead, reaches the effect for improving systematic function.
Fig. 6 is refer to, the structure drawing of device of the control device of one embodiment of the invention offer is provided.The control dress Put and can be used for performing method as shown in Figure 1 or 2 under Observer Pattern.The control device can include:
First receiver module 601, for receiving the mark and the strategy corresponding with the scheduled event of scheduled event Parameter;
Enquiry module 602, for corresponding between the mark and response policy according to the scheduled event for pre-building Response policy described in relational query;
Sending module 603 is notified, for sending to the corresponding observer's device of the response policy notice is performed, it is described to hold Row includes the policing parameter and the response policy in notifying, the execution is notified for indicating observer's device root The response policy is performed according to the policing parameter.
In sum, control device provided in an embodiment of the present invention, by receive scheduled event mark and with this After the corresponding policing parameter of scheduled event, according to corresponding between the mark and response policy of the scheduled event for pre-building The relational query response policy, and send to the corresponding observer's device of the response policy and include the policing parameter and the response Tactful performs notice, and the response policy is performed according to the policing parameter by observer's device, it is not necessary to transmitted by Intent Data, it is not required that observer's device inquires about corresponding response policy according to the mark of scheduled event, in solving prior art Increase the problem of the problem of overhead and the code structure complexity of observer's device, reach raising systematic function and observer The readable and maintainable effect of code.
Fig. 7 is refer to, the structure drawing of device of the control device of another embodiment of the present invention offer is provided.The control dress Put and can be used for performing method as shown in Figure 1 or 2 under Observer Pattern.The control device can include:
First receiver module 701, for receiving the mark and the strategy corresponding with the scheduled event of scheduled event Parameter;
Enquiry module 702, for corresponding between the mark and response policy according to the scheduled event for pre-building Response policy described in relational query;
Sending module 703 is notified, for sending to the corresponding observer's device of the response policy notice is performed, it is described to hold Row includes the policing parameter and the response policy in notifying, the execution is notified for indicating observer's device root The response policy is performed according to the policing parameter.
Described device also includes:
Registration request receiver module 704, for first receiver module 701 receive scheduled event mark and with Before the corresponding policing parameter of the scheduled event, the registration request that observer's device sends is received;
Spider module 705, for holding for including in the source code that observer's device is traveled through by Java reflex mechanisms Row strategy;
Detection module 706, for detecting whether the Java to there is predefined type is explained the executable strategy;
First acquisition module 707, if the testing result for the detection module 706 is described executable tactful to having The Java of the predefined type is explained, then the executable strategy is retrieved as into the response policy;
Second acquisition module 708, if the testing result for the detection module 706 is described executable tactful to having The Java of the predefined type is explained, then obtain the predetermined thing in the attribute explained from the executable tactful corresponding Java The mark of part;
Module 709 is set up, for setting up the corresponding relation between the mark of the scheduled event and the response policy.
Described device also includes:
Revocation request receiving module 710, for receiving the revocation request that observer's device sends;
Removing module 711, deletes for the corresponding relation between the mark and the response policy by the scheduled event.
In sum, control device provided in an embodiment of the present invention, by receive scheduled event mark and with this After the corresponding policing parameter of scheduled event, according to corresponding between the mark and response policy of the scheduled event for pre-building The relational query response policy, and send to the corresponding observer's device of the response policy and include the policing parameter and the response Tactful performs notice, and performing the response policy, i.e. control device according to the policing parameter by observer's device can directly adjust With the object reference of observer's device, observer's device no longer needs voluntarily to be judged whether to perform according to the mark of the scheduled event The response policy, so as to reach the code structure of simplified observer's device, improves the readable and maintainable effect of code.
Additionally, control device provided in an embodiment of the present invention, directly can be sent to sight by policing parameter and response policy The person's of examining device, it is not necessary to serialize to data, to solve and increase system caused by the serializing for increasing data in prior art The problem of system expense, reaches the effect for improving systematic function.
Fig. 8 is refer to, the structure drawing of device of observer's device of one embodiment of the invention offer is provided.The observation Person's device can be used for performing method as shown in Figure 3 or Figure 4 under Observer Pattern.The control device can include:
Receiver module 801 is notified, for what receiving control device sent notice is performed, described execution in notice includes plan Omit parameter and response policy corresponding with observer's device;Described execution notifies to receive predetermined thing for the control device The mark of part and the policing parameter, and according between the mark and the response policy of the scheduled event for pre-building Corresponding relation inquire after the response policy send notice;
Performing module 802, for performing the response policy according to the policing parameter.
In sum, observer's device provided in an embodiment of the present invention, by receiving control device scheduled event is being received Mark and the policing parameter, and according to the scheduled event for pre-building mark it is corresponding between the response policy pass System inquires the notice sent after the response policy, and performs the response policy according to the policing parameter, it is not necessary to pass through Intent transmits data, it is not required that observer's device inquires about corresponding response policy according to the mark of scheduled event, solves Increase the problem of the problem of overhead and the code structure complexity of observer's device in prior art, reach raising systematicness Can be with the readable effect with maintainability of observer's code.
Fig. 9 is refer to, the structure drawing of device of observer's device of another embodiment of the present invention offer is provided.The observation Person's device can be used for performing method as shown in Figure 3 or Figure 4 under Observer Pattern.The control device can include:
Receiver module 901 is notified, for what receiving control device sent notice is performed, described execution in notice includes plan Omit parameter and response policy corresponding with observer's device;Described execution notifies to receive predetermined thing for the control device The mark of part and the policing parameter, and according between the mark and the response policy of the scheduled event for pre-building Corresponding relation inquire after the response policy send notice;
Performing module 902, for performing the response policy according to the policing parameter.
Described device also includes:
Registration request sending module 903, the execution for sending in notice receiver module 901 receiving control device is led to Before knowing, registration request is sent to the control device, the registration request is used to indicate that the control device is anti-by Java The executable strategy included in the source code for penetrating mechanism traversal observer's device, and detecting the executable strategy correspondence After the Java for having the predefined type is explained, the executable strategy is retrieved as into the response policy, and be can perform from described The mark of the scheduled event is obtained in the attribute that the corresponding Java of strategy is explained, and sets up mark and the institute of the scheduled event State the corresponding relation between response policy.
Described device also includes:
Revocation request sending module 904, it is described to cancel request for referring to for sending revocation request to the control device Show that the control device deletes the corresponding relation between the mark and the response policy of the scheduled event.
In sum, observer's device provided in an embodiment of the present invention, by receiving control device scheduled event is being received Mark and the policing parameter, and according to the scheduled event for pre-building mark it is corresponding between the response policy pass System inquires the notice sent after the response policy, and performs the response policy according to the policing parameter, it is not necessary to pass through Intent transmits data, it is not required that observer's device inquires about corresponding response policy according to the mark of scheduled event, solves Increase the problem of the problem of overhead and the code structure complexity of observer's device in prior art, reach raising systematicness Can be with the readable effect with maintainability of observer's code.
Figure 10 is refer to, the system pie graph of the strategy execution system of one embodiment of the invention offer is provided.Should Strategy execution system can be used for performing policy execution method as shown in Figure 5 under Observer Pattern.The system can include:
Control device 001 as is seen in fig. 6 or fig. 7 and the observer's device 002 as shown in Fig. 8 or Fig. 9.
In sum, strategy execution system provided in an embodiment of the present invention, control device is receiving the mark of scheduled event And after the policing parameter corresponding with the scheduled event, according to the mark of the scheduled event for pre-building and response policy it Between corresponding relation inquire about the response policy, and send to the corresponding observer's device of the response policy and include the policing parameter Notice is performed with the response policy, perform the response policy, i.e. control device according to the policing parameter by observer's device can To directly invoke the object reference of observer's device, observer's device no longer needs voluntarily to be judged according to the mark of the scheduled event The response policy whether is performed, so as to reach the code structure of simplified observer's device, code is improved readable and maintainable Effect.
Additionally, strategy execution system provided in an embodiment of the present invention, control device can directly by policing parameter and response Strategy is sent to observer's device, it is not necessary to which data are serialized, and solving increases the serializing of data in prior art The caused problem for increasing overhead, reaches the effect for improving systematic function.
It should be noted that:Above-described embodiment provide control device and observer's device perform response policy when, only Be illustrated with the division of above-mentioned each functional module, in practical application, can as desired by above-mentioned functions distribution by Different functional modules are completed, will the internal structure of device be divided into different functional modules, it is described above complete to complete Portion or partial function.In addition, the enforcement of the control device of above-described embodiment offer and observer's device and policy execution method Example belongs to same design, and it implements process and refers to embodiment of the method, repeats no more here.
The embodiments of the present invention are for illustration only, do not represent the quality of embodiment.
One of ordinary skill in the art will appreciate that realizing all or part of step of above-described embodiment can pass through hardware To complete, it is also possible to which the hardware that correlation is instructed by program is completed, and described program can be stored in a kind of computer-readable In storage medium, storage medium mentioned above can be read only memory, disk or CD etc..
The foregoing is only presently preferred embodiments of the present invention, not to limit the present invention, all spirit in the present invention and Within principle, any modification, equivalent substitution and improvements made etc. should be included within the scope of the present invention.

Claims (9)

1. the policy execution method under a kind of Observer Pattern, in control device, it is characterised in that methods described includes:
Receive the mark and the policing parameter corresponding with the scheduled event of scheduled event;
The response policy is inquired about according to the corresponding relation between the mark and response policy of the scheduled event for pre-building;
Send to the corresponding observer's device of the response policy and perform notice, described execution includes the strategy ginseng in notice Number and the response policy, the execution is notified for indicating that observer's device performs the sound according to the policing parameter Should be tactful,
Before the mark and the policing parameter corresponding with the scheduled event for receiving scheduled event, including:
Receive the registration request that observer's device sends;
The executable strategy included in the source code that observer's device is traveled through by Java reflex mechanisms;
Detect whether the Java to there is predefined type is explained the executable strategy;
If testing result is the Java that the executable strategy correspondence has the predefined type explaining, by the executable strategy It is retrieved as obtaining the scheduled event in the response policy, and the attribute explained from the executable tactful corresponding Java Mark;
The corresponding relation set up between the mark of the scheduled event and the response policy.
2. method according to claim 1, it is characterised in that methods described also includes:
Receive the revocation request that observer's device sends;
Corresponding relation between the mark and the response policy of the scheduled event is deleted.
3. the policy execution method under a kind of Observer Pattern, in observer's device, it is characterised in that methods described bag Include:
What receiving control device sent performs notice, and described execution includes policing parameter and fill with the observer in notice Put corresponding response policy;It is described to perform the mark and the strategy ginseng for notifying to receive scheduled event for the control device Number, and the sound is inquired according to the corresponding relation between the mark and the response policy of the scheduled event for pre-building Answer the notice sent after strategy;
The response policy is performed according to the policing parameter,
Before the execution that the receiving control device sends is notified, also include:
Registration request is sent to the control device, the registration request is used to indicate that the control device reflects machine by Java The executable strategy included in the source code of system traversal observer's device, and detecting that the executable strategy is pre- to having After determining the Java notes of type, the executable strategy is retrieved as into the response policy, and from the executable strategy correspondence The attributes explained of Java in obtain the mark of the scheduled event, and set up the mark and the response plan of the scheduled event Corresponding relation between slightly.
4. method according to claim 3, it is characterised in that methods described also includes:
Revocation request is sent to the control device, the revocation is asked for indicating the control device by the scheduled event Mark and the response policy between corresponding relation delete.
5. the control device under a kind of Observer Pattern, it is characterised in that described device includes:
First receiver module, for receiving the mark and the policing parameter corresponding with the scheduled event of scheduled event;
Enquiry module, for the corresponding relation inquiry between the mark and response policy according to the scheduled event for pre-building The response policy;
Sending module is notified, for sending to the corresponding observer's device of the response policy notice is performed, it is described to perform notice In include the policing parameter and the response policy, the execution is notified for indicating observer's device according to described Policing parameter performs the response policy;
Registration request receiver module, for first receiver module receive scheduled event mark and with the predetermined thing Before the corresponding policing parameter of part, the registration request that observer's device sends is received;
Spider module, for the executable strategy included in the source code that observer's device is traveled through by Java reflex mechanisms;
Detection module, for detecting whether the Java to there is predefined type is explained the executable strategy;
First acquisition module, if the testing result for the detection module has the predetermined class for the executable strategy correspondence The Java of type is explained, then the executable strategy is retrieved as into the response policy;
Second acquisition module, if the testing result for the detection module has the predetermined class for the executable strategy correspondence The Java of type is explained, then the mark of the scheduled event is obtained in the attribute explained from the executable tactful corresponding Java;
Module is set up, for setting up the corresponding relation between the mark of the scheduled event and the response policy.
6. device according to claim 5, it is characterised in that described device also includes:
Revocation request receiving module, for receiving the revocation request that observer's device sends;
Removing module, deletes for the corresponding relation between the mark and the response policy by the scheduled event.
7. the observer's device under a kind of Observer Pattern, it is characterised in that described device includes:
Receiver module is notified, for what receiving control device sent notice is performed, described execution in notice includes policing parameter And response policy corresponding with observer's device;It is described to perform the mark for notifying to receive scheduled event for the control device Know and the policing parameter, and according to the scheduled event for pre-building mark with it is corresponding between the response policy The notice that relational query sends to after the response policy;
Performing module, for performing the response policy according to the policing parameter;
Registration request sending module, for before the execution that the notice receiver module receiving control device sends is notified, to The control device sends registration request, and the registration request is used to indicate that the control device is traveled through by Java reflex mechanisms The executable strategy included in the source code of observer's device, and detecting the executable strategy to there is predefined type Java explain after, the executable strategy is retrieved as into the response policy, and from the executable tactful corresponding Java The mark of the scheduled event is obtained in the attribute of note, and is set up between the mark of the scheduled event and the response policy Corresponding relation.
8. device according to claim 7, it is characterised in that described device also includes:
Revocation request sending module, for sending revocation request to the control device, the revocation request is described for indicating Control device deletes the corresponding relation between the mark and the response policy of the scheduled event.
9. the strategy execution system under a kind of Observer Pattern, it is characterised in that the system includes:
Control device and observer's device as claimed in claim 7 or 8 as described in claim 5 or 6.
CN201410072394.1A 2014-02-28 2014-02-28 Strategy execution method, strategy execution device and strategy execution system Active CN103838615B (en)

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 CN103838615A (en) 2014-06-04
CN103838615B true 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)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1056007A2 (en) * 1999-05-28 2000-11-29 Lucent Technologies Inc. System and method of exchanging information between software modules
CN101639774A (en) * 2009-08-31 2010-02-03 腾讯科技(深圳)有限公司 Encapsulation method of browser control part and device thereof
CN103098023A (en) * 2010-04-18 2013-05-08 Voxeo研究有限公司 Unified framework and method for call control and media control

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1056007A2 (en) * 1999-05-28 2000-11-29 Lucent Technologies Inc. System and method of exchanging information between software modules
CN101639774A (en) * 2009-08-31 2010-02-03 腾讯科技(深圳)有限公司 Encapsulation method of browser control part and device thereof
CN103098023A (en) * 2010-04-18 2013-05-08 Voxeo研究有限公司 Unified framework and method for call control and media control

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
《java学习脚印: 设计模式之观察者模式 JAVA事件委托》;nudge;《http://www.xuebuyuan.com/1853477.html》;20140217;正文第1-6页 *

Also Published As

Publication number Publication date
CN103838615A (en) 2014-06-04

Similar Documents

Publication Publication Date Title
CN103608780B (en) Methods, apparatuses and computer program products for provisioning applications to in vehicle infotainment systems with secured access
EP2806357A1 (en) Method and communication device for updating a web application
CN108347331A (en) The method and apparatus that T_Box equipment is securely communicated with ECU equipment in car networking system
CN109800598A (en) Certificate administration method, apparatus, electronic equipment and storage medium based on block chain
CN106612250A (en) Resource utilization authority judgment system and method
CN105786511B (en) The implementation method of terminal device Web application management
CN104503745A (en) Method and device for generating application channel package
CN106412975B (en) A kind of test method and device of content charging loophole
CN108667770A (en) A kind of loophole test method, server and the system of website
CN103838615B (en) Strategy execution method, strategy execution device and strategy execution system
CN106709323A (en) Method and apparatus for identifying cloaked downloading link
CN107729746A (en) A kind of application program of installation tamper resistant method and system based on digital signature
CN110247917A (en) Method and apparatus for authenticating identity
JP2017506401A (en) Resource transfer method, apparatus, program, and recording medium
CN112398654B (en) Method, device, equipment and medium for supporting packet grabbing
CN107729072A (en) Control property read method, device, terminal and readable storage medium storing program for executing
CN106257879A (en) A kind of method and apparatus downloading application
CN112162770A (en) Firmware version upgrading method and device for realizing integrity verification based on block chain
US8510423B2 (en) Install system and install method
JP2008049515A5 (en)
WO2024022277A1 (en) Map update data downloading method and apparatus, device, and readable medium
US20140003438A1 (en) Methods, systems, and computer readable media for updating sequence and acknowledgment numbers associated with replay packets
CN109582344A (en) Increment updating method, device, Cloud Server and computer readable storage medium
CN110380857A (en) Digital certificate processing method and processing device, block chain node, storage medium
CN105930177A (en) Method and device for installing application

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

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.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant