CN112051985B - Event triggering method, device, electronic equipment and readable storage medium - Google Patents

Event triggering method, device, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN112051985B
CN112051985B CN202010719028.6A CN202010719028A CN112051985B CN 112051985 B CN112051985 B CN 112051985B CN 202010719028 A CN202010719028 A CN 202010719028A CN 112051985 B CN112051985 B CN 112051985B
Authority
CN
China
Prior art keywords
preset
monitored
value
field
flag bit
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
CN202010719028.6A
Other languages
Chinese (zh)
Other versions
CN112051985A (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.)
Beijing QIYI Century Science and Technology Co Ltd
Original Assignee
Beijing QIYI Century Science and 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 Beijing QIYI Century Science and Technology Co Ltd filed Critical Beijing QIYI Century Science and Technology Co Ltd
Priority to CN202010719028.6A priority Critical patent/CN112051985B/en
Publication of CN112051985A publication Critical patent/CN112051985A/en
Application granted granted Critical
Publication of CN112051985B publication Critical patent/CN112051985B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/20Software design
    • G06F8/24Object-oriented
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Debugging And Monitoring (AREA)
  • Testing And Monitoring For Control Systems (AREA)

Abstract

The invention provides an event triggering method, an event triggering device, electronic equipment and a readable storage medium, and belongs to the technical field of computers. In the method, a preset zone bit updating method is established according to at least two fields to be monitored in an entity to be monitored in a target file, and the value of the preset zone bit in the target file is set to be a preset value under the condition that any field to be monitored changes in a specified mode by running the preset zone bit updating method. Judging whether the value of the preset zone bit is set to be a preset value or not by a preset zone bit judging method in the target file, wherein the total number of the preset zone bits is smaller than the total number of the fields to be monitored; and if the value of the preset flag bit is set to be a preset value, triggering a target event. Thus, the intrusion to the target file can be reduced to a certain extent, and the increase of the coupling degree of the target file is avoided.

Description

