CN114661385A - Application calling method, medium, device and computing equipment - Google Patents

Application calling method, medium, device and computing equipment Download PDF

Info

Publication number
CN114661385A
CN114661385A CN202210429266.2A CN202210429266A CN114661385A CN 114661385 A CN114661385 A CN 114661385A CN 202210429266 A CN202210429266 A CN 202210429266A CN 114661385 A CN114661385 A CN 114661385A
Authority
CN
China
Prior art keywords
function
calling
execution
class loader
agent
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210429266.2A
Other languages
Chinese (zh)
Inventor
卢豪帅
翁扬慧
裴斐
冯常健
陈谔
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Langhe Technology Co Ltd
Original Assignee
Hangzhou Langhe Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Langhe Technology Co Ltd filed Critical Hangzhou Langhe Technology Co Ltd
Priority to CN202210429266.2A priority Critical patent/CN114661385A/en
Publication of CN114661385A publication Critical patent/CN114661385A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4488Object-oriented
    • G06F9/449Object-oriented method invocation or resolution
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • G06F9/44526Plug-ins; Add-ons

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the disclosure provides a calling method of an application program. The method comprises the following steps: receiving a call request for an application program, and acquiring a function for calling the application program; determining a first agent function for calling the application program according to the function; and 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, calling an execution object in a second class loader to enable the application program to run a first agent function, wherein the second class loader is not associated with the first class loader. According to the method and the device, the execution environment of the agent program is isolated from the execution environment of the application program, class loading conflict between the application program and the agent program is avoided, normal operation of the agent program is guaranteed, and the agent program can solve potential safety hazards, potential performance hazards and excessive computing resource occupation existing in agent function operation. Furthermore, embodiments of the present disclosure provide a medium, an apparatus, and a computing device.

Description

