A message collection method, system, device and medium
By configuring target information in the configuration file and utilizing the class reflection mechanism and dynamic proxy, the execution results of the message collection method are automatically obtained, which solves the problems of low development efficiency and poor scalability in the existing technology, realizes flexible message collection strategies and frequency adjustments, and improves the development efficiency of business module message access.
Patent Information
- Application Number
- CN202411371186.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2044-09-29
AI Technical Summary
Existing message collection methods have low development efficiency and poor scalability. They require individual adaptation and adjustment for each target data source, resulting in high development complexity and difficulty in quickly responding to changes in business needs.
By pre-configuring the target configuration information in the configuration file and utilizing the class reflection mechanism and dynamic proxy mechanism, the execution result of the target method is automatically obtained and a unique identifier is obtained. Based on the identifier, the message content and push target are obtained, avoiding hard-coded parameter values and realizing flexible adjustment of message collection strategies and frequencies.
Without modifying the code, message collection is automatically triggered to meet different business needs and environmental requirements, improving the efficiency and flexibility of message access development.
Smart Images

Figure CN119254740B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information technology, and in particular 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 existing message collection systems, message content and push targets are often acquired through pre-defined interfaces in the program, executing message collection based on a preset target data source. Specifically, the preset target data source is processed to generate message content, and the message is then pushed to the push target. However, these code-based message collection methods not only require developers to have a deep understanding of the business modules, various technology platforms, and APIs being connected, but also, because the data structures and page layouts of different business modules vary, the written code cannot fully adapt to all target data sources, requiring separate adaptation and adjustment for each target data source, increasing the difficulty of developing and maintaining message collection functions. Furthermore, because the message collection logic is hard-coded in the code, changes in message sending requirements require extensive code modifications. For example, when the target data source changes, the message collection logic needs to be re-modified based on the changed target data source. This not only increases the complexity and maintenance costs of message collection development and reduces development efficiency, but also suffers from poor scalability, making it 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 this 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 and other related purposes, the present invention provides a message collection method, which pre-configures target configuration information in a configuration file. 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. The method includes the following steps:
[0007] According to the target configuration information, the currently corresponding target method is confirmed; a first execution result obtained after the target method is executed is extracted; and the first execution result is converted into a corresponding unique identifier using an identifier conversion method;
[0008] 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;
[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, after obtaining the second execution result, the message collection method further includes:
[0013] Based on the second execution result, according to the collection condition expression, a judgment result of whether messages need to be collected is obtained; 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 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 message collection is not necessary, 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, the proxy execution of the class method corresponding to the unique identifier based on the unique identifier and in combination with the target configuration information using a class reflection mechanism to obtain a second execution result corresponding to the class method includes:
[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] An 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, based on the unique identifier and in combination with the target configuration information, utilize a class reflection mechanism to proxy execution of a class method corresponding to the unique identifier, and obtain a second execution result corresponding to the class method;
[0023] The acquisition module is used 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; and to obtain an expression according to the push target based on the second execution result, and 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 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.
[0026] Correspondingly, the present invention provides a computer device, the device comprising: a memory for storing a computer program;
[0027] The processor is configured to execute the computer program stored in the memory so as to enable the apparatus to execute 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 described above is implemented.
[0029] As described above, the message collection method, system, device, and medium described in this application have at least the following beneficial effects:
[0030] By configuring the parameters and settings required for the message collection method to run in a configuration file corresponding to the message collection method, a first execution result of the target method is automatically obtained after the target method is executed. Based on the first execution result, a corresponding unique identifier is obtained. Based on the unique identifier and in combination with configuration information, a class reflection mechanism is used to obtain a second execution result of the class method corresponding to the target method. Based on the second execution result, the message content and push target are obtained. The method can automatically obtain the message content and push target based on the dynamic content of the target data source without hard-coding the parameter values of the message collection. This allows the message collection method to 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 based on the execution frequency of the target method, thereby meeting different business needs or environmental requirements and improving the development efficiency of business module message access. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 The figure shows a flow chart of a message collection method provided by the present application in a first embodiment.
[0032] Figure 2 The figure shows a flow chart of the message collection method provided by the present application in the second embodiment.
[0033] Figure 3 The figure shows a flow chart of the message collection method provided by the present application in the third embodiment.
[0034] Figure 4 The figure shows a flow chart of the message collection method provided by the present application in the fourth embodiment.
[0035] Figure 5The following is a module structure diagram of a message collection system provided by the present application in one embodiment.
[0036] Figure 6 Shown is a module structure diagram of the message collection system provided by this application in another embodiment.
[0037] Figure 7 FIG2 is a schematic structural diagram of a computer device provided by the present application in one embodiment.
[0038] Description of Reference Numerals
[0039] S1 to 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. Those skilled in the art can easily understand the other advantages and effects of the present application from the content disclosed in this specification. The present application can also be implemented or applied through other different specific embodiments. The details in this specification can also be modified or changed 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 unless they 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. Therefore, the illustrations only show components related to the present application and are not drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component can be changed at will, and the component layout type may also be more complicated.
[0042] To facilitate understanding of the technical solutions provided by this application, the relevant terms in this application are defined 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, including class methods, properties, and constructors, when the program is running, 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: It is 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, used to process the methods in the class, including the method name, access modifiers, parameters and other information.
[0050] The following embodiments of the present application are described in detail with reference to 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, a first execution result of the target method is automatically obtained after the execution of the target method is completed. Based on the first execution result, a corresponding unique identifier is obtained. Based on the unique identifier, in combination with configuration information, a class reflection mechanism is used to obtain a second execution result of the class method corresponding to the target method. Based on the second execution result, the message content and push target are obtained. The method can automatically obtain the message content and push target based on the dynamic content of the target data source without hard-coding the parameter values of the message collection. This achieves that 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 based on the execution frequency of the target method, thereby meeting different business needs or environmental requirements and improving the development efficiency of business module message access.
[0052] See also Figure 1 , which is 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: confirming the current corresponding target method according to the target configuration information; obtaining a first execution result of the target method; and converting the first execution result into a corresponding unique identifier 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 obtain 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 current 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, obtaining the unique identifier, 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 the 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 collecting 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 from the root path of the class method to collect and process data, 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 method corresponding to the unique identifier is executed by proxy using a class reflection mechanism 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 the 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, a calculation result output by the push target acquisition expression is acquired as a push target corresponding to the second execution result; and the second execution result is input into the message content acquisition expression, a calculation result of the message content acquisition expression is acquired as message content corresponding to the second execution result.
[0075] Optionally, after the message content and the push target are acquired, the message collection method further 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 an attribute of the message class at a message sending position, obtaining a corresponding message body, and sending the message body to the push target.
[0076] Optionally, the message content includes a message title, a message lead, and / or a message body.
[0077] Optionally, when the message body needs to be sent or stored through a network, the message body is serialized into a JSON or XML format.
[0078] Optionally, the message body can be sent to a message queue, stored in a database, or sent to other services through a network.
[0079] In order to facilitate understanding of the technical content provided by the present scheme, in a specific embodiment, the message collection method provided by the present scheme is exemplarily described as follows:
[0080] In order to facilitate the project manager to timely master the rectification situation of the project, the message collection method provided by the present scheme is in the business module of the rectification work order, the method of "submitting the rectified work order" is taken as a target method, the class method corresponding to the rectification work order is taken as a class method corresponding to the target method, and the corresponding target configuration information is configured in the configuration file corresponding to the message collection method. When the application program is started, the target configuration information is used to determine that the method of "submitting the rectified work order" is the current corresponding target method. When it is detected that the operation of "submitting the rectified work order" is completed, the execution result of "submitting the rectified work order" is acquired, the identification conversion method is used to convert the execution result into a corresponding unique identifier; based on the unique identifier, the class reflection mechanism is used to proxy execute the class method corresponding to the unique identifier based on the target configuration information, and the business data of the class method is acquired; based on the business data, the message content acquisition expression and the push target acquisition expression are used to correspondingly acquire message content and push targets.
[0081] Please refer to Figure 2, which is 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:
[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. 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] The 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 that after the execution of the target method is completed, the first execution result of the target method is automatically obtained, and based on the first execution result, a corresponding unique identifier is obtained. Based on the unique identifier and in combination with the configuration information, a class reflection mechanism is used to obtain a second execution result of the class method corresponding to the target method. Based on the second execution result, the message content and push target are obtained. The method can automatically obtain the message content and push target based on the dynamic content of the target data source without hard-coding the parameter values of the message collection. This achieves that 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 based on the execution frequency of the target method, thereby meeting different business needs or environmental requirements and improving the development efficiency of business module message access.
[0086] See also Figure 3 , which is 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 changing the execution order of the target method before the end position, 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 of the instructions 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 , which is 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 target configuration information in the configuration file when the application is started, and execute the control flow jump process based on each target configuration information;
[0096] 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 process 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, automatically executes the construction method in the startup class when the application is started, traverses each target configuration information in the configuration file, and controls the program execution process of the target method corresponding to each 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, which includes:
[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 configured to, based on the unique identifier and in combination with the target configuration information, utilize a class reflection mechanism to proxy the execution of a class method corresponding to the unique identifier, and obtain a second execution result corresponding to the class method;
[0103] The acquisition module 203 is used 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; and to obtain an expression according to the push target based on the second execution result, and 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 further 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 , which is 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 apparatus 300 provided by the present invention includes a memory 301 and a processor 302. The memory 301 is used to store computer programs; the processor 302 is used to execute the computer programs stored in the memory 301, so that the terminal 300 performs 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 various media that can store program codes, such as ROM (Read Only Memory image), RAM (Random Access Memory), a magnetic disk, a USB flash drive, a memory card, or an optical disk.
[0110] The processor 302 is connected to the memory 301 and is configured to execute the computer program stored in the memory 301 so as to enable the terminal 300 to execute the above-mentioned message collection method.
[0111] The embodiment of the present application also provides a computer-readable storage medium. Those skilled in the art will understand that all or part of the steps in the method for implementing the above embodiment can be completed by instructing the processor through a program, 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 drive, 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. The available medium can be a magnetic medium (for example, a floppy disk, a hard disk, a tape), an optical medium (for example, a digital video disc (DVD)), or a semiconductor medium (for example, a solid-state drive (SSD)), etc.
[0112] The embodiment of the present application 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 one website, computer or data center to another website, computer or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method.
[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 can be a software installation package. When the above method is needed, the computer program product can be downloaded and executed on the computer.
[0114] The descriptions of the processes or structures corresponding to the above 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 this application and are not intended to limit this application. Anyone skilled in the art may modify or alter the above embodiments without departing from the spirit and scope of this application. Therefore, all equivalent modifications or alterations made by one of ordinary skill in the art without departing from the spirit and technical concepts disclosed in this application shall be covered by the claims of this 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, the currently corresponding target method is confirmed; a first execution result obtained after the target method is executed is extracted; and the first execution result is converted into a corresponding unique identifier using an identifier conversion method; 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; 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, obtaining the unique identifier.
3. The method according to claim 1, characterized in that The preset parameter expression also includes: an acquisition 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 messages need to be collected is obtained; 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 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 message collection is not necessary, exit.
4. The method according to claim 1, wherein 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 proxy execution of the class method corresponding to the unique identifier based on the unique identifier and in combination with the target configuration information, using a class reflection mechanism, and obtaining 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, based on the unique identifier and in combination with the target configuration information, utilize a class reflection mechanism to proxy execution of a class method corresponding to the unique identifier, and obtain a second execution result corresponding to the class method; 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; and based on the second execution result, obtaining a push target corresponding to the second execution result according to a push target acquisition expression; Among them, the target configuration information corresponds to the current message sending requirements; the target configuration information is pre-configured in the configuration file, and the target configuration information includes: the path information of the target method, the path information of the class method corresponding to the target method and the preset parameter expression; the preset parameter expression includes at least: the message content acquisition expression and the 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 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.
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 cause 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