Event triggering method, device, electronic equipment and readable storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to an event triggering method, an event triggering device, an electronic device, and a readable storage medium.
Background
In the development of code files in JAVA, the concept of events is often touched. To meet development requirements, it is sometimes necessary to trigger an event when a change occurs to a field contained in an entity in a target file. For example, the object file includes fields "title" and "description", and it is sometimes required to trigger a message event when the values of the fields "title" and "description" are changed.
In the prior art, a judging logic code for a field to be monitored is added in a target file to judge whether the field is changed or not, and a target event is triggered when the field is changed. However, in an actual scenario, there are often cases where multiple fields trigger an event, so that more fields are often to be monitored, and accordingly, since a judgment logic code needs to be added for each field to be monitored, a large number of logic codes are added in the target file, so that the coupling degree of the target file is higher.
Disclosure of Invention
The invention provides an event triggering method, an event triggering device, electronic equipment and a readable storage medium, so as to solve the problem that the coupling degree of a target file is high due to the fact that a large amount of logic codes are added in the target file.
In a first aspect of the present invention, there is provided an event triggering method, the method comprising:
creating a preset zone bit updating method according to at least two fields to be monitored in an entity to be monitored in the target file; the preset flag bit updating method is used for setting a value of a preset flag bit in the target file to be a preset value under the condition that any field to be monitored has specified change, wherein the preset value is used for indicating that the field to be monitored has specified change;
operating the preset flag bit updating method;
judging whether the value of the preset marker bit is set to be the preset value or not through a preset marker bit judging method in the target file; the total number of the preset zone bits is smaller than the total number of the fields to be monitored;
and if the value of the preset flag bit is set to be the preset value, triggering a target event.
In a second aspect of the present invention, there is also provided an event triggering apparatus, the apparatus comprising:
the first creating module is used for creating a preset zone bit updating method according to at least two fields to be monitored in the entity to be monitored in the target file; the preset flag bit updating method is used for setting a value of a preset flag bit in the target file to be a preset value under the condition that any field to be monitored has specified change, wherein the preset value is used for indicating that the field to be monitored has specified change;
The operation module is used for operating the preset flag bit updating method;
the judging module is used for judging whether the value of the preset marker bit is set to be the preset value or not through a preset marker bit judging method in the target file; the total number of the preset zone bits is smaller than the total number of the fields to be monitored;
and the triggering module is used for triggering a target event if the value of the preset flag bit is set to be the preset value.
In yet another aspect of the present invention, there is also provided a computer readable storage medium having instructions stored therein which, when executed on a computer, cause the computer to perform any of the event triggering methods described above.
In yet another aspect of the invention, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform any of the event triggering methods described above.
According to the event triggering method provided by the embodiment of the invention, a preset zone bit updating method is created according to at least two fields to be monitored in an entity to be monitored in a target file, wherein the preset zone bit updating method is used for setting the value of a preset zone bit in the target file to be a preset value under the condition that any field to be monitored changes in a specified mode. Then, running a preset zone bit updating method so that the value of the preset zone bit is set to be a preset value under the condition that any field to be monitored has specified change, and judging whether the value of the preset zone bit is set to be the preset value or not by a preset zone bit judging method in the target file, wherein the total number of the preset zone bits is smaller than the total number of the fields to be monitored; and if the value of the preset flag bit is set to be a preset value, triggering a target event. Because the preset zone bit updating method can automatically monitor a plurality of fields to be monitored, the value of the preset zone bit is set to be a preset value under the condition that the fields to be monitored have specified changes. Therefore, the event triggering for a plurality of fields to be monitored can be realized without adding corresponding logic codes for each field to be monitored, only a preset flag bit updating method and a preset flag bit judging method with a small number of preset flag bits are added in the target file, the value of the preset flag bit is maintained through the updating method, the value of the preset flag bit is judged through the preset flag bit judging method, and the target event is triggered under the condition that the value of the preset flag bit is set to be a preset value, so that the invasion of the target file can be reduced to a certain extent, and the coupling degree of the target file is prevented from being increased.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below.
FIG. 1 is a flowchart illustrating steps of an event triggering method according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating steps of another event triggering method according to an embodiment of the present invention;
FIG. 3A is a block diagram of an event triggering device provided by an embodiment of the present invention;
FIG. 3B is a block diagram of another event triggering device provided by an embodiment of the present invention;
FIG. 3C is a block diagram of yet another event triggering device provided by an embodiment of the present invention
Fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be described below with reference to the accompanying drawings in the embodiments of the present invention.
Fig. 1 is a flowchart of steps of an event triggering method according to an embodiment of the present invention, as shown in fig. 1, the method may include:
step 101, creating a preset zone bit updating method according to at least two fields to be monitored in an entity to be monitored in a target file; the preset flag bit updating method is used for setting a value of a preset flag bit in the target file to be a preset value under the condition that any field to be monitored changes in a specified mode, and the preset value is used for indicating that the field to be monitored changes in the specified mode.
In the embodiment of the invention, the target file may be a code file, and the entity to be monitored may be an entity defined in the target file, where the entity is also called an entity class, and the entity refers to a class having a Set method and a Get method, and often includes a field. Further, the field to be monitored may be a field to be monitored in the entity to be monitored, and whether the field to be monitored has a specified change may determine whether a trigger event is required. The specified change may be set according to an actual requirement, and the specified change may be a change of a value of all or part of the fields to be monitored, or a change of a value of all or part of the fields to be monitored to a specified value, or a change of a name of all or part of the fields to be monitored, or the like.
For example, in the embodiment of the present invention, a flag of a preset flag bit may be configured for each field to be monitored, and for the field to be monitored having the flag, the preset flag bit updating method may monitor whether a specified change occurs in the field, and change the value of the preset flag bit if the specified change occurs. For example, assuming that there are 3 fields to be monitored, the same flag bit flag may be configured for all the 3 fields to be monitored, so that the preset flag bit update method may monitor the 3 fields, and when any one field is monitored to perform a specified change, the value of the preset flag bit is set to a preset value.
Further, a preset flag bit in the target file may be used to indicate whether a field to be monitored changes, and a preset value may be used to indicate that a specified change occurs in the field to be monitored. The specific representation form of the preset flag bit may be set according to actual requirements, for example, the preset flag bit may be "isModified". The specific value of the preset value may be set according to the actual requirement, and the preset value may be a number, a character string, a combination thereof, or the like, for example, the preset value may be "true".
Further, the preset flag bit updating method may be a code for implementing processing logic for setting a value of a preset flag bit in the target file to a preset value in the case that any field to be monitored changes in specification. According to the embodiment of the invention, the preset zone bit updating method is configured for the target file according to at least two fields to be monitored, so that the change of the fields to be monitored can be conveniently monitored through the preset zone bit updating method, and the value of the preset zone bit is set to indicate whether the specified change of the fields to be monitored exists or not.
Step 102, running the preset flag bit updating method.
In the embodiment of the invention, the preset flag bit updating method can execute corresponding processing logic by operating the preset flag bit updating method. Accordingly, if the field to be monitored changes in a specified manner, the value of the preset flag bit in the target file is set to a preset value, and if the field to be monitored does not change in a specified manner, the value of the preset flag bit in the target file is not set to the preset value.
Step 103, judging whether the value of the preset marker bit is set as the preset value or not through a preset marker bit judging method in the target file; the total number of the preset flag bits is smaller than the total number of the fields to be monitored.
In the embodiment of the present invention, the preset flag bit judging method may be a code for implementing processing logic for judging whether the value of the preset flag bit is set to a preset value and triggering an event according to the value of the preset flag bit. The method for judging the preset zone bits can be used for judging whether the appointed change occurs in a plurality of fields to be monitored or not, accordingly, the appointed change can be monitored or not in a plurality of fields to be monitored, a set of corresponding judging logic codes are not required to be added for each field to be monitored, triggering events according to the field change can be realized only by adding a small number of preset zone bit judging methods into the target file, and further the code quantity increased in the target file can be reduced to a certain extent, and the coupling degree of the target file is reduced.
For example, assuming that there are 5 fields to be monitored, in the scheme in the prior art, codes for implementing judgment and trigger logic need to be added for each field to be monitored, so that 5 sections of judgment logic codes exist, but in the embodiment of the invention, a small number of preset flag bits, for example, one preset flag bit, are set, so that only 1 section of judgment logic code needs to be set in the preset flag bit judgment method, therefore, the amount of codes to be added can be reduced to a certain extent, and the coupling degree of the target file is reduced.
Step 104, if the value of the preset flag bit is set to the preset value, triggering a target event.
In the embodiment of the invention, if the value of the preset flag bit is set to the preset value, the fact that the field to be monitored has specified change is indicated, and accordingly, the target event can be triggered. For example, a target event may be predefined in a preset flag bit judging method, and a trigger condition may be set for the target event: the value of the preset flag bit is set to a preset value setting. Correspondingly, the preset flag bit judging method can trigger the target event after judging that the value of the preset flag bit is set to the preset value. The target event may be defined according to actual requirements, for example, the target event may be an event for sending a notification message.
In summary, according to the event triggering method provided by the embodiment of the present invention, a preset flag bit updating method is created according to at least two fields to be monitored in an entity to be monitored in a target file, where the preset flag bit updating method is used to set a value of a preset flag bit in the target file to a preset value under a condition that any one of the fields to be monitored changes in a specified manner. Then, running a preset zone bit updating method so that the value of the preset zone bit is set to be a preset value under the condition that any field to be monitored has specified change, and judging whether the value of the preset zone bit is set to be the preset value or not by a preset zone bit judging method in the target file, wherein the total number of the preset zone bits is smaller than the total number of the fields to be monitored; and if the value of the preset flag bit is set to be a preset value, triggering a target event. Because the preset zone bit updating method can automatically monitor a plurality of fields to be monitored, the value of the preset zone bit is set to be a preset value under the condition that the fields to be monitored have specified changes. Therefore, the event triggering for a plurality of fields to be monitored can be realized without adding corresponding logic codes for each field to be monitored, only a preset flag bit updating method and a preset flag bit judging method with a small number of preset flag bits are added in the target file, the value of the preset flag bit is maintained through the updating method, the value of the preset flag bit is judged through the preset flag bit judging method, and the target event is triggered under the condition that the value of the preset flag bit is set to be a preset value, so that the invasion of the target file can be reduced to a certain extent, and the coupling degree of the target file is prevented from being increased.
Meanwhile, according to the preset zone bit judging method provided by the embodiment of the invention, whether the target event is triggered is determined by judging the value of the preset zone bit, and the number of the fields to be monitored, and the fields to be monitored, particularly the fields, do not influence the judging logic of the preset zone bit judging method. In this way, the judgment logic of the preset zone bit judgment method and the field to be monitored in the target file can be decoupled, namely, the judgment logic of the preset zone bit judgment method is stripped from the business logic of the target file, so that the preset zone bit judgment method can be generalized.
Fig. 2 is a flowchart of steps of another event triggering method according to an embodiment of the present invention, as shown in fig. 2, the method may include:
step 201, creating a mark adding class.
In this step, the tag-added class may be a class for adding tags. For example, in the case where the object file is JAVA code, the tag add class may be an annotation (section) class. The section class is also called Java annotation, and is an annotation mechanism. The method can conveniently mark classes, methods, variables, parameters and the like in the Java-based code, namely, marks are added. Further, when creating the tag add class, a Target (Target) attribute and a reservation (reply) attribute of the annotation class may be defined first, then, a name, a data type and a variable of the annotation class are defined through a preset format, and the annotation class is indicated by using a "Document" field. The Target attribute may be used to indicate the scope of use of the annotation, and may be defined as "METHOD" to indicate that the annotation may be used on a METHOD, for example. The retrieval attribute may be used to indicate the stage of annotation reservation, and illustratively, the retrieval attribute may be defined as "RUNTIME" to indicate that the annotation is reserved to the run-time stage. The name of the annotation class may be set according to actual requirements, and by way of example, the name of the annotation class may be denoted as "updaterecord", and updaterecord may represent that a record is made when the value of a field is updated. The data type may be denoted as "String", which is used to indicate that the data type is a character, and the variable may be denoted as "value () default { }; the predetermined format may be "public@interface a", where a represents a name, a data type, and a variable.
Step 202, adding record marks for the field setting method corresponding to each field to be monitored through the mark adding class; the record mark is used for indicating that the field setting method is used for creating the preset flag bit updating method.
In this step, a field to be monitored may be defined in the tag addition class, and a tag is recorded, and then the tag addition class is operated, so as to add a record tag for a field setting method corresponding to the field to be monitored. The content style of the recording mark can be set according to actual requirements. By way of example, the record flag may be "@ updaterecord", the field setting method may be a method provided by a programming language for setting field contents, for example, values of fields, for example, the field setting method may be a setter method by which a new value may be defined for a field, with which the current value of the field is replaced. Because the field setting method can change the content of the field, namely, the field is changed, in the embodiment of the invention, the record mark is added for the field setting method corresponding to the field to be monitored, so that the field setting method can be accurately positioned and monitored in the subsequent step, and further whether the field to be monitored changes in a specified way can be accurately judged to a certain extent.
By way of example, assume that the entity to be monitored is a class named Video, defined with an identification (id), title (title) and description (description), i.e., the entity to be monitored contains fields "id", "title" and "description". Further, assuming that the fields "title" and "description" are fields to be monitored, the method "setTitle (String title)" may be set for the field corresponding to the field "title" to be monitored and the method "setDescription (String description)" may be set for the field corresponding to the field "description" to be monitored, so as to configure the record mark for the field to be monitored.
Accordingly, in the subsequent process, whether the field to be monitored "title" changes or the field to be monitored "description" changes, because both the field to be monitored "title" and the field to be monitored "description" are configured with record marks, the preset flag bit updating method monitors whether the "title" field and the "description" field change in a specified manner, and sets the value of the preset flag bit to a preset value when any one of the fields changes.
Compared with a manual searching and adding mode, in the embodiment of the invention, the record mark is added for the field setting method corresponding to the field to be monitored through the mark adding class by creating the mark adding class, so that the labor cost can be saved to a certain extent, and the efficiency of adding the record mark is improved.
It should be noted that, in the embodiment of the present invention, after a new field is added to the entity to be monitored, it may also be determined whether the new field is a field to be monitored; if yes, adding a record mark for a field setting method corresponding to the field to be monitored; specifically, an attribute identifier corresponding to the new field may be obtained first, where the attribute identifier may be used to characterize whether the new field is a field to be monitored, and if the attribute identifier characterizes that the new field is a field to be monitored, a record mark may be further added for a method set in the field corresponding to the new field. After pruning the fields in the entity to be monitored, determining whether the pruned fields are fields to be monitored; specifically, the pruned field may be compared with a pre-recorded field to be monitored, and if a field matching the pruned field exists in the recorded field to be monitored, the pruned field may be considered as the field to be monitored. Further, if yes, deleting the record mark of the field setting method corresponding to the field to be monitored; the target field to be monitored is the field to be monitored represented by the pruned field. Therefore, through corresponding updating, the method for setting the field corresponding to each field to be monitored can be ensured to be added with the record mark, and further the accuracy of subsequent judgment is ensured.
Step 203, setting a field setting method added with the record mark as a tangent point, and creating a tangent plane method through the tangent point to obtain the preset zone bit updating method; and the preset flag bit updating method is used for triggering the operation of determining whether the field to be monitored changes or not based on the field setting method corresponding to the field to be monitored when the preset flag bit updating method is operated to the tangent point.
The tangent plane method can be an updated logic code for realizing field change judgment and setting the value of a preset flag bit. The tangent point may be used to specify a tangent plane method execution occasion. In this way, the tangent plane method is created by setting the field setting method provided with the record mark as the tangent point, so that the tangent plane method for realizing the update logic and the field setting method can be woven, and the update logic can be accurately triggered when the field setting method of the field to be monitored is operated, and further the accurate and timely judgment can be ensured to a certain extent. When the section method for realizing the update logic and the field setting method are woven, the section method, namely the update logic, can be woven before the execution of the setting method, so that the execution of the update logic can be triggered as soon as possible, and the delay of a subsequent trigger target event is reduced. For example, taking the Video entity as an example, before executing all the setting methods marked as updaterecord, logic of whether a specified change occurs in a field and a preset flag bit is set is automatically executed. Of course, the setter method may also be followed, which is not limited by the embodiment of the present invention.
Further, in creating the facet method, the facet may be created using a facet-oriented programming (Aspect Oriented Programming, AOP) technique, for example, an AOP technique using a Load Time Weaver (LTW), a compile Time Weaver (Compile Time Weaver, CTW), or a lightweight AOP framework (Spring AOP). For example, when creating a cut plane, it may be stated by a preset declaration format that those methods are required as tangent points. For example, the preset declaration format may be "@ Aspect public class {" where "@ indicates a label carried by the method as a tangent point. For example, the flag may be denoted as "UpdateRecord". Then, a tangent point may be defined, which may be expressed as "@ Pointcut (" @ point (com. Iqiyi. Library. Image. Core. Action. Updated recorded) ", after which a tangent method body to be executed at the tangent point may be declared.
Correspondingly, when the preset flag bit updating method is operated to the tangent point, the operation of determining whether the field to be monitored changes in a specified mode or not based on the field setting method corresponding to the field to be monitored can be triggered. Specifically, the operation can be realized by the following substep (1) to substep (2):
Substep (1): and acquiring an initial value and a change value of the field to be monitored based on the parameters of the field setting method by the preset flag bit updating method.
In this step, the field setting method may be parsed to obtain an initial value and a changed value of the field to be monitored from the parameters of the field setting method, where the initial value may represent a current value of the field to be monitored, and the changed value may represent a value to which the current value of the field to be monitored needs to be changed. When acquiring, a parameter acquisition method, for example, a getParameterTypes method may be used for acquisition. Or the parameter name can be obtained by the reflection technology, then the parameter value corresponding to the parameter name is obtained by the reflection technology according to the parameter name, and finally the initial value and the change value of the field to be monitored are obtained according to the parameter name. The embodiment of the present invention is not limited thereto.
Substep (2): and if the initial value is inconsistent with the change value, determining that the field to be monitored has specified change.
In the embodiment of the invention, the appointed change of the field to be monitored can be determined under the condition that the initial value and the changed value are inconsistent. Specifically, if the initial value and the change value are not identical, it may be determined whether the change value is a specified value, and if the change value is a specified value, it may be determined that the field to be monitored has a specified change. In this way, it is possible to implement triggering of an event in the case where the value of the field to be monitored changes and the value of the field to be monitored changes to a specified value. The specified value may be a preset value.
In an actual application scene, the field is often changed by a field setting method, so that in the embodiment of the invention, the initial value and the change value of the field to be monitored are obtained based on the parameters of the field setting method, and whether the field to be monitored changes in a specified manner is determined based on the initial value and the change value, so that whether the field to be monitored changes in a specified manner can be monitored more accurately to a certain extent.
For example, the main body execution logic corresponding to the above step-slicing method may be: judging whether the value of a preset flag bit 'modyflag' is changed, if the value of the 'modyflag' is changed, acquiring parameters of a field setting method to obtain an initial value and a changed value when the field setting method added with a record mark runs to a tangent point, and finally judging whether the initial value and the changed value are consistent, and if the initial value and the changed value are inconsistent, determining that the designated change occurs.
And 204, running the preset flag bit updating method.
Specifically, the implementation manner of this step may refer to the foregoing step 102, and the embodiments of the present invention are not described herein in detail.
Step 205, judging whether the value of the preset flag bit is set to the preset value or not by a preset flag bit judging method in the target file; the total number of the preset flag bits is smaller than the total number of the fields to be monitored.
Specifically, the implementation manner of this step may refer to the foregoing step 103, and the embodiments of the present invention are not described herein in detail.
Step 206, if the value of the preset flag bit is set to the preset value, triggering a target event.
Specifically, the implementation manner of this step may refer to the foregoing step 103, and the embodiments of the present invention are not described herein in detail.
Further, taking the entity to be monitored as the Video entity as an example, when an event of sending a notification message is triggered under the condition that a title field or a description field is desired to be changed, in the prior art, a setting method corresponding to the title field is often required to be called for the title field, a judgment logic code is added for the title field, and after the judgment logic code added for the title field judges that the value of the title field is actually changed, the event is triggered. And calling a button method corresponding to the description field for the description field, adding a judgment logic code for the description field, and triggering an event after the judgment logic code added for the description field judges that the value of the title field is actually changed.
Thus, when there are multiple fields to be monitored in the Video entity, for example, the Video entity has 100 fields, and when 50 of the fields change, a trigger to send event is required, that is, there are 50 fields to be monitored. Thus, a large amount of logic codes need to be added in the target file, and if the changes of the 50 fields are scattered at all places and all corners in the target file, the difficulty of logic judgment of the logic codes is increased.
According to the event triggering method provided by the embodiment of the invention, only a judging logic code for judging whether the value of the preset zone bit is the preset value is added, so that the target event can be triggered when the field to be monitored in the Video entity changes through the judging logic code. Assuming that there are 50 fields to be monitored, since the value of the preset flag bit can represent whether the specified change occurs in the 50 fields to be monitored, in the embodiment of the invention, no logic code needs to be added for each field to be monitored, and when the field needs to be changed, the setter method only needs to be normally called, and accordingly, in the embodiment of the invention, the accurate triggering of the target event can be realized only by adding the judging logic code for judging the preset flag bit and triggering according to the judging result.
It should be noted that: after triggering a target event, the value of the preset flag bit can be restored to a default value, wherein the default value can be used for indicating whether a field to be monitored is required to be judged to be subjected to specified change at present; and if the value of the preset flag bit is a default value, executing the parameter based on the field setting method, and acquiring the initial value and the changed value of the field to be monitored. The specific value of the default value may be set according to actual requirements, and the default value may be a number, a character string, a combination thereof, or the like, for example, the default value may be "false". Specifically, a value of a preset flag bit of the entity to be monitored may be obtained. For example, the acquisition may be performed by a reflection technique. And then judging the obtained value, if the value is a default value, executing the substep (1), and if the value is the default value, indicating that the subsequent trigger target event is enough to be controlled, wherein the judgment and the setting operation of the preset zone bit are not needed to be executed at present. Accordingly, the method can directly return, and further avoid the problem of processing resource waste caused by unnecessary operation execution.
Further, the value of the preset flag bit can be stored in the database according to the requirement, and a preset keyword 'transaction' annotation is marked on the preset flag bit. By way of example, taking the use of a distributed document storage database (mongo db) service, without the need to store the value of a preset flag bit to the database, the annotation may be expressed as "org.
In summary, in the event triggering method provided by the embodiment of the invention, the mark adding class is created first, and the record mark is added for the field setting method corresponding to each field to be monitored through the mark adding class, so that the labor cost can be saved to a certain extent, and the efficiency of adding the record mark is improved. Then, the field setting method added with the record mark can be set as a tangent point, and a tangent plane method is established through the tangent point, so that a preset zone bit updating method is obtained. Then, a preset zone bit updating method is operated so that the value of the preset zone bit is set to be a preset value under the condition that any appointed change occurs in a field to be monitored, whether the value of the preset zone bit is set to be the preset value is judged through a preset zone bit judging method in the target file, and if the value of the preset zone bit is set to be the preset value, a target event is triggered. Because the preset zone bit updating method can automatically monitor a plurality of fields to be monitored, the value of the preset zone bit is set to be a preset value under the condition that the fields to be monitored have specified changes. Therefore, the event triggering for a plurality of fields to be monitored can be realized without adding corresponding logic codes for each field to be monitored, only a preset flag bit updating method and a preset flag bit judging method with a small number of preset flag bits are added in the target file, the value of the preset flag bit is maintained through the updating method, the value of the preset flag bit is judged through the preset flag bit judging method, and the target event is triggered under the condition that the value of the preset flag bit is set to be a preset value, so that the invasion of the target file can be reduced to a certain extent, and the coupling degree of the target file is prevented from being increased.
Fig. 3A is a block diagram of an event triggering device according to an embodiment of the present invention, and as shown in fig. 3A, the device 30 may include:
the first creating module 301 is configured to create a preset flag bit updating method according to at least two fields to be monitored in the entity to be monitored in the target file; the preset flag bit updating method is used for setting a value of a preset flag bit in the target file to be a preset value under the condition that any field to be monitored has specified change, wherein the preset value is used for indicating that the field to be monitored has specified change;
an operation module 302, configured to operate the preset flag bit updating method;
a judging module 303, configured to judge whether a value of a preset flag bit is set to the preset value by using a preset flag bit judging method in the target file; the total number of the preset zone bits is smaller than the total number of the fields to be monitored;
and the triggering module 304 is configured to trigger a target event if the value of the preset flag bit is set to the preset value.
Optionally, fig. 3B is a block diagram of another event triggering device provided in an embodiment of the present invention, as shown in fig. 3B, where the device 30 further includes:
A second creating module 305, configured to create a label add class;
a first adding module 306, configured to add a record mark to a field setting method corresponding to each field to be monitored through the mark adding class; the record mark is used for indicating that the field setting method is used for creating the preset flag bit updating method.
Optionally, the first creating module 301 is specifically configured to:
setting a field setting method added with the record mark as a tangent point, and creating a tangent plane method through the tangent point to obtain the preset zone bit updating method;
and triggering an operation of determining whether the field to be monitored changes or not based on a field setting method corresponding to the field to be monitored when the preset flag bit updating method is operated to the tangent point.
Optionally, the preset flag bit updating method is specifically used for:
acquiring an initial value and a change value of the field to be monitored based on parameters of the field setting method by the preset flag bit updating method;
and if the initial value is inconsistent with the change value, determining that the field to be monitored has specified change.
Optionally, the preset flag bit updating method is further specifically used for:
Judging whether the change value is a designated value or not;
and determining that the field to be monitored changes in a specified mode under the condition that the change value is a specified value.
Optionally, the apparatus 30 further includes:
a restoring module 307, configured to restore the value of the preset flag bit to a default value; the default value is used for indicating whether the field to be monitored is required to be judged to have specified change at present;
the preset flag bit updating method is also specifically used for:
acquiring the value of the preset flag bit;
and if the value of the preset flag bit is the default value, executing the parameter based on the field setting method, and acquiring the initial value and the changed value of the field to be monitored.
Optionally, fig. 3C is a block diagram of still another event triggering device provided in an embodiment of the present invention, and as shown in fig. 3C, the device 30 further includes:
a second adding module 308, configured to determine, after adding a new field to the entity to be monitored, whether the new field is a field to be monitored; if yes, adding a record mark for a field setting method corresponding to the field to be monitored;
a deleting module 309, configured to determine, after deleting a field in the entity to be monitored, whether the deleted field is a field to be monitored; if yes, deleting the record mark of the field setting method corresponding to the field to be monitored; the target field to be monitored is the field to be monitored represented by the pruned field.
In summary, according to the event triggering device provided by the embodiment of the present invention, a preset flag bit updating method may be created according to at least two fields to be monitored in an entity to be monitored in a target file, where the preset flag bit updating method is used to set a value of a preset flag bit in the target file to a preset value under a condition that any field to be monitored changes in a specified manner. Then, running a preset zone bit updating method so that the value of the preset zone bit is set to be a preset value under the condition that any field to be monitored has specified change, and judging whether the value of the preset zone bit is set to be the preset value or not by a preset zone bit judging method in the target file, wherein the total number of the preset zone bits is smaller than the total number of the fields to be monitored; and if the value of the preset flag bit is set to be a preset value, triggering a target event. Because the preset zone bit updating method can automatically monitor a plurality of fields to be monitored, the value of the preset zone bit is set to be a preset value under the condition that the fields to be monitored have specified changes. Therefore, the event triggering for a plurality of fields to be monitored can be realized without adding corresponding logic codes for each field to be monitored, only a preset flag bit updating method and a preset flag bit judging method with a small number of preset flag bits are added in the target file, the value of the preset flag bit is maintained through the updating method, the value of the preset flag bit is judged through the preset flag bit judging method, and the target event is triggered under the condition that the value of the preset flag bit is set to be a preset value, so that the invasion of the target file can be reduced to a certain extent, and the coupling degree of the target file is prevented from being increased.
For the above-described device embodiments, the description is relatively simple, as it is substantially similar to the method embodiments, with reference to the description of the method embodiments in part.
The embodiment of the invention also provides an electronic device, as shown in fig. 4, which comprises a processor 401, a communication interface 402, a memory 403 and a communication bus 404, wherein the processor 401, the communication interface 402 and the memory 403 complete communication with each other through the communication bus 404,
a memory 403 for storing a computer program;
the processor 401, when executing the program stored in the memory 403, implements the following steps:
creating a preset zone bit updating method according to at least two fields to be monitored in an entity to be monitored in the target file; the preset flag bit updating method is used for setting a value of a preset flag bit in the target file to be a preset value under the condition that any field to be monitored has specified change, wherein the preset value is used for indicating that the field to be monitored has specified change;
operating the preset flag bit updating method;
judging whether the value of the preset marker bit is set to be the preset value or not through a preset marker bit judging method in the target file; the total number of the preset zone bits is smaller than the total number of the fields to be monitored;
And if the value of the preset flag bit is set to be the preset value, triggering a target event.
The communication bus mentioned by the above terminal may be a peripheral component interconnect standard (Peripheral Component Interconnect, abbreviated as PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, abbreviated as EISA) bus, etc. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The communication interface is used for communication between the terminal and other devices.
The memory may include random access memory (Random Access Memory, RAM) or non-volatile memory (non-volatile memory), such as at least one disk memory. Optionally, the memory may also be at least one memory device located remotely from the aforementioned processor.
The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU for short), a network processor (Network Processor, NP for short), etc.; but also digital signal processors (Digital Signal Processing, DSP for short), application specific integrated circuits (Application Specific Integrated Circuit, ASIC for short), field-programmable gate arrays (Field-Programmable Gate Array, FPGA for short) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
In yet another embodiment of the present invention, a computer readable storage medium is provided, in which instructions are stored which, when run on a computer, cause the computer to perform the event triggering method of any of the above embodiments.
In yet another embodiment of the present invention, a computer program product comprising instructions which, when run on a computer, cause the computer to perform the event triggering method of any of the above embodiments is also provided.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, produces a flow or function in accordance with embodiments of the present invention, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another, for example, by wired (e.g., coaxial cable, optical fiber, digital Subscriber Line (DSL)), or wireless (e.g., infrared, wireless, microwave, etc.). The computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid State Disk (SSD)), etc.
It is noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In this specification, each embodiment is described in a related manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, as relevant to see a section of the description of method embodiments.
The foregoing description is only of the preferred embodiments of the present invention and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims (8)

