Processing method and apparatus for applications

By injecting target bytecode into the bytecode file of a distributed transaction application, the problems of long development cycles and high costs are solved, enabling the rapid addition of distributed transaction chain query functionality, which is suitable for applications that have already been developed.

CN114968496BActive Publication Date: 2026-01-23INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210355957.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-06
Publication Date
2026-01-23
Estimated Expiration
2042-04-06

AI Technical Summary

Technical Problem

Existing technologies for implementing distributed transaction link query functionality in distributed transactions have long development cycles and high costs, and cannot add this functionality to already developed applications.

Method used

By injecting the target bytecode, preset functions are injected into the bytecode file of the target application, especially the class file used to implement the transaction interface, thereby realizing the distributed transaction chain query function.

Benefits of technology

It reduces development cycle and cost, while enabling completed applications to have distributed transaction chain query capabilities, thus improving application flexibility and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114968496B_ABST
    Figure CN114968496B_ABST
Patent Text Reader

Abstract

The application provides an application processing method and device. The application processing method can be applied to the field of cloud computing. The application processing method provided by the application comprises the following steps: obtaining a class file of a target application, wherein the class file is a bytecode file; judging whether the class file is a file used for implementing a transaction interface or a transaction interface implementation class; if the class file is a file used for implementing a transaction interface or a transaction interface implementation class, injecting a target bytecode into the class file, wherein the target bytecode is used for implementing a preset function when a target transaction of the target application fails. The application processing method provided by the application can reduce the long development cycle and high cost of the application. In addition, the preset function can be added to the application for some applications that have been developed.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer data processing, and particularly relates to a processing method and device of an application. BACKGROUND

[0002] Distributed transactions are born in the background of the evolution of monolithic applications to distributed applications. Distributed applications will split themselves into multiple independently deployable sub-applications (sub-services) and deploy them on different servers, so remote cooperation between sub-services is needed to complete transaction operations. The transaction completed by remote cooperation between different sub-services in a distributed application environment is called a distributed transaction.

[0003] For a certain distributed transaction, there may be a failure in execution. Therefore, it is usually necessary to obtain the transaction data of all servers when executing local sub-transactions, and then analyze the transaction data to query which sub-service of the distributed transaction has an exception. However, since the transaction data of each sub-transaction is stored on the local server when executing the distributed transaction in the same library deployment mode, and different servers are independent of each other, in order to realize link query of the distributed transaction in the same library deployment mode, the application corresponding to the distributed transaction needs to have a distributed transaction link query function.

[0004] At present, a method for realizing that the application corresponding to the distributed transaction has the distributed transaction link query function is as follows: a developer adds the logic code of the distributed link query method in the source code of the application, and compiles the source code, thereby obtaining the application with the distributed transaction link query function.

[0005] However, the above method will cause the problems of long development cycle and high cost of the application. In addition, for some already developed applications, since the source code cannot be obtained, the function of the distributed link query cannot be added in the application. SUMMARY

[0006] The present application provides a processing method and device of an application, which can reduce the problems of long development cycle and high cost of the application. In addition, for some already developed applications, the function of the distributed link query can also be added in the application.

[0007] In a first aspect, an embodiment of the present application provides a processing method of an application, comprising: obtaining a class file of a target application, the class file being a bytecode file; determining whether the class file is a file for implementing a transaction interface or a transaction interface implementation class; if the class file is a file for implementing a transaction interface or a transaction interface implementation class, injecting a target bytecode into the class file, the target bytecode being used to implement a preset function when the target application fails to execute a target transaction.

[0008] The processing method of the application provided by the embodiment makes the target application have the preset function by using the method of injecting the target bytecode. In the technical solution provided by the present application, the class file of the target application used when the target bytecode is injected is a bytecode file, i.e., a file that has been compiled. Therefore, the step of compiling the source code is not needed, thereby reducing the development cycle and high cost of the application. In addition, the technical solution provided by the present application is directed to the bytecode file, and the bytecode file is a file after the source program is compiled. Therefore, the embodiment of the present application can also make the target application that has been developed have the preset function.

[0009] With reference to the first aspect, in a possible implementation manner, the target application is a distributed application, and the target transaction executed by the target application is a distributed transaction.