Application calling method, medium, device and computing equipment
Technical Field
Embodiments of the present disclosure relate to the field of software, and more particularly, to a method, a medium, an apparatus, and a computing device for invoking an application.
Background
This section is intended to provide a background or context to the embodiments of the disclosure recited in the claims. The description herein is not admitted to be prior art by inclusion in this section.
Sidecar, a Sidecar, is a term of art in the field of microservices, and is connected with a main application as an independent process and container. The Sidecar is loosely coupled with the main application program, so that the difference of different programming languages can be shielded, and the agency functions of observability, monitoring, log recording, configuration, circuit breakers, flow control and the like of the micro-service are uniformly realized.
The Sidecar model deploys a cohesive set of tasks with the host application and generally tends to require isolation of the tasks from the host application into separate processes or containers. This approach may allow more functionality to be added to the operating environment of the application without requiring additional third party component configurations or modifications to the application code. Sidecar intercepts traffic in an iptables (the iptables is a stateful firewall) mode, and the governance capability of various traffic is realized.
Because the iptables needs to intercept the traffic of the outlet and the inlet, the link which is originally processed for 2 times in the kernel mode is changed into the link which is processed for 4 times, so that the performance of the kernel mode is lost, and the potential performance hazard exists when the iptables intercepts the traffic. In addition, the iptables passes the defined rules to a network filter for reading so as to realize the function of the firewall, that is, the iptables is not a real firewall and cannot identify viruses in data, and potential safety hazards exist when the iptables intercepts flow. In addition, iptables needs to intercept traffic at the egress and ingress, causing the kernel mode to need to process 4 links, which increases additional network overhead that causes unacceptable delay for high performance applications. In addition, the standalone process of the Sidecar mode occupies additional computing resources, which brings additional management overhead. It can be known that the implementation of the proxy function has the problems of potential safety hazard, potential performance hazard and excessive occupation of computing resources.
To address these concerns, a proxy program may be used to implement various proxy functions instead of the Sidecar mode. The existing agent program and the application program are executed in the same class loader environment, so that the application program is loaded by using the class loader and conflicts with the agent program when the application program is loaded by using the class loader, the agent program cannot normally run, and the agent program cannot solve the problems of potential safety hazard, potential performance hazard and excessive computing resource occupation existing in the running of agent functions.
Disclosure of Invention
The disclosure provides a calling method, a calling medium, a calling device and a calling computing device of an application program, and aims to solve the problems that an agent program cannot solve potential safety hazards and potential performance hazards existing in the operation of an agent function, and computing resources are excessively occupied.
In a first aspect of the disclosed embodiments, there is provided an application calling method, including: receiving a call request for an application program, and acquiring a function for calling the application program; determining to call a first proxy function of the application program according to the function; and weaving the function into a first class loader corresponding to an agent program for the agent program to execute the function in the first class loader, and calling an execution object in a second class loader to enable the application program to run the first agent function, wherein the second class loader is not associated with the first class loader, and the execution object is determined according to the first agent function.
In an embodiment of the present disclosure, the executing object includes a first executing object, and the step of calling the executing object in the second class loader to make the application program run the first proxy function includes: obtaining a first execution object cached by the first agent function in the second class loader, wherein the first execution object is obtained by encapsulating execution logic of the first agent function; calling the first execution object in the second type loader to enable the application program to run the first proxy function.
In another embodiment of the present disclosure, the obtaining the first execution object cached by the first proxy function in the second class loader includes: acquiring execution logic of each second agent function in a plug-in chain corresponding to the agent program, wherein each second agent function comprises the first agent function; adopting a first packaging mode to package the execution logic of each second proxy function to obtain a second execution object of each second proxy function; caching each second execution object into the second class loader, and acquiring a first execution object corresponding to the first proxy function from each second execution object.
In another embodiment of the present disclosure, the step of caching each of the second execution objects in the second class loader includes: initializing the second type loader, and performing reflection call on each second execution object to acquire each second execution object; and caching each second execution object in the second type loader.
In yet another embodiment of the present disclosure, the executing object includes a third executing object, and the step of calling the executing object in the second class loader to make the application program run the first proxy function includes: acquiring execution logic of the first agent function; packaging the execution logic of the first proxy function into a third execution object by adopting a second packaging mode; 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 program to run the first proxy function.
In a further embodiment of the present disclosure, the determining to invoke the first proxy function of the application according to the function includes: determining an execution mode of the function, wherein the execution mode comprises pre-execution or post-execution; and determining a first agent function to be operated by the application program in a plug-in chain corresponding to the agent program according to the execution mode, wherein the plug-in chain comprises a plurality of arranged agent functions.
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.
In a second aspect of the embodiments of the present disclosure, there is provided an apparatus for calling an application, including: the receiving module is used for receiving a calling request for an application program and acquiring a function for calling the application program; the determining module is used for determining and calling a first proxy function of the application program according to the function; the calling module is used for weaving the function into a first class loader corresponding to an agent program so that the agent program can execute the function in the first class loader, and calling an execution object in a second class loader to enable the application program to run the first agent function, wherein the second class loader is not associated with the first class loader, and the execution object is determined according to the first agent function.
In an embodiment of the present disclosure, the method includes: an obtaining module, configured to obtain a first execution object cached by the first proxy function in the second class loader, where the first execution object is obtained by encapsulating execution logic of the first proxy function; the calling module is further configured to call the first execution object in the second class loader to enable the application program to run the first proxy function.
In yet another embodiment of the present disclosure, includes: the obtaining module is further configured to obtain an execution logic of each second proxy function in a plug-in chain corresponding to the agent, where each second proxy function includes the first proxy function; the first encapsulation module is used for encapsulating the execution logic of each second proxy function in a first encapsulation mode to obtain a second execution object of each second proxy function; and the caching module is used for caching the second execution objects into the second class loader and acquiring the first execution object corresponding to the first proxy function from the second execution objects.
In yet another embodiment of the present disclosure, includes: the calling module is further configured to initialize the second class loader and perform a reflection call on each second execution object to obtain each second execution object; the cache module is further configured to cache each second execution object in the second class loader.
In yet another embodiment of the present disclosure, includes: the obtaining module is further configured to obtain execution logic of the first proxy function; the second packaging module is used for packaging the execution logic of the first proxy function into a third execution object by adopting a second packaging mode; and the reflecting module is used for 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 program to run the first proxy function.
In yet another embodiment of the present disclosure, includes: the determining module is further configured to determine an execution manner of the function, where the execution manner includes pre-execution or post-execution; the determining module is further configured to determine, according to the execution manner, a first proxy function to be run by the application program in a plug-in chain corresponding to the proxy program, where the plug-in chain includes a plurality of arranged proxy functions.
In yet another embodiment of the present disclosure, includes: the calling module is further configured to synchronously call the function in the first class loader and the execution object in the second class loader.
In a third aspect of embodiments of the present disclosure, there is provided a medium comprising: computer-executable instructions for implementing the calling method of the application program according to the first aspect when executed by a processor.
In a fourth aspect of embodiments of the present disclosure, there is provided a computing device comprising: a memory and a processor; the memory stores computer-executable instructions; the processor executes computer-executable instructions stored by the memory, causing the processor to perform a method of calling an application program as described in the first aspect.
According to the embodiment of the disclosure, a call request of an application program is received, a function for calling the application program is obtained, a proxy function for calling the application program is determined according to the function, the function is woven into a first class loader corresponding to the proxy program so that the proxy program can execute the function in the first class loader, and an execution object is called in a second class loader which is not associated with the first class loader so that the application program runs the proxy function. The agent program executes the function in the first class loader, the application program calls the execution object in the second class loader, and the first class loader is not associated with the second class loading, so that the execution environment of the agent program is isolated from the execution environment of the application program, class loading conflict between the application program and the agent program is avoided, normal operation of the agent program is ensured, and the agent program can solve the potential safety hazard, potential performance hazard and excessive computing resource occupation existing in the operation of the agent function.
Drawings
The above and other objects, features and advantages of exemplary embodiments of the present disclosure will become readily apparent from the following detailed description read in conjunction with the accompanying drawings. Several embodiments of the present disclosure are illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings and in which:
fig. 1 schematically shows a structural diagram of a calling device of an application according to the present disclosure;
FIG. 2 schematically shows a flow diagram according to an embodiment of the present disclosure;
FIG. 3 schematically shows a flow diagram according to yet another embodiment of the present disclosure;
FIG. 4 schematically shows a flow diagram according to yet another embodiment of the disclosure;
FIG. 5 schematically shows a flow diagram according to another embodiment of the disclosure;
FIG. 6 schematically shows a flow diagram according to a further embodiment of the disclosure;
FIG. 7 is a schematic diagram schematically illustrating an application scenario in accordance with the present disclosure;
FIG. 8 schematically illustrates a schematic diagram of a storage medium according to an embodiment of the present disclosure;
FIG. 9 schematically illustrates a calling device function module diagram of an application according to an embodiment of the present disclosure;
fig. 10 schematically shows a hardware configuration diagram of a calling device of an application according to an embodiment of the present disclosure;
in the drawings, the same or corresponding reference numerals indicate the same or corresponding parts.
Detailed Description
The principles and spirit of the present disclosure will be described with reference to a number of exemplary embodiments. It is understood that these embodiments are given solely for the purpose of enabling those skilled in the art to better understand and to practice the present disclosure, and are not intended to limit the scope of the present disclosure in any way. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
As will be appreciated by one skilled in the art, embodiments of the present disclosure may be embodied as a system, apparatus, device, method, or computer program product. Accordingly, the present disclosure may be embodied in the form of: entirely hardware, entirely software (including firmware, resident software, micro-code, etc.), or a combination of hardware and software.
According to the embodiment of the disclosure, a method, a medium, a device and a computing device for calling an application program are provided.
In this context, it is to be understood that the terms referred to and the meanings ascribed to them are as follows:
the function is: refers to a method of calling an application;
the agent program: refers to a program written by java technology, and java refers to a parameter of a java command;
the proxy function: the method comprises the functions of service discovery, load balancing, fusing, current limiting, service routing, monitoring and collection and the like;
plug-in chain: the device comprises a queue formed by a plurality of arranged proxy functions and used for determining the proxy functions to be executed when the function is called;
a first proxy function: refers to the function that needs to be called currently;
a second proxy function: refers to the proxy function arranged in the plug-in chain;
the first type loader: the system can be a self-defined class loader and is used for carrying out class loading on the agent program in a java agent environment;
the second type loader: the system comprises an application class loader, an extension class loader and a start class loader, wherein after class loading is carried out on an application program in an application class loader in a user environment, class loading is carried out on the extension class loader, and finally class loading is carried out in the start class loader, and data interaction can be carried out between the first class loader and the second class loader;
executing the object: is encapsulated according to the execution logic of the first proxy function;
the first execution object: the method comprises the steps of indicating an execution object corresponding to a first proxy function cached in a second type loader;
a second execution object: refers to an execution object encapsulated by the execution logic of the second proxy function in the plug-in chain;
the first packaging mode: refers to a way of packaging by adopting the functional (functional interface) characteristic of jdk8 (a version developed by Java language);
the second packaging mode: a method of packaging by using callable. call () (callable. call () refers to a callable function);
a third execution object: the method refers to an execution object obtained by adopting a second packaging mode to package execution logic of the first agent function.
The user environment is as follows: refers to an environment in which an application is executed in a terminal.
Class conflict: the method refers to a situation that one class logger loads a class in a base class library corresponding to another class logger, so that the class logger cannot load the class normally.
Furthermore, the number of any elements in the drawings is intended to be illustrative and not restrictive, and any nomenclature is used for distinction only and not for any restrictive meaning.
The principles and spirit of the present disclosure are explained in detail below with reference to several representative embodiments thereof.
Summary of The Invention
The inventor finds that the sidecar intercepts TCP traffic through iptables to realize logic of analysis, governance, forwarding and the like, and extra performance loss of the sidecar mainly focuses on the logic of analysis, governance and forwarding, namely the sidecar has potential safety hazard and potential performance hazard and occupies too much computing resources due to the fact that the sidecar realizes the logic of analysis, governance, forwarding and the like. In the process of the agent, the frame itself is already operated for flow construction and analysis, and the agent can perform corresponding flow management based on the result of the frame analysis, so that no additional network overhead is generated, and no unacceptable delay is caused to the application program, and thus the agent cannot become the performance bottleneck of the application. Meanwhile, the java agent is enhanced by pure byte codes, some frame functions cannot be used, only the frame and the class library used by a user are enhanced, and the subsequent supplement and perfection of the support for various tool libraries in the java language can meet the treatment support of any application under the full java system. Therefore, the java agent can completely realize the capability of the sidecar on the technical level, and the problems of potential safety hazard, potential performance hazard, excessive computing resource occupation and the like do not exist.
When using an agent programmed by java, the inventors have found that the agent and the application execute in the same class loader environment. Because the agent program and the application program both have respective basic class libraries, and class names in the two basic class libraries may be the same, when the application program is loaded by using a class loader, the application program may be loaded by using classes in the basic class libraries of the agent program, so that class conflict exists between the agent program and the application program, the agent program cannot normally run, and further the agent program cannot solve the problems of potential safety hazard, potential performance hazard and excessive computing resource occupation existing in agent function running.
Therefore, the agent program is isolated from the class loader adopted by the application program, so that when the application program calls the class loader to carry out class loading, the application program cannot adopt the class in the basic class library of the agent program to carry out loading, thereby avoiding the occurrence of class conflict, and solving the problems of potential safety hazard and potential performance hazard existing in the operation of the agent function and excessive occupation of computing resources of the agent program
Having described the general principles of the present disclosure, various non-limiting embodiments of the present disclosure are described in detail below.
Application scene overview
Referring first to fig. 1, fig. 1 schematically illustrates a structural diagram of a calling device of an application program according to an embodiment of the present disclosure. The calling means of the application can be any terminal with data processing capabilities. As shown in fig. 1, a schematic diagram of class loading between an agent and an application in an application calling device 100 is shown. The agent may execute a function in the first class loader 110 in the java agent environment and the application may call an execution object in the second class loader 120 in the user environment. Since the first type loader 110 is located in the java agent environment and the second type loader 120 is located in the user environment, the first type loader 110 is not associated with the second type loader, thereby isolating the application from the agent.
The calling device of the application program may be a Personal Digital Assistant (PDA) device, a handheld device (e.g., a smart phone or a tablet computer) with a wireless communication function, a computing device (e.g., a Personal Computer (PC)), an in-vehicle device, a wearable device (e.g., a smart watch or a smart band), a smart home device (e.g., a smart display device), and the like, a cloud server, and the like.
Exemplary method
A method for calling an application according to an exemplary embodiment of the present disclosure is described below with reference to fig. 2 to 6 in conjunction with a schematic structural diagram of a calling device of an application of fig. 1. It should be noted that the above application scenarios are only illustrated for the convenience of understanding the spirit and principles of the present disclosure, and the embodiments of the present disclosure are not limited in any way in this respect. Rather, embodiments of the present disclosure may be applied to any scenario where applicable.
For example, the execution subject of the embodiment of the present disclosure may be a terminal.
Referring to fig. 2, fig. 2 schematically shows a flow diagram of a method for calling an application program according to an embodiment of the present disclosure. As shown in fig. 2, the calling method of the application program includes:
step S201, receiving a call request for the application program, and acquiring a function for calling the application program.
In an embodiment, during the running of the application, a call request is received, and the call request is used for requesting the application to call some proxy functions. After receiving the call request, the terminal calls the application program by adopting a corresponding function, wherein the function is a method for calling the application program, and the function can be determined by the proxy function required to be called by the call request. The agent intercepts the function call, i.e. the agent in the terminal obtains the function of the calling application program.
Step S202, determining to call the first proxy function of the application program according to the function.
After the function of the calling application program is obtained, a first proxy function of the calling application program is determined based on the function. The first agent function may be current limiting, fusing or monitoring collection. Monitor collection refers to the collection of data of a specified type by monitoring the data generated by the running of an application.
In one example, the function and the proxy function have a mapping relationship therebetween, and the first proxy function can be determined through the mapping relationship and the function.
Step S203, weaving the function into the first class loader corresponding to the agent program for the agent program to execute the function in the first class loader, and calling the execution object in the second class loader to enable the application program to run the first agent function, where the second class loader is not associated with the first class loader, and the execution object is determined according to the first agent function.
The terminal is provided with a first type loader and a second type loader. The first class of loaders is not associated with the second class of loaders. 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 start class loader. The terminal adopts a byte code weaving mode to weave the function into the first class loader, and the agent program can load the class in the first class loader to execute the function. The terminal calls the execution object in the second type loader to enable the application program to run the first agent function. The execution object is determined according to the first proxy function, for example, the execution object is obtained based on the execution logic package of the first proxy function, and the first proxy function can be understood as a function added to the application program.
It should be noted 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, so that the application program does not delay the running of the externally added proxy function. Furthermore, weaving refers to connecting the cut surface to external parameters. Calling a method will have three facets, namely "method run time", "method run", and "after method run".
Because the first type loader is not associated with the second type loader, the agent program and the application program do not need to consider whether the opposite side uses the same type of problem, and the class conflict generated by the application program is avoided.
In this embodiment, a call request of an application program is received, a function of the application program is obtained, a proxy function of the application program is determined according to the function, the function is woven into a first class loader corresponding to the proxy program so that the proxy program executes the function in the first class loader, and an execution object is called in a second class loader unrelated to the first class loader so that the application program runs the proxy function. The agent program executes a function in the first class loader, the application program calls an execution object in the second class loader, the first class loader is not associated with the second class loading, so that the execution environment of the agent program is isolated from the execution environment of the application program, the first class loader loads classes in the basic class library in the execution environment of the agent program, the second class loader loads the classes in the basic class library in the execution environment of the application program (the class basic libraries and the execution environment have corresponding relations), class loading conflict between the application program and the agent program is avoided, normal operation of the agent program is guaranteed, and the agent program can solve potential safety hazards, potential performance hazards and excessive computing resource occupation existing in agent function operation.
Referring to fig. 3, fig. 3 schematically illustrates a second flowchart of a method for calling an application program according to an embodiment of the present disclosure, and on the basis of the embodiment illustrated in fig. 2, the step S203 of "calling an execution object in a second class loader to make the application program run a first proxy function" includes:
step S301, a first execution object cached by the first agent function in the second class loader is obtained, where the first execution object is obtained by encapsulating the execution logic of the first agent function.
In this embodiment, a plurality of execution objects are cached in the second class loader, and each cached execution object is encapsulated by the execution logic of each agent function.
After the first proxy function is determined, the execution object corresponding to the first proxy function is determined in each execution object of the cache, and the execution object of the cache corresponding to the first proxy function is defined as the first execution object.
Step S302, calling the first execution object in the second type loader to enable the application program to run the first proxy function.
After the first execution object is obtained, the first execution object can be called in the second type loader, so that the application program runs the first proxy function.
In this embodiment, since the first execution object is cached in the second class loader, when the first execution object needs to be called, the cached first execution object can be directly obtained from the second class loader, the first execution object does not need to be obtained by encapsulating the execution logic of the first proxy function in the first class loader, and the first execution object does not need to be reflected from the first class loader into the second class loader by using a reflection mechanism, so that the time for the second class loader to execute the first execution object is saved, and the application scenario for calling the execution object in a large scale can be applied.
Referring to fig. 4, fig. 4 schematically illustrates a third flowchart of a method for calling an application program according to an embodiment of the present disclosure, and on the basis of the embodiment illustrated in fig. 3, step S301 includes:
step S401, acquiring an execution logic of each second proxy function in the plug-in chain corresponding to the proxy program, where each second proxy function includes the first proxy function.
The terminal is provided with various proxy functions for function calling, the proxy functions are arranged to obtain a plug-in chain, and the plug-in chain and the proxy program have a mapping relation. The proxy function in the plug-in chain is defined as the second proxy function. And the terminal can obtain each second proxy function in the plug-in chain corresponding to the proxy program based on the mapping relation and obtain the execution logic of each proxy function. Each of the second proxy functions includes the first proxy function, that is, the first proxy function that the application program needs to be currently operated is one of the respective second proxy functions.
Step S402, the executing logic of each second agency function is packaged by adopting a first packaging mode, and a second executing object of each second agency function is obtained.
After the execution logic of each second agent function is obtained, the terminal encapsulates the execution logic of each second agent function in a first encapsulation mode, and thus a second execution object of each second agent function can be obtained. The first encapsulation mode refers to a mode of encapsulating by using the functional (functional interface) characteristic of jdk8, that is, the second execution object is the function object.
Step S403, 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.
And the terminal caches each second execution object in the second class loader and caches the mapping relation 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 mapping relation of the cache.
In one example, the terminal caches each second execution object in the second class loader through the initialized reflection. Specifically, the second class loader is initialized, each second execution object is called in a reflection mode to obtain each second execution object, and each second execution object is cached in the second class loader. When in subsequent calling, the cached execution object can be directly called in the second type loader without reflection, so that the performance of the second type loader in the operation period is improved.
In this embodiment, the execution logic of each second agent function in the plug-in chain corresponding to the agent is obtained, the execution logic of each second agent function is encapsulated in a first encapsulation manner, a second execution object of each second agent function is obtained, each second execution object is cached in the second class loader, and when the execution object is subsequently called, the cached execution object is directly obtained from the second class loader without reflection, so that the obtaining duration of the execution object is reduced, and the first agent function is rapidly operated by the application program.
Referring to fig. 5, fig. 5 schematically illustrates a fourth flowchart of a method for calling an application according to an embodiment of the present disclosure, and on the basis of the embodiment illustrated in fig. 2, the step S203 of "calling an execution object in a second class loader to make the application run a first proxy function" includes:
in step S501, an execution logic of the first proxy function is acquired.
In this embodiment, the agent obtains the execution logic of the first agent function from the plug-in chain after intercepting the function. The execution objects of the first proxy function include a third execution object.
Step S502, the execution logic of the first agent function is encapsulated into a third execution object by adopting a second encapsulation mode.
Callablel.call () is also arranged in the plug-in chain, and a second packaging mode is adopted to package the execution logic to obtain a third execution object, namely the execution logic is packaged through callablel.call (). The third execution object is a callable object in java language. call () is a function that the first type loader needs to execute, and calling callable.
Step S503, 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 program to run the first proxy function.
And reflecting the third execution object to the second class loader to enable the second class loader to acquire the third execution object, so that the third execution object is called in the second class loader to enable the application program to run the first proxy function.
In this embodiment, the third execution object of the first agent function is transferred to the second class loader through a reflection mechanism, so that the second class loader can successfully call the third execution object, and the application program is ensured to smoothly run the first agent function.
Referring to fig. 6, fig. 6 schematically illustrates a fifth flowchart of a method for calling an application according to an embodiment of the present disclosure, and based on any one of the embodiments illustrated in fig. 2 to 5, the step of "determining a first proxy function to be run by calling an application according to a function" in step S203 includes:
step S601, determining an execution mode of the function, where the execution mode includes pre-execution or post-execution.
In this embodiment, the respective second proxy functions of the plug-in chain arrangement are arranged based on the execution manner of the function. The execution mode of the function comprises a front execution mode and a back execution mode.
In an example, a plug-in chain includes current limiting, fusing, monitoring, and rollback. The method comprises the steps of limiting current and fusing the weaving logic belonging to the function front execution, and monitoring and backing off the weaving logic belonging to the function rear execution.
Step S602, determining a first proxy function to be run by the application program in a plug-in chain corresponding to the proxy program according to the execution mode, where the plug-in chain includes a plurality of arranged proxy functions.
And the terminal determines a first proxy function to be operated by the application program in the plug-in chain corresponding to the proxy program based on the execution mode. Specifically, if the plug-in chain includes current limiting, fusing, monitoring and rollback, and the execution mode of the function is pre-execution, the first proxy function is current limiting and/or fusing; if the execution mode of the function is post-execution, the first proxy function is monitoring and/or fusing.
In this embodiment, the terminal determines the execution mode of the function, and accurately determines the first proxy function of the application in the plug-in chain of the proxy according to the execution mode.
With reference to the foregoing embodiments, a method for calling an application program provided in the embodiments of the present disclosure is briefly described.
Referring to fig. 7, the left side is a second type loader, and the application program is loaded and executed in the second type loader. When the application program receives a call request (the vertical arrow in the second type loader is the transmission direction of the call request), the application program intercepts a call method (function), and the intercepted function is woven into the first type loader on the right side. The function includes pre-execution and post-execution. The front-end execution and the back-end execution have corresponding proxy functions in the plug-in chain in the first type loader (the vertical arrow corresponding to the plug-in chain is the arrangement direction of each proxy function in the plug-in chain), for example, the front-end execution corresponds to the proxy function A in the plug-in chain of the first type loader, and the back-end execution corresponds to the proxy function B in the plug-in chain in the first type loader. The first class loader packages the execution logic of the agent function A to obtain an execution object A, and the first class loader packages the execution logic of the agent function B to obtain an execution object B. The first type loader transfers the execution object A and the execution object B to the second type loader for caching. If the function is pre-execution, the application program directly calls the cached execution object A in the second type loader; if the function is executed in the post-position, the application program directly calls the cached execution object B in the second type loader.
Based on the above embodiment, the application program calling method provided by the present disclosure has the following beneficial effects:
1. the agent program executes the function in the first class loader, the application program calls the execution object in the second class loader, and the first class loader is not associated with the second class loading, so that the execution environment of the agent program is isolated from the execution environment of the application program, class loading conflict between the application program and the agent program is avoided, normal operation of the agent program is ensured, and the agent program can solve potential safety hazard, potential performance hazard and excessive computing resource occupation existing in agent function operation.
2. Because the first execution object is cached in the second class loader, when the first execution object needs to be called, the cached first execution object can be directly obtained from the second class loader, the first execution object does not need to be obtained by packaging the execution logic of the first proxy function in the first class loader, and the first execution object does not need to be reflected into the second class loader from the first class loader by using a reflection mechanism, so that the time for the second class loader to execute the first execution object is saved, and the application scene for calling the execution object in a large scale can be applied.
3. And the third execution object of the first agent function is transmitted to the second class loader through a reflection mechanism, so that the second class loader can successfully call the third execution object, the first agent function can be ensured to be smoothly operated by the application program, and the method is applicable to application scenes without time delay requirements on the operation of the agent program.
Exemplary Medium
Having described the method of the exemplary embodiment of the present disclosure, next, a storage medium of the exemplary embodiment of the present disclosure will be described with reference to fig. 8.
Referring to fig. 8, a storage medium 80 stores therein a program product for implementing the above method according to an embodiment of the present disclosure, which may employ a portable compact disc read only memory (CD-ROM) and includes computer-executable instructions for causing a computing device to perform a calling method of an application provided by the present disclosure. However, the program product of the present disclosure is not limited thereto.
The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
A readable signal medium may include a propagated data signal with computer-executable instructions embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. The readable signal medium may also be any readable medium other than a readable storage medium.
Computer-executable instructions for carrying out operations of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The computer executable instructions may execute entirely on the user computing device, partly on the user device, partly on a remote computing device, or entirely on the 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 through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN).
Exemplary devices
After introducing the media of the exemplary embodiment of the present disclosure, next, a calling device of an application program of the exemplary embodiment of the present disclosure is described with reference to fig. 8, which is used for implementing the method in any of the method embodiments described above, and the implementation principle and the technical effect are similar, and are not described again here.
Referring to fig. 9, fig. 9 schematically illustrates a structural diagram of a calling device of an application program provided according to an embodiment of the present disclosure. As shown in fig. 9, the calling device of the application includes:
a receiving module 901, configured to receive a call request for an application program and obtain a function for calling the application program;
a determining module 902, configured to determine, according to a function, a first proxy function of a calling application;
the calling module 903 is configured to weave a 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 call an execution object in a second class loader to enable the application program to run the first agent function, where the second class loader is not associated with the first class loader, and the execution object is determined according to the first agent function.
In one embodiment of the present disclosure, the calling device of the application program includes:
an obtaining module 904, configured to obtain a first execution object cached by the first agent function in the second class loader, where the first execution object is obtained by encapsulating execution logic of the first agent function;
the calling module 903 is further configured to call the first execution object in the second class loader to enable the application program to run the first proxy function.
In still another embodiment of the present disclosure, the calling device of the application includes:
an obtaining module 904, configured to obtain execution logic of each second proxy function in the plug-in chain corresponding to the agent, where each second proxy function includes the first proxy function;
a first encapsulation module 905, configured to encapsulate, in a first encapsulation manner, execution logic of each second proxy function, so as to obtain a second execution object of each second proxy function;
the caching module 906 is configured to cache each second execution object into the second class loader, and obtain a first execution object corresponding to the first proxy function from each second execution object.
In still another embodiment of the present disclosure, the calling device of the application includes:
the calling module 903 is further configured to initialize a second class loader and perform a reflection call on each second execution object to obtain each second execution object;
the caching module 906 is further configured to cache each second execution object in the second class loader.
In still another embodiment of the present disclosure, the calling device of the application includes:
an obtaining module 904, further configured to obtain an execution logic of the first proxy function;
a second encapsulating module 907, configured to encapsulate the execution logic of the first proxy function into a third execution object in a second encapsulating manner;
and a reflection module 908, configured 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 program to run the first proxy function.
In still another embodiment of the present disclosure, the calling device of the application includes:
the determining module 902 is further configured to determine an execution manner of the function, where the execution manner includes pre-execution or post-execution;
the determining module 902 is further configured to determine, according to the execution manner, a first proxy function to be run by the application program in a plug-in chain corresponding to the proxy program, where the plug-in chain includes multiple arranged proxy functions.
In still another embodiment of the present disclosure, the calling device of the application includes:
the calling module 903 is further configured to synchronously call a function in the first class loader and execute an object in the second class loader.
Exemplary computing device
Having described the methods, media, and apparatus of the exemplary embodiments of the present disclosure, a computing device of the exemplary embodiments of the present disclosure is described next with reference to fig. 10.
The computing device 100 shown in fig. 10 is only one example and should not impose any limitations on the functionality or scope of use of embodiments of the disclosure. As shown in fig. 10, computing device 100 is embodied in the form of a general purpose computing device. Components of computing device 100 may include, but are not limited to: at least one processing unit 1001, at least one memory unit 1002, and a bus 1003 connecting the various system components (including the processing unit 1001 and the memory unit 1002). Wherein, the at least one storage unit 1002 stores computer executable instructions; the at least one processing unit 1001 comprises a processor executing the computer executable instructions to implement the method described above.
The bus 1003 includes a data bus, a control bus, and an address bus.
The storage unit 1002 may include readable media in the form of volatile memory, such as Random Access Memory (RAM)10021 and/or cache memory 10022, and may further include readable media in the form of non-volatile memory, such as Read Only Memory (ROM) 10023.
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 thereof, may comprise an implementation of a network environment.
Computing device 100 may also communicate with one or more external devices 1004 (e.g., keyboard, pointing device, etc.). Such communication may occur via input/output (I/O) interface 1005. Moreover, 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) through network adapter 1006. As shown in FIG. 10, network adapter 1006 communicates with the other modules of computing device 100 via bus 1003. It should be understood that although not shown in the figures, other hardware and/or software modules may be used in conjunction with 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, among others.
It should be noted that although in the above detailed description several units/modules or sub-units/modules of the calling means of the application are mentioned, such a division is merely exemplary and not mandatory. Indeed, the features and functions of two or more units/modules described above may be embodied in one unit/module according to embodiments of the present disclosure. Conversely, the features and functions of one unit/module described above may be further divided into embodiments by a plurality of units/modules.
Further, while the operations of the disclosed methods are depicted in the drawings in a particular order, this does not require or imply that the operations must be performed in this particular order, or that all of the illustrated operations must be performed, to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step execution, and/or one step broken down into multiple step executions.
While the spirit and principles of the present disclosure have been described with reference to several particular embodiments, it is to be understood that the present disclosure is not limited to the particular embodiments disclosed, nor is the division of aspects, which is for convenience only as the features in such aspects may not be combined to benefit. The disclosure is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims.