1. An event triggering method, characterized in that the event triggering method comprises:
creating a mark adding class;
adding record marks for a field setting method corresponding to each field to be monitored in the entity to be monitored in the target file through the mark adding class; the record mark is used for indicating that the field setting method is used for creating a preset flag bit updating method;
setting a field setting method added with the record mark as a tangent point, and creating a tangent plane method through the tangent point to obtain the preset zone bit updating method;
the preset flag bit updating method is used for triggering an operation of determining whether the field to be monitored changes or not based on a field setting method corresponding to the field to be monitored when the preset flag bit updating method is operated to the tangent point; the preset flag bit updating method is used for setting a value of a preset flag bit in the target file to be a preset value under the condition that any field to be monitored has specified change, wherein the preset value is used for indicating that the field to be monitored has specified change;
Operating the preset flag bit updating method;
judging whether the value of the preset marker bit is set to be the preset value or not through a preset marker bit judging method in the target file; the total number of the preset zone bits is smaller than the total number of the fields to be monitored;
and if the value of the preset flag bit is set to be the preset value, triggering a target event.
2. The event triggering method according to claim 1, wherein the preset flag updating method is specifically configured to:
acquiring an initial value and a change value of the field to be monitored based on parameters of the field setting method by the preset flag bit updating method;
and if the initial value is inconsistent with the change value, determining that the field to be monitored has specified change.
3. The event triggering method according to claim 2, wherein the preset flag updating method is further specifically configured to:
judging whether the change value is a designated value or not;
and determining that the field to be monitored changes in a specified mode under the condition that the change value is a specified value.
4. The event triggering method according to claim 2, wherein the value of the preset flag bit is the preset value, and after triggering a target event, the event triggering method further comprises:
Restoring the value of the preset zone bit to a default value; the default value is used for indicating whether the field to be monitored is required to be judged to have specified change at present;
the preset flag bit updating method is also specifically used for:
acquiring the value of the preset flag bit;
and if the value of the preset flag bit is the default value, executing the parameter based on the field setting method, and acquiring the initial value and the changed value of the field to be monitored.
5. The event triggering method as recited in claim 1, wherein the event triggering method further comprises:
after adding a new field into the entity to be monitored, determining whether the new field is a field to be monitored; if yes, adding a record mark for a field setting method corresponding to the field to be monitored;
after pruning the fields in the entity to be monitored, determining whether the pruned fields are fields to be monitored; if yes, deleting the record mark of the field setting method corresponding to the field to be monitored; the target field to be monitored is the field to be monitored represented by the pruned field.
6. An event triggering device, the device comprising:
The first creating module is used for creating a preset zone bit updating method according to at least two fields to be monitored in the entity to be monitored in the target file; the preset flag bit updating method is used for setting a value of a preset flag bit in the target file to be a preset value under the condition that any field to be monitored has specified change, wherein the preset value is used for indicating that the field to be monitored has specified change;
the operation module is used for operating the preset flag bit updating method;
the judging module is used for judging whether the value of the preset marker bit is set to be the preset value or not through a preset marker bit judging method in the target file; the total number of the preset zone bits is smaller than the total number of the fields to be monitored;
the triggering module is used for triggering a target event if the value of the preset flag bit is set to be the preset value;
the second creation module is used for creating a mark adding class;
the first adding module is used for adding record marks for the field setting method corresponding to each field to be monitored through the mark adding class; the record mark is used for indicating that the field setting method is used for creating the preset flag bit updating method;
The first creation module is specifically configured to:
setting a field setting method added with the record mark as a tangent point, and creating a tangent plane method through the tangent point to obtain the preset zone bit updating method;
and triggering an operation of determining whether the field to be monitored changes or not based on a field setting method corresponding to the field to be monitored when the preset flag bit updating method is operated to the tangent point.
7. The electronic equipment is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
a processor for implementing the event triggering method steps of any of claims 1-5 when executing a program stored on a memory.
8. A computer readable storage medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the steps of the event triggering method as claimed in any of claims 1-5.
CN202010719028.6A 2020-07-23 2020-07-23 Event triggering method, device, electronic equipment and readable storage medium Active CN112051985B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010719028.6A CN112051985B (en) 2020-07-23 2020-07-23 Event triggering method, device, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010719028.6A CN112051985B (en) 2020-07-23 2020-07-23 Event triggering method, device, electronic equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN112051985A CN112051985A (en) 2020-12-08
CN112051985B true CN112051985B (en) 2023-07-25