[0010] With reference to the first aspect, in a possible implementation manner, the preset function includes a function of querying transaction data corresponding to the distributed transaction when the distributed application fails to execute the distributed transaction.

[0011] In this implementation manner, the method of injecting the target bytecode can make the target application have the function of querying the transaction data in the distributed transaction.

[0012] With reference to the first aspect, in a possible implementation manner, the injecting the target bytecode into the class file comprises: injecting the target bytecode into the class file by using a preset technology.

[0013] For example, the preset technology can be a "Javassist" technology, an "ASM" technology, a "ByteBuddy" technology, or the like.

[0014] With reference to the first aspect, in a possible implementation manner, each of the different servers comprises a first database.

[0015] For example, the first database is a relational database management system.

[0016] In a second aspect, an embodiment of the present application provides a processing apparatus of an application, comprising: an obtaining module configured to obtain a class file of a target application, the class file being a bytecode file; a processing module configured to determine whether the class file is a file for implementing a transaction interface or a transaction interface implementation class; and the processing module is further configured to inject a target bytecode into the class file if the class file is a file for implementing a transaction interface or a transaction interface implementation class, the target bytecode being used to implement a preset function when the target application fails to execute a target transaction.

[0017] With reference to the second aspect, in a possible implementation manner, the target application is a distributed application, and the target transaction executed by the target application is a distributed transaction.

[0018] With reference to the second aspect, in a possible implementation manner, the preset function includes a function of querying transaction data corresponding to the distributed transaction when the distributed application fails to execute the distributed transaction.

[0019] With reference to the second aspect, in a possible implementation manner, the injecting the target bytecode into the class file comprises: injecting the target bytecode into the class file by using a preset technology.

[0020] With reference to the second aspect, in a possible implementation manner, each of the different servers comprises a first database.

[0021] With reference to the second aspect, in a possible implementation manner, each of the different servers comprises a first database.

[0022] In a third aspect, an embodiment of the present application provides a processing apparatus of an application, comprising: a memory and a processor; the memory is configured to store program instructions; and the processor is configured to invoke the program instructions in the memory to execute the method in the first aspect or any possible implementation manner thereof.

[0023] In some implementation manners, the apparatus can be a chip. In this implementation manner, the apparatus can optionally further comprise a communication interface configured to communicate with other apparatuses or devices.

[0024] In a fifth aspect, an embodiment of the present application provides a computer readable medium, the computer readable medium storing program codes for computer execution, the program codes comprising instructions for executing the method in the first aspect or any possible implementation manner thereof.

[0025] In a sixth aspect, the present application provides a computer program product, which comprises computer program codes, and when the computer program codes are run on a computer, the computer is caused to implement the method according to the first aspect or any possible implementation manner thereof.

[0026] The technical effects brought by the implementation manners of the second aspect to the sixth aspect can refer to the technical effects brought by the implementation manners of the first aspect, which will not be repeated here. BRIEF DESCRIPTION OF DRAWINGS

[0027] The accompanying drawings, which are incorporated herein and form a part of the specification, illustrate embodiments consistent with the present application and, together with the description, further serve to explain the principles of the present application.

[0028] Figure 1 A structural schematic diagram of an application scenario provided by the present application is shown in the following figure;

[0029] Figure 2 A flow schematic diagram of a processing method of an application provided by an embodiment of the present application is shown in the following figure;

[0030] Figure 3 A structural schematic diagram of a processing device of an application provided by an embodiment of the present application is shown in the following figure;

[0031] Figure 4 A structural schematic diagram of a processing device of an application provided by another embodiment of the present application is shown in the following figure. DETAILED DESCRIPTION

[0032] The exemplary embodiments will be described in detail herein with reference to the attached drawings. The following description is only exemplary and is not intended to limit the present application, unless otherwise explicitly indicated. In the following description, same numbers refer to same or similar elements unless otherwise explicitly indicated.

