Plug-in configuration method and device, equipment and storage medium

By setting up a load queue in a componentized program and using a custom URL class loader, the logical confusion and information leakage problems during hot updates of componentized programs in the existing technology are solved, and flexible extensions and dynamic updates of the plug-in are realized.

CN120020712AActive Publication Date: 2025-05-20CHINA UNITED NETWORK COMM GRP CO LTD
View PDF 11 Cites 0 Cited by

Patent Information

Application Number
CN202311553509.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-20
Publication Date
2025-05-20
Estimated Expiration
2043-11-20

AI Technical Summary

Technical Problem

The prior art is not suitable for hot updates of componentized programs, resulting in logical confusion and information leakage problems.

Method used

By setting up a load queue, sort the plug-in loading and uninstalling instructions, use a custom URL class loader and hot-swap service framework to achieve dynamic loading and uninstalling of plug-ins to avoid logical confusion and data loss.

Benefits of technology

It effectively avoids the problem of plug-in dependence logic chaos, retains unloaded data, improves system security, and realizes flexible expansion of componentized programs and dynamic updates of functions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120020712A_ABST
    Figure CN120020712A_ABST
Patent Text Reader

Abstract

The invention provides a plug-in configuration method and device, equipment and a storage medium. The method comprises the steps that when a plug-in processing instruction obtained from a target bit in a target plug-in loading queue is a plug-in loading instruction, a class loader and an instance of the class loader are obtained according to the plug-in loading instruction and a plug-in loader, and the target plug-in loading queue is a mirror image queue of the plug-in loading queue; creating a target URL class loader according to the instance of the class loader; according to the target URL class loader, a to-be-loaded code package is loaded into the Java virtual machine, a plug-in loading result is obtained, and the to-be-loaded code package is a plug-in code package stored in a plug-in corresponding to the plug-in loading instruction. According to the method, the service efficiency and safety of the service process are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of plug-in configuration, and particularly to a plug-in configuration method, device, equipment and storage medium. Background Art

[0002] Hot update refers to the behavior that software directly updates the software data downloaded by the application itself without passing the software version update review of the operation store.

[0003] The existing hot update technology updates the class definition by starting the Arthas process, connecting to the target process through the Attach API, creating an InstrumentationImpl object, calling the loadClassAndCallAgentmain method, and calling the agentmain method of the specified Agent-Class class to complete the hot update processing of the class in the Java virtual machine.

[0004] However, the existing technology is not applicable to the scenario of hot updating componentized programs, which will cause logical confusion problems and is prone to information leakage. Summary of the Invention

[0005] This application provides a plug-in configuration method, device, equipment and storage medium to solve the problems that the existing technology is not applicable to the scenario of hot updating componentized programs, which will cause logical confusion problems and is prone to information leakage.

[0006] In a first aspect, this application provides a plug-in configuration method, including:

[0007] When the plug-in processing instruction obtained from the target position in the target plug-in loading queue is a plug-in loading instruction, according to the plug-in loading instruction, the plug-in loader obtains a class loader and an instance of the class loader, and the target plug-in loading queue is a mirror queue of the plug-in loading queue;

[0008] According to the instance of the class loader, a target URL class loader is created, and the parent class loader of the target URL class loader is the instance of the class loader;

[0009] According to the target URL class loader, the code package to be loaded is loaded into the Java virtual machine to obtain a plug-in loading result, where the code package to be loaded is the plug-in code package stored corresponding to the plug-in loading instruction.

[0010] In this application, before when the plug-in processing instruction obtained from the target position in the target plug-in loading queue is a plug-in loading instruction, and according to the plug-in loading instruction, the plug-in loader obtains a class loader and an instance of the class loader, the method further includes:

[0011] Determine the target plug-in loading queue, where the target plug-in loading queue includes plug-in loading instructions and plug-in disassembly instructions, and the plug-in loading instructions and plug-in disassembly instructions are arranged in the order of instruction input.

[0012] In this application, when the plug-in processing instruction obtained from the target position in the target plug-in loading queue is a plug-in loading instruction, before the plug-in loader obtains the class loader and the instance of the class loader according to the plug-in loading instruction, the method further includes:

[0013] Obtain the user requirement instruction;

[0014] Send the user requirement instruction to the task scheduling unit for task scheduling to obtain task arrangement information;

[0015] According to the task arrangement information, obtain the plug-in processing instruction from the target position in the target plug-in loading queue.

[0016] In this application, when the task arrangement information is plug-in upload, after sending the user requirement instruction to the task scheduling unit for task scheduling to obtain the task arrangement information, the method includes:

[0017] Determine the plug-in file package corresponding to the task arrangement information, where the plug-in file package includes plug-in configuration information and plug-in files;

[0018] Upload the plug-in configuration information to the database;

[0019] Upload the plug-in file to the loading library to obtain the plug-in upload result;

[0020] According to the plug-in upload result, add a plug-in loading instruction to the end of the target plug-in loading queue.

[0021] In this application, when the task arrangement information is plug-in call, after sending the user requirement instruction to the task scheduling unit for task scheduling to obtain the task arrangement information, the method includes:

[0022] Obtain the user's write operation;

[0023] According to the user's write operation, determine the scheduled task information, where the scheduled task information includes the target time, target plug-in, target method, and target operation;

[0024] According to the target plug-in in the scheduled task information, determine the class loader so that the class loader loads the target class, the instance of the target class, and the target method instance;

[0025] According to the target method instance, control the target plug-in to perform the target operation at the target time to obtain the plug-in call result.

[0026] In this application, when the task arrangement information is an execution status instruction, after sending the user requirement instruction to the task scheduling unit for task scheduling to obtain the task arrangement information, the method includes:

[0027] Determine the target plugin in the user requirement instruction;

[0028] Obtain the plugin information in the loading library according to the target plugin in the user requirement instruction;