Family

ID=73602528

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010719028.6A Active CN112051985B (en) 2020-07-23 2020-07-23 Event triggering method, device, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN112051985B (en)

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9449189B1 (en) * 2015-11-03 2016-09-20 International Business Machines Corporation Protection of state data in computer system code
CN108415814A (en) * 2018-01-11 2018-08-17 平安科技(深圳)有限公司 Automatically record field changing method, application server and computer readable storage medium
CN109190119A (en) * 2018-08-22 2019-01-11 腾讯科技(深圳)有限公司 Time extracting method and device, storage medium and electronic device
CN110209377A (en) * 2019-04-26 2019-09-06 平安科技(深圳)有限公司 Interface packet processing method, device, equipment and storage medium based on factory class
WO2019233293A1 (en) * 2018-06-07 2019-12-12 阿里巴巴集团控股有限公司 Method and apparatus for developing application program
CN110688355A (en) * 2018-06-19 2020-01-14 北京京东尚科信息技术有限公司 Method and device for changing container state
CN110780875A (en) * 2019-10-25 2020-02-11 维沃移动通信有限公司 Update interface display method and electronic equipment
CN111046317A (en) * 2019-12-27 2020-04-21 北京奇艺世纪科技有限公司 Page data acquisition method, device, equipment and computer readable storage medium
CN111324593A (en) * 2020-02-17 2020-06-23 广州虎牙科技有限公司 Data table detection method and device, electronic equipment and computer readable storage medium
CN111400102A (en) * 2020-03-18 2020-07-10 深圳前海微众银行股份有限公司 Application program change monitoring method, device, equipment and storage medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8719781B2 (en) * 2011-12-01 2014-05-06 Amer Agovic Universal and adaptive software development platform for data-driven applications
US20150113121A1 (en) * 2013-10-18 2015-04-23 Telefonaktiebolaget L M Ericsson (Publ) Generation at runtime of definable events in an event based monitoring system

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9449189B1 (en) * 2015-11-03 2016-09-20 International Business Machines Corporation Protection of state data in computer system code
CN108415814A (en) * 2018-01-11 2018-08-17 平安科技(深圳)有限公司 Automatically record field changing method, application server and computer readable storage medium
WO2019233293A1 (en) * 2018-06-07 2019-12-12 阿里巴巴集团控股有限公司 Method and apparatus for developing application program
CN110688355A (en) * 2018-06-19 2020-01-14 北京京东尚科信息技术有限公司 Method and device for changing container state
CN109190119A (en) * 2018-08-22 2019-01-11 腾讯科技(深圳)有限公司 Time extracting method and device, storage medium and electronic device
CN110209377A (en) * 2019-04-26 2019-09-06 平安科技(深圳)有限公司 Interface packet processing method, device, equipment and storage medium based on factory class
CN110780875A (en) * 2019-10-25 2020-02-11 维沃移动通信有限公司 Update interface display method and electronic equipment
CN111046317A (en) * 2019-12-27 2020-04-21 北京奇艺世纪科技有限公司 Page data acquisition method, device, equipment and computer readable storage medium
CN111324593A (en) * 2020-02-17 2020-06-23 广州虎牙科技有限公司 Data table detection method and device, electronic equipment and computer readable storage medium
CN111400102A (en) * 2020-03-18 2020-07-10 深圳前海微众银行股份有限公司 Application program change monitoring method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN112051985A (en) 2020-12-08