[0033] Distributed transactions are born in the background of the evolution of monolithic applications to distributed applications. Distributed applications will be split into multiple independently deployable services and deployed on different servers, so remote cooperation between services is needed to complete transaction operations. The transaction completed by remote cooperation between different services in this distributed application environment is called distributed transaction. That is, distributed transaction refers to splitting a transaction into multiple independent sub-transactions, and different sub-transactions are executed by different servers, and multiple sub-transactions can be completed by remote cooperation.

[0034] A common deployment method for distributed transactions is the same-database deployment mode. In this mode, each server used to execute distributed transactions persists some state data (called transaction data) that reflects the server's state when executing the local sub-transaction (also known as local sub-transaction) on its local server after completing its own sub-transaction (also known as local sub-transaction).

[0035] For ease of understanding, Figure 1 This is a structural diagram of a distributed transaction system provided in one embodiment of this application. Figure 1 As shown, servers 100, 101, and 102 can be considered to form a distributed system, wherein server 100 includes database 0, server 101 includes database 1, and server 102 includes database 2.

[0036] for Figure 1 In the distributed transaction system shown, server 100 can remotely call an interface to instruct server 101 to complete sub-transaction 1. Then, server 101 can remotely call an interface to instruct server 102 to complete sub-transaction 2, thus completing the entire transaction operation. It can be seen that the above continuous remote interface calls form a distributed transaction chain call (also known as a distributed chain call). It should be noted that after each server completes its local sub-transaction, it persists some state data (called transaction data) reflecting the server's state during the execution of the local sub-transaction in its local database. For example... Figure 1 As shown, server 101 will persist some transaction data from the execution of sub-transaction 1 in database 1, and server 102 will persist some transaction data from the execution of sub-transaction 2 in database 2.

[0037] To make it easier to understand, let's take a money transfer as an example. Suppose a distributed transaction occurs where Xiaoming needs to transfer 100 yuan to Xiaobai. Figure 1 Taking the distributed transaction system shown as an example, the specific call chain can be as follows: the main transaction in server 100 calls the deduction interface; after calling the deduction interface, sub-transaction 1 in server 101 performs the deduction operation for Xiaoming; subsequently, the deduction interface in server 102 can call the increase interface; after calling the increase interface, sub-transaction 2 in server 102 performs the increase operation for Xiaobai. More specifically, when the main transaction in server 100 calls the deduction interface, database 0 in server 100 records some transaction data at the time of the deduction interface call. Similarly, when the increase interface is called, server 101 records some transaction data at the time of executing the increase interface call.

[0038] It should be understood that different servers can record transaction data in tables in their local databases when executing distributed transactions.

[0039] The above example is taken as an example. The distributed transaction data of the above transfer can be stored in Tables 1 to 3 respectively.

[0040] As shown in Table 1, the following information can be recorded in the master transaction record table in database 0.

[0041] Table 1 Master transaction record table

[0042]

[0043] As shown in Table 2, the following information can be recorded in the sub-transaction record table in database 0.

[0044]

[0045] As shown in Table 2, the following information can be recorded in the sub-transaction record table in database 1.

[0046]

[0047] Any in Tables 1 to 3 represents all state information when executing a transaction.

[0048] It should be understood that for a certain distributed transaction, there can be a failure to execute. Therefore, it is usually necessary to obtain the transaction data of all servers when executing local sub-transactions when the distributed transaction fails, and then analyze all the transaction data to query which sub-service the distributed transaction occurred. For example, for the distributed transaction system shown in Figure 1 Assuming that server 102 executing sub-transaction 2 fails when executing a distributed transaction (which includes master transaction, sub-transaction 1 and sub-transaction 2), which will cause the entire distributed transaction to fail, in this case, the stored transaction data in each server needs to be analyzed to query which sub-service the distributed transaction occurred.

[0049] However, since the transaction data of each sub-transaction is stored on the local server when executing the distributed transaction in the same library deployment mode, and different servers are independent of each other, in order to realize the link query of the distributed transaction in the same library deployment mode, the distributed application corresponding to the distributed transaction needs to have the distributed transaction link query function.

[0050] Currently, one method for implementing distributed transaction tracing functionality in applications corresponding to distributed transactions is as follows: Developers add logic code for a distributed tracing query method to the application's source code and compile the source code to obtain an application with distributed transaction tracing query functionality. Specifically, the logic code for the distributed tracing query method is used by the application to query the transaction data corresponding to the distributed transaction when the execution of the target distributed transaction fails.