[0029] Obtain the execution status instruction result according to the plugin information;

[0030] Upload the plugin execution result to the interaction interface through the task scheduling unit for display.

[0031] In this application, when a system restart or abnormal exit occurs in the service process, and when the plugin processing instruction obtained from the target position in the target plugin loading queue is a plugin loading instruction, before the plugin loader obtains the class loader and the instance of the class loader according to the plugin loading instruction, the method further includes:

[0032] Determine the memory image where the target plugin loading queue is located;

[0033] Create a local disk image of the target plugin loading queue according to the memory image where the target plugin loading queue is located;

[0034] Load the incomplete queue data according to the local disk image of the target plugin loading queue.

[0035] In this application, for the plugin loader to obtain the class loader and the instance of the class loader according to the plugin loading instruction, it includes:

[0036] The plugin loader obtains the class loader ClassLoader according to the plugin loading instruction;

[0037] Instantiate the class loader ClassLoader to obtain the class loader instance.

[0038] In this application, the method further includes:

[0039] When the plugin processing instruction obtained from the target position in the target plugin loading queue is a plugin uninstallation instruction, obtain the target uninstalled plugin, as well as the plugin entry class reference, plugin entry method reference, and plugin ClassLoader reference of the target uninstalled plugin;

[0040] Clear the plugin entry class reference, plugin entry method reference, and plugin ClassLoader reference of the target uninstalled plugin;

[0041] After clearing the references to the plugin entry class, the plugin entry method, and the plugin ClassLoader of the target uninstalled plugin, the garbage collection mechanism is triggered to uninstall the target uninstalled plugin from the Java virtual machine, and the plugin uninstallation result is obtained.

[0042] In a second aspect, the present application provides a plugin configuration device, including:

[0043] An acquisition module, configured to, when the plugin processing instruction obtained from the target position in the target plugin loading queue is a plugin loading instruction, according to the plugin loading instruction, the plugin loader acquires a class loader and an instance of the class loader, and the target plugin loading queue is a mirror queue of the plugin loading queue;

[0044] A loading module, configured to create a target URL class loader according to the instance of the class loader, and the parent class loader of the target URL class loader is the instance of the class loader;

[0045] An execution module, configured to load the code package to be loaded into the Java virtual machine according to the target URL class loader to obtain a plugin loading result, where the code package to be loaded is a plugin code package stored corresponding to the plugin loading instruction.

[0046] In a third aspect, the present application provides an electronic device, including: a processor and a memory communicatively connected to the processor;

[0047] The memory stores computer execution instructions;

[0048] The processor executes the computer execution instructions stored in the memory to implement the method of the present application.

[0049] In a fourth aspect, the present application provides a computer-readable storage medium, including: computer execution instructions are stored in the computer-readable storage medium, and when the computer execution instructions are executed by a processor, they are used to implement the method of the present application.

[0050] A plug-in configuration method, device, equipment and storage medium provided by this application. When the plug-in processing instruction obtained from the target position in the target plug-in loading queue is a plug-in loading instruction, according to the plug-in loading instruction, the plug-in loader obtains a class loader and an instance of the class loader. The target plug-in loading queue is a mirror queue of the plug-in loading queue. According to the instance of the class loader, a target URL class loader is created, and the parent class loader of the target URL class loader is the instance of the class loader. According to the target URL class loader, the code package to be loaded is loaded into the Java virtual machine to obtain a plug-in loading result. The code package to be loaded is a means of storing the plug-in code package corresponding to the plug-in loading instruction. By setting the loading queue, the plug-in loading and plug-in disassembly instructions of the user are sorted to avoid the problem of chaotic plug-in dependency logic. By mapping the memory mirror to the disk mirror, the unloaded data is retained to avoid the inefficiency problem caused by data loss due to system restart or abnormal exit. At the same time, the use of a custom URL class loader improves the security of the system. In addition, this application uses a hot-pluggable service framework, and the system can dynamically load or unload plug-ins during operation to achieve flexible expansion of the system and dynamic update of functions, making the present invention applicable to componentized program hot update scenarios such as automatic inspection. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] The accompanying drawings herein are incorporated into the specification and constitute a part of this specification, showing embodiments consistent with this application and used together with the specification to explain the principles of this application.

[0052] Figure 1 It is a schematic diagram of the scenario of the plug-in configuration method provided by an embodiment of this application;

[0053] Figure 2 It is a schematic flowchart of the plug-in configuration method provided by an embodiment of this application;

[0054] Figure 3 It is a schematic flowchart of another plug-in configuration method provided by an embodiment of this application;

[0055] Figure 4 It is a schematic structural diagram of the plug-in configuration device provided by an embodiment of this application;

[0056] Figure 5 It is a schematic structural diagram of the electronic equipment provided by an embodiment of this application.

[0057] Through the above-mentioned accompanying drawings, specific embodiments of this application have been shown, and there will be more detailed descriptions hereinafter. These drawings and textual descriptions are not intended to limit the scope of the concept of this application in any way, but to illustrate the concept of this application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0058] Exemplary embodiments will be described in detail herein, and examples thereof are shown in the accompanying drawings. When the following description refers to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0059] When performing hot updates in the prior art, the Arthas process is started under the same user privilege as the application. The Arthas process automatically scans other processes of the current user, and the user selects which process to attach to. Arthas connects to the Java virtual machine through the Attach API (Application Programming Interface), connects to the target process through the Attach API, creates an InstrumentationImpl object, listens for the ClassFileLoadHook event, updates the class definition by calling the loadClassAndCallAgentmain method of InstrumentationImpl, and then calls the agentmain method of the Agentmain-Class class specified in the javaagent MANIFEST.MF to complete the hot update process of the Java virtual machine. However, since the Attach API is not a standard API of the Java virtual machine, it cannot be adapted to all Java virtual machines, and the prior art is not applicable to scenarios such as automated inspection, reconciliation, and testing for hot updates of componentized programs. When multiple people update plugins, there may be problems with chaotic plugin dependency logic, and restarting the service process will cause data loss, resulting in low efficiency. The prior art needs to start a third-party application, creating a vulnerability in the business system and easily causing information leakage.

