CN114942796A - Plug-in compiling and calling method, device, equipment and storage medium - Google Patents

Plug-in compiling and calling method, device, equipment and storage medium Download PDF

Info

Publication number
CN114942796A
CN114942796A CN202210482972.3A CN202210482972A CN114942796A CN 114942796 A CN114942796 A CN 114942796A CN 202210482972 A CN202210482972 A CN 202210482972A CN 114942796 A CN114942796 A CN 114942796A
Authority
CN
China
Prior art keywords
plug
function
target
host program
identifier
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.)
Granted
Application number
CN202210482972.3A
Other languages
Chinese (zh)
Other versions
CN114942796B (en
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.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet Information 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 Beijing Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN202210482972.3A priority Critical patent/CN114942796B/en
Publication of CN114942796A publication Critical patent/CN114942796A/en
Application granted granted Critical
Publication of CN114942796B publication Critical patent/CN114942796B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • 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

Landscapes

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

Abstract

The disclosure relates to a plug-in compiling and calling method, device, equipment and storage medium, after a host program receives a plug-in calling request, firstly determining a target plug-in object corresponding to a target plug-in identifier and a plug-in subclass corresponding to the target plug-in object; and accessing the function mapping inside the plug-in subclass to determine a target function corresponding to the target index identifier, and finally calling the target function in the target plug-in object. The host program and the plug-in can realize various functions in the plug-in through the calling mechanism, and meanwhile, when the service plug-in has a newly added or deleted function, only the compiled dynamic library file needs to be issued, the host program is automatically hot-loaded, the host program does not need any change, and the decoupling of the framework and the service logic is realized. According to the technical scheme, the plug-in and the host program are decoupled in the development stage, and the plug-in function and the host program function are fused in the deployment stage.

Description

Plug-in compiling and calling method, device, equipment and storage medium
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a storage medium for compiling and calling a plug-in.
Background
A plug-in is a program written from an application program interface that complies with a certain specification, for implementing a specific business function. And compiling the plug-in codes through a compiler to generate a dynamic link library file. And when the host program starts to run, loading the dynamic link library file, and further calling the function defined in the plug-in.
In practical application, different business functions usually need the same basic capability support, and if independent software development is performed on each business function, repeated construction exists in the basic capability part, so that the development and maintenance efficiency is greatly reduced. Therefore, how to improve the development and maintenance efficiency of the plug-in is an urgent technical problem to be solved.
Disclosure of Invention
The disclosure provides a plug-in compiling and calling method, device, equipment and storage medium, which can realize the function fusion of development stage decoupling and deployment stage of a plug-in, thereby improving the development and maintenance efficiency of the plug-in. The technical scheme of the disclosure is as follows:
according to a first aspect of the embodiments of the present disclosure, there is provided a plug-in calling method, including: receiving a plug-in calling request, wherein the plug-in calling request comprises a target plug-in identifier and a target index identifier; according to the target plug-in identification, determining a target plug-in object and a plug-in subclass which is predefined in a host program and corresponds to the target plug-in object, wherein functions in the target plug-in object have index identifications, the plug-in subclass comprises function mapping, and the function mapping comprises mapping from the index identification of each function in the target plug-in object to the corresponding function; determining a target function corresponding to the target index identifier from the function mapping of the plug-in subclass; and calling the target function in the target plug-in object.
With reference to the first aspect, in a possible implementation manner of the first aspect, before the receiving a plug-in invocation request, the method further includes: loading a dynamic library file, wherein the dynamic library file corresponds to the target plug-in object, the dynamic library file comprises export functions and plug-in code blocks, and the export functions comprise each function in the plug-in code blocks and the index identification of each function; and calling the export function to generate the target plug-in object according to the plug-in code block through the export function, acquiring a pointer of the target plug-in object, and assigning values to function mapping in a plug-in sub-class corresponding to the target plug-in object according to each function in the plug-in code block and the index identifier of each function.
With reference to the first aspect, in a possible implementation manner of the first aspect, after the invoking the derived function, the method further includes: and establishing a corresponding relation between the pointer of the target plug-in object and the target plug-in identification.
With reference to the first aspect, in a possible implementation manner of the first aspect, the loading the dynamic library file includes: monitoring file information under a specified path; and loading the newly added dynamic library file when the newly added dynamic library file is monitored.
With reference to the first aspect, in a possible implementation manner of the first aspect, the determining, according to the target plug-in identifier, a target plug-in object and a plug-in subclass predefined in a host program and corresponding to the target plug-in object includes: determining a pointer corresponding to the target plug-in identification according to a corresponding relation between a pointer of a pre-established plug-in object and a plug-in identification, wherein the plug-in object pointed by the pointer corresponding to the target plug-in identification is the target plug-in object; and converting the pointer corresponding to the target plug-in identifier into a pointer corresponding to a plug-in subclass according to the type of the target plug-in object, wherein the plug-in subclass pointed by the pointer corresponding to the plug-in subclass is the plug-in subclass corresponding to the target plug-in object.
With reference to the first aspect, in a possible implementation manner of the first aspect, the host program has a first variable space, where the first variable space includes a variable of each plug-in object of the host program; the method further comprises the following steps: responding to an operation executed by a first plug-in object on a variable of a corresponding plug-in object in the first variable space according to a first plug-in object identifier or a second plug-in object identifier through a variable operation interface preset in the first variable space, wherein the first plug-in object is any plug-in object of the host program, the second plug-in object is any plug-in object except the first plug-in object, and the operation comprises an operation of acquiring the variable, an operation of setting the variable and an operation of deleting the variable.
With reference to the first aspect, in a possible implementation manner of the first aspect, the host program has a second variable space, where the second variable space includes a host function that the host program opens to each plug-in object of the host program; the method further comprises the following steps: and responding to the calling of any plug-in object to the target host function in the second variable space according to the function identification of the target host function through a function calling interface preset in the second variable space.
With reference to the first aspect, in a possible implementation manner of the first aspect, the second variable space further includes a host variable that is opened by the host program for each plug-in object, and the method further includes: responding to the operation of any plug-in object on any variable in the second variable space through a variable operation interface preset in the second variable space, wherein the operation comprises the operation of acquiring the variable and the operation of setting the variable.
With reference to the first aspect, in a possible implementation manner of the first aspect, the host program defines a plug-in base class, where at least one type of function and attribute common to plug-in objects are defined in the plug-in base class, and a plug-in subclass corresponding to each type of plug-in object inherits the plug-in base class.
With reference to the first aspect, in a possible implementation manner of the first aspect, the index identifier of each function in the target plug-in object is a function identifier declared in a plug-in sub-class corresponding to the target plug-in object.
According to a second aspect of embodiments of the present disclosure, there is provided a plug-in compiling method, the method including: acquiring configuration information corresponding to a plug-in code block to be compiled, wherein the configuration information comprises each function defined in the plug-in code block and an index identifier of each function; generating a derived function code block according to the index identifier of each function and each function, wherein the derived function is used for generating a plug-in object according to the plug-in code block, returning a pointer of the plug-in object to a host program, and assigning a function mapping which is defined in advance in a plug-in sub-class corresponding to the plug-in object in the host program according to the index identifier of each function and each function; and compiling the export function code block and the plug-in code block to obtain a dynamic library file, and issuing the dynamic library file to a specified path of the host program.
With reference to the second aspect, in a possible implementation manner of the second aspect, the generating a derived function code block according to each function defined in a plug-in code block to be compiled and an index identifier of each function includes: obtaining a template code block, wherein the template code block is used for realizing the derivation function; and rendering each function and the index identifier of each function into the template code block to obtain the derived function code block.
According to a third aspect of the embodiments of the present disclosure, there is provided a plug-in calling apparatus including: the system comprises a request receiving module, a request sending module and a request receiving module, wherein the request receiving module is used for receiving a plug-in calling request, and the plug-in calling request comprises a target plug-in identifier and a target index identifier; the plug-in object determining module is used for determining a target plug-in object and a plug-in subclass which is predefined in a host program and corresponds to the target plug-in object according to the target plug-in identifier, wherein a function in the target plug-in object has an index identifier, the plug-in subclass comprises function mapping, and the function mapping comprises mapping from the index identifier of each function in the target plug-in object to a corresponding function; a function determining module, configured to determine, from the function map of the plug-in subclass, an object function corresponding to the object index identifier; and the function calling module is used for calling the target function in the target plug-in object.
With reference to the third aspect, in a possible implementation manner of the third aspect, the method further includes: a loading module, configured to load a dynamic library file, where the dynamic library file corresponds to the target plug-in object, the dynamic library file includes a derivation function and a plug-in code block, and the derivation function includes each function in the plug-in code block and the index identifier of each function; and the export module is used for calling the export function so as to generate the target plug-in object according to the plug-in code block through the export function, obtain a pointer of the target plug-in object, and assign values to the function mapping in the plug-in subclass corresponding to the target plug-in object according to each function in the plug-in code block and the index identification of each function.
With reference to the third aspect, in a possible implementation manner of the third aspect, the apparatus further includes: and the corresponding relation establishing module is used for establishing the corresponding relation between the pointer of the target plug-in object and the target plug-in identifier.
With reference to the third aspect, in a possible implementation manner of the third aspect, the loading module is specifically configured to: monitoring file information under a specified path; and loading the newly added dynamic library file when the newly added dynamic library file is monitored.
With reference to the third aspect, in a possible implementation manner of the third aspect, the plug-in object determining module is specifically configured to: determining a pointer corresponding to the target plug-in identification according to a corresponding relation between a pointer of a pre-established plug-in object and a plug-in identification, wherein the plug-in object pointed by the pointer corresponding to the target plug-in identification is the target plug-in object; and converting the pointer corresponding to the target plug-in identifier into a pointer corresponding to a plug-in subclass according to the type of the target plug-in object, wherein the plug-in subclass pointed by the pointer corresponding to the plug-in subclass is the plug-in subclass corresponding to the target plug-in object.
With reference to the third aspect, in a possible implementation manner of the third aspect, the apparatus further includes: the host program has a first variable space that includes variables for each plug-in object of the host program; the device further comprises: the first operation module is configured to respond to an operation, executed by a first plug-in object according to a first plug-in object identifier or a second plug-in object identifier, of a variable corresponding to the plug-in object in the first variable space through a variable operation interface preset in the first variable space, where the first plug-in object is any plug-in object of the host program, the second plug-in object is any plug-in object except the first plug-in object, and the operation includes an operation of acquiring the variable, an operation of setting the variable, and an operation of deleting the variable.
With reference to the third aspect, in a possible implementation manner of the third aspect, the host program has a second variable space, where the second variable space includes a host function that the host program opens to each plug-in object of the host program; the device further comprises: and the second operation module is used for responding to the calling of any plug-in object to the target host function in the second variable space according to the function identifier of the target host function through a preset function calling interface in the second variable space.
With reference to the third aspect, in a possible implementation manner of the third aspect, the second variable space further includes a host variable that is opened by the host program for each plug-in object, and the second operation module is further configured to: responding to the operation of any plug-in object on any variable in the second variable space through a variable operation interface preset in the second variable space, wherein the operation comprises the operation of acquiring the variable and the operation of setting the variable.
With reference to the third aspect, in a possible implementation manner of the third aspect, the host program defines a plug-in base class, where at least one type of function and attribute common to the plug-in objects are defined in the plug-in base class, and a plug-in subclass corresponding to each type of plug-in object inherits the plug-in base class.
With reference to the third aspect, in a possible implementation manner of the third aspect, the index identifier of each function in the target plug-in object is a function identifier declared in a plug-in sub-class corresponding to the target plug-in object.
According to a fourth aspect of the embodiments of the present disclosure, there is provided a plug-in compiling apparatus, the apparatus including: the system comprises a configuration information acquisition module, a compiling module and a compiling module, wherein the configuration information acquisition module is used for acquiring configuration information corresponding to a plug-in code block to be compiled, and the configuration information comprises each function defined in the plug-in code block and an index identifier of each function; a function generating module, configured to generate a derived function code block according to each function and the index identifier of each function, where the derived function is used to generate a plug-in object according to the plug-in code block, return a pointer of the plug-in object to a host program, and assign a function map, which is predefined in the host program, in a plug-in subclass corresponding to the plug-in object according to the index identifier of each function and each function; and the compiling module is used for compiling the export function code block and the plug-in code block to obtain a dynamic library file and publishing the dynamic library file to a specified path of the host program.
With reference to the fourth aspect, in a possible implementation manner of the fourth aspect, the function generating module is specifically configured to: obtaining a template code block, wherein the template code block is used for realizing the derivation function; and rendering each function and the index identification of each function into the template code block to obtain the derived function code block.
According to a fifth aspect of embodiments of the present disclosure, there is provided an electronic apparatus including: a processor and a memory for storing processor-executable instructions; wherein the processor is configured to execute the executable instructions to implement the method of any of the first or second aspects.
According to a sixth aspect of embodiments of the present disclosure, there is provided a computer-readable storage medium having instructions which, when executed by an apparatus, enable the apparatus to perform the method of any one of the first or second aspects; the instructions in the computer readable storage medium, when executed by a processor of an electronic device, enable the processor of the electronic device to perform the method of any of the first or second aspects.
According to a seventh aspect of embodiments of the present disclosure, there is provided a computer program product comprising a computer program or instructions which, when executed by a processor, implements the method of any one of the first or second aspects.
The technical scheme provided by the embodiment of the disclosure at least brings the following beneficial effects:
in the development stage, a plug-in base class and a plug-in subclass corresponding to each type of plug-in are defined in a host program in advance, the base class comprises methods and attributes necessary for each type of plug-in, and the subclass inherits the base class and defines a function prototype of a service function according to a specific service scene. Also included in the plugin subclass is function mapping.
In the compiling stage, firstly, a configuration file for a compiler to read is provided, and the key includes each function defined in the plug-in and its index identification (referring to the function identification declared in the plug-in subclass) in addition to the basic description information of the plug-in the configuration file. The compiler firstly generates export function codes according to the configuration file, generates a dynamic library file containing the export function codes and the plug-in codes, and adds the dynamic library file into the host program.
In the plug-in loading stage, after the host program finishes loading the dynamic library file, the host program generates a plug-in object and returns a pointer of the plug-in object to the host program through the export function, and the host program establishes a corresponding relation between the plug-in pointer and the plug-in identifier. Meanwhile, the export function assigns values to the function mappings inside the plug-in subclasses, so that the function mappings include mappings from the index identifiers of each function of the plug-in to the corresponding functions.
In the plug-in calling stage, a target function defined in the target plug-in object can be requested to be called according to the target plug-in identifier and the target index identifier. After receiving a plug-in calling request, a host program firstly determines a target plug-in object corresponding to a target plug-in identifier and a plug-in subclass corresponding to the target plug-in object; and accessing the function mapping inside the plug-in subclass to determine a target function corresponding to the target index identifier, and finally calling the target function in the target plug-in object.
The host program and the plug-in can realize various service functions in the plug-in through the calling mechanism, and when the service plug-in has a newly added or deleted function, only the compiled dynamic library file needs to be issued, the host program is automatically hot-loaded, the host program does not need any change, and the decoupling of the framework and the service logic is realized. According to the technical scheme, the plug-in and the host program are decoupled in the development stage, and the plug-in function and the host program function are fused in the deployment stage.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the disclosure and are not to be construed as limiting the disclosure.
FIG. 1 is a diagram illustrating a plug-in implementation mechanism in accordance with an illustrative embodiment;
FIG. 2 is a flow diagram illustrating a plug-in compilation method in accordance with an illustrative embodiment;
FIG. 3 is a flowchart illustrating a plug-in invocation method in accordance with an illustrative embodiment;
FIG. 4 is a diagram illustrating a plug-in compilation apparatus according to an exemplary embodiment;
FIG. 5 is a diagram illustrating a plug-in invocation device in accordance with an illustrative embodiment;
fig. 6 is a schematic diagram of a structure of an electronic device shown in accordance with an exemplary embodiment.
Detailed Description
In order to make the technical solutions of the present disclosure better understood by those of ordinary skill in the art, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein are capable of operation in sequences other than those illustrated or otherwise described herein. The implementations described in the exemplary embodiments below do not represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
In addition, in the description of the embodiments of the present disclosure, "/" indicates an inclusive meaning, for example, a/B may indicate a or B, unless otherwise specified. "and/or" herein is merely an association describing an associated object, and means that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, in the description of the embodiments of the present disclosure, "a plurality" means two or more.
Before describing embodiments of the present disclosure, terms related to the embodiments of the present disclosure are explained as follows:
plug-in (plug-in): a software program package developed by using the golang language can realize the actual service function, and a dynamic link library so file is generated by compiling through a compiler. So file, and then can call the function defined in plug-in the host program.
Host program: a fully functional, independently running program. The dynamic link library of the plug-in can be loaded during the operation, so that the function defined in the plug-in can be called.
Insert type (kidd): representing the types of plug-in, the plug-in can be divided into a plurality of types according to functions, and each type is represented by one Kind. Such as a data service plug-in and a job type plug-in. One or more functions are defined inside the data service plug-in, and services are provided to the outside by calling the functions, so that the functions of M and C of the MVCC Web server are realized. One or more operation functions are defined in the operation plug-in, and after the host program loads the plug-in of the type, each operation function is triggered in sequence to be executed.
And (3) thermal loading: and under the condition of not restarting the host program, loading the new function of the plug-in into the host program so that the host program has the new function.
As described in the background art, different business functions generally require the same basic capability support, and if independent software development is performed for each business function, repeated construction exists in the basic capability part, which greatly reduces development and maintenance efficiency. Therefore, how to independently add the basic capabilities required by different service functions to the plug-in platform, and then develop the plug-in based on the specific requirements of each service function, so as to implement the function integration in the development stage and the deployment stage, is a technical problem to be solved urgently.
There is a set of plug-in implementation schemes based on golang native plug-in package (plug-in) in the Tidb database. In the scheme, a structural prototype (struct prototype, similar to an interface class in java) of the plug-in is stated in advance in the host program, and a function prototype necessary for the plug-in of the class is defined in the host program. When developing the service plug-in, the corresponding structure prototype is inherited to realize all functions stated by the interface. After the development of the plug-in is completed, a configuration file (manifest. tom) is required to describe key information of the plug-in, such as a plug-in name, a plug-in type, a plug-in version and the like, and most importantly, a configuration item (export configuration item) is specified in the manifest. tom configuration file to realize one-to-one association between a function declared in a plug-in interface and a specific function in a business plug-in. Finally, the business plug-ins are compiled using a specific compilation tool to generate a so dynamic link library (.so file).
However, the above implementation has the following drawbacks:
first, when it defines plug-in types, the number of functions, function declarations (including function names) included in each type of plug-in is fixed. The developer can only export a fixed number of functions when realizing the specific service plug-in, and if a larger number of functions need to be exported, the prototype definition of the plug-in needs to be modified, and the host program needs to be compiled and issued. Meanwhile, the fixed function name indicates that the host program can only call the function of the plug-in a hard coding mode, and decoupling cannot be really realized.
Second, the plug-in system provides a system variable space for the business plug-ins so that the business plug-ins can register and update variables in the system variable space, but requires that all variable names must be globally unique. In a multi-plug-in scenario, variable conflicts are likely to occur. In order to avoid variable conflicts, the name of a plug-in is generally required to be added to a variable name as a prefix, which affects the readability of the variable to a certain extent; meanwhile, a unified approach is not provided for exposing some internal functions of the host program to the plug-in, so that the plug-in cannot well utilize some existing functions of the host program.
Finally, the application scenario is relatively single, the expansibility is poor, and the requirements of different actual services under different scenarios cannot be met. For example, when developing Web services, it is required that an unlimited number of functions and arbitrary function names can be exposed; for another example, in some operation scenarios, it is necessary that the plug-in triggers the specified function to execute resident execution once it is loaded successfully.
Based on this, the embodiments of the present disclosure provide a flexible and extensible plug-in implementation mechanism, that is, a plug-in compiling method and a plug-in calling method, which may be applied to an electronic device, such as a terminal device or a server. The terminal device may be a mobile phone, a tablet computer, a desktop, a laptop, a handheld computer, a notebook, an ultra-mobile personal computer (UMPC), a netbook, a cellular phone, a Personal Digital Assistant (PDA), an Augmented Reality (AR) device, a Virtual Reality (VR) device, and other devices that can install and use an application program, and the present disclosure does not particularly limit the specific form of the terminal. The system can be used for man-machine interaction with a user through one or more modes of a keyboard, a touch pad, a touch screen, a remote controller, voice interaction or handwriting equipment and the like.
Fig. 1 is a schematic diagram of an implementation process of a plug-in implementation mechanism provided in an embodiment of the present disclosure, as shown in fig. 1:
in the development stage, the host program internally defines plug-in base classes for all plug-ins, and simultaneously predefines plug-in subclasses meeting specific service scenes.
One plug-in base class content that the present disclosure exemplarily illustrates is as follows:
Figure BDA0003628586320000081
it can be seen that the plug-in base class contains the methods and attributes necessary for each type of plug-in, such as type, name, version number, dependent plug-in name and its version, description information and lifecycle function.
One example plug-in subclass illustrated by the present disclosure is as follows:
Figure BDA0003628586320000091
it can be seen that the plug-in subclass inherits the plug-in base class and defines a function prototype meeting the requirements of a specific service scenario, and the interior of the plug-in subclass has a function mapping with an indefinite number through hash mapping (hashMap). When the plug-in is developed based on a specific service scene, the service function is realized only according to the function prototype defined by the corresponding plug-in subclass. It should be appreciated that when there are new business scenario requirements that cannot be met by existing plug-in types, new plug-in subclasses can be defined in this way.
In the compiling stage, a configuration file for a compiler to read is provided, the configuration file includes basic description information of the plug-in, and the key includes an export configuration item, in which an index identifier of each function defined in the plug-in subclass is recorded, and the index identifier is a function identifier declared by the plug-in externally, that is, an index (key) value of a hashMap in the corresponding plug-in subclass. The index identification of a certain function is used as an index value, and the actual function can be found in the hashMap in the plug-in subclass. During compiling, the compiler firstly generates export function codes according to the configuration file, stores the export function codes into a temporary golang code file, compiles the code file together with the service plug-in codes to generate a dynamic library file, and finally releases the dynamic library file to a directory specified by a host program.
In the plug-in loading stage, the host program loads the dynamic library file through a plug-in package. After the dynamic library file is loaded, the export function is searched for in the dynamic library through the function name, and the pointer after the plug-in is instantiated is obtained by executing the export function. And the host program establishes the corresponding relation between the plug-in identification and the plug-in object pointer. Optionally, after obtaining the plug-in object pointer, the host program may perform some special processing according to the specific plug-in type requirement. For example, after the host program has loaded the job type plug-in and obtained the plug-in object pointer, the host program may traverse the function mapping inside the plug-in and trigger the function execution.
Based on the implementation of the development phase, the compilation phase and the plug-in loading phase, hash mapping is stored in the plug-in object, and the hash mapping includes mapping from the index identifier of each function of the plug-in to the actual function.
In the plug-in calling stage, a target function defined in the target plug-in object can be requested to be called according to the target plug-in identifier and the target index identifier. For example, after receiving a plug-in call request, the host program first determines a pointer of a target plug-in object corresponding to a target plug-in identifier, converts the pointer of the target plug-in object into a pointer corresponding to a plug-in subclass by judging the type of the target plug-in object, accesses hash mapping inside the plug-in subclass through the pointer of the plug-in subclass to determine a target function corresponding to the target index identifier, and finally calls the target function in the target plug-in object.
As can be seen from the implementation process of the plug-in implementation mechanism shown in fig. 1, the technical solution of the present disclosure implements decoupling of the plug-in and the host program in the development phase, and fusion of the plug-in function and the host program in the deployment phase.
Fig. 2 is a flowchart of a plug-in compiling method provided in an embodiment of the present disclosure, and as shown in fig. 2, the method may include the following steps:
s201, obtaining configuration information corresponding to the plug-in code block to be compiled, wherein the configuration information comprises each function defined in the plug-in code block and an index identifier of each function.
In a possible implementation, the configuration information may be a manifest.
One configuration file content that the present disclosure exemplarily illustrates is as follows:
kind="Service"
name="serviceHandLe"
version=1
description="just a test"
validate="Validate"
onInit="OnInit"
onShutdown="OnShutdown"
requirements=[
]
export=[
{name="aaa",impl="DoService"},
{name="bbb",impl="GetAgentList"},
{name="ccc",impl="ExecTask"}
]
it can be seen that some basic information describing the plugin in the configuration file, such as a plugin type, a plugin name, a plugin version, and description information of the plugin, further includes an export configuration item, which is specifically a json array, where each json { name ═ and "", each plugin ═ states a function to be exported, name is an index identifier of the function, and plugin is the function.
S202, generating a derived function code block according to the configuration information.
The export function is used for creating a plug-in object of a specific plug-in type and assigning values to variables in the plug-in object, including assigning values to member variables and life cycle functions declared by a plug-in base class. In particular, the function mappings in the plug-in subclass are assigned by each function and the index identification of each function included in the configuration information.
The function mapping may be a mapping from index identifiers of functions to actual functions.
In a possible implementation manner, S202 specifically includes: obtaining a template code block, wherein the template code block is used for realizing the derivation function; and rendering the basic information of the plug-in, each function and the index identification of each function into a template code block to obtain a derived function code block. By rendering the functions and their index identifications into the template code blocks, the export function can assign each function and its index identification to a function map inside the plug-in subclass.
The template code text provided by the embodiment of the disclosure is as follows:
Figure BDA0003628586320000111
Figure BDA0003628586320000121
in a more specific implementation, the template code block is defined inside the encoder. The compiler firstly reads the configuration information, then renders the read content into template codes, and finally writes the rendered codes into a temporary go file. The temporary go file and the plug-in code block jointly generate a dynamic link library file.
In a possible implementation manner, the export function is further configured to obtain a pointer corresponding to the plug-in object, and return the pointer to the host program. The host program can obtain the pointer of the plug-in object through the pointer returned by the export function, and then pre-establish the corresponding relation between the pointer of the plug-in object and the plug-in object identifier, so that under the condition that the plug-in object identifier is known, the pointer of the plug-in object can be found according to the corresponding relation, and then the data in the plug-in object can be accessed according to the pointer of the plug-in object, and the call of the function in the plug-in object is realized.
It should be understood that the export function is used to create and initialize the plug-in object and return the pointer of the plug-in object, when there is a special service scene that requires a completely new plug-in type, and the new type of plug-in can prepare a new export function template code for the new type of plug-in when there is a special requirement for object creation and initialization. Therefore, the whole plug-in system has expansibility.
S203, compiling the export function code block and the service plug-in code block to generate a dynamic library file, and issuing the dynamic library file to a specified path of the host program.
As can be seen from the above S201-S203, in the compiling stage, a configuration file is first provided for the compiler to read, and the key includes each function defined in the plug-in and its index identifier in addition to the basic description information of the plug-in. The compiler firstly generates export function codes according to the configuration file, compiles and generates dynamic library files containing the export function codes and specific service plug-in codes, and issues the dynamic library files to the host program. Based on this, in the plug-in loading stage, after the host program finishes loading the dynamic library file, a plug-in object pointer is generated through the export function, and the corresponding relation between the plug-in object identifier and the plug-in object pointer is maintained inside. Based on this, in the plug-in loading stage, after the host program finishes loading the dynamic library file, the host program generates the plug-in object and returns the pointer of the plug-in object to the host program through the export function, and the host program establishes the corresponding relationship between the plug-in pointer and the plug-in identifier. Meanwhile, the export function assigns values to the function mapping inside the corresponding plug-in subclass, so that the function mapping comprises the mapping from the index identifier of each function of the plug-in to the actual function. In this way, it can be ensured that in the calling phase, the caller can request the host program to call the corresponding function by using the target plug-in identifier and the target index identifier, and at this time, the host program first determines the target plug-in object corresponding to the target plug-in identifier and the plug-in subclass corresponding to the target plug-in object; and accessing the function mapping inside the plug-in subclass to determine a target function corresponding to the target index identifier, and finally calling the target function in the target plug-in object.
The host program and the plug-in can realize various service functions in the plug-in through the calling mechanism, and when the service plug-in has a newly added or deleted function, only the compiled dynamic library file needs to be issued, the host program is automatically hot-loaded, the host program does not need any change, and the decoupling of the framework and the service logic is realized. According to the technical scheme, the plug-in and the host program are decoupled in the development stage, and the plug-in function and the host program function are fused in the deployment stage.
Fig. 3 is a flowchart of a plug-in calling method provided in an embodiment of the present disclosure, and as shown in fig. 3, the method may include the following steps:
s301, receiving a plug-in calling request, wherein the plug-in calling request comprises a target plug-in identifier and a target index identifier.
In S301, the target plug-in identifier is a plug-in identifier of the target plug-in object, i.e. a plug-in name. The target plug-in object is the plug-in object requested to be called by the plug-in calling request. The target index mark is an index mark of a target function, and the target function is a function defined in the target plug-in object.
In the embodiment of the disclosure, base classes of all plug-ins are defined inside a host program, plug-in subclasses corresponding to various plug-in types are predefined, the plug-in base classes include attributes and life cycle functions commonly possessed by all plug-in objects, the plug-in subclasses of specific types inherit the plug-in base classes, and specific function prototypes and function mappings are defined based on business scene requirements supported by the plug-in subclasses. For example, the plug-in base class and plug-in subclass defined in the host program can be as shown in the above embodiments. The plug-in base class and the plug-in subclasses of the plug-ins of various types are predefined in the host program, when the plug-ins are developed based on a specific service scene, the service functions are developed according to the function prototypes declared by the corresponding plug-in subclasses, plug-in codes are compiled into the dynamic libraries of the corresponding plug-in subclasses through the configuration files, and the host program can be called by the instantiation objects of the plug-in subclasses after being loaded. The decoupling and deployment stage function fusion in the development stage is realized.
S302, determining a target plug-in object corresponding to the target plug-in identifier and a plug-in subclass which is predefined in the host program and corresponds to the target plug-in object, wherein the plug-in subclass comprises function mapping, and the function mapping comprises mapping from the index identifier of each function in the target plug-in object to the corresponding function.
In the embodiment of the present disclosure, before S301, the method further includes: loading a dynamic library file, wherein the dynamic library file corresponds to a target plug-in object and comprises a lead-out function and a plug-in code block; and calling an export function, wherein the export function is used for creating and initializing the plug-in object and returning a pointer of the plug-in object. Specifically, the export function first creates and initializes the plug-in object, and assigns the attribute of the plug-in object according to the configuration file of the plug-in, where the function defined in the configuration file and the index identifier thereof are also assigned to the function map of the plug-in object one by one. In this way, after the host program determines the target plug-in object corresponding to the target plug-in identifier and the corresponding plug-in subclass, the target function corresponding to the target index identifier can be determined by accessing the function mapping inside the plug-in subclass, and then the target function is called.
In the embodiment of the disclosure, a host program monitors file information under a specified path; and when the newly added dynamic library file is monitored, loading the dynamic library file. And storing the dynamic library files corresponding to the plug-ins under the specified path of the host program in a unified way, monitoring the file information under the specified path by the host program, and loading the newly added dynamic library files when the newly added dynamic library files are monitored so as to realize the hot loading of the dynamic library files.
In the above implementation, the host program may further obtain the pointer of the target plug-in object through the export function. The host program can establish the corresponding relation between the pointer of the target plug-in object and the target plug-in identifier according to the pointer of the target plug-in object. By pre-establishing the corresponding relation between the pointer of the plug-in object and the plug-in object identifier, under the condition of knowing the plug-in object identifier, the pointer of the plug-in object can be found according to the corresponding relation, and then the data in the plug-in object can be accessed according to the pointer of the plug-in object, so that the calling of the internal function is realized.
Specifically, the pointer corresponding to the target plug-in identifier may be determined according to a correspondence between a pointer of a pre-established plug-in object and a plug-in identifier, where the plug-in object pointed by the pointer corresponding to the target plug-in identifier is the target plug-in object. And converting the pointer corresponding to the target plug-in identifier into a pointer corresponding to a plug-in subclass according to the type of the target plug-in object, wherein the plug-in subclass pointed by the pointer corresponding to the plug-in subclass is the plug-in subclass corresponding to the target plug-in object. The corresponding relation between the pointer of the plug-in object and the plug-in object identification is established in advance, so that the pointer of the plug-in object can be found according to the corresponding relation under the condition that the plug-in object identification is known, and then the data in the plug-in object can be accessed according to the pointer of the plug-in object, and the calling of the function in the plug-in object is realized. And converting the pointer of the corresponding plug-in subclass according to the pointer of the plug-in object, and further accessing the function mapping of the plug-in subclass according to the pointer of the plug-in subclass so as to determine the corresponding function when the index identifier of the function is given.
S303, determining an objective function corresponding to the objective index identifier from the function mapping in the plug-in subclass.
S304, calling the target function in the target plug-in object.
Based on the implementation of the development phase, the compilation phase and the plug-in loading phase, function mapping is stored in the plug-in subclass corresponding to the plug-in object, and the function mapping includes mapping from the index identifier of each function of the plug-in to the corresponding function. And requesting to call a target function defined in the target plug-in object according to the target plug-in identifier and the target index identifier. After receiving a plug-in calling request, a host program firstly determines a target plug-in object corresponding to a target plug-in identifier; and then converting the pointer of the plug-in object into a pointer corresponding to the plug-in subclass according to the type of the plug-in object, accessing function mapping inside the plug-in subclass to determine a target function corresponding to the target index identifier, and finally calling the target function. Since the above function mappings are maintained within the plug-in subclass, any number and name of functions can be defined within the plug-in during the development phase, without being limited by the number of functions defined within the host program. When a specific function is called, the target function can be found in the function mapping according to the index identification of the target function. According to the technical scheme, the plug-in and the host program are decoupled in the development stage, and the plug-in function and the host program function are fused in the deployment stage.
In some embodiments, a first variable space is set inside the host program, and is used for storing variables related to all plug-in objects, and the variables of each plug-in object are bound to plug-in identifiers, so that the limitation that all variable names must be globally unique in the related art is eliminated, and the problem that the variables cannot be registered due to the fact that the variable names are the same among different plug-ins is avoided. At the same time, all plug-in objects are provided with variable operation interfaces. Based on this, the plug-in calling method provided by the embodiment of the present disclosure further includes: responding to an operation executed by the first plug-in object on a variable associated with the specified plug-in object identifier in the first variable space according to the specified plug-in object identifier through a variable operation interface preset in the first variable space, wherein the first variable space comprises the variable of each plug-in object, the variable of each plug-in object is associated with the plug-in object identifier, and the operation comprises an operation of acquiring the variable, an operation of setting the variable and an operation of deleting the variable. For example, through a variable operation interface preset in the first variable space, in response to an operation performed by the first plug-in object on a variable of the first plug-in object in the first variable space according to the first plug-in object identifier, the first plug-in object may be any plug-in object of the host program. For another example, in response to an operation performed by the first plug-in object on a variable of the second plug-in object in the first variable space according to the second plug-in object identifier through a variable operation interface preset in the first variable space, the second plug-in object may be any plug-in object of the host program except the first plug-in object.
By setting the first variable space in the host program, on one hand, the plug-in object can operate, such as setting, obtaining or deleting, the self variable in the first variable space based on the variable operation interface and the self plug-in identifier; on the other hand, the plug-in object can access the variables of other plug-ins in the first variable space based on the variable operation interface and the identifications of other plug-ins, so that data communication between the plug-ins is realized.
In some embodiments, a second variable space is set inside the host program, and is used to store functions (i.e., host functions) that are opened by the host program to all plug-in objects, and provide a function call interface for the plug-in objects, so that the plug-in objects can call the target host functions in the second variable space based on the function call interface and the function identifiers of the target host functions, so that the plug-in can reuse the functions of the host program. That is to say, the plug-in calling method provided by the embodiment of the present disclosure further includes: and responding to the calling of any plug-in object to the target host function in the second variable space according to the function identifier of the target host function through a function calling interface preset in the second variable space, wherein the second variable space comprises a host function which is opened by the host program to the plug-in object.
With reference to the foregoing embodiments, in other embodiments, the second variable space further includes a host variable that is opened by the host program to the target plug-in object. The plug-in calling method provided by the embodiment of the disclosure further comprises the following steps: and receiving the operation of the target plug-in object on any variable in the second variable space through a variable operation interface preset in the second variable space, wherein the operation comprises the operation of acquiring the variable and the operation of setting the variable. By storing the variables (namely the host variables) opened by the host program to the plug-in object in the second variable space and providing the variable operation interface for the plug-in object, the plug-in object can acquire, set and operate any host variable in the second variable space based on the variable operation interface, and data communication between the plug-in and the host program is realized.
The plug-in object that can operate the variable in the first variable space and the variable and function in the second variable control may be any plug-in object.
According to the technical scheme, the plug-in system with the hot loading capability, the service and framework high decoupling and the web server function can be constructed, and meanwhile, the realization idea of the plug-in system is provided for other special service scenes. The function derived by the plug-in is stored and indexed by using function mapping, and the hard limit of the tidb plug-in on the number and signature of the function is broken; providing data and function communication channels among different plug-ins and between the plug-ins and the host program, and achieving the purpose of function multiplexing; through the design of a plug-in calling mode, the plug-in system has the basic function of a web server; meanwhile, plug-in types (such as operation type plug-ins and the like) can be expanded as required, more service scenes are covered, and universality is improved. Through the plug-in system implementation mechanism, decoupling of business logic and a basic framework can be realized for a project developed by golang.
An embodiment of the present disclosure further provides a plug-in compiling apparatus as shown in fig. 4, where the apparatus includes:
a configuration information obtaining module 401, configured to obtain configuration information corresponding to a plug-in code block to be compiled, where the configuration information includes each function defined in the plug-in code block and an index identifier of each function. For example, the configuration information obtaining module 401 may be configured to execute S201 in fig. 2.
A function generating module 402, configured to generate a derived function code block according to each function and the index identifier of each function, where the derived function is configured to generate a plug-in object according to the plug-in code block, return a pointer of the plug-in object to a host program, and assign a function map, which is predefined in the host program and in a plug-in subclass corresponding to the plug-in object, according to the index identifier of each function and each function. For example, the function generation module 402 may be configured to execute S202 in fig. 2.
A compiling module 403, configured to compile the export function code block and the plug-in code block to obtain a dynamic library file, and issue the dynamic library file to a specified path of the host extent. For example, the compiling module 403 may be used to execute S203 in fig. 2.
In a possible implementation manner, the function generating module 402 is specifically configured to: obtaining a template code block, wherein the template code block is used for realizing the derivation function; and rendering each function and the index identification of each function into the template code block to obtain the derived function code block.
An embodiment of the present disclosure further provides a plug-in calling device as shown in fig. 5, where the device includes:
a request receiving module 501, configured to receive a plug-in call request, where the plug-in call request includes a target plug-in identifier and a target index identifier. For example, the request receiving module 501 may be configured to execute S301 in fig. 3.
A plug-in object determining module 502, configured to determine, according to the target plug-in identifier, a target plug-in object and a plug-in subclass predefined in the host program and corresponding to the target plug-in object, where a function in the target plug-in object has an index identifier, and the plug-in subclass includes a function map, where the function map includes a mapping from the index identifier of each function in the target plug-in object to a corresponding function. For example, the plug-in object determination module 502 may be used to perform S302 in fig. 3.
A function determining module 503, configured to determine, from the function map of the plug-in subclass, an objective function corresponding to the objective index identifier. For example, the function determination module 503 may be configured to perform S303 in fig. 3.
A function calling module 504, configured to call the target function in the target plug-in object. For example, function call module 504 may be used to perform S304 in fig. 3.
In a possible implementation manner, the method further includes: a loading module, configured to load a dynamic library file, where the dynamic library file corresponds to the target plug-in object, the dynamic library file includes a derivation function and a plug-in code block, and the derivation function includes each function in the plug-in code block and the index identifier of each function; and the export module is used for calling the export function so as to generate the target plug-in object according to the plug-in code block through the export function, obtain a pointer of the target plug-in object, and assign values to the function mapping in the plug-in subclass corresponding to the target plug-in object according to each function in the plug-in code block and the index identification of each function.
In a possible implementation manner, the apparatus further includes: and the corresponding relation establishing module is used for establishing the corresponding relation between the pointer of the target plug-in object and the target plug-in identifier.
In a possible implementation manner, the plug-in object determining module is specifically configured to: determining a pointer corresponding to the target plug-in identification according to a corresponding relation between a pointer of a pre-established plug-in object and a plug-in identification, wherein the plug-in object pointed by the pointer corresponding to the target plug-in identification is the target plug-in object; and converting the pointer corresponding to the target plug-in identifier into a pointer corresponding to a plug-in subclass according to the type of the target plug-in object, wherein the plug-in subclass pointed by the pointer corresponding to the plug-in subclass is the plug-in subclass corresponding to the target plug-in object.
In a possible implementation manner, the host program has a first variable space, and the first variable space includes a variable of each plug-in object of the host program; the device further comprises: the first operation module is configured to respond to an operation, executed by a first plug-in object according to a first plug-in object identifier or a second plug-in object identifier, of a variable corresponding to the plug-in object in the first variable space through a variable operation interface preset in the first variable space, where the first plug-in object is any plug-in object of the host program, the second plug-in object is any plug-in object except the first plug-in object, and the operation includes an operation of acquiring the variable, an operation of setting the variable, and an operation of deleting the variable.
In a possible implementation manner, the host program has a second variable space, where the second variable space includes a host function that is opened by the host program to a plug-in object of the host program; the device further comprises: and the second operation module is used for responding to the calling of any plug-in object to the target host function in the second variable space according to the function identifier of the target host function through a preset function calling interface in the second variable space.
In a possible implementation manner, the second variable space further includes a host variable that is open to a plug-in object of the host program by the host program in the second variable space, and the second operation module is further configured to: responding to the operation of any plug-in object on any variable in the second variable space through a variable operation interface preset in the second variable space, wherein the operation comprises the operation of acquiring the variable and the operation of setting the variable.
In a possible implementation manner, the loading module is specifically configured to: monitoring file information under a specified path; and when the newly added dynamic library file is monitored, loading the newly added dynamic library file.
In a possible implementation manner, the host program is defined with a plug-in base class, the plug-in base class is defined with at least one type of function and attribute common to the plug-in objects, and a plug-in subclass corresponding to each type of plug-in object inherits the plug-in base class.
In a possible implementation manner, the index identifier of each function in the target plug-in object is a function identifier declared in a plug-in sub-class corresponding to the target plug-in object.
The technical scheme provided by the embodiment of the disclosure at least brings the following beneficial effects:
in the development stage, a plug-in base class and a plug-in subclass corresponding to each type of plug-in are defined in a host program in advance, the base class comprises methods and attributes necessary for each type of plug-in, and the subclass inherits the base class and defines a function prototype of a service function according to a specific service scene. Also included in the plug-in subclass is a function map.
In the compiling stage, a configuration file for a compiler to read is provided, and the key includes each function defined in the plug-in and its index identifier (referring to the function identifier declared in the plug-in subclass) in addition to the basic description information of the plug-in the configuration file. The compiler firstly generates export function codes according to the configuration file, generates a dynamic library file containing the export function codes and the plug-in codes, and adds the dynamic library file into the host program.
In the plug-in loading stage, after the host program finishes loading the dynamic library file, the host program generates a plug-in object and returns a pointer of the plug-in object to the host program through the export function, and the host program establishes a corresponding relation between the plug-in pointer and the plug-in identifier. Meanwhile, the export function assigns values to the function mappings inside the plug-in subclasses, so that the function mappings include mappings from the index identifiers of each function of the plug-in to the corresponding functions.
In the plug-in calling stage, a target function defined in the target plug-in object can be requested to be called according to the target plug-in identifier and the target index identifier. After receiving a plug-in calling request, a host program firstly determines a target plug-in object corresponding to a target plug-in identifier and a plug-in subclass corresponding to the target plug-in object; and accessing the function mapping inside the plug-in subclass to determine a target function corresponding to the target index identifier, and finally calling the target function in the target plug-in object.
The host program and the plug-in can realize various service functions in the plug-in through the calling mechanism, and when the service plug-in has a newly added or deleted function, only the compiled dynamic library file needs to be issued, the host program is automatically hot-loaded, the host program does not need any change, and the decoupling of the framework and the service logic is realized. According to the technical scheme, the plug-in and the host program are decoupled in the development stage, and the plug-in function and the host program function are fused in the deployment stage.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
The embodiment of the disclosure also provides an electronic device, and fig. 6 is a schematic structural diagram of the electronic device provided by the disclosure. As shown in fig. 6, the electronic device 10 may include at least one processor 101 and a memory 103 for storing processor-executable instructions. Wherein the processor 101 is configured to execute instructions in the memory 103 to implement the plug-in invocation method in the above-described embodiments.
In addition, the electronic device 10 may also include a communication bus 102 and at least one communication interface 104.
The processor 101 may be a processor (CPU), a micro-processing unit, an ASIC, or one or more integrated circuits for controlling the execution of programs in accordance with the disclosed aspects.
The communication bus 102 may include a path that conveys information between the aforementioned components.
The communication interface 104 may be any device, such as a transceiver, for communicating with other devices or communication networks, such as an ethernet, a Radio Access Network (RAN), a Wireless Local Area Network (WLAN), etc.
The memory 103 may be, but is not limited to, a read-only memory (ROM) or other type of static storage device that may store static information and instructions, a Random Access Memory (RAM) or other type of dynamic storage device that may store information and instructions, an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disk storage, optical disk storage (including compact disc, laser disc, optical disc, digital versatile disc, blu-ray disc, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer. The memory may be self-contained and connected to the processing unit by a bus. The memory may also be integrated with the processing unit.
The memory 103 is used for storing instructions for executing the disclosed solution, and is controlled by the processor 101. The processor 101 is configured to execute instructions stored in the memory 103 to implement the functions of the disclosed method.
In particular implementations, processor 101 may include one or more CPUs such as CPU0 and CPU1 of fig. 1 for one embodiment.
In particular implementations, electronic device 10 may include multiple processors, such as processor 101 and processor 107 in FIG. 6, for example, as an embodiment. Each of these processors may be a single-core (single-CPU) processor or a multi-core (multi-CPU) processor. A processor herein may refer to one or more devices, circuits, and/or processing cores for processing data (e.g., computer program instructions).
In particular implementations, electronic device 10 may also include an output device 105 and an input device 106, as one embodiment. The output device 105 is in communication with the processor 101 and may display information in a variety of ways. For example, the output device 105 may be a Liquid Crystal Display (LCD), a Light Emitting Diode (LED) display device, a Cathode Ray Tube (CRT) display device, a projector (projector), or the like. The input device 106 is in communication with the processor 101 and can accept user input in a variety of ways. For example, the input device 106 may be a mouse, a keyboard, a touch screen device, or a sensing device, among others.
In addition, the present disclosure also provides a computer-readable storage medium, wherein when the instructions in the computer-readable storage medium are executed by the processor of the server, the server is enabled to execute the method provided by the above embodiment.
In addition, the present disclosure also provides a computer program product comprising computer instructions which, when run on a server, cause the server to perform the method as provided in the above embodiments.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (10)

1. A plug-in invocation method, comprising:
receiving a plug-in calling request, wherein the plug-in calling request comprises a target plug-in identifier and a target index identifier;
according to the target plug-in identification, determining a target plug-in object and a plug-in subclass which is predefined in a host program and corresponds to the target plug-in object, wherein functions in the target plug-in object have index identifications, the plug-in subclass comprises function mapping, and the function mapping comprises mapping from the index identification of each function in the target plug-in object to the corresponding function;
determining a target function corresponding to the target index identifier from the function mapping of the plug-in subclass;
and calling the target function in the target plug-in object.
2. The plug-in invocation method according to claim 1, wherein before said receiving a plug-in invocation request, further comprising:
loading a dynamic library file, wherein the dynamic library file corresponds to the target plug-in object, the dynamic library file comprises export functions and plug-in code blocks, and the export functions comprise each function in the plug-in code blocks and the index identification of each function;
and calling the export function to generate the target plug-in object according to the plug-in code block through the export function, acquiring a pointer of the target plug-in object, and assigning values to function mapping in a plug-in sub-class corresponding to the target plug-in object according to each function in the plug-in code block and the index identifier of each function.
3. The plug-in invocation method according to claim 2, wherein after said invoking said derived function, said method further comprises:
and establishing a corresponding relation between the pointer of the target plug-in object and the target plug-in identification.
4. The plug-in calling method according to claim 2, wherein the loading of the dynamic library file comprises:
monitoring file information under a specified path;
and loading the newly added dynamic library file when the newly added dynamic library file is monitored.
5. A plug-in compilation method, the method comprising:
acquiring configuration information corresponding to a plug-in code block to be compiled, wherein the configuration information comprises each function defined in the plug-in code block and an index identifier of each function;
generating a derived function code block according to the index identifier of each function and each function, wherein the derived function is used for generating a plug-in object according to the plug-in code block and returning a pointer of the plug-in object to a host program, and assigning a function mapping which is defined in advance in the host program and is in a plug-in sub-class corresponding to the plug-in object according to the index identifier of each function and each function;
and compiling the export function code block and the plug-in code block to obtain a dynamic library file, and issuing the dynamic library file to a specified path of the host program.
6. A plug-in calling apparatus, comprising:
the system comprises a request receiving module, a request sending module and a request receiving module, wherein the request receiving module is used for receiving a plug-in calling request, and the plug-in calling request comprises a target plug-in identifier and a target index identifier;
the plug-in object determining module is used for determining a target plug-in object and a plug-in subclass which is predefined in a host program and corresponds to the target plug-in object according to the target plug-in identifier, wherein a function in the target plug-in object has an index identifier, the plug-in subclass comprises function mapping, and the function mapping comprises mapping from the index identifier of each function in the target plug-in object to a corresponding function;
a function determining module, configured to determine, from the function map of the plug-in subclass, an objective function corresponding to the objective index identifier;
and the function calling module is used for calling the target function in the target plug-in object.
7. A plug-in compilation apparatus, the apparatus comprising:
the system comprises a configuration information acquisition module, a compiling module and a compiling module, wherein the configuration information acquisition module is used for acquiring configuration information corresponding to a plug-in code block to be compiled, and the configuration information comprises each function defined in the plug-in code block and an index identifier of each function;
a function generating module, configured to generate a derived function code block according to the index identifier of each function, where the derived function is used to generate a plug-in object according to the plug-in code block, return a pointer of the plug-in object to a host program, and assign a function map, which is predefined in the host program and in a plug-in subclass corresponding to the plug-in object, according to the index identifier of each function;
and the compiling module is used for compiling the export function code block and the plug-in code block to obtain a dynamic library file, and issuing the dynamic library file to a specified path of the host program.
8. An electronic device, comprising:
a processor and a memory for storing processor-executable instructions; wherein the processor is configured to execute the executable instructions to implement the method of any one of claims 1 to 4 or to implement the method of claim 5.
9. A computer-readable storage medium, wherein instructions in the computer-readable storage medium, when executed by an apparatus, enable the apparatus to perform the method of any of claims 1 to 4 or the method of claim 5; the instructions in the computer readable storage medium, when executed by a processor of an electronic device, enable the processor of the electronic device to perform the method of any of claims 1 to 4 or the method of claim 5.
10. A computer program product comprising a computer program or instructions, characterized in that the computer program or instructions, when executed by a processor, implement the method of any one of claims 1 to 4 or the method of claim 5.
CN202210482972.3A 2022-05-05 2022-05-05 Plug-in compiling and calling method, device, equipment and storage medium Active CN114942796B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210482972.3A CN114942796B (en) 2022-05-05 2022-05-05 Plug-in compiling and calling method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210482972.3A CN114942796B (en) 2022-05-05 2022-05-05 Plug-in compiling and calling method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN114942796A true CN114942796A (en) 2022-08-26
CN114942796B CN114942796B (en) 2024-07-02

Family

ID=82907758

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210482972.3A Active CN114942796B (en) 2022-05-05 2022-05-05 Plug-in compiling and calling method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114942796B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115185712A (en) * 2022-09-08 2022-10-14 中化现代农业有限公司 Data interaction method and device, electronic equipment and storage medium
CN115373763A (en) * 2022-10-24 2022-11-22 北京达佳互联信息技术有限公司 Plug-in loading method and device, electronic equipment and storage medium
CN115794040A (en) * 2022-11-14 2023-03-14 深圳十沣科技有限公司 Method, device, equipment and storage medium for constructing CAE software architecture
CN116991380A (en) * 2023-09-21 2023-11-03 腾讯科技(深圳)有限公司 Application program construction method and device, electronic equipment and storage medium
CN118245139A (en) * 2024-05-30 2024-06-25 北京基调网络股份有限公司 Probe processing method and device, storage medium and electronic equipment

Citations (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060036578A1 (en) * 2004-08-10 2006-02-16 Palo Alto Research Center Incorporated Extension of XQuery in a high performance XML/XQuery database
US20070283344A1 (en) * 2006-06-05 2007-12-06 Ajay A Apte Programming model generic application deployment
CN102520967A (en) * 2011-12-28 2012-06-27 深圳市融创天下科技股份有限公司 Method, system and mobile terminal for creating and using mobile platform plug-in component
CN105912362A (en) * 2016-04-11 2016-08-31 北京金山安全软件有限公司 Method and device for loading plug-in and electronic equipment
CN106155749A (en) * 2016-07-28 2016-11-23 浪潮(北京)电子信息产业有限公司 A kind of monitoring plug-in extension method and device
US20180322136A1 (en) * 2017-05-05 2018-11-08 Esoptra NV Plug-in function platform and methods
CN109460215A (en) * 2018-11-13 2019-03-12 北京奇虎科技有限公司 Application control method and device
US20190129734A1 (en) * 2017-10-31 2019-05-02 Ca, Inc. Data collection workflow extension
CN110162345A (en) * 2019-05-05 2019-08-23 网宿科技股份有限公司 A kind of application program access method, device and storage medium
CN110531981A (en) * 2019-08-27 2019-12-03 珠海格力智能装备有限公司 Visual software system and application method thereof
CN110704035A (en) * 2019-10-17 2020-01-17 北京首贝科技发展有限公司 Plug-in type software architecture system and implementation method thereof
CN110928531A (en) * 2019-11-19 2020-03-27 中国电子科技集团公司第四十一研究所 Electromagnetic spectrum monitoring system software platform construction method
CN112559083A (en) * 2020-12-24 2021-03-26 成都新希望金融信息有限公司 Function plug-in execution method and device, electronic equipment and storage medium
CN114281321A (en) * 2021-12-10 2022-04-05 珠海豹趣科技有限公司 Software development fast editing method and device, electronic equipment and medium

Patent Citations (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060036578A1 (en) * 2004-08-10 2006-02-16 Palo Alto Research Center Incorporated Extension of XQuery in a high performance XML/XQuery database
US20070283344A1 (en) * 2006-06-05 2007-12-06 Ajay A Apte Programming model generic application deployment
CN102520967A (en) * 2011-12-28 2012-06-27 深圳市融创天下科技股份有限公司 Method, system and mobile terminal for creating and using mobile platform plug-in component
CN105912362A (en) * 2016-04-11 2016-08-31 北京金山安全软件有限公司 Method and device for loading plug-in and electronic equipment
CN106155749A (en) * 2016-07-28 2016-11-23 浪潮(北京)电子信息产业有限公司 A kind of monitoring plug-in extension method and device
US20180322136A1 (en) * 2017-05-05 2018-11-08 Esoptra NV Plug-in function platform and methods
US20190129734A1 (en) * 2017-10-31 2019-05-02 Ca, Inc. Data collection workflow extension
CN109460215A (en) * 2018-11-13 2019-03-12 北京奇虎科技有限公司 Application control method and device
CN110162345A (en) * 2019-05-05 2019-08-23 网宿科技股份有限公司 A kind of application program access method, device and storage medium
CN110531981A (en) * 2019-08-27 2019-12-03 珠海格力智能装备有限公司 Visual software system and application method thereof
CN110704035A (en) * 2019-10-17 2020-01-17 北京首贝科技发展有限公司 Plug-in type software architecture system and implementation method thereof
CN110928531A (en) * 2019-11-19 2020-03-27 中国电子科技集团公司第四十一研究所 Electromagnetic spectrum monitoring system software platform construction method
CN112559083A (en) * 2020-12-24 2021-03-26 成都新希望金融信息有限公司 Function plug-in execution method and device, electronic equipment and storage medium
CN114281321A (en) * 2021-12-10 2022-04-05 珠海豹趣科技有限公司 Software development fast editing method and device, electronic equipment and medium

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115185712A (en) * 2022-09-08 2022-10-14 中化现代农业有限公司 Data interaction method and device, electronic equipment and storage medium
CN115185712B (en) * 2022-09-08 2022-12-27 中化现代农业有限公司 Data interaction method and device, electronic equipment and storage medium
CN115373763A (en) * 2022-10-24 2022-11-22 北京达佳互联信息技术有限公司 Plug-in loading method and device, electronic equipment and storage medium
CN115373763B (en) * 2022-10-24 2023-02-17 北京达佳互联信息技术有限公司 Plug-in loading method and device, electronic equipment and storage medium
CN115794040A (en) * 2022-11-14 2023-03-14 深圳十沣科技有限公司 Method, device, equipment and storage medium for constructing CAE software architecture
CN115794040B (en) * 2022-11-14 2024-02-06 深圳十沣科技有限公司 Method, device, equipment and storage medium for constructing CAE software architecture
CN116991380A (en) * 2023-09-21 2023-11-03 腾讯科技(深圳)有限公司 Application program construction method and device, electronic equipment and storage medium
CN116991380B (en) * 2023-09-21 2024-01-09 腾讯科技(深圳)有限公司 Application program construction method and device, electronic equipment and storage medium
CN118245139A (en) * 2024-05-30 2024-06-25 北京基调网络股份有限公司 Probe processing method and device, storage medium and electronic equipment
CN118245139B (en) * 2024-05-30 2024-08-09 北京基调网络股份有限公司 Probe processing method and device, storage medium and electronic equipment

Also Published As

Publication number Publication date
CN114942796B (en) 2024-07-02

Similar Documents

Publication Publication Date Title
CN114942796B (en) Plug-in compiling and calling method, device, equipment and storage medium
CN109840429B (en) Intelligent contract deployment and calling method and device
KR101795844B1 (en) Runtime system
CN109196476B (en) Seamless high performance interoperability between different types of graphs sharing a garbage collector
CN111399840A (en) Module development method and device
CN111736913B (en) Class loading method and device
CN112769706B (en) Componentized routing method and system
US11537367B1 (en) Source code conversion from application program interface to policy document
US20230418623A1 (en) Application remodeling method, system, cluster, medium, and program product
CN113986402A (en) Function calling method and device, electronic equipment and storage medium
CN113485830A (en) Micro-service automatic capacity expansion method for power grid monitoring system
CN107977243A (en) A kind of third party's interface call method and device
CN113626071B (en) Function registration method, system, electronic device and storage medium
CN109558121B (en) Interface driver development method, device, equipment and storage medium
CN118093007A (en) Method for customizing Web end integrated development environment and related products
CN111488144B (en) Data processing method and device
CN110806891B (en) Method and device for generating software version of embedded device
CN110233842B (en) Request verification method and related device
CN109947407B (en) Data acquisition method and device
CN111221560B (en) Resource management method and device and electronic equipment
CN114064176A (en) View interaction method and device, electronic equipment and computer readable medium
CN110333870B (en) Simulink model variable distribution processing method, device and equipment
CN111737964A (en) Form dynamic processing method, equipment and medium
US8082553B2 (en) Client management of java management extensions (JMX) Mbean state
US12079595B2 (en) Runtime support for role types that extend underlying types

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
GR01 Patent grant