[0051] However, the above methods result in long application development cycles and high costs. Furthermore, for some already developed applications, the source code cannot be obtained, making it impossible to add distributed link query functionality.

[0052] In view of this, embodiments of this application provide an application processing method. The technical solution provided in this application employs a method based on injecting target bytecode to enable the target application to add distributed link query functionality. This eliminates the need for developers to add distributed link query logic code to the application's source code and to compile the source code, thereby reducing the problems of long development cycles and high costs. Furthermore, since the target bytecode is injected into the bytecode file in this application embodiment, it can also implement the functionality of the target bytecode in some already developed applications.

[0053] Figure 2 This is a flowchart illustrating a processing method for an application provided in one embodiment of this application. Figure 2 As shown, the method in this embodiment may include S201, S202, and S203. The method in this embodiment may be... Figure 1 Distributed system execution in.

[0054] S201, Obtain the class file of the target application, wherein the class file is a bytecode file.

[0055] In this embodiment, the target application can be considered to have the function of completing a certain transaction (target transaction).

[0056] In this embodiment, bytecode files refer to files obtained by compiling some source code files in the target application. That is, in this embodiment, class files of the target application refer to compiled class files.

[0057] In a possible solution, the target application is a distributed application, and the target transaction executed by the target application is a distributed transaction. That is, in this solution, the target application can be divided into a plurality of sub-applications (sub-services), which can be independently deployed on different servers, and each sub-service can complete a corresponding sub-transaction, and then the plurality of sub-services can complete the transaction operation through remote cooperation, that is, a plurality of sub-transactions constitute a distributed transaction. The concept of transaction can be referred to the description in the related art, and will not be described here.

[0058] Exemplarily, as shown in Figure 1 , the target application can be split into a plurality of sub-applications, and then the plurality of sub-applications are deployed into the server 100, the server 101 and the server 102. Among them, the server 100 can complete a corresponding main transaction, the server 101 can complete a sub-transaction 1, and the server 102 can complete a sub-transaction 2. The server 100, the server 101 and the server 102 cooperate through mutual remote calling to complete the entire distributed transaction.

[0059] In S202, it is judged whether the class file is a file for implementing a transaction interface or a transaction interface implementation class.

[0060] It should be understood that the target application can include a plurality of different class files, and each class file can be used to implement a certain function. Different class files can be used to implement different functions. For example, some class files can be only some configuration files, such as files receiving some input configuration parameters, and some class files can be class files related to completing a distributed transaction.

[0061] Therefore, in this embodiment, after obtaining the class file, it is first judged whether the class file is a file for implementing a transaction interface or a transaction interface implementation class.

[0062] Specifically, it can be understood that each class file includes some defined classes or defined methods. Therefore, in this embodiment, after obtaining the class file of the target application, some classes or defined methods defined in the class file of the target application can be analyzed to judge the function that the classes defined in the class file of the target application can implement or the function that the defined methods in the target application can implement, and then whether the class file of the target application is a file for implementing a transaction interface or a transaction interface implementation class is judged based on the function that the defined classes can implement or the function that the defined methods can implement. It is stated here that the specific form of the transaction interface or the transaction interface implementation class is not limited by the embodiments of the present application. For example, the transaction interface can be a remote calling interface, etc.

[0063] S203, if the class file is a file for implementing a transaction interface or a transaction interface implementation class, injecting target bytecodes into the class file, the target bytecodes being used for implementing a preset function when the target application fails to execute a target transaction.

[0064] In this embodiment, the target bytecodes include codes capable of implementing the preset function, which are also codes in the form of bytecodes.

[0065] In an embodiment, the preset technology may, for example, be a "Javassist" technology, an "ASM" technology, a "ByteBuddy" technology, or the like. Details of the "Javassist" technology, the "ASM" technology, and the "ByteBuddy" technology can be referred to the description in the related art, and will not be described herein.

[0066] Illustratively, in order to be able to inject the target bytecodes into the class file, the developer may perform the following operations:

[0067] 1. Write a "Premain" method.

[0068] Specifically, public static void premain (String agentArgs, Instrumentation inst) {

[0069] Add a class file converter;

[0070] };

[0071] Wherein, String agentArgs represents the first parameter of the premain function, and Instrumentation inst represents the second parameter of the premain function. Details of public static void premain (String agentArgs, Instrumentation inst) can be referred to the description in the related art, and will not be described herein.

[0072] Illustratively, in order to be able to inject the target bytecodes into the class file, the developer may perform the following operations:

[0073] 2. Write the MyTransformer class implementation file conversion (ClassFileTransformer) interface, override the transform method.

[0074] Specifically, the code can include the following code:

[0075] public class MyTransformer implements ClassFileTransformer {

[0076] public byte[] transform(ClassLoader cl, String className, Class<?> c, ProtectionDomain pd, byte[] b) {

[0077] According to the class name, read all the methods under this class, judge whether this class is a transaction interface or a transaction interface implementation class;

[0078] The class that meets the above conditions is modified by bytecode injection;

[0079] Use Javassist technology to splice and inject the bytecode into the class file, and the injected logic is to query the organization distributed transaction link data.

[0080] Among them, ClassLoader cl represents the class loader, String className represents the full name of the class, Class<?> c represents the class metadata, ProtectionDomain pd represents the scope, and byte[] b represents the byte array. Among them, the detailed description of the class loader, class metadata, scope and byte array can refer to the description in the related technology, which will not be repeated here.

[0081] 3. Package the contents in 1 and 2.

[0082] It can be understood that when the application is downloaded on its own server and restarted, if a certain class file is used to implement a transaction interface or a transaction interface implementation class, at this time the target bytecode can be injected into the class file, so that the certain class file can complete the preset function.

[0083] In the embodiment, when the class file is a file for implementing the transaction interface or the transaction interface implementation class, the target bytecode is injected into the class file, where the target bytecode is used to implement a preset function when the target application fails to execute the target transaction. For example, the preset function includes a function of querying transaction data corresponding to the target transaction when the target application fails to execute the target transaction. Illustratively, when the target transaction is a distributed transaction, the preset function includes a function of querying transaction data corresponding to the distributed transaction when the distributed application fails to execute the distributed transaction.

[0084] As an optional embodiment, the target application includes a plurality of sub-applications, different sub-applications in the plurality of sub-applications are deployed on different servers, and different sub-applications in the plurality of sub-applications execute different sub-transactions in the target transaction. That is, in this embodiment, the plurality of sub-applications constitute the target application to execute the distributed transaction by executing different sub-transactions in the target transaction.

[0085] It should be understood that, in the case where the target application includes a plurality of sub-applications and different sub-applications in the plurality of sub-applications are deployed on different servers, the sub-application in each server stores transaction data in the database when executing the sub-transaction. It is explained that the form of the database is not limited in the embodiment. For example, the database in the embodiment is a relational database management system.

[0086] It should be noted that, in the specific implementation, since the distributed transaction relies on remote procedure call (RPC) service calls for network communication, the "invoker" of the business method is needed to discover and call the downstream service at each link query, so the current call needs to be intercepted and the logic direction needs to be modified before the actual business call. In order to achieve this, the filter of the RPC framework needs to be dynamically modified, for example, a new filter class can be dynamically generated in the Java virtual machine (JVM) and loaded into the meta space for the "Dubbo" framework, so that the filter can be recognized and constructed into the service call filter link when the RPC service call environment is initialized in the subsequent application.

[0087] It also needs to be understood that, in specific implementation, since the distributed transaction database in the same library mode is deployed on the application side and supports multiple database types, the query logic in the target bytecode also needs to be adapted to these databases. In specific implementation, in order to identify the correct database driver type, the database driver type used in the JVM context needs to be configured, so that the logic of reading the JVM context parameter to obtain the database driver type can be woven in the target bytecode to obtain the correct database driver object, and then the query of the link information is completed according to the template method to point to the corresponding database operation.

[0088] Figure 3 A structural schematic diagram of a processing apparatus of an application is provided for an embodiment of the present application. As shown in the figure, the apparatus 300 comprises an obtaining module 301 and a processing module 302. Figure 3

[0089] The obtaining module 301 is configured to obtain a class file of a target application, the class file being a bytecode file; and the processing module 302 is configured to determine whether the class file is a file for implementing a transaction interface or a transaction interface implementation class; and the processing module 302 is further configured to, if the class file is a file for implementing a transaction interface or a transaction interface implementation class, inject a target bytecode into the class file, the target bytecode being used to implement a preset function when the target application fails to execute a target transaction.

[0090] In a possible implementation, the target application is a distributed application, and the target transaction executed by the target application is a distributed transaction.

[0091] In a possible implementation, the preset function comprises a function of querying transaction data corresponding to the distributed transaction when the distributed application fails to execute the distributed transaction.

[0092] In a possible implementation, the processing module 302 is specifically configured to inject the target bytecode into the class file by using a preset technology.

[0093] In a possible implementation, each of the different servers comprises a first database.

[0094] In a possible implementation, the first database is a relational database management system.

[0095] Figure 4 A structural schematic diagram of a processing apparatus of an application is provided for another embodiment of the present application. Figure 4 The apparatus shown in the figure can be used to execute the method described in any one of the preceding embodiments.

[0096] As​Figure 4 As shown in the figure, the device 400 of the embodiment includes a memory 401, a processor 402, a communication interface 403, and a bus 404. The memory 401, the processor 402, and the communication interface 403 are communicatively connected to each other through the bus 404.

[0097] The memory 401 can be a read only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 401 can store a program, and when the program stored in the memory 401 is executed by the processor 402, the processor 402 is configured to perform the steps of the method shown in the figure. Figure 2 The steps of the method shown in the figure.

[0098] The processor 402 can be a general-purpose central processing unit (CPU), a microprocessor, an application specific integrated circuit (ASIC), or one or more integrated circuits, configured to execute related programs to implement the methods of the embodiments of the present application. Figure 2 The method shown in the figure.

[0099] The processor 402 can also be an integrated circuit chip with a processing capability of signals. In the implementation process, the steps of the method of the embodiments of the present application Figure 2 may be completed by integrated logic circuits or instructions in the form of software in the processor 402.

[0100] The processor 402 described above can also be a general-purpose processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a ready-to-use programmable gate array (FPGA), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps, and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor or the like.

[0101] The steps of the method disclosed in the embodiments of the present application can be directly embodied as hardware code processing executed by a coded processor, or executed by a combination of hardware and software modules in the coded processor. The software modules can be located in the random access memory, the flash memory, the read-only memory, the programmable read-only memory, the electrically erasable programmable memory, the register, or other mature storage mediums in the field. The storage medium is located in the memory 401, and the processor 402 reads the information in the memory 401, and combines the hardware to complete the functions required by the units included in the device of the present application, for example, the processor can execute the steps of the method disclosed in the embodiments of the present application. Figure 2 The steps / functions of the embodiments shown in the embodiments of the present application.

[0102] The communication interface 403 can use, but is not limited to, a transceiver type transceiving device to realize the communication between the device 400 and other devices or communication networks.

[0103] The bus 404 can include a path for transmitting information between the various components (for example, the memory 401, the processor 402, the communication interface 403) of the device 400.

[0104] It should be understood that the device 400 shown in the embodiments of the present application can be an electronic device, or can also be a chip configured in an electronic device.

[0105] It should be noted that the fault prediction method and device in the present application can be used in the field of big data, and can also be used in any field other than the field of big data. The application field of the fault prediction method and device is not limited in the present application.

[0106] The above embodiments can be realized all or partially by software, hardware, firmware or any combination thereof. When realized by software, the above embodiments can be realized in the form of a computer program product all or partially. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, the processes or functions described in the embodiments of the present application are all or partially generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable devices. The computer instructions can be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired (for example, infrared, wireless, microwave, etc.) mode. The computer readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, data center and the like containing one or more available medium sets. The available medium can be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium. The semiconductor medium can be a solid state disk.​

[0107] It should be understood that the term "and / or" in this document is only used to describe associated objects, which means that there can be three relationships, for example, A and / or B can mean that A exists alone, A and B exist together, B exists alone, and A, B can be singular or plural. In addition, the character " / " in this document generally represents an "or" relationship between the front and back associated objects, but it can also represent an "and / or" relationship, which can be understood in the context before and after.

[0108] In this application, "at least one" means one or more, and "multiple" means two or more. "At least one of the following" or the like means any combination of the items, including any combination of single or multiple items. For example, at least one of a, b, or c can mean a, b, c, a-b, a-c, b-c, or a-b-c, where a, b, and c can be single or multiple.

[0109] It should be understood that in various embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution, and the execution order of the processes should be determined by its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0110] Those of ordinary skill in the art can realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be realized by electronic hardware or a combination of computer software and electronic hardware. Whether the functions are realized in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0111] Those skilled in the art can clearly understand that, for the convenience and brevity of the description, the specific working process of the above-described system, device and unit can refer to the corresponding process in the foregoing method embodiments, which will not be repeated here.

[0112] In several embodiments provided in the present application, it should be understood that the disclosed system, device and method can be implemented in other manners. For example, the described device embodiments are merely schematic. For example, the division of the units is only a logical function division. There can be another division manner for the actual implementation, for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections between the units can be indirect couplings or communication connections through some interfaces, devices or units, and can be electrical, mechanical or in other forms.

[0113] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, i.e., can be located in one place, or can be distributed on multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.

[0114] In addition, each functional unit in the various embodiments of the present application can be integrated into a processing unit, or each unit can be a physically separate unit, or two or more units can be integrated into a unit.

[0115] If the functions are realized in the form of software function units and sold or used as independent products, they can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application can be embodied in the form of a software product, and the computer software product is stored in a storage medium, and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory, a random access memory, a magnetic disk or an optical disk, and various program code storage media.

[0116] The above is merely specific embodiments of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art can easily think of changes or replacements within the technical scope disclosed in the present application, which should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A processing method for an application, characterized in that, include: Obtain the class file of the target application, wherein the class file is a bytecode file; The class file includes defined classes or defined methods; Based on the analysis of the defined class or the defined method, the functions that the defined class or the defined method can implement are obtained; based on the functions that the defined class or the defined method can implement, it is determined whether the class file is a file used to implement a transaction interface or a transaction interface implementation class; If the class file is a file for implementing a transaction interface or a transaction interface implementation class, then target bytecode is injected into the class file. The target bytecode is used to implement a preset function when the target application fails to execute the target transaction. The target application is a distributed application, and the target transaction executed by the target application is a distributed transaction. The preset function includes the function of querying the transaction data corresponding to the distributed transaction when the distributed application fails to execute the distributed transaction.

2. The method according to claim 1, characterized in that, The injection of target bytecode into the class file includes: The target bytecode is injected into the class file using a preset technique.

3. A processing apparatus for an application, characterized in that, include: The acquisition module is used to acquire the class file of the target application, wherein the class file is a bytecode file; The class file includes defined classes or defined methods; The processing module is used to analyze the defined class or the defined method to obtain the functionality that the defined class or the defined method can implement; and based on the functionality that the defined class or the defined method can implement, to determine whether the class file is a file used to implement a transaction interface or a transaction interface implementation class. The processing module is further configured to inject target bytecode into the class file if the class file is a file for implementing a transaction interface or a transaction interface implementation class. The target bytecode is used to implement a preset function when the target application fails to execute the target transaction. The target application is a distributed application, and the target transaction executed by the target application is a distributed transaction. The preset function includes the function of querying the transaction data corresponding to the distributed transaction when the distributed application fails to execute the distributed transaction.

4. A processing apparatus for an application, characterized in that, include: Memory and processor; The memory is used to store program instructions; The processor is used to invoke program instructions in the memory to execute the method as described in any one of claims 1 to 2.

5. A computer-readable medium, characterized in that, The computer-readable medium stores program code for computer execution, the program code including instructions for performing the method as described in any one of claims 1 to 2.

6. A computer program product, said computer program product comprising computer program instructions, characterized in that, When the computer program instructions are executed on a computer, the computer causes the computer to perform the method as described in any one of claims 1 to 2.

Citation Information

Patent Citations

  • Data processing method, device, equipment and system based on byte code

    CN111782340A