[0060] Based on the defects existing in the prior art when performing hot updates, the present application sorts the plugin loading and plugin uninstallation instructions of the user by setting a loading queue, avoiding problems with chaotic plugin dependency logic. By performing disk image mapping on the memory image, the unloaded data is retained, avoiding the low efficiency problem caused by data loss due to system restart or abnormal exit. At the same time, the use of a custom URL class loader improves the security of the system. In addition, the present application uses a hot-pluggable service framework, and the system can dynamically load or unload plugins during runtime, achieving flexible expansion of the system and dynamic update of functions, making the present invention applicable to hot update scenarios of componentized programs such as automated inspection.

[0061] The plugin configuration method provided by the present application aims to solve the above technical problems of the prior art.

[0062] The following uses specific embodiments to elaborate in detail on the technical solution of the present application and how the technical solution of the present application solves the above technical problems. The following several specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0063] Figure 1 It is a schematic diagram of the application scenario of the plugin configuration method provided by the embodiment of the present application. As Figure 1 shown, the execution subject of this plugin configuration method can be a plugin configuration system, and this system includes: a web console, a Server side, a loading library, and a database.

[0064] Among them, the web console is a tool for debugging and monitoring web browsers and web applications. It usually provides an interactive interface that allows developers to enter JavaScript code to check the status of the web page, debug errors, and monitor performance. In the plugin configuration system of the present application, the web console includes the following function entrances: plugin upload, plugin loading, plugin unloading, plugin invocation, and execution status.

[0065] The Server side can refer to software running on a server, which is usually used to provide a certain network service. This service can provide resources to the client, save client data, etc. The client can be an ordinary computer. As long as it is connected to the Server side and has obtained authorization from the Server side, it can use the services of the Server side. In the plugin configuration system of the present application, the service-side API interface used by the Server side is an open API to support the management functions of the web console. The plugin loading queue in the Server side is used to manage the queuing of all plugin loading and unloading processes, playing a role in avoiding dependency chaos. The plugin loader core is used to implement plugin loading and unloading and is the core controller for the plugin loading system and the removal system. The task scheduler is used to manage the plugin invocation execution cycle and trigger plugin invocation execution. The plugin invocation core is used to implement the dynamic invocation of plugins.

[0066] The loading library is a shared resource that can be dynamically loaded and used by other programs. These libraries contain code and data that can be reused by other programs. When the program runs, these libraries can be loaded and used by calling functions provided by the system's dynamic linker. At the same time, the shared libraries to be pre-loaded and the search path of the shared libraries can be specified by setting environment variables and other methods. In the plugin configuration system of the present application, the loading library classifies and manages plugin resources in three stages: to be loaded, already loaded, and already unloaded.

[0067] A database is a repository that organizes, stores, and manages data according to a data structure. It is a collection of a large amount of data that is stored in a computer for a long time, organized, shareable, and uniformly managed. It can provide fast access to and operation on the stored large amount of data. A database usually consists of one or more tables, each table contains multiple rows and columns, each row represents a record, and each column represents an attribute. In this application, the database is mainly used to store the data information in the plugin file package.

[0068] The web console receives the user's write operation, and sends the requirement instruction in the write operation to the task scheduler on the Server side through the server API. After the task scheduler makes an arrangement, it retrieves the target file from the database and the loading library to complete the plugin processing instruction.

[0069] In some embodiments, the execution subject of the plugin configuration method provided in the embodiments of this application can also be a server. Among them, the server can be a device such as a mobile phone, a computer, a tablet, etc. This embodiment does not make special restrictions on the implementation manner of the execution subject, as long as the execution subject can, when the plugin processing instruction obtained from the target position in the target plugin loading queue is a plugin loading instruction, according to the plugin loading instruction, the plugin loader obtains a class loader and an instance of the class loader. The target plugin loading queue is a mirror queue of the plugin loading queue; according to the instance of the class loader, create a target URL class loader, and the parent class loader of the target URL class loader is the instance of the class loader; according to the target URL class loader, load the code package to be loaded into the Java virtual machine to obtain the plugin loading result.

[0070] Among them, the plugin loading queue can refer to a queue waiting for plugin configuration, which contains a list of plugins to be loaded, a list of plugins to be unloaded, etc. When the plugin loader starts to load a plugin, it will take the plugin out of the queue and load it into the runtime environment. If a certain plugin depends on other plugins, it will be postponed until the plugins it depends on are loaded. In the embodiments of this application, the plugin loading queue manages the sorting of all plugin loading and unloading processing processes through a Java Queue object, and its first-in-first-out characteristic enables the plugins that initiate loading or unloading first to be processed first.

[0071] Figure 2 It is a schematic flowchart of the plugin configuration method provided in the embodiments of this application. The execution subject of this method can be a server or other servers, and this embodiment does not make special restrictions here, such as Figure 2 As shown, this method may include:

[0072] S201. When the plugin processing instruction obtained from the target position in the target plugin loading queue is a plugin loading instruction, according to the plugin loading instruction, the plugin loader obtains a class loader and an instance of the class loader.

[0073] Among them, the plug-in processing instruction can refer to the relevant instructions for operating the plug-in, including plug-in loading, plug-in unloading, and plug-in invocation. These instructions can be transmitted through command lines, configuration files, graphical interfaces, etc.

[0074] Among them, the class loader is an important part of the Java virtual machine. It is responsible for loading the bytecode of Java classes into the virtual machine and dynamically linking and initializing classes at runtime. The class loader adopts the parent delegation model, that is, when a class loader needs to load a class, it will first delegate it to its parent class loader for loading. If the parent class loader cannot load it, then the class loader will load it by itself. This hierarchical relationship enables the class loader to achieve class sharing and isolation, improving the security and reliability of the code. The class loader instance can refer to the object actually loaded in the class loader.

[0075] Among them, upon receiving the plug-in loading instruction for a certain plug-in, the task scheduler obtains the ID of the target plug-in, matches the source file of the target plug-in from the set of plug-ins to be loaded in the loading library, matches the configuration information of the target plug-in from the database, obtains the class loader instance through the core class loader of the Java virtual machine, creates a custom URL class loader, and uses the Java reflection mechanism to load the plug-in code package to be installed by using the addURL method, thus completing the plug-in loading task.

[0076] Among them, when obtaining the class loader instance through the core class loader of the Java virtual machine, if it is a Spring project, then use ClassUtils.getDefaultClassLoader() to obtain it.

[0077] Among them, using the addURL method to load the plug-in code package to be installed can refer to passing in the method name and parameter type, obtaining the method object through the getDeclareMethod of the Class object, then using setAccessible(true) to modify the accessibility of the method object, and using the obtained class loader instance to execute its addURL method through invoke to load the code package to be loaded into the JVM, thus completing the plug-in loading task.

[0078] Among them, in the embodiment of the present application, before the plug-in loader obtains the class loader and the instance of the class loader according to the plug-in loading instruction when the plug-in processing instruction obtained from the target position in the target plug-in loading queue is a plug-in loading instruction, the method further includes:

[0079] Determine the target plug-in loading queue, where the target plug-in loading queue includes plug-in loading instructions and plug-in disassembly instructions, and the plug-in loading instructions and plug-in disassembly instructions are arranged in the order of instruction input.

[0080] Among them, since the data saved in the system memory image will be lost and need to be reloaded when the service process restarts or exits abnormally, resulting in low efficiency, when it is detected that the system needs to restart or is about to exit abnormally, the embodiment of the present application first performs disk image mapping on the unloaded data. After the system process restarts or exits abnormally and logs in again, the unloaded queue data is retrieved from the disk image data, and the loading task continues.

[0081] Among them, in the embodiment of the present application, before the plug-in loader obtains the class loader and the instance of the class loader according to the plug-in loading instruction when the plug-in processing instruction obtained from the target position in the target plug-in loading queue is a plug-in loading instruction, the method further includes:

[0082] Obtain the user requirement instruction;

[0083] Send the user requirement instruction to the task scheduling unit for task scheduling to obtain task arrangement information;

[0084] According to the task arrangement information, obtain the plug-in processing instruction from the target position in the target plug-in loading queue.

[0085] Among them, the user's requirement instructions include plug-in loading instructions, plug-in disassembly instructions, plug-in upload instructions, plug-in call instructions, and execution status instructions.

[0086] Among them, the task scheduler matching the task arrangement according to the user's requirement instruction may mean that when the user's requirement instruction is a plug-in loading instruction or a plug-in disassembly instruction, the task arrangement is that the task scheduler controls the plug-in loader core to read the plug-in loading queue to complete the instruction; when the user's requirement instruction is a plug-in upload instruction, the task arrangement is that the task scheduler uploads the configuration information in the plug-in package to the database and uploads the plug-in files in the plug-in package to the to-be-loaded plug-in set in the loading library; when the user's requirement instruction is a plug-in call instruction, the task arrangement is that the task scheduler obtains the timing task written by the user and controls the plug-in call core to complete the plug-in execution according to the timing task; when the user's requirement instruction is an execution status instruction, the task arrangement is that the task scheduler retrieves the execution status of the target plug-in from the loading library.

[0087] Among them, according to the task arrangement information, obtaining the plug-in processing instruction from the target position in the target plug-in loading queue may refer to determining the plug-in loading queue, sending the plug-in loading queue to the plug-in loader, and adding user demand instructions to the end of the plug-in loading queue according to the task arrangement. The user demand instructions include plug-in loading instructions and plug-in unloading instructions. Pull the instruction from the head of the plug-in loading queue to obtain the target position plug-in processing instruction. Move the second user demand instruction in the plug-in loading queue to the head of the queue to become the new target position plug-in processing instruction, and wait for the plug-in loader to read it.

[0088] Among them, the plug-in loading instructions and plug-in unloading instructions in the plug-in loading queue follow the rules of platform-level timing tasks. The platform-level timing tasks provide a fixed polling service to pull the target position plug-in processing instruction from the plug-in loading queue. When the execution of the target position plug-in processing instruction ends, according to the timing task information of the user demand instruction, the task scheduler controls the plug-in loader to read the new target position plug-in processing instruction in the plug-in loading queue.

[0089] Among them, obtain the user's demand instruction from the function entry of the web console. The user's demand instruction reaches the task scheduler through the server-side API interface of the Server side. The task scheduler matches the task arrangement according to the user's demand instruction. If the task arrangement is a plug-in loading instruction or a plug-in disassembly instruction, obtain the plug-in processing instruction from the target position of the plug-in loading queue.

[0090] Among them, in the embodiment of the present application, when the task arrangement information is plug-in upload, after sending the user demand instruction to the task scheduling unit for task scheduling to obtain the task arrangement information, the method includes:

[0091] Determine the plug-in file package corresponding to the task arrangement information. The plug-in file package includes plug-in configuration information and plug-in files;

[0092] Upload the plug-in configuration information to the database;

[0093] Upload the plug-in file to the loading library to obtain the plug-in upload result;

[0094] According to the plug-in upload result, add a plug-in loading instruction to the tail of the target plug-in loading queue.

[0095] Among them, the user selects information such as the plugin software package, plugin name, and entry program in the web form. According to the user's write operation, the plugin upload instruction is imported into the task scheduler through the server API interface. The task scheduler determines the configuration information, plugin file, and plugin ID of the plugin according to the plugin upload instruction, stores the plugin ID of the target plugin, creates a plugin information record in the database, uploads the configuration information of the plugin to the database, uploads the plugin file to the to-be-loaded plugin set of the loading library, and pushes the plugin loading instruction to the end of the plugin loading queue, waiting for the platform-level timed task to poll the plugin loading queue and obtain the instruction to start executing the plugin loading.

[0096] Among them, in the embodiment of the present application, when the task arrangement information is a plugin call, after sending the user requirement instruction to the task scheduling unit for task scheduling to obtain the task arrangement information, the method includes:

[0097] Obtain the user's write operation;

[0098] According to the user's write operation, determine the timed task information, where the timed task information includes the target time, target plugin, target method, and target operation;

[0099] According to the target plugin in the timed task information, determine the class loader so that the class loader loads the target class, the instance of the target class, and the target method instance;

[0100] According to the target method instance, control the target plugin to execute the target operation at the target time to obtain the plugin call result.

[0101] Among them, the task scheduler receives the user's plugin call instruction through the web console, and according to the timed task information in the user plugin call instruction, triggers the subsequent execution operation at the target execution time.

[0102] Among them, the subsequent execution operation may refer to determining the target plugin from the loaded plugin set of the loading library according to the plugin ID in the plugin call instruction, controlling the plugin call core to find the corresponding custom class loader according to the target plugin, loading the target class through ClassLoader.loadClass(), obtaining the target class instance through Class.newInstance(), obtaining the target method instance through the Class.getDeclaredMethod() method, triggering the plugin execution through the invoke method of the target method instance, receiving the plugin execution result object and sending it to the task scheduler to complete the plugin execution.

[0103] Among them, when obtaining the target class, Class.forName() cannot be used because the target plug-in class is loaded by a custom ClassLoader, while Class.forName() by default uses the system's top-level class loader.

[0104] Among them, in the embodiment of the present application, when the task arrangement information is an execution situation instruction, after sending the user requirement instruction to the task scheduling unit for task scheduling to obtain the task arrangement information, the method includes:

[0105] Determine the target plug-in in the user requirement instruction;

[0106] Obtain the plug-in information in the loading library according to the target plug-in in the user requirement instruction;

[0107] Obtain the execution situation instruction result according to the plug-in information;

[0108] Upload the plug-in execution result to the interaction interface through the task scheduling unit for display.

[0109] Among them, when the execution situation function entry of the web console detects the user's write operation, the user's execution situation instruction is imported into the task scheduling program through the server-side API interface of the Server side. The task scheduling program retrieves the execution situation of the target plug-in from the loading library according to the plug-in information in the execution situation instruction, and uploads the execution situation of the target plug-in to the interaction interface of the execution situation window of the web console.

[0110] Among them, in the embodiment of the present application, when a system restart or abnormal exit occurs in the service process, when the plug-in processing instruction obtained from the target position in the target plug-in loading queue is a plug-in loading instruction, before the plug-in loader obtains the class loader and the instance of the class loader according to the plug-in loading instruction, the method further includes:

[0111] Determine the memory image where the target plug-in loading queue is located;

[0112] Create a local disk image of the target plug-in loading queue according to the memory image where the target plug-in loading queue is located;

[0113] Load the uncompleted queue data according to the local disk image of the target plug-in loading queue.

[0114] Among them, a disk image can refer to the process of completely copying all the data of one disk to another disk. This process can be completed using specialized disk imaging software, such as OSDeployer. Disk imaging can be used for backing up and restoring operating systems, applications, data, etc., and can also be used for quickly deploying the same configuration on multiple computers.

[0115] Among them, before the system process restarts or exits abnormally and before restarting the Server side, mirror mapping is performed on the data in the memory mirror that has not been loaded, and it is mapped to the local disk. After restarting the Server side, the task scheduler controls the plugin loader to read the data to be loaded in the local disk mirror.

[0116] Among them, in the embodiments of the present application, according to the plugin loading instruction, the plugin loader obtains the class loader and the instance of the class loader, including:

[0117] According to the plugin loading instruction, the plugin loader obtains the class loader ClassLoader;

[0118] The class loader ClassLoader is instantiated to obtain the class loader instance.

[0119] Among them, in the embodiments of the present application, the method further includes:

[0120] When the plugin processing instruction obtained from the target position in the target plugin loading queue is a plugin disassembly instruction, obtain the target uninstalled plugin, as well as the plugin entry class reference, plugin entry method reference, and plugin ClassLoader reference of the target uninstalled plugin;

[0121] Perform a clearing process on the plugin entry class reference, plugin entry method reference, and plugin ClassLoader reference of the target uninstalled plugin;

[0122] After the clearing process on the plugin entry class reference, plugin entry method reference, and plugin ClassLoader reference of the target uninstalled plugin, trigger the garbage collection mechanism to uninstall the target uninstalled plugin from the Java virtual machine to obtain the plugin uninstallation result.

[0123] Among them, when the user's requirement instruction is a plugin disassembly instruction, the task scheduler receives the plugin disassembly instruction through the server API interface. According to the plugin ID in the plugin disassembly instruction, the target plugin is determined from the set of loaded plugins in the loading library. Using the JVM garbage collection mechanism, the references to the target plugin entry method and entry class are set to null, and after setting the URLClassLoader object loaded by the corresponding plugin to null, the System.gc() mechanism is triggered to uninstall the plugin from the JVM, and the uninstalled target plugin is stored in the set of uninstalled plugins in the loading library.

[0124] S202. Create a target URL class loader according to the instance of the class loader.

[0125] Among them, the parent class loader of the target URL class loader is the instance of the class loader.

[0126] Among them, using a custom URL class loader can extend the functionality of the Java class loader and implement a custom class loading method. The custom URL class loader can load class files in the local file system or on the network, thus realizing the function of dynamically loading classes. In addition, the custom URL class loader can also implement class isolation to avoid conflicts between different versions of class files. For example, when different versions of class files need to be loaded in the same application, the custom URL class loader can be used to achieve class isolation, thereby avoiding conflicts between class files and improving the security of the service process.

[0127] S203. According to the target URL class loader, load the code package to be loaded into the Java virtual machine to obtain the plugin loading result.

[0128] Among them, the code package to be loaded is the plugin code package stored corresponding to the plugin loading instruction.

[0129] The plugin configuration method provided by this application uses a hot-pluggable service framework for management based on a web console. The plugin loading library is isolated outside the Server side, and the plugin execution is hosted on the unified service base of the Server side for unified scheduling and unified monitoring. Except for specific scenarios, there is no need to update and restart the Server side. After restarting, it can automatically resume loading the original plugin. By sorting the plugin loading instructions and plugin uninstallation instructions input by users in the web console, a plugin loading queue is generated to ensure that the loading and unloading processes are controllable in order during multi-person collaborative operations. At the same time, to avoid data loss in the process due to Server side restart or abnormal exit, this application maps the memory image and stores the unloaded data on the local disk.

[0130] Figure 3 It is a schematic flowchart of another plugin configuration method provided by an embodiment of this application. As Figure 3 shown, this method includes:

[0131] S301. Obtain the user's requirement instruction.

[0132] Among them, the user's requirement instruction on the web console is sent to the task scheduler through the server API.

[0133] S302. Determine the task arrangement according to the user's requirement instruction.

[0134] The task scheduler matches the user's requirement instruction with the task arrangement to determine the target plugin and the target task arrangement.

[0135] S303. Control the plugin to execute the task according to the task arrangement.

[0136] Among them, when the task arrangement is a plug-in loading instruction, the task scheduler controls the plug-in loader to read the plug-in loading queue to determine the target plug-in information. The plug-in loader core obtains the class loader ClassLoader according to the target plug-in information, instantiates the class loader ClassLoader to obtain a class loader instance, creates a custom URLClassLoader according to the top-level class loader instance, and designates the top-level class loader instance as the parent class loader. The Native code package is obtained from the set of plug-ins to be loaded in the loading library, and the Native code package is loaded into the JVM through the URLClassLoader to obtain the plug-in loading result, and the plug-in loading result is uploaded to the web console interaction interface through the task scheduler.

[0137] Among them, the addURL method of the URLClassLoader cannot be directly called. The scope modifier of the addURL method is protected, and it cannot be directly called by non-subclasses outside the target class path. In the embodiment of the present application, the Java reflection mechanism is used to perform an invoke call on the method with the scope of protected.

[0138] Among them, when the task arrangement is a plug-in uninstallation instruction, the task scheduler controls the plug-in loader to read the plug-in loading queue to determine the target uninstalled plug-in information, and clears the entry method of the target uninstalled plug-in, the reference to the entry class, and the URLClassLoader object loaded by the target uninstalled plug-in, so that the clearing operation triggers the garbage collection mechanism, and the plug-in is uninstalled from the JVM to obtain the plug-in uninstallation result.

[0139] Among them, when the task arrangement is a plug-in call instruction, the task scheduler obtains the scheduled task content written by the user in the plug-in call instruction, determines the target plug-in according to the scheduled task content written by the user, determines the custom ClassLoader according to the target plug-in, loads the target class according to the custom ClassLoader, instantiates according to the target class to obtain a target class instance, determines the target method instance according to the target class instance, triggers the plug-in to execute the scheduled task according to the target method instance to obtain the plug-in execution result, and uploads the plug-in execution result to the interaction interface of the web console through the task scheduler.

[0140] Among them, when the task arrangement is a plug-in upload instruction, the task scheduler determines the file package of the plug-in. Among them, the file package includes the configuration information of the plug-in and the plug-in file. The configuration information of the plug-in is uploaded to the database, and the plug-in file of the plug-in is uploaded to the loading library to obtain the plug-in upload result.

[0141] Among them, when the task arrangement is an execution status instruction, the task scheduler determines the target plugin data in the execution status instruction. According to the target plugin data, the task scheduler obtains the target plugin information in the loaded plugin set of the loading library, obtains the execution status instruction result, and uploads the execution status instruction result to the interactive interface of the web console through the task scheduler.

[0142] Figure 4 The structural schematic diagram of the plugin configuration device provided by the embodiment of the present application is shown as Figure 4 shown. The plugin configuration device 40 includes: an acquisition module 401, a loading module 402, and an execution module 403. Among them:

[0143] The acquisition module 401 is configured to, when the plugin processing instruction obtained from the target position in the target plugin loading queue is a plugin loading instruction, according to the plugin loading instruction, the plugin loader obtains a class loader and an instance of the class loader, and the target plugin loading queue is a mirror queue of the plugin loading queue;

[0144] The loading module 402 is configured to create a target URL class loader according to the instance of the class loader, and the parent class loader of the target URL class loader is the instance of the class loader;

[0145] The execution module 403 is configured to load the code package to be loaded into the Java virtual machine according to the target URL class loader to obtain a plugin loading result, where the code package to be loaded is a plugin code package stored corresponding to the plugin loading instruction.

[0146] In the embodiment of the present application, the acquisition module 401 may also specifically be used for:

[0147] Before, when the plugin processing instruction obtained from the target position in the target plugin loading queue is a plugin loading instruction, and according to the plugin loading instruction, the plugin loader obtains a class loader and an instance of the class loader, the method further includes:

[0148] Determine the target plugin loading queue, where the target plugin loading queue includes a plugin loading instruction and a plugin disassembly instruction, and the plugin loading instruction and the plugin disassembly instruction are arranged in the instruction input order.

[0149] In the embodiment of the present application, the acquisition module 401 may also specifically be used for:

[0150] Obtain a user requirement instruction;

[0151] Send the user requirement instruction to the task scheduling unit for task scheduling to obtain task arrangement information;

[0152] According to the task arrangement information, obtain a plugin processing instruction from the target position in the target plugin loading queue.

[0153] In an embodiment of the present application, the obtaining module 401 may further be specifically configured to:

[0154] Determine a plug-in file package corresponding to the task arrangement information, where the plug-in file package includes plug-in configuration information and plug-in files;

[0155] Upload the plug-in configuration information to the database;

[0156] Upload the plug-in file to the loading library to obtain a plug-in upload result;

[0157] According to the plug-in upload result, add a plug-in loading instruction to the end of the target plug-in loading queue.

[0158] In an embodiment of the present application, the obtaining module 401 may further be specifically configured to:

[0159] Obtain the write operation of the user;

[0160] According to the write operation of the user, determine the timing task information, where the timing task information includes the target time, the target plug-in, the target method, and the target operation;

[0161] According to the target plug-in in the timing task information, determine a class loader to enable the class loader to load the target class, an instance of the target class, and an instance of the target method;

[0162] According to the instance of the target method, control the target plug-in to perform the target operation at the target time to obtain a plug-in call result.

[0163] In an embodiment of the present application, the obtaining module 401 may further be specifically configured to:

[0164] Determine the target plug-in in the user requirement instruction;

[0165] According to the target plug-in in the user requirement instruction, obtain the plug-in information in the loading library;

[0166] According to the plug-in information, obtain an execution situation instruction result;

[0167] Upload the plug-in execution result to the interaction interface through the task scheduling unit for display.

[0168] In an embodiment of the present application, the obtaining module 401 may further be specifically configured to:

[0169] Determine the memory image where the target plug-in loading queue is located;

[0170] According to the memory image where the target plug-in loading queue is located, create a local disk image of the target plug-in loading queue;

[0171] According to the local disk image of the target plug-in loading queue, load the uncompleted queue data.

[0172] In the embodiments of the present application, the obtaining module 401 may further be specifically configured to:

[0173] According to the plug-in loading instruction, the plug-in loader obtains a class loader ClassLoader;

[0174] Instantiate the class loader ClassLoader to obtain a class loader instance.

[0175] In the embodiments of the present application, the execution module 403 may further be specifically configured to:

[0176] When the plug-in processing instruction obtained from the target position in the target plug-in loading queue is a plug-in uninstallation instruction, obtain the target uninstalled plug-in, as well as the plug-in entry class reference, plug-in entry method reference, and plug-in ClassLoader reference of the target uninstalled plug-in;

[0177] Clear the plug-in entry class reference, plug-in entry method reference, and plug-in ClassLoader reference of the target uninstalled plug-in;

[0178] After clearing the plug-in entry class reference, plug-in entry method reference, and plug-in ClassLoader reference of the target uninstalled plug-in, trigger the garbage collection mechanism to uninstall the target uninstalled plug-in from the Java virtual machine to obtain a plug-in uninstallation result.

[0179] Figure 5 It is a schematic structural diagram of the electronic device provided in the embodiments of the present application. As Figure 5 shown, the electronic device 50 includes:

[0180] The electronic device 50 may include a processor 501 with one or more processing cores, a memory 502 with one or more computer-readable storage media, a communication component 503, and other components. Among them, the processor 501, the memory 502, and the communication component 503 are connected through a bus 504.

[0181] In a specific implementation process, at least one processor 501 executes the computer execution instructions stored in the memory 502, so that at least one processor 501 executes the above plug-in configuration method.

[0182] For the specific implementation process of the processor 501, reference may be made to the above method embodiments, and the implementation principle and technical effects are similar, which will not be elaborated here in this embodiment.

[0183] In the above Figure 5In the illustrated embodiment, it should be understood that the processor may be a central processing unit (CPU for short), or may also be other general-purpose processors, digital signal processors (DSP for short), application specific integrated circuits (ASIC for short), etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the method disclosed in combination with the invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules in the processor.

[0184] The memory may include a random access memory (RAM), and may also include a non-volatile memory (NVM), such as at least one disk memory.

[0185] The bus may be an industry standard architecture (ISA) bus, a peripheral component interconnect (PCI) bus, an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, the bus in the drawings of this application is not limited to only one bus or one type of bus.

[0186] In some embodiments, a computer program product is also proposed, including a computer program or instruction, and when the computer program or instruction is executed by a processor, the steps in any of the above plug-in configuration methods are implemented.

[0187] For the specific implementation of each of the above operations, reference may be made to the previous embodiments, which will not be elaborated here.

[0188] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructions, or by controlling relevant hardware through instructions. The instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.

[0189] Therefore, an embodiment of the present application provides a computer-readable storage medium, in which multiple instructions are stored, and the instructions can be loaded by a processor to execute the steps in any of the plug-in configuration methods provided by the embodiments of the present application.

[0190] Among them, the storage medium may include: read-only memory (ROM, Read Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disc, etc.

[0191] According to one aspect of the present application, there is provided a computer program product or a computer program, the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium.

[0192] Since the instructions stored in the storage medium can execute the steps in any of the plugin configuration methods provided by the embodiments of the present application, the beneficial effects achievable by any of the plugin configuration methods provided by the embodiments of the present application can be realized. For details, refer to the previous embodiments and will not be elaborated here.

[0193] Those skilled in the art will readily conceive of other implementations of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any variations, uses, or adaptations of the present application, which follow the general principles of the present application and include well-known knowledge or conventional technical means in the technical field not disclosed in the present application. The specification and the embodiments are only regarded as exemplary, and the true scope and spirit of the present application are pointed out by the following claims.

[0194] It should be understood that the present application is not limited to the exact structures already described and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present application is only limited by the appended claims.

Claims

1. A plug-in configuration method, characterized in that: include: When the plug-in processing instruction obtained from the target position in the target plug-in loading queue is a plug-in loading instruction, the plug-in loader obtains a class loader and an instance of the class loader according to the plug-in loading instruction, and the target plug-in loading queue is a mirror queue of the plug-in loading queue; According to the instance of the class loader, a target URL class loader is created, wherein the parent class loader of the target URL class loader is the instance of the class loader; According to the target URL class loader, the code package to be loaded is loaded into the Java virtual machine to obtain a plug-in loading result, wherein the code package to be loaded is a plug-in code package stored in correspondence with the plug-in loading instruction.

2. The method according to claim 1, characterized in that: When the plug-in processing instruction obtained from the target position in the target plug-in loading queue is a plug-in loading instruction, before the plug-in loader obtains the class loader and the instance of the class loader according to the plug-in loading instruction, the method further includes: A target plug-in loading queue is determined, wherein the target plug-in loading queue includes plug-in loading instructions and plug-in removal instructions, and the plug-in loading instructions and the plug-in removal instructions are arranged in an instruction input sequence.

3. The method according to claim 1, characterized in that When the plug-in processing instruction obtained from the target position in the target plug-in loading queue is a plug-in loading instruction, before the plug-in loader obtains the class loader and the instance of the class loader according to the plug-in loading instruction, the method further includes: Obtain user demand instructions; Sending the user demand instruction to the task scheduling unit to perform task scheduling and obtain task arrangement information; According to the task scheduling information, a plug-in processing instruction is obtained from a target position in the target plug-in loading queue.

4. The method according to claim 3, characterized in that When the task arrangement information is uploaded by a plug-in, after sending the user demand instruction to a task scheduling unit, performing task scheduling, and obtaining the task arrangement information, the method includes: Determine a plug-in file package corresponding to the task scheduling information, wherein the plug-in file package includes plug-in configuration information and a plug-in file; Uploading the plug-in configuration information to a database; Upload the plug-in file to the loading library to obtain the plug-in upload result; According to the plug-in upload result, a plug-in loading instruction is added to the tail of the target plug-in loading queue.

5. The method according to claim 3, characterized in that: When the task arrangement information is a plug-in call, after sending the user demand instruction to the task scheduling unit, performing task scheduling, and obtaining the task arrangement information, the method includes: Get the user's write operation; Determine the scheduled task information according to the user's write operation, wherein the scheduled task information includes a target time, a target plug-in, a target method, and a target operation; Determine a class loader according to the target plug-in in the scheduled task information, so that the class loader loads a target class, an instance of the target class, and a target method instance; According to the target method instance, the target plug-in is controlled to perform the target operation at the target time to obtain a plug-in calling result.

6. The method according to claim 3, characterized in that When the task arrangement information is an execution status instruction, after sending the user demand instruction to the task scheduling unit, performing task scheduling, and obtaining the task arrangement information, the method includes: Determine the target plug-in in the user requirement instruction; According to the target plug-in in the user demand instruction, the plug-in information in the loading library is obtained; Obtaining execution status instruction results according to the plug-in information; The execution status instruction result is uploaded to the interactive interface through the task scheduling unit for display.

7. The method according to claim 1, characterized in that When a system restart or abnormal exit occurs in the service process, when the plug-in processing instruction obtained from the target position in the target plug-in loading queue is a plug-in loading instruction, before the plug-in loader obtains the class loader and the instance of the class loader according to the plug-in loading instruction, the method further includes: Determine the memory image where the target plug-in loading queue is located; Creating a local disk image of the target plug-in loading queue according to the memory image where the target plug-in loading queue is located; The local disk image of the queue is loaded according to the target plug-in, and the unfinished queue data is loaded.

8. The method according to claim 1, characterized in that According to the plug-in loading instruction, the plug-in loader obtains a class loader and an instance of the class loader, including: According to the plug-in loading instruction, the plug-in loader obtains the class loader ClassLoader; Instantiate the class loader ClassLoader to obtain a class loader instance.

9. The method according to claim 1, characterized in that: The method further comprises: When the plug-in processing instruction obtained from the target position in the target plug-in loading queue is a plug-in removal instruction, obtaining a target uninstall plug-in, and a plug-in entry class reference, a plug-in entry method reference, and a plug-in ClassLoader reference of the target uninstall plug-in; Clear the plug-in entry class reference, plug-in entry method reference, and plug-in ClassLoader reference of the target uninstall plug-in; After the plug-in entry class reference, plug-in entry method reference, and plug-in ClassLoader reference of the target uninstall plug-in are cleared, a garbage collection mechanism is triggered to uninstall the target uninstall plug-in from the Java virtual machine to obtain a plug-in uninstall result.

10. A plug-in configuration device, characterized in that: include: an acquisition module, configured to, when the plug-in processing instruction acquired from the target position in the target plug-in loading queue is a plug-in loading instruction, obtain a class loader and an instance of the class loader according to the plug-in loading instruction, and the target plug-in loading queue is a mirror queue of the plug-in loading queue; A loading module, used to create a target URL class loader according to the instance of the class loader, wherein the parent class loader of the target URL class loader is the instance of the class loader; The execution module is used to load the code package to be loaded into the Java virtual machine according to the target URL class loader to obtain the plug-in loading result, wherein the code package to be loaded is the plug-in code package stored in the plug-in loading instruction corresponding to the plug-in loading instruction.

11. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 9 when executed by a processor.

Citation Information

Patent Citations

  • Hot-load method and device and information system

    CN102819438A

  • Method and device for running APK plug-in of application

    CN106909409A

  • Method and device for implementing plug-in type development of client, readable medium and storage controller

    CN107493336A

  • Category loading method, device and equipment and readable storage medium

    CN109697103A

  • Plug-in loading method and electronic terminal

    CN110032400A