Claims (10)

1. A method for calling an application program, comprising:
receiving a call request for an application program, and acquiring a function for calling the application program;
determining to call a first proxy function of the application program according to the function;
weaving the function into a first class loader corresponding to an agent program for the agent program to execute the function in the first class loader, and calling an execution object in a second class loader to enable the application program to run the first agent function, wherein the second class loader is not associated with the first class loader, and the execution object is determined according to the first agent function.
2. The method for calling an application according to claim 1, wherein the execution object comprises a first execution object, and the step of calling the execution object in the second class loader to cause the application to execute the first proxy function comprises:
obtaining a first execution object cached by the first agent function in the second class loader, wherein the first execution object is obtained by encapsulating execution logic of the first agent function;
calling the first execution object in the second type loader to enable the application program to run the first proxy function.
3. The method for calling the application program according to claim 2, wherein the obtaining the first execution object cached by the first proxy function in the second class loader comprises:
acquiring execution logic of each second proxy function in a plug-in chain corresponding to the proxy program, wherein each second proxy function comprises the first proxy function;
adopting a first packaging mode to package the execution logic of each second proxy function to obtain a second execution object of each second proxy function;
caching each second execution object into the second class loader, and acquiring a first execution object corresponding to the first proxy function from each second execution object.
4. The method for calling an application according to claim 3, wherein the step of caching each of the second execution objects in the second class loader comprises:
initializing the second type loader, and performing reflection call on each second execution object to acquire each second execution object;
and caching each second execution object in the second type loader.
5. The method for calling an application according to claim 1, wherein the execution object comprises a third execution object, and the step of calling the execution object in the second class loader to cause the application to execute the first proxy function comprises:
acquiring execution logic of the first agent function;
packaging the execution logic of the first proxy function into a third execution object by adopting a second packaging mode;
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 program to run the first proxy function.
6. The method for calling an application according to any one of claims 1 to 5, wherein the step of determining from the function to call the first proxy function of the application comprises:
determining an execution mode of the function, wherein the execution mode comprises pre-execution or post-execution;
and determining a first agent function to be operated by the application program in a plug-in chain corresponding to the agent program according to the execution mode, wherein the plug-in chain comprises a plurality of arranged agent functions.
7. The calling method of the application program according to any of claims 1 to 5, wherein 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. An apparatus for calling an application, comprising:
the receiving module is used for receiving a calling request for an application program and acquiring a function for calling the application program;
the determining module is used for determining and calling a first proxy function of the application program according to the function;
the calling module is used for weaving the function into a first class loader corresponding to an agent program so that the agent program can execute the function in the first class loader, and calling an execution object in a second class loader to enable the application program to run the first agent function, wherein the second class loader is not associated with the first class loader, and the execution object is determined according to the first agent function.
9. A medium, comprising: computer-executable instructions for implementing a calling method of an application program as claimed in any one of claims 1 to 7 when executed by a processor.
10. A computing device, comprising: a memory and a processor;
the memory stores computer-executable instructions;
the processor executing the computer-executable instructions stored by the memory causes the processor to perform the method of calling an application program of any of claims 1 to 7.
CN202210429266.2A 2022-04-22 2022-04-22 Application calling method, medium, device and computing equipment Pending CN114661385A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210429266.2A CN114661385A (en) 2022-04-22 2022-04-22 Application calling method, medium, device and computing equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210429266.2A CN114661385A (en) 2022-04-22 2022-04-22 Application calling method, medium, device and computing equipment

Publications (1)

Publication Number Publication Date
CN114661385A true CN114661385A (en) 2022-06-24

Family

ID=82037632

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210429266.2A Pending CN114661385A (en) 2022-04-22 2022-04-22 Application calling method, medium, device and computing equipment

Country Status (1)

Country Link
CN (1) CN114661385A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024045141A1 (en) * 2022-09-01 2024-03-07 Huawei Cloud Computing Technologies Co., Ltd. Confidential and performant lambda/function system in cloud

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024045141A1 (en) * 2022-09-01 2024-03-07 Huawei Cloud Computing Technologies Co., Ltd. Confidential and performant lambda/function system in cloud

Similar Documents

Publication Publication Date Title
CN109032706B (en) Intelligent contract execution method, device, equipment and storage medium
US20170161493A1 (en) Executing Native-Code Applications in a Browser
CN109213611B (en) Cross-process communication method, device, terminal and storage medium
CN111090536B (en) Method, device, medium and electronic equipment for acquiring memory leakage information
US8639492B2 (en) Accelerated execution for emulated environments
EP3964948B1 (en) Hardware acceleration method, compiler, and device
KR20200070085A (en) Method and apparatus for processing information
CN105278996A (en) Log collection method and device and log service system
CN107025135B (en) Application process management method, device and medium in Docker container
CN108334779B (en) Application processing method, device and computing storage medium
US20100186024A1 (en) System and Method of Invoking Multiple Remote Operations
CN111427782B (en) Android dynamic link library operation method, device, equipment and storage medium
CN113076253A (en) Test method and test device
US8726287B2 (en) Method for reducing inter-process communication latency
CN114661385A (en) Application calling method, medium, device and computing equipment
CN110704131B (en) Method and device for calling native application by HTML5 application
CN111506368A (en) Method, device, equipment and storage medium for transferring asynchronous call to synchronous call
US9274922B2 (en) Low-level checking of context-dependent expected results
CN117931576A (en) Front-end data collection method and device and electronic equipment
CN111045746A (en) Code expansion method and framework
WO2023083071A1 (en) View interaction method and apparatus, electronic device, and computer readable medium
CN114979303B (en) Method, device, equipment and readable medium for processing service quality of network data packet
CN111352644A (en) Applet updating method, device, server and storage medium
EP4194067A1 (en) Game engine resource processing method and apparatus, and electronic device and computer-readable storage medium
CN114237684A (en) Component management system, method, device, electronic device and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 310052 Room 301, Building No. 599, Changhe Street Network Business Road, Binjiang District, Hangzhou City, Zhejiang Province

Applicant after: Hangzhou NetEase Shuzhifan Technology Co.,Ltd.

Address before: 310052 Room 301, Building No. 599, Changhe Street Network Business Road, Binjiang District, Hangzhou City, Zhejiang Province

Applicant before: HANGZHOU LANGHE TECHNOLOGY Ltd.