Message collection method, system and device and medium
By configuring the target configuration information in the configuration file and using the class reflection mechanism to dynamically obtain the message content and push targets, the problems of low development efficiency and poor scalability of message collection methods in the existing technology are solved, automation and flexibility are achieved, and improvements are achieved. Development efficiency and adaptability.
Patent Information
- Application Number
- CN202411371186.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2025-01-03
- Estimated Expiration
- 2044-09-29
AI Technical Summary
The existing message collection methods are inefficient in development and poor scalability, and need to be adapted and adjusted separately for different data sources, resulting in high development complexity and high maintenance costs, making it difficult to quickly respond to market changes or changes in business needs.
By preconfiguring the target configuration information in the configuration file, including the path information of the target method, the path information of the class method and the preset parameter fetch expression, using the identification conversion method and the class reflection mechanism, dynamically obtain the message content and push the target, and realize the message Automation and flexibility of acquisition.
Without hard-coded message acquisition parameters, it realizes automatic triggering of message acquisition after the target method is executed, flexibly adjusts the message acquisition strategy and frequency, improves the development efficiency of message access for business modules, and meets different business needs and environmental requirements.
Smart Images

Figure CN119254740A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of information technology, and in particular, relates to a message collection method, system, device and medium. Background Art
[0002] The message collection system is responsible for collecting, processing and distributing message content and push targets corresponding to various businesses, so as to push message content to push targets, thereby supporting key business processes such as decision making, customer service and internal communications.
[0003] In the existing message collection system, the acquisition of message content and push targets is often performed through the interface pre-set by the program, based on the preset target data source to perform message collection, that is, the preset target data source is processed to form the message content and push the message to the push target. However, the above-mentioned message collection method based on code development not only requires developers to have a deep understanding of the business modules to be connected, various technical platforms and APIs, but also because the data structure and page layout of different business modules are different, the written code cannot fully adapt to all target data sources, and each target data source needs to be adapted and adjusted separately, which increases the difficulty of developing and maintaining the message collection function; and, because the logic of message collection is hard-coded in the code, when the message sending requirements change, a large number of code modifications are required, for example, when the target data source changes, the logic of message collection needs to be re-modified according to the changed target data source. This not only increases the complexity and maintenance cost of message collection function development, reduces development efficiency, but also has poor scalability and is difficult to quickly respond to market changes or changes in business needs.
[0004] Based on this, how to provide a simple, efficient and scalable message collection method is an important issue that needs to be solved urgently. Summary of the invention
[0005] In view of the above-mentioned shortcomings of the prior art, the purpose of the present application is to provide a message collection method to solve the problems of low development efficiency and poor scalability of the current message collection method.
[0006] To achieve the above-mentioned purpose and other related purposes, the present invention provides a message collection method, which pre-configures target configuration information in a configuration file, wherein the target configuration information includes: path information of a target method, path information of a class method corresponding to the target method, and a preset parameter expression; the preset parameter expression includes at least: a message content acquisition expression and a push target acquisition expression, and the method includes the following steps:
[0007] According to the target configuration information, confirm the currently corresponding target method; extract the first execution result obtained after the target method is executed; and use the identification conversion method to convert the first execution result into a corresponding unique identification;
[0008] Based on the unique identifier and in combination with the target configuration information, the agent executes the class method corresponding to the unique identifier by using the class reflection mechanism to obtain a second execution result corresponding to the class method;
[0009] Based on the second execution result, acquiring the message content corresponding to the second execution result according to the message content acquisition expression; and based on the second execution result, acquiring the push target corresponding to the second execution result according to the push target acquisition expression;
[0010] The target configuration information corresponds to the current message sending requirement.
[0011] In one embodiment of the present invention, the preset parameter expression also includes: an identifier acquisition expression; then the identifier conversion method is used to convert the first execution result into a corresponding unique identifier, including: based on the first execution result, according to the identifier acquisition expression, obtaining the unique identifier.
[0012] In one embodiment of the present invention, the preset parameter expression further includes: a collection condition expression; then the message collection method further includes: after obtaining the second execution result:
[0013] Based on the second execution result, according to the collection condition expression, a judgment result of whether it is necessary to collect messages is obtained; if the judgment result is that messages need to be collected, based on the second execution result, according to the push target acquisition expression and, the push target corresponding to the second execution result is obtained; and based on the second execution result, according to the message content acquisition expression, the message content corresponding to the second execution result is obtained; if the judgment result is that it is not necessary to collect messages, exit.
[0014] In one embodiment of the present invention, before obtaining the first execution result, the message collection method further includes:
[0015] The control flow jump process is executed, including: obtaining the end position of the target method, and changing the execution order of the target method before the end position so that the program flow of the target method is transferred to the message collection method.
[0016] In one embodiment of the present invention, before obtaining the end position of the target method, the message collection method further includes:
[0017] A startup class is created in the application; the startup class includes a construction method; the construction method is used to traverse each target configuration information in the configuration file when the application is started, so as to execute the control flow jump process based on the target configuration information; the application includes the target method and the message collection method.
[0018] In one embodiment of the present invention, based on the unique identifier and in combination with the target configuration information, using a class reflection mechanism, the proxy executes the class method corresponding to the unique identifier to obtain a second execution result corresponding to the class method, including:
[0019] Use the reflection API to obtain the class method corresponding to the unique identifier, use the dynamic proxy mechanism to create a proxy object, call the class method through the proxy object, use the unique identifier as the input parameter of the class method, and obtain the output result of the class method as the second execution result.
[0020] Correspondingly, the present invention provides a message collection system, characterized by comprising:
[0021] The identification acquisition module is used to confirm the current corresponding target method according to the target configuration information; extract the first execution result obtained after the target method is executed; and use the identification conversion method to convert the first execution result into a corresponding unique identification;
[0022] An agent module, configured to execute the class method corresponding to the unique identifier based on the unique identifier and in combination with the target configuration information, and to obtain a second execution result corresponding to the class method by using a class reflection mechanism;
[0023] A collection module is used to obtain an expression according to the message content based on the second execution result to obtain the message content corresponding to the second execution result; and to obtain an expression according to the push target based on the second execution result to obtain the push target corresponding to the second execution result.
[0024] In one embodiment of the present invention, the message collection system further includes:
[0025] A judgment module is used to obtain a judgment result of whether it is necessary to collect messages based on the second execution result and according to a collection condition expression; if the judgment result is that messages need to be collected, then based on the second execution result, according to the push target acquisition expression, the push target corresponding to the second execution result is acquired; and based on the second execution result, according to the message content acquisition expression, the message content corresponding to the second execution result is acquired; if the judgment result is that it is not necessary to collect messages, exit.
[0026] Correspondingly, the present invention provides a computer device, the device comprising: a memory for storing a computer program;
[0027] The processor is used to execute the computer program stored in the memory so that the device executes the message collection method as described above.
[0028] Correspondingly, the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the message collection method as described above is implemented.
[0029] As described above, the message collection method, system, device and medium described in the present application have at least the following beneficial effects:
[0030] By configuring the parameters and settings required for the message collection method to run in the configuration file corresponding to the message collection method, the first execution result of the target method is automatically obtained after the execution of the target method is completed, and the corresponding unique identifier is obtained based on the first execution result. Based on the unique identifier, in combination with the configuration information, the class reflection mechanism is used to obtain the second execution result of the class method corresponding to the target method. Based on the second execution result, the message content and the push target are obtained. The method can automatically obtain the message content and the push target according to the dynamic content of the target data source without hard-coding the parameter values of the message collection. The message collection method can be automatically triggered to perform message collection after the target method is executed without modifying the code. Not only can the message collection strategy and / or target of the message collection method be flexibly adjusted, but the message collection frequency of the message collection method can also be determined according to the execution frequency of the target method, etc., so as to meet different business needs or environmental requirements and improve the development efficiency of business module message access. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 A flow chart of a message collection method provided by the present application in a first embodiment is shown.
[0032] Figure 2 A flow chart of the message collection method provided in the present application in a second embodiment is shown.
[0033] Figure 3 A flow chart of the message collection method provided in the present application in the third embodiment is shown.
[0034] Figure 4 A schematic diagram showing the flow of the message collection method provided in the present application in a fourth embodiment.
[0035] Figure 5A module structure diagram of a message collection system provided by the present application in one embodiment is shown.
[0036] Figure 6 A module structure diagram of the message collection system provided in the present application in another embodiment is shown.
[0037] Figure 7 A schematic diagram of the structure of a computer device provided by the present application in one embodiment is shown.
[0038] Description of Reference Numerals
[0039] S1~S6, steps; S1', step; 200, message collection system; 201, identification acquisition module; 202, agent module; 203, collection module; 204, judgment module; 300, device; 301, memory; 302, processor. DETAILED DESCRIPTION
[0040] The following describes the embodiments of the present application through specific examples, and those skilled in the art can easily understand other advantages and effects of the present application from the contents disclosed in this specification. The present application can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present application. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.
[0041] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present application, and thus the drawings only show components related to the present application rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed at will, and the component layout may also be more complicated.
[0042] To facilitate the understanding of the technical solutions provided by the present application, the relevant terms in the present application are explained before the specific embodiments, as follows:
[0043] Configuration table: used to store the configuration information of the software system, providing the necessary parameters and settings for the software system to adjust and optimize the behavior of the system in different environments (development, testing, production, etc.).
[0044] Configuration information: Data used to describe and set various parameters and settings required for software or system operation.
[0045] Root path: refers to the top-level directory or starting location of a project, which is the starting point for accessing and referencing files, directories, and resources within the project.
[0046] Class reflection mechanism: refers to dynamically obtaining class information when the program is running, including class methods, properties, and constructors, etc., so as to call the class methods and create objects at runtime through the reflection mechanism based on the class information.
[0047] Dynamic proxy mechanism: a design pattern that creates a proxy object to access the target object instead.
[0048] ClassVisitor subclass: It is an abstract class in the ASM library used to access all elements of a Java class and perform read and write operations.
[0049] visitMethod method: It is a method in the ClassVisitor subclass, which is used to process the methods in the class, including the method name, access modifiers, parameters and other information.
[0050] The embodiments of the present application are described in detail below in conjunction with the accompanying drawings. In the absence of conflict, the features of the following embodiments and implementations can be combined with each other.
[0051] The following embodiments of the present application provide a message collection method, by configuring the parameters and settings required for the message collection method to run in a configuration file corresponding to the message collection method, so as to automatically obtain a first execution result of the target method after the execution of the target method is completed, obtain a corresponding unique identifier based on the first execution result, obtain a second execution result of the class method corresponding to the target method based on the unique identifier and in combination with configuration information, and obtain a message content and a push target based on the second execution result. The method can automatically obtain the message content and the push target according to the dynamic content of the target data source without hard-coding the parameter values of the message collection, so that the message collection method can be automatically triggered to perform message collection after the target method is executed without modifying the code, and not only can the message collection strategy and / or target of the message collection method be flexibly adjusted, but the message collection frequency of the message collection method can also be determined according to the execution frequency of the target method, etc., so as to meet different business needs or environmental requirements and improve the development efficiency of business module message access.
[0052] See also Figure 1 , showing a flow chart of a message collection method provided by the present invention in a first embodiment.
[0053] like Figure 1As shown, in this embodiment, the message collection method provided by the present invention is pre-configured with target configuration information in the configuration file corresponding to the method; the target configuration information includes: path information of the target method, path information of the class method corresponding to the target method and a preset parameter expression; the preset parameter expression includes at least: a push target acquisition expression and a message content acquisition expression; the method includes the following steps:
[0054] Step S2: confirm the currently corresponding target method according to the target configuration information; obtain the first execution result of the target method; and convert the first execution result into a corresponding unique identifier by using an identifier conversion method;
[0055] The unique identifier is a unique identifier of a second execution result obtained after the class method is executed;
[0056] The message content acquisition expression is a pre-built language expression used to acquire the message content;
[0057] The push target acquisition expression is a pre-built language expression used to acquire the push target.
[0058] Specifically, according to the path information of the target method in the target configuration information, the currently corresponding target method is determined; the first execution result of the target method is obtained, and the first execution result is converted into a corresponding unique identifier using the identifier conversion method.
[0059] Optionally, the class method is executed earlier than the target method.
[0060] Optionally, the implementation method of configuring the target configuration information in a configuration file corresponding to the message collection method includes:
[0061] A configuration table corresponding to the message collection method is obtained, and the target configuration information is stored in the configuration table to implement the configuration of settings and parameters required when the message collection method is running.
[0062] Optionally, the preset parameter expression also includes: an identifier acquisition expression; then the identifier conversion method is used to convert the first execution result into a corresponding unique identifier, including: based on the first execution result, according to the identifier acquisition expression, the unique identifier is obtained, including: inputting the first execution result into the identifier acquisition expression, and obtaining the calculation result output by the identifier acquisition expression as the unique identifier.
[0063] Optionally, the path information of the target method includes: the root path of the target method.
[0064] Optionally, the path information of the class method includes: the root path of the class method.
[0065] Optionally, the type of each expression includes: SpEL expression, OGNL expression, MVEL expression or JEXL expression, etc.
[0066] Exemplarily, the unique identifier is an ID of the second execution result.
[0067] It should be noted that the root path of the target method is configured in the configuration file corresponding to the message collection method, so that the target method is used as the trigger node for the message collection method to execute message collection, so that the message collection method starts to collect messages after the execution of the target method is completed; and the root path of the class method is configured in the corresponding configuration file, so that the message collection method starts to collect and process data from the root path of the class method, so as to efficiently locate and collect the data required by the message collection method, and can flexibly adjust the position of the target data source without modifying the code or performing complex configuration adjustments, which is convenient for management and maintenance of the collection configuration.
[0068] Step S4: Based on the unique identifier and in combination with the target configuration information, the class reflection mechanism is used to proxy and execute the class method corresponding to the unique identifier to obtain a second execution result corresponding to the class method;
[0069] Specifically, the reflection API is used to obtain the class method corresponding to the unique identifier, the dynamic proxy mechanism is used to create a proxy object, the class method is called through the proxy object, the unique identifier is used as an input parameter of the class method, and the output result of the class method is obtained as the second execution result.
[0070] Optionally, the class reflection mechanism includes: a Java class reflection mechanism.
[0071] Optionally, the reflection API includes: Java reflection API.
[0072] Optionally, the dynamic proxy mechanism includes: Java's dynamic proxy mechanism.
[0073] Step S6: based on the second execution result, obtain an expression according to the message content to obtain the message content corresponding to the second execution result; and based on the second execution result, obtain an expression according to the push target to obtain the push target corresponding to the second execution result.
[0074] Specifically, the second execution result is input into the push target acquisition expression, and the calculation result output by the push target acquisition expression is obtained as the push target corresponding to the second execution result; the second execution result is input into the message content acquisition expression, and the calculation result of the message content acquisition expression is obtained as the message content corresponding to the second execution result.
[0075] Optionally, after obtaining the message content and the push target, the message collection method also includes: sending a message containing the message content to the message notification target, including: creating a message class containing the message content and the push target, creating an instance of the message class and setting properties of the message class at the message sending location, obtaining the corresponding message body, and sending the message body to the push target.
[0076] Optionally, the message content includes: a message title, a message introduction and / or a message body, etc.
[0077] Optionally, when the message body needs to be sent or stored over a network, the message body is serialized into a format such as JSON or XML.
[0078] Optionally, the message body may be sent to a message queue, stored in a database, or sent to other services via a network.
[0079] To facilitate understanding of the technical content provided by this solution, in a specific embodiment, an exemplary description of the message collection method provided by this solution is given as follows:
[0080] In order to facilitate the project leader to grasp the rectification status of the project in a timely manner, the message collection method provided by this scheme uses the "submit rectified work order" method as the target method in the business module of the rectification work order, and uses the class method corresponding to the "rectification work order" as the class method corresponding to the target method, and configures the corresponding target configuration information in the configuration file corresponding to the message collection method. When the application is started, the message collection method determines that the "submit rectified work order" method is the current corresponding target method according to the target configuration information. When it is detected that the "submit rectified work order" operation is completed, the execution result of "submit rectified work order" is obtained, and the identification conversion method is used to convert the execution result into a corresponding unique identification; based on the unique identification, combined with the target configuration information, the class reflection mechanism is used to proxy the execution of the class method corresponding to the unique identification to obtain the business data of the class method; based on the business data, the message content and the push target are obtained according to the message content acquisition expression and the push target acquisition expression respectively.
[0081] See also Figure 2, showing a flow chart of a message collection method provided by the present invention in a second embodiment.
[0082] Optional, such as Figure 2 As shown, the preset parameter expression also includes: a collection condition expression, which is a preset trigger condition for controlling message collection based on the second execution result; then the message collection method further includes, before executing step S6:
[0083] Step S5: Based on the second execution result and according to the collection condition expression, a judgment result of whether messages need to be collected is obtained. When the judgment result is that messages need to be collected, step S6 is executed; when the judgment result is that messages do not need to be collected, the process exits.
[0084] Specifically, the second execution result is input into the collection condition expression to obtain the calculation result output by the collection condition expression, and based on the calculation result output by the collection condition expression, it is determined whether the message needs to be collected. If so, step S6 is executed; if not, exit.
[0085] A message collection method provided in the above embodiment configures the parameters and settings required for the message collection method to run in a configuration file corresponding to the message collection method, so as to automatically obtain the first execution result of the target method after the execution of the target method is completed, obtain the corresponding unique identifier based on the first execution result, obtain the second execution result of the class method corresponding to the target method based on the unique identifier and in combination with the configuration information, and obtain the message content and push target based on the second execution result. The method can automatically obtain the message content and push target according to the dynamic content of the target data source without hard-coding the parameter values of the message collection, so that the message collection method can be automatically triggered to perform message collection after the target method is executed without modifying the code, and the message collection strategy and / or target of the message collection method can be flexibly adjusted, and the message collection frequency of the message collection method can be determined according to the execution frequency of the target method, so as to meet different business needs or environmental requirements and improve the development efficiency of business module message access.
[0086] See also Figure 3 , showing a flow chart of a message collection method provided by the present invention in a third embodiment;
[0087] Optional, such as Figure 3 As shown, the message collection method provided by the present invention further includes, before executing step S2:
[0088] Step S1, executing the control flow jump process, including: obtaining the end position of the target method, and before the end position, changing the execution order of the target method so that the program execution flow of the target method is transferred to the message collection method.
[0089] Specifically, create a ClassVisitor subclass, and rewrite the visitMethod method in the ClassVisitor subclass so that the visitMethod method detects whether the method name it visits is the method name of the target method. If so, then according to the execution order of the instructions, each instruction is detected in turn to see if it is a return instruction. If so, a jump instruction is inserted before the return instruction to make the program execution flow of the target method jump to the message collection method.
[0090] Optionally, the jump instruction includes: GOTO, etc.
[0091] Optionally, the return instruction includes: RETURN, IRETURN and ARETURN, etc.
[0092] The message collection method provided in this embodiment obtains the end position of the target method and changes the execution order of the target method before the end position, so that the program execution process of the target method is transferred to the message collection method to automatically obtain the execution result of the target method, and uses the execution result as the input parameter of the message collection method to realize automatic message collection.
[0093] See also Figure 4 , showing a flow chart of a message collection method provided by the present invention in a fourth embodiment;
[0094] Optional, such as Figure 4 As shown, the message collection method provided by the present invention further includes, before executing step S1:
[0095] Step S1', creating a startup class in the application; the startup class includes a construction method; the construction method is used to traverse each of the target configuration information in the configuration file when the application is started, so as to execute the control flow jump process respectively based on each of the target configuration information;
[0096] Wherein, the application includes the target method and the message collection method.
[0097] Specifically, a startup class is created in the application, and a construction method is created in the startup class, so that when the application is started, the construction method traverses each target configuration information in the configuration file, and calls the ClassVisitor subclass according to each target configuration information, so that the program execution flow of the target method in the corresponding target configuration information jumps to the message collection method to automatically perform message collection.
[0098] The message collection method provided in this embodiment creates a startup class, and when the application is started, automatically executes the construction method in the startup class, traverses each of the target configuration information in the configuration file, and controls the program execution flow of the target method corresponding to each of the target configuration information to jump to the message collection method, so as to realize automatic message collection without code intrusion.
[0099] See also Figure 5 , showing a module structure diagram of a message collection system provided by the present invention in one embodiment;
[0100] like Figure 5 As shown, in this embodiment, the present invention provides a message collection system 200, the system comprising:
[0101] The identification acquisition module 201 is used to confirm the current corresponding target method according to the target configuration information; extract the first execution result obtained after the target method is executed; and use the identification conversion method to convert the first execution result into a corresponding unique identification;
[0102] The proxy module 202 is used to proxy the execution of the class method corresponding to the unique identifier based on the unique identifier and in combination with the target configuration information, and to obtain a second execution result corresponding to the class method by using a class reflection mechanism;
[0103] The acquisition module 203 is used to obtain an expression according to the message content based on the second execution result to obtain the message content corresponding to the second execution result; and to obtain an expression according to the push target based on the second execution result to obtain the push target corresponding to the second execution result.
[0104] See also Figure 6 , showing a module structure diagram of a message collection system provided by the present invention in another embodiment;
[0105] like Figure 6 As shown, in this embodiment, the message collection system also includes:
[0106] A judgment module is used to obtain a judgment result of whether it is necessary to collect messages based on the second execution result and the collection condition expression; if the judgment result is that messages need to be collected, then based on the second execution result, according to the push target acquisition expression, the push target corresponding to the second execution result is obtained; and based on the second execution result, according to the message content acquisition expression, the message content corresponding to the second execution result is obtained; if the judgment result is that it is not necessary to collect messages, exit.
[0107] See also Figure 7 , showing a schematic structural diagram of a computer device provided by the present invention in one embodiment;
[0108] like Figure 7 As shown, in this embodiment, the device 300 provided by the present invention includes a memory 301 and a processor 302, the memory 301 is used to store a computer program; the processor 302 is used to execute the computer program stored in the memory 301, so that the terminal 300 executes the message collection method of any of the above embodiments of the present application. Since the specific implementation process of the steps of the message collection method has been described in detail in the above embodiments, it will not be repeated here.
[0109] The memory 301 includes: ROM (Read Only Memory image), RAM (Random Access Memory), a disk, a USB flash drive, a memory card, or an optical disk, etc., which can store program codes.
[0110] The processor 302 is connected to the memory 301 and is used to execute the computer program stored in the memory 301 so that the terminal 300 executes the above-mentioned message collection method.
[0111] The present application embodiment also provides a computer-readable storage medium. A person of ordinary skill in the art can understand that all or part of the steps in the method for implementing the above embodiment can be completed by a program to instruct the processor, and the program can be stored in a computer-readable storage medium, and the storage medium is a non-transitory medium, such as a random access memory, a read-only memory, a flash memory, a hard disk, a solid-state hard disk, a magnetic tape, a floppy disk, an optical disc, and any combination thereof. The above storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or a data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a digital video disc (DVD)), or a semiconductor medium (e.g., a solid-state hard disk (SSD)), etc.
[0112] The present application embodiment may also provide a computer program product, the computer program product including one or more computer instructions. When the computer instructions are loaded and executed on a computing device, the process or function described in the embodiment of the present application is generated in whole or in part. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer or data center.
[0113] When the computer program product is executed by a computer, the computer executes the method described in the above method embodiment. The computer program product may be a software installation package, and when the above method is required, the computer program product may be downloaded and executed on a computer.
[0114] The descriptions of the processes or structures corresponding to the above-mentioned figures have different emphases. For parts that are not described in detail in a certain process or structure, please refer to the relevant descriptions of other processes or structures.
[0115] The above embodiments are merely illustrative of the principles and effects of the present application and are not intended to limit the present application. Anyone familiar with the technology may modify or change the above embodiments without violating the spirit and scope of the present application. Therefore, all equivalent modifications or changes made by a person of ordinary skill in the art without departing from the spirit and technical ideas disclosed in the present application shall still be covered by the claims of the present application.
Claims
1. A message collection method, characterized in that: Pre-configure target configuration information in a configuration file, the target configuration information includes: path information of the target method, path information of the class method corresponding to the target method, and a preset parameter expression; the preset parameter expression includes at least: a message content acquisition expression and a push target acquisition expression; the method includes: According to the target configuration information, confirm the current corresponding target method; extract the first execution result obtained after the target method is executed; and use the identification conversion method to convert the first execution result into a corresponding unique identification; Based on the unique identifier and in combination with the target configuration information, the agent executes the class method corresponding to the unique identifier by using the class reflection mechanism to obtain a second execution result corresponding to the class method; Based on the second execution result, acquiring the message content corresponding to the second execution result according to the message content acquisition expression; and based on the second execution result, acquiring the push target corresponding to the second execution result according to the push target acquisition expression; The target configuration information corresponds to the current message sending requirement.
2. The method according to claim 1, characterized in that The preset parameter expression also includes: an identifier acquisition expression; then the identifier conversion method is used to convert the first execution result into a corresponding unique identifier, including: based on the first execution result, according to the identifier acquisition expression, to obtain the unique identifier.
3. The method according to claim 1, characterized in that The preset parameter expression also includes: a collection condition expression; Then, after obtaining the second execution result, the message collection method further includes: Based on the second execution result, according to the collection condition expression, a judgment result of whether it is necessary to collect messages is obtained; if the judgment result is that messages need to be collected, based on the second execution result, according to the push target acquisition expression and, the push target corresponding to the second execution result is obtained; and based on the second execution result, according to the message content acquisition expression, the message content corresponding to the second execution result is obtained; if the judgment result is that it is not necessary to collect messages, exit.
4. The method according to claim 1, characterized in that: Before obtaining the first execution result, the message collection method further includes: The control flow jump process is executed, including: obtaining the end position of the target method, and changing the execution order of the target method before the end position so that the program flow of the target method is transferred to the message collection method.
5. The method according to claim 4, characterized in that Before obtaining the end position of the target method, the message collection method further includes: A startup class is created in the application; the startup class includes a construction method; the construction method is used to traverse each target configuration information in the configuration file when the application is started, so as to execute the control flow jump process based on the target configuration information; the application includes the target method and the message collection method.
6. The method according to claim 1, characterized in that The method of executing the class method corresponding to the unique identifier based on the unique identifier and in combination with the target configuration information by using a class reflection mechanism to obtain a second execution result corresponding to the class method includes: Use the reflection API to obtain the class method corresponding to the unique identifier, use the dynamic proxy mechanism to create a proxy object, call the class method through the proxy object, use the unique identifier as the input parameter of the class method, and obtain the output result of the class method as the second execution result.
7. A message collection system, characterized in that: include: The identification acquisition module is used to confirm the current corresponding target method according to the target configuration information; Extracting a first execution result obtained after executing the target method; Using an identification conversion method, converting the first execution result into a corresponding unique identification; An agent module, configured to execute the class method corresponding to the unique identifier based on the unique identifier and in combination with the target configuration information, and to obtain a second execution result corresponding to the class method by using a class reflection mechanism; A collection module, configured to obtain an expression according to the message content based on the second execution result, and obtain the message content corresponding to the second execution result; Based on the second execution result, a push target corresponding to the second execution result is obtained according to a push target acquisition expression.
8. The system according to claim 7, characterized in that The system further comprises: A judgment module is used to obtain a judgment result of whether it is necessary to collect messages based on the second execution result and according to a collection condition expression; if the judgment result is that messages need to be collected, then based on the second execution result, according to the push target acquisition expression, the push target corresponding to the second execution result is obtained; and based on the second execution result, according to the message content acquisition expression, the message content corresponding to the second execution result is obtained; if the judgment result is that it is not necessary to collect messages, exit.
9. A computer device, characterized in that: The device comprises: Memory for storing computer programs; A processor, configured to execute the computer program stored in the memory so as to enable the apparatus to perform the method according to any one of claims 1 to 6.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Method and device for sending system short message based on SPI
CN113795001A
Byte code instrumentation method and system and byte code instrumentation plug-in framework
CN113885879A
Method and device for acquiring service calling information and method for testing vulnerability of service
CN115244516A
Method and apparatus for acquiring service calling information, and vulnerability test method for service
WO2021248310A1