Similar Documents

Publication Publication Date Title
US20210109748A1 (en) Application programming interface for a registry
US20060010337A1 (en) Management system and management method
US20200264853A1 (en) System for generating a map illustrating bindings
CN110990346A (en) File data processing method, device, equipment and storage medium based on block chain
CN112416957A (en) Data increment updating method and device based on data model layer and computer equipment
CN115357590A (en) Recording method and device for data change, electronic device and storage medium
CN111651196A (en) Document publishing method, device and server
CN110716804A (en) Method and device for automatically deleting useless resources, storage medium and electronic equipment
CN112051985B (en) Event triggering method, device, electronic equipment and readable storage medium
CN117376092A (en) Fault root cause positioning method, device, equipment and storage medium
CN112241355A (en) Link tracking method, system, computer readable storage medium and electronic device
CN114500249B (en) Root cause positioning method and device
CN113268401B (en) Log information output method and device and computer readable storage medium
CN115878864A (en) Data retrieval method, device and equipment and readable storage medium
CN110083509B (en) Method and device for arranging log data
CN114896082A (en) Message processing method and device, electronic equipment and storage medium
CN114281688A (en) Codeless or low-code automatic case management method and device
CN110221952B (en) Service data processing method and device and service data processing system
CN110888643A (en) Page processing method and device
CN114077587A (en) Rule engine based business processing method, rule engine, medium and device
CN111694676A (en) Processing method and device for key value observation mode
CN113672910B (en) Security event processing method and device
CN112948362B (en) Data quality evaluation method, device, computer equipment and storage medium
CN114625395A (en) Data processing method and device and electronic equipment
US20240168826A1 (en) Method of analyzing change in api in cloud

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant