Application program calling method, medium, device and computing device

By receiving application call requests in Sidecar mode, obtaining call functions, and executing them in different class loader environments, the performance and security risks caused by traffic interception in Sidecar mode, as well as the conflict between agents and application classes, achieving normal operation and efficient performance of proxy functions.

CN114661385BActive Publication Date: 2025-06-06HANGZHOU NETEASE ZHIQI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

When Sidecar mode intercepts traffic through iptables, there are problems such as performance risks, security risks and excessive computing resource utilization. The agent and the application are executed in the same class loader environment, resulting in class conflicts and cannot run normally.

Method used

By receiving the application's call request, obtaining the calling function, and determining the first proxy function according to the function, weaving the function into the first type of loader corresponding to the agent for execution, and calling the execution object in the second type of loader not associated with the first type of loader, so that the application can run the first proxy function.

Benefits of technology

The class loader environment of the agent and application is isolated, class conflicts are avoided, and the normal operation of the agent is ensured, and the security risks, performance risks and excessive computing resource utilization in the operation of the agent function.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114661385B_ABST
    Figure CN114661385B_ABST
Patent Text Reader

Abstract

The embodiments of the present disclosure provide a method for calling an application. The method includes: receiving a call request for an application and obtaining a function for calling the application; determining a first proxy function for calling the application according to the function; weaving the function into the first class loader corresponding to the proxy program so that the proxy program can execute the function in the first class loader, calling the execution object in the second class loader so that the application program runs the first proxy function, and the second class loader is not associated with the first class loader. The execution environment of the proxy program of the present disclosure is isolated from the execution environment of the application program to avoid class loading conflicts between the application program and the proxy program, thereby ensuring the normal operation of the proxy program, and enabling the proxy program to solve the security risks, performance risks and excessive computing resource usage in the operation of the proxy function. In addition, the embodiments of the present disclosure provide a medium, an apparatus and a computing device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present disclosure relate to the field of software, and more specifically, the embodiments of the present disclosure relate to a method, medium, apparatus, and computing device for calling an application program. Background Art

[0002] This section is intended to provide a background or context to the embodiments of the disclosure that are recited in the claims. No description herein is admitted to be prior art by inclusion in this section.

[0003] Sidecar is a professional term in the field of microservices. As an independent process and container, Sidecar is connected to the main application. Sidecar is loosely coupled with the main application, which can shield the differences between different programming languages ​​and uniformly implement the observability, monitoring, logging, configuration, circuit breaker, traffic management and other proxy functions of microservices.

[0004] The Sidecar mode deploys a set of cohesive tasks together with the main application, and generally requires isolating the tasks from the main application into separate processes or containers. This approach allows more features to be added to the application's operating environment without the need for additional third-party component configuration or modification of application code. Sidecar intercepts traffic through iptables (iptables is a stateful firewall) to achieve the governance of various traffic.

[0005] Since iptables needs to intercept the traffic at both the exit and the entrance, it will turn the kernel state into processing four links instead of processing two links, which will cause the performance loss of the kernel state. Therefore, there will be performance risks when iptables intercepts traffic. In addition, iptables passes the defined rules to the network filter for reading to realize the firewall function, which means that iptables is not a real firewall and cannot identify viruses in the data. There will be security risks when iptables intercepts traffic. In addition, iptables needs to intercept the traffic at both the exit and the entrance, which causes the kernel state to process four links, adding additional network overhead, and the additional network overhead will cause unacceptable delays for applications with high performance requirements. In addition, the independent process of the Sidecar mode occupies additional computing resources, which brings additional management overhead. It can be seen that the implementation of the proxy function has security risks, performance risks and excessive computing resources.

[0006] To solve these hidden dangers, we can use proxy programs to replace the Sidecar mode to implement multiple proxy functions. The existing proxy programs and applications are executed in the same class loader environment, which causes conflicts between the application and the proxy when loading the class loader, making the proxy program unable to run normally, and thus making it impossible for the proxy program to solve the security risks, performance risks, and excessive computing resource usage in the operation of the proxy function. Summary of the invention

[0007] The present disclosure provides a method, medium, device and computing equipment for calling an application program to solve the problems that an agent program cannot solve the potential safety hazards, performance hazards and excessive computing resource usage existing in the operation of an agent function.

[0008] In a first aspect of an embodiment of the present disclosure, a method for calling an application is provided, comprising: receiving a call request for an application, and obtaining a function for calling the application; determining a first proxy function for calling the application based on the function; weaving the function into a first class loader corresponding to the agent program so that the agent program executes the function in the first class loader, and calling an execution object in a second class loader to enable the application to run the first proxy function, the second class loader is not associated with the first class loader, and the execution object is determined based on the first proxy function.

[0009] In one embodiment of the present disclosure, the execution object includes a first execution object, and the step of calling the execution object in the second class loader to enable the application to run the first proxy function includes: obtaining the first execution object cached by the first proxy function in the second class loader, the first execution object being obtained by encapsulating the execution logic of the first proxy function; and calling the first execution object in the second class loader to enable the application to run the first proxy function.

[0010] In another embodiment of the present disclosure, obtaining the first execution object cached by the first proxy function in the second class loader includes: obtaining the execution logic of each second proxy function in the plug-in chain corresponding to the proxy program, each second proxy function including the first proxy function; encapsulating the execution logic of each second proxy function in a first encapsulation method to obtain the second execution object of each second proxy function; caching each second execution object in the second class loader, and obtaining the first execution object corresponding to the first proxy function in each second execution object.

[0011] In another embodiment of the present disclosure, the step of caching each second execution object in the second class loader includes: initializing the second class loader, and performing reflective calls on each second execution object to obtain each second execution object; and caching each second execution object in the second class loader.

[0012] In another embodiment of the present disclosure, the execution object includes a third execution object, and the step of calling the execution object in the second class loader to enable the application to run the first proxy function includes: obtaining the execution logic of the first proxy function; encapsulating the execution logic of the first proxy function into a third execution object using a second encapsulation method; reflecting the third execution object to the second class loader, and calling the third execution object in the second class loader to enable the application to run the first proxy function.

[0013] In another embodiment of the present disclosure, the step of determining the first proxy function to call the application according to the function includes: determining an execution mode of the function, the execution mode including pre-execution or post-execution; according to the execution mode, determining the first proxy function to be run of the application in the plug-in chain corresponding to the agent program, wherein the plug-in chain includes a plurality of arranged proxy functions.

[0014] In yet another embodiment of the present disclosure, the calling of the function in the first class loader and the calling of the execution object in the second class loader are performed synchronously.

[0015] In a second aspect of the embodiments of the present disclosure, a device for calling an application is provided, comprising: a receiving module for receiving a call request for an application and obtaining a function for calling the application; a determining module for determining a first proxy function for calling the application based on the function; a calling module for weaving the function into a first class loader corresponding to the agent program so that the agent program executes the function in the first class loader, and calling an execution object in a second class loader to enable the application to run the first proxy function, the second class loader is not associated with the first class loader, and the execution object is determined based on the first proxy function.

[0016] In one embodiment of the present disclosure, it includes: an acquisition module, used to obtain a first execution object cached by the first proxy function in the second class loader, wherein the first execution object is obtained by encapsulating the execution logic of the first proxy function; the calling module is also used to call the first execution object in the second class loader to enable the application to run the first proxy function.

[0017] In another embodiment of the present disclosure, it includes: the acquisition module, which is also used to obtain the execution logic of each second proxy function in the plug-in chain corresponding to the agent program, and each second proxy function includes the first proxy function; a first encapsulation module, which is used to encapsulate the execution logic of each second proxy function using a first encapsulation method to obtain a second execution object of each second proxy function; a cache module, which is used to cache each second execution object into the second class loader, and obtain the first execution object corresponding to the first proxy function in each second execution object.

[0018] In another embodiment of the present disclosure, it includes: the calling module is also used to initialize the second class loader and reflectively call each second execution object to obtain each second execution object; the caching module is also used to cache each second execution object in the second class loader.

[0019] In another embodiment of the present disclosure, it includes: the acquisition module, which is also used to obtain the execution logic of the first proxy function; the second encapsulation module, which is used to encapsulate the execution logic of the first proxy function into a third execution object using a second encapsulation method; and the reflection module, which is used to reflect the third execution object to the second class loader, and call the third execution object in the second class loader to enable the application to run the first proxy function.

[0020] In another embodiment of the present disclosure, it includes: the determination module is also used to determine the execution mode of the function, and the execution mode includes pre-execution or post-execution; the determination module is also used to determine the first proxy function to be run of the application in the plug-in chain corresponding to the agent program according to the execution mode, wherein the plug-in chain includes multiple arranged proxy functions.

[0021] In another embodiment of the present disclosure, it includes: the calling module is also used to synchronously call the function in the first class loader and the execution object in the second class loader.

[0022] In a third aspect of the embodiments of the present disclosure, a medium is provided, comprising: computer-executable instructions, wherein when the computer-executable instructions are executed by a processor, the method for calling the application program described in the first aspect is implemented.

[0023] In a fourth aspect of an embodiment of the present disclosure, a computing device is provided, comprising: a memory and a processor; the memory stores computer execution instructions; the processor executes the computer execution instructions stored in the memory, so that the processor executes the calling method of the application as described in the first aspect.

[0024] According to the disclosed embodiment, a call request of an application is received, and a function of calling the application is obtained, and a proxy function of calling the application is determined according to the function, and then the function is woven into the first class loader corresponding to the proxy program so that the proxy program can execute the function in the first class loader, and the execution object is called in the second class loader that is not associated with the first class loader so that the application program runs the proxy function. The proxy program executes the function in the first class loader, and the application program calls the execution object in the second class loader. The first class loader is not associated with the second class loader, so that the execution environment of the proxy program is isolated from the execution environment of the application program, avoiding class loading conflicts between the application program and the proxy program, ensuring the normal operation of the proxy program, and enabling the proxy program to solve the security risks, performance risks and excessive computing resource occupation existing in the operation of the proxy function. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] The above and other objects, features and advantages of the exemplary embodiments of the present disclosure will become readily understood by reading the detailed description below with reference to the accompanying drawings. In the accompanying drawings, several embodiments of the present disclosure are shown in an exemplary and non-limiting manner, in which:

[0026] Figure 1 The structure diagram of the calling device of the application program involved in the present disclosure is schematically shown;

[0027] Figure 2 The flowchart according to an embodiment of the present disclosure is schematically shown;

[0028] Figure 3 Schematically shows a flow chart according to another embodiment of the present disclosure;

[0029] Figure 4 The flowchart according to another embodiment of the present disclosure is schematically shown;

[0030] Figure 5 The flowchart according to another embodiment of the present disclosure is schematically shown;

[0031] Figure 6 Schematically shows a flow chart according to another embodiment of the present disclosure;

[0032] Figure 7 It is a schematic diagram showing an application scenario according to the present disclosure;

[0033] Figure 8 A schematic diagram schematically shows a storage medium according to an embodiment of the present disclosure;

[0034] Fig. 9 The following schematically shows a functional module diagram of a calling device of an application according to an embodiment of the present disclosure;

[0035] Fig.10 The following schematically shows a hardware structure diagram of a device for calling an application program according to an embodiment of the present disclosure;

[0036] In the drawings, the same or corresponding reference numerals represent the same or corresponding parts. DETAILED DESCRIPTION

[0037] The principles and spirit of the present disclosure will be described below with reference to several exemplary embodiments. It should be understood that these embodiments are provided only to enable those skilled in the art to better understand and implement the present disclosure, and are not intended to limit the scope of the present disclosure in any way. On the contrary, these embodiments are provided to make the present disclosure more thorough and complete, and to fully convey the scope of the present disclosure to those skilled in the art.

[0038] Those skilled in the art will appreciate that the embodiments of the present disclosure may be implemented as a system, device, apparatus, method or computer program product. Therefore, the present disclosure may be specifically implemented in the following forms, namely: complete hardware, complete software (including firmware, resident software, microcode, etc.), or a combination of hardware and software.

[0039] According to an embodiment of the present disclosure, a method, medium, apparatus and computing device for calling an application are proposed.

[0040] In this article, it is important to understand that the terms and meanings used are as follows:

[0041] Function: refers to the method of calling the application;

[0042] Agent program: refers to the program written by javaagent technology. Javaagent refers to a parameter of java command;

[0043] Proxy functions: including service discovery, load balancing, circuit breaking, current limiting, service routing, monitoring collection and other functions;

[0044] Plugin chain: A queue formed by multiple arranged proxy functions, used to determine the proxy function to be executed when a function is called;

[0045] First agent function: refers to the function that needs to be called currently;

[0046] Second proxy function: refers to the proxy function arranged in the plugin chain;

[0047] The first class loader: can be a custom class loader, used by the agent to load classes in the javaagent environment;

[0048] The second class loader includes the application class loader, the extension class loader and the startup class loader. The application is loaded in the application class loader in the user environment, then in the extension class loader, and finally in the startup class loader. The first class loader and the second class loader can exchange data.

[0049] Execution object: It is encapsulated according to the execution logic of the first agent function;

[0050] The first execution object refers to the execution object corresponding to the first proxy function cached in the second class loader;

[0051] Second execution object: refers to the execution object encapsulating the execution logic of the second proxy function in the plug-in chain;

[0052] The first encapsulation method refers to the encapsulation method using the functional interface feature of jdk8 (a version developed in the Java language);

[0053] The second encapsulation method: using callable.call() (callable.call() refers to a callable function) for encapsulation;

[0054] The third execution object refers to the execution object obtained by encapsulating the execution logic of the first proxy function by using the second encapsulation method.

[0055] User environment: refers to the environment in which the application is executed on the terminal.

[0056] Class conflict: refers to the situation where a class recorder loads the class in the base class library corresponding to other class recorders, causing the class recorder to be unable to load the class normally.

[0057] In addition, any number of elements in the drawings is for illustration and not limitation, and any naming is only for distinction and does not have any limiting meaning.

[0058] The principle and spirit of the present disclosure are explained in detail below with reference to several representative embodiments of the present disclosure. SUMMARY OF THE INVENTION

[0060] The inventor found that sidecar intercepts TCP traffic through iptables to implement parsing, governance, forwarding and other logics. The additional performance loss of sidecar is also mainly concentrated on parsing, governance, and forwarding logics. That is, the reasons why sidecar has security risks, performance risks, and excessive computing resources are occupied are because sidecar implements parsing, governance, and forwarding logics. In the agent process, the framework itself has already done the operations of traffic construction and parsing. The agent can do the corresponding traffic management based on the results of the framework parsing, and will not generate additional network overhead, that is, it will not cause unacceptable delays to the application, and thus will not become a performance bottleneck for the application. At the same time, javaagent uses pure bytecode enhancement and will not use some framework functions. As long as the framework and class library used by the user are enhanced, the subsequent supplementation and improvement of support for various tool libraries in the java language can meet the governance support of any application under the entire java system. Therefore, javaagent can fully realize the capabilities that sidecar can achieve at the technical level, and there will be no security risks, performance risks, and excessive computing resources.

[0061] When using the agent program obtained by javaagent programming, the inventor found that the agent program and the application program are executed in the same class loader environment. Since the agent program and the application program have their own basic class libraries, the class names in the two basic class libraries may be the same, which will cause the application program to load the class in the basic class library of the agent program when using the class loader to load, so that there is a class conflict between the agent program and the application program, causing the agent program to be unable to run normally, and further making the agent program unable to solve the security risks, performance risks and excessive computing resource occupation problems existing in the operation of the agent function.

[0062] Therefore, the proxy program is isolated from the class loader used by the application, so that when the application calls the class loader to load the class, the application will not use the class in the proxy program's basic class library to load, thereby avoiding the occurrence of class conflicts and allowing the proxy program to solve the security risks, performance risks and excessive computing resource usage problems in the operation of the proxy function.

[0063] After introducing the basic principles of the present disclosure, various non-limiting embodiments of the present disclosure are described in detail below.

[0064] Application Scenario Overview

[0065] First reference Figure 1 , Figure 1The schematic diagram of the structure of the application calling device provided according to the embodiment of the present disclosure is exemplarily shown. The application calling device can be any terminal with data processing capability. Figure 1 As shown, a schematic diagram of class loading of an agent program and an application program in an application calling device 100 is shown. The agent program can execute functions in a first class loader 110 in a Javaagent environment, and the application program can call and execute objects in a second class loader 120 in a user environment. Since the first class loader 110 is located in a Javaagent environment and the second class loader 120 is located in a user environment, the first class loader 110 is not associated with the second class loader, thereby isolating the application program from the agent program.

[0066] Among them, the application calling device can be a personal digital assistant (PDA) device, a handheld device with wireless communication function (such as a smart phone, a tablet computer), a computing device (such as a personal computer (PC)), a vehicle-mounted device, a wearable device (such as a smart watch, a smart bracelet), a smart home device (such as a smart display device), a cloud server, etc.

[0067] Exemplary Methods

[0068] Combine the following Figure 1 For a schematic diagram of the structure of the calling device of the application, refer to Figure 2-Figure 6 To describe the method for calling an application according to an exemplary embodiment of the present disclosure. It should be noted that the above application scenarios are only shown to facilitate understanding of the spirit and principles of the present disclosure, and the embodiments of the present disclosure are not limited in this regard. On the contrary, the embodiments of the present disclosure can be applied to any applicable scenario.

[0069] Exemplarily, the execution subject of the embodiments of the present disclosure may be a terminal.

[0070] Reference Figure 2 , Figure 2 The following schematically shows a process diagram of a method for calling an application program according to an embodiment of the present disclosure. Figure 2 As shown, the calling method of the application includes:

[0071] Step S201, receiving a request to call an application and obtaining a function for calling the application.

[0072] In the embodiment, during the running process of the application, a call request is received, and the call request is used to request the application to call certain proxy functions. After receiving the call request, the terminal uses the corresponding function to call the application, and the function is the method of calling the application. The function can be determined by the proxy function to be called by the call request. The proxy program intercepts the call of the function, that is, the proxy program in the terminal obtains the function of calling the application.

[0073] Step S202: determining a first proxy function of calling the application program according to the function.

[0074] After obtaining the function of the calling application, the first proxy function of the calling application is determined based on the function. The first proxy function can be current limiting, fuse breaking or monitoring collection. Monitoring collection refers to collecting data of a specified type by monitoring the data generated by the running of the application.

[0075] In one example, there is a mapping relationship between the function and the proxy function, and the first proxy function can be determined through the mapping relationship and the function.

[0076] Step S203, weave the function into the first class loader corresponding to the agent program so that the agent program can execute the function in the first class loader, and call the execution object in the second class loader to enable the application to run the first agent function. The second class loader is not associated with the first class loader, and the execution object is determined based on the first agent function.

[0077] The terminal is provided with a first class loader and a second class loader. The first class loader is not associated with the second class loader. The first class loader is a custom class loader, and the second class loader is an application class loader, an extension class loader, and a startup class loader. The terminal uses bytecode weaving to weave functions into the first class loader, and the agent program can load classes in the first class loader to execute functions. The terminal then calls the execution object in the second class loader to enable the application to run the first agent function. The execution object is determined based on the first agent function. For example, the execution object is obtained based on the execution logic encapsulation of the first agent function. The first agent function can be understood as a function added to the application.

[0078] It should be noted that the call of the function in the first class loader and the call of the execution object in the second class loader are performed synchronously, so that the application will not delay the running of the external proxy function. In addition, weaving refers to connecting aspects with external parameters. There are three aspects when calling a method, namely "method runtime", "method execution" and "method post-execution".

[0079] Since the first class loader is not associated with the second class loader, the agent program and the application program do not need to consider whether the other party uses the same class, thereby avoiding class conflicts between the application programs.

[0080] In this embodiment, a call request of an application is received, and a function of calling the application is obtained, and a proxy function of calling the application is determined according to the function, and then the function is woven into the first class loader corresponding to the proxy program so that the proxy program can execute the function in the first class loader, and the execution object is called in the second class loader that is not associated with the first class loader so that the application program runs the proxy function. The proxy program executes the function in the first class loader, and the application program calls the execution object in the second class loader. The first class loader is not associated with the second class loader, so that the execution environment of the proxy program is isolated from the execution environment of the application program, so that the first class loader uses the class in the basic class library in the execution environment of the proxy program to load, and the second class loader uses the class in the basic class library in the execution environment of the application program to load (the class base library has a corresponding relationship with the execution environment), avoiding class loading conflicts between the application program and the proxy program, ensuring the normal operation of the proxy program, and enabling the proxy program to solve the security risks, performance risks and excessive computing resource occupation in the operation of the proxy function.

[0081] Reference Figure 3 , Figure 3 The process diagram of the calling method of the application program provided in accordance with the embodiment of the present disclosure is schematically shown. Figure 2 ,exist Figure 2 Based on the embodiment shown, in step S203, "calling the execution object in the second class loader to enable the application to run the first proxy function" includes:

[0082] Step S301, obtaining a first execution object cached by a first proxy function in a second class loader, where the first execution object is obtained by encapsulating the execution logic of the first proxy function.

[0083] In this embodiment, a plurality of execution objects are cached in the second class loader, and each cached execution object is obtained by encapsulating the execution logic of each proxy function.

[0084] After the first proxy function is determined, the execution object corresponding to the first proxy function is determined from among the execution objects in the cache, and the execution object in the cache corresponding to the first proxy function is defined as the first execution object.

[0085] Step S302: calling the first execution object in the second class loader to enable the application to run the first proxy function.

[0086] After obtaining the first execution object, the first execution object can be called in the second class loader to enable the application to run the first proxy function.

[0087] In this embodiment, since the first execution object is cached in the second class recorder, when the first execution object needs to be called, the cached first execution object can be directly obtained from the second class loader. There is no need to encapsulate the execution logic of the first proxy function in the first class loader to obtain the first execution object, and there is no need to use the reflection mechanism to reflect the first execution object from the first class loader to the second class loader, which saves the time of the second class loader to execute the first execution object, and is suitable for application scenarios of large-scale calling of execution objects.

[0088] Reference Figure 4 , Figure 4 The process diagram of the calling method of the application program provided in accordance with the embodiment of the present disclosure is schematically shown. Figure 3 ,exist Figure 3 Based on the embodiment shown, step S301 includes:

[0089] Step S401, obtaining the execution logic of each second agent function in the plug-in chain corresponding to the agent program, each second agent function including the first agent function.

[0090] The terminal is provided with various proxy functions that can be used for function calls. The various proxy functions are arranged to obtain a plug-in chain, and there is a mapping relationship between the plug-in chain and the proxy program. The proxy function in the plug-in chain is defined as a second proxy function. Based on the mapping relationship, the terminal can obtain each second proxy function in the plug-in chain corresponding to the proxy program, and obtain the execution logic of each proxy function. Each second proxy function includes a first proxy function, that is, the first proxy function that the application currently needs to run is one of the second proxy functions.

[0091] Step S402: Encapsulate the execution logic of each second proxy function in a first encapsulation manner to obtain a second execution object of each second proxy function.

[0092] After obtaining the execution logic of each second proxy function, the terminal encapsulates the execution logic of each second proxy function using the first encapsulation method to obtain the second execution object of each second proxy function. The first encapsulation method refers to the encapsulation method using the functional (functional interface) feature of jdk8, that is, the second execution object is a function object.

[0093] Step S403: cache each second execution object in the second class loader, and obtain the first execution object corresponding to the first proxy function from each second execution object.

[0094] The terminal caches each second execution object in the second class loader, and also caches the mapping relationship between the second execution object and the second proxy function. When the first execution object needs to be obtained, the first execution object corresponding to the first proxy function can be obtained from each second execution object based on the cached mapping relationship.

[0095] In one example, the terminal caches each second execution object in the second class loader through initialization reflection. Specifically, the second class loader is initialized first, and then each second execution object is reflected and called to obtain each second execution object, and finally each second execution object is cached in the second class loader. In subsequent calls, the cached execution object can be directly called in the second class loader without reflection, which improves the performance of the second class loader during operation.

[0096] In this embodiment, the execution logic of each second proxy function in the plug-in chain corresponding to the proxy program is obtained, and the execution logic of each second proxy function is encapsulated using the first encapsulation method to obtain the second execution object of each second proxy function, and then each second execution object is cached in the second class loader. When the execution object is subsequently called, the cached execution object is directly obtained from the second class loader without the need for reflection to obtain the execution object, thereby reducing the time required to obtain the execution object, so that the first proxy function can be quickly run by the application.

[0097] Reference Figure 5 , Figure 5 The process diagram of the calling method of the application program provided in accordance with the embodiment of the present disclosure is schematically shown. Figure 4 ,exist Figure 2 Based on the embodiment shown, in step S203, "calling the execution object in the second class loader to enable the application to run the first proxy function" includes:

[0098] Step S501, obtaining the execution logic of the first proxy function.

[0099] In this embodiment, after intercepting the function, the agent program obtains the execution logic of the first agent function from the plug-in chain. The execution object of the first agent function includes the third execution object.

[0100] Step S502: Encapsulate the execution logic of the first proxy function into a third execution object by using a second encapsulation method.

[0101] The plug-in chain also has callablel.call(), which uses the second encapsulation method to encapsulate the execution logic to obtain the third execution object, that is, the execution logic is encapsulated through callablel.call(). The third execution object is a callable object in the Java language. callablel.call() is the function that the first class loader needs to execute, and calling callablel.call() can be regarded as executing the third execution object.

[0102] Step S503: reflect the third execution object to the second class loader, and call the third execution object in the second class loader to enable the application to run the first proxy function.

[0103] The third execution object is reflected to the second class loader, so that the second class loader obtains the third execution object, and then the third execution object is called in the second class loader to enable the application to run the first proxy function.

[0104] In this embodiment, the third execution object of the first proxy function is transferred to the second class loader through the reflection mechanism, so that the second class loader can successfully call the third execution object, ensuring that the application program runs the first proxy function smoothly.

[0105] Reference Figure 6 , Figure 6 The process diagram of the calling method of the application program provided in accordance with the embodiment of the present disclosure is schematically shown. Figure 5 ,exist Figures 2 to 5 Based on any of the embodiments shown in , the step of "determining, according to the function, to call the first proxy function of the application to be executed" in step S202 includes:

[0106] Step S601, determining the execution mode of the function, the execution mode includes pre-execution or post-execution.

[0107] In this embodiment, the second proxy functions arranged in the plug-in chain are arranged based on the execution mode of the function, which includes pre-execution and post-execution.

[0108] In one example, the plug-in chain includes current limiting, circuit breaking, monitoring, and fallback. Current limiting and circuit breaking belong to the weaving logic of the function pre-execution, while monitoring and fallback belong to the weaving logic of the function post-execution.

[0109] Step S602: According to the execution mode, a first proxy function to be executed by the application program is determined in a plug-in chain corresponding to the agent program, wherein the plug-in chain includes a plurality of arranged proxy functions.

[0110] The terminal determines the first proxy function to be run by the application in the plug-in chain corresponding to the proxy program based on the execution mode. Specifically, if the plug-in chain includes current limiting, fuse breaking, monitoring, and fallback, and the execution mode of the function is pre-execution, the first proxy function is current limiting and / or fuse breaking; if the execution mode of the function is post-execution, the first proxy function is monitoring and / or fuse breaking.

[0111] In this embodiment, the terminal determines the execution mode of the function, and accurately determines the first agent function of the application program in the plug-in chain of the agent program according to the execution mode.

[0112] In combination with the above embodiments, the calling method of the application provided by the embodiments of the present disclosure is briefly described.

[0113] Reference Figure 7 , the second class loader is on the left, and the application is loaded and executed in the second class loader. When the application receives a call request (the vertical arrow in the second class loader is the transmission direction of the call request), the application intercepts the call method (function) and weaves the intercepted function into the first class loader on the right. Functions include pre-execution and post-execution. Pre-execution and post-execution have corresponding proxy functions on the plug-in chain in the first class loader (the vertical arrow corresponding to the plug-in chain is the arrangement direction of each proxy function on the plug-in chain). For example, pre-execution corresponds to proxy function A on the plug-in chain of the first class loader, and post-execution corresponds to proxy function B on the plug-in chain in the first class loader. The first class loader encapsulates the execution logic of proxy function A to obtain execution object A, and the first class loader encapsulates the execution logic of proxy function B to obtain execution object B. The first class loader transfers execution object A and execution object B to the second class loader for caching. If the function is pre-execution, the application directly calls the cached execution object A in the second class loader; if the function is post-execution, the application directly calls the cached execution object B in the second class loader.

[0114] Based on the above embodiments, the application calling method provided by the present disclosure has the following beneficial effects:

[0115] 1. The agent executes functions in the first class loader, and the application calls the execution object in the second class loader. The first class loader is unrelated to the second class loader, so that the execution environment of the agent is isolated from the execution environment of the application, avoiding class loading conflicts between the application and the agent, ensuring the normal operation of the agent, and enabling the agent to solve the security risks, performance risks and excessive computing resources in the operation of the agent function.

[0116] 2. Since the first execution object is cached in the second class recorder, when the first execution object needs to be called, the cached first execution object can be directly obtained from the second class loader. There is no need to encapsulate the execution logic of the first proxy function in the first class loader to obtain the first execution object, and there is no need to use the reflection mechanism to reflect the first execution object from the first class loader to the second class loader, which saves the time of the second class loader to execute the first execution object and is suitable for application scenarios of large-scale calling of execution objects.

[0117] 3. The third execution object of the first proxy function is passed to the second class loader through the reflection mechanism, so that the second class loader can successfully call the third execution object, ensuring that the application runs the first proxy function smoothly, which can be suitable for application scenarios that require no delay in running the proxy program.

[0118] Exemplary Media

[0119] After introducing the method of the exemplary embodiment of the present disclosure, next, refer to Figure 8 A storage medium according to an exemplary embodiment of the present disclosure is described.

[0120] refer to Figure 8 As shown, the storage medium 80 stores a program product for implementing the above method according to an embodiment of the present disclosure, which may adopt a portable compact disk read-only memory (CD-ROM) and include computer execution instructions, which are used to enable a computing device to execute the method for calling the application provided by the present disclosure. However, the program product of the present disclosure is not limited thereto.

[0121] The program product may adopt any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, a system, device or component of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination thereof. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.

[0122] The readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-executable instructions. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The readable signal medium may also be any readable medium other than a readable storage medium.

[0123] Computer-executable instructions for performing the disclosed operations of the present disclosure may be written in any combination of one or more programming languages, including object-oriented programming languages, such as Java, C++, etc., and conventional procedural programming languages, such as "C" or similar programming languages. The computer-executable instructions may be executed entirely on the user computing device, partially on the user device, partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device via any type of network, including a local area network (LAN) or a wide area network (WAN).

[0124] Exemplary Devices

[0125] After introducing the medium of the exemplary embodiment of the present disclosure, next, reference is made to Figure 8 The calling device of the application program of the exemplary embodiment of the present disclosure is described, which is used to implement the method in any of the above method embodiments. The implementation principle and technical effect are similar and will not be repeated here.

[0126] refer to Fig. 9 , Fig. 9 The structure diagram of the calling device of the application program provided in accordance with the embodiment of the present disclosure is schematically shown. Fig. 9 As shown, the calling device of the application program includes:

[0127] The receiving module 901 is used to receive a request to call an application and obtain a function for calling the application;

[0128] A determination module 902, configured to determine a first proxy function of calling an application program according to a function;

[0129] The calling module 903 is used to weave the function into the first class loader corresponding to the agent program so that the agent program can execute the function in the first class loader, and call the execution object in the second class loader to enable the application to run the first agent function. The second class loader is not associated with the first class loader, and the execution object is determined based on the first agent function.

[0130] In one embodiment of the present disclosure, the application program calling device includes:

[0131] An acquisition module 904 is used to acquire a first execution object cached by the first proxy function in the second class loader, where the first execution object is obtained by encapsulating the execution logic of the first proxy function;

[0132] The calling module 903 is further used to call the first execution object in the second class loader to enable the application to run the first proxy function.

[0133] In another embodiment of the present disclosure, the application program calling device includes:

[0134] The acquisition module 904 is further used to acquire the execution logic of each second agent function in the plug-in chain corresponding to the agent program, each second agent function includes the first agent function;

[0135] A first encapsulation module 905 is used to encapsulate the execution logic of each second proxy function in a first encapsulation manner to obtain a second execution object of each second proxy function;

[0136] The cache module 906 is used to cache each second execution object in the second class loader, and obtain the first execution object corresponding to the first proxy function in each second execution object.

[0137] In another embodiment of the present disclosure, the application program calling device includes:

[0138] The calling module 903 is further used to initialize the second class loader and perform reflective calling on each second execution object to obtain each second execution object;

[0139] The cache module 906 is further configured to cache each second execution object in the second class loader.

[0140] In another embodiment of the present disclosure, the application program calling device includes:

[0141] The acquisition module 904 is further used to acquire the execution logic of the first proxy function;

[0142] The second encapsulation module 907 is used to encapsulate the execution logic of the first proxy function into a third execution object by adopting a second encapsulation method;

[0143] The reflection module 908 is used to reflect the third execution object to the second class loader, and call the third execution object in the second class loader to enable the application to run the first proxy function.

[0144] In another embodiment of the present disclosure, the application program calling device includes:

[0145] The determination module 902 is further used to determine the execution mode of the function, and the execution mode includes pre-execution or post-execution;

[0146] The determination module 902 is further used to determine, according to the execution mode, a first proxy function to be run by the application program in a plug-in chain corresponding to the agent program, wherein the plug-in chain includes a plurality of arranged proxy functions.

[0147] In another embodiment of the present disclosure, the application program calling device includes:

[0148] The calling module 903 is also used to synchronously call the function in the first class loader and execute the object in the second class loader.

[0149] Exemplary Computing Devices

[0150] After introducing the method, medium and apparatus of the exemplary embodiments of the present disclosure, next, reference is made to Fig.10 A computing device according to an exemplary embodiment of the present disclosure is described.

[0151] Fig.10 The computing device 100 shown is only an example and should not limit the functionality and scope of use of the embodiments of the present disclosure. Fig.10 As shown, the computing device 100 is in the form of a general computing device. The components of the computing device 100 may include, but are not limited to: at least one processing unit 1001, at least one storage unit 1002, and a bus 1003 connecting different system components (including the processing unit 1001 and the storage unit 1002). Among them, at least one storage unit 1002 stores computer-executable instructions; at least one processing unit 1001 includes a processor, and the processor executes the computer-executable instructions to implement the method described above.

[0152] The bus 1003 includes a data bus, a control bus, and an address bus.

[0153] The storage unit 1002 may include a readable medium in the form of a volatile memory, such as a random access memory (RAM) 10021 and / or a cache memory 10022 , and may further include a readable medium in the form of a non-volatile memory, such as a read-only memory (ROM) 10023 .

[0154] The storage unit 1002 may also include a program / utility 10025 having a set (at least one) of program modules 10024, such program modules 10024 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include the implementation of a network environment.

[0155] The computing device 100 may also communicate with one or more external devices 1004 (e.g., keyboards, pointing devices, etc.). Such communication may be performed via an input / output (I / O) interface 1005. Furthermore, the computing device 100 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 1006. Fig.10As shown, the network adapter 1006 communicates with other modules of the computing device 100 via the bus 1003. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the computing device 100, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0156] It should be noted that, although several units / modules or sub-units / modules of the calling device of the application are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more units / modules described above can be embodied in one unit / module. Conversely, the features and functions of one unit / module described above can be further divided to be embodied by multiple units / modules.

[0157] In addition, although the operations of the disclosed method are described in a specific order in the drawings, this does not require or imply that the operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.

[0158] Although the spirit and principle of the present disclosure have been described with reference to several specific embodiments, it should be understood that the present disclosure is not limited to the disclosed specific embodiments, and the division of various aspects does not mean that the features in these aspects cannot be combined to benefit, and such division is only for the convenience of expression. The present disclosure is intended to cover various modifications and equivalent arrangements included in the spirit and scope of the attached claims.

Claims

1. A method for calling an application program. It is characterized in that include: Receiving a request to call an application and obtaining a function for calling the application; Determine, according to the function, to call a first proxy function of the application; the first proxy function is a function added to the application; The function is woven into the first class loader corresponding to the agent program so that the agent program executes the function in the first class loader, and the execution object is called in the second class loader to enable the application to run the first agent function. The second class loader is not associated with the first class loader, and the execution object is obtained based on the execution logic encapsulation of the agent function.

2. The method for calling an application according to claim 1, It is characterized in that The execution object includes a first execution object, and the step of calling the execution object in the second class loader to enable the application to run the first proxy function includes: Obtaining a first execution object cached by the first proxy function in the second class loader, where the first execution object is obtained by encapsulating the execution logic of the first proxy function; The first execution object is called in the second class loader to enable the application to run the first proxy function.

3. The method for calling an application according to claim 2, It is characterized in that The obtaining the first execution object cached by the first proxy function in the second class loader includes: Acquire the execution logic of each second proxy function in the plug-in chain corresponding to the proxy program, each second proxy function includes the first proxy function; the plug-in chain is obtained by arranging each proxy function that can be called by a function and is set in the terminal, and has a mapping relationship with the proxy program; Encapsulating the execution logic of each of the second proxy functions in a first encapsulation manner to obtain a second execution object of each of the second proxy functions; Each of the second execution objects is cached in the second class loader, and a first execution object corresponding to the first proxy function is obtained from each of the second execution objects.

4. The method for calling an application according to claim 3, It is characterized in that The step of caching each of the second execution objects into the second class loader comprises: Initializing the second class loader, and performing a reflection call on each of the second execution objects to obtain each of the second execution objects; Each of the second execution objects is cached in the second class loader.

5. The method for calling an application according to claim 1, It is characterized in that The execution object includes a third execution object, and the step of calling the execution object in the second class loader to enable the application to run the first proxy function includes: Obtaining the execution logic of the first proxy function; Encapsulating the execution logic of the first proxy function into a third execution object by using a second encapsulation method; The third execution object is reflected to the second class loader, and the third execution object is called in the second class loader to enable the application to run the first proxy function.

6. The method for calling an application according to any one of claims 1 to 5, It is characterized in that The step of determining to call the first proxy function of the application according to the function comprises: Determine an execution mode of the function, wherein the execution mode includes pre-execution or post-execution; According to the execution mode, a first agent function to be executed by the application program is determined in a plug-in chain corresponding to the agent program, wherein the plug-in chain includes a plurality of arranged agent functions.

7. The method for calling an application according to any one of claims 1 to 5, It is characterized in that The calling of the function in the first class loader and the calling of the execution object in the second class loader are performed synchronously.

8. A device for calling an application program, It is characterized in that include: A receiving module, used to receive a call request to an application program and obtain a function for calling the application program; A determination module, configured to determine, according to the function, a first proxy function for calling the application; the first proxy function is a function added to the application; A calling module is used to weave the function into the first class loader corresponding to the agent program so that the agent program executes the function in the first class loader, and to call the execution object in the second class loader to enable the application to run the first agent function. The second class loader is not associated with the first class loader, and the execution object is obtained based on the execution logic encapsulation of the agent function.

9. The application calling device according to claim 8, It is characterized in that include: an acquisition module, used to acquire a first execution object cached by the first proxy function in the second class loader, where the first execution object is obtained by encapsulating the execution logic of the first proxy function; The calling module is further used to call the first execution object in the second class loader to enable the application to run the first proxy function.

10. The application calling device according to claim 9, It is characterized in that include: The acquisition module is further used to acquire the execution logic of each second proxy function in the plug-in chain corresponding to the proxy program, each second proxy function includes the first proxy function; the plug-in chain is obtained by arranging various proxy functions that can be called by functions and is set in the terminal, and has a mapping relationship with the proxy program; A first encapsulation module, configured to encapsulate the execution logic of each of the second proxy functions in a first encapsulation manner to obtain a second execution object of each of the second proxy functions; A cache module is used to cache each of the second execution objects in the second class loader, and obtain the first execution object corresponding to the first proxy function in each of the second execution objects.

11. The application calling device according to claim 10, It is characterized in that include: The calling module is further used to initialize the second class loader and perform reflective calling on each of the second execution objects to obtain each of the second execution objects; The cache module is further used to cache each of the second execution objects in the second class loader.

12. The application calling device according to claim 8, It is characterized in that include: An acquisition module, used to acquire the execution logic of the first proxy function; A second encapsulation module, used to encapsulate the execution logic of the first proxy function into a third execution object by adopting a second encapsulation method; A reflection module is used to reflect the third execution object to the second class loader, and call the third execution object in the second class loader to enable the application to run the first proxy function.

13. The device for calling an application according to any one of claims 8 to 12, It is characterized in that include: The determination module is further used to determine the execution mode of the function, wherein the execution mode includes pre-execution or post-execution; The determination module is further used to determine, according to the execution mode, a first proxy function to be run by the application in a plug-in chain corresponding to the agent program, wherein the plug-in chain includes a plurality of arranged proxy functions.

14. The application calling device according to any one of claims 8 to 12, It is characterized in that include: The calling module is also used to synchronously call the function in the first class loader and the execution object in the second class loader.

15. A medium, include: A computer-executable instruction, wherein when the computer-executable instruction is executed by a processor, it is used to implement the calling method of the application program according to any one of claims 1 to 7.

16. A computing device, include: Memory and processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor executes the method for calling the application program according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Performance data log obtaining method and device

    CN108228147A

  • Data monitoring and application program processing method, device and equipment

    CN111309402A