A plug-in configuration method, apparatus, device, and storage medium

CN120020712BActive Publication Date: 2026-08-14CHINA UNITED NETWORK COMM GRP CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

[0005]本申请提供一种插件配置方法、装置、设备及存储介质,用以解决现有技术不适用于对组件化程序热更新的场景,会产生逻辑混乱问题,易产生信息泄露问题

Benefits of technology

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

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120020712B_ABST
    Figure CN120020712B_ABST
Patent Text Reader

Abstract

This application provides a plugin configuration method, apparatus, device, and storage medium. The method includes: when a plugin processing instruction obtained from a target location in a target plugin loading queue is a plugin loading instruction, the plugin loader obtains a class loader and an instance of the class loader according to the plugin loading instruction; the target plugin loading queue is a mirror queue of the plugin loading queue; a target URL class loader is created based on the class loader instance; and a code package to be loaded is loaded into the Java Virtual Machine according to the target URL class loader to obtain a plugin loading result, wherein the code package to be loaded is the plugin code package stored corresponding to the plugin loading instruction. This method improves the service efficiency and security of the service process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of plug-in configuration technology, and in particular to a plug-in configuration method, apparatus, device and storage medium. Background Technology

[0002] Hot update refers to the act of updating software directly through software data downloaded by the application itself, without going through the software version update review of the operating store.

[0003] Existing hot update technology completes the hot update of classes in the Java Virtual Machine by starting the Arthas process, connecting to the target process via the Attach API, creating an InstrumentationImpl object, calling the loadClassAndCallAgentmain method to update the class definition, and calling the agentmain method of the specified Agent-Class class.

[0004] However, existing technologies are not suitable for scenarios involving hot updates of componentized programs, as they can lead to logical confusion and information leakage. Summary of the Invention

[0005] This application provides a plugin configuration method, apparatus, device, and storage medium to solve the problem that the prior art is not suitable for scenarios involving hot updates of componentized programs, which can lead to logical confusion and information leakage.

[0006] Firstly, this application provides a plugin configuration method, including:

[0007] When the plugin processing instruction obtained from the target bit in the target plugin loading queue is a plugin loading instruction, the plugin loader obtains the class loader and the instance of the class loader according to the plugin loading instruction, and the target plugin loading queue is a mirror queue of the plugin loading queue.

[0008] Create a target URL class loader based on an instance of a class loader. The parent class loader of the target URL class loader is an instance of the class loader.

[0009] Based on the target URL class loader, the code package to be loaded is loaded into the Java Virtual Machine to obtain the plugin loading result. The code package to be loaded is the plugin code package stored in the plugin loading instruction.

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

[0011] Determine the target plugin loading queue, which includes plugin loading instructions and plugin unloading instructions, and the plugin loading instructions and plugin unloading instructions are arranged in the order of instruction input.

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

[0013] Obtain user request instructions;

[0014] The user's request instruction is sent to the task scheduling unit for task scheduling, and task arrangement information is obtained.

[0015] Based on the task scheduling information, obtain the plugin processing instructions from the target bit in the target plugin loading queue.

[0016] In this application, when the task scheduling information is uploaded by a plugin, after sending the user's request instruction to the task scheduling unit for task scheduling and obtaining the task scheduling information, the method includes:

[0017] Identify the plugin file package corresponding to the task scheduling information. The plugin file package includes plugin configuration information and plugin files.

[0018] Upload the plugin configuration information to the database;

[0019] Upload the plugin file to the loading library to get the plugin upload result;

[0020] Based on the plugin upload results, add a plugin loading instruction to the end of the target plugin loading queue.

[0021] In this application, when the task scheduling information is invoked by a plugin, after sending the user request instruction to the task scheduling unit for task scheduling and obtaining the task scheduling information, the method includes:

[0022] Retrieve user write operations;

[0023] Based on the user's write operation, the scheduled task information is determined. The scheduled task information includes the target time, target plugin, target method, and target operation.

[0024] Based on the target plugin in the scheduled task information, determine the class loader so that the class loader can load the target class, an instance of the target class, and an instance of the target method;

[0025] Based on the target method instance, control the target plugin to execute the target operation at the target time and obtain the plugin call result.

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

[0027] Identify the target plugin in the user's requirements instructions;

[0028] Based on the target plugin in the user's request instructions, obtain the plugin information in the loading library;

[0029] Based on the plugin information, the execution status command results are obtained;

[0030] The plugin execution results are uploaded to the interactive interface for display via the task scheduling unit.

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

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

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

[0034] Load incomplete queue data based on the local disk image of the target plugin's load queue.

[0035] In this application, according to the plugin loading instruction, the plugin loader obtains the class loader and an instance of the class loader, including:

[0036] According to the plugin loading instructions, the plugin loader obtains the class loader (ClassLoader).

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

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

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

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

[0041] After clearing the plugin entry class reference, plugin entry method reference, and plugin ClassLoader reference of the target uninstall plugin, the garbage collection mechanism is triggered to uninstall the target uninstall plugin from the Java Virtual Machine, thus obtaining the plugin uninstallation result.

[0042] Secondly, this application provides a plug-in configuration device, comprising:

[0043] The acquisition module is used to obtain the class loader and the instance of the class loader according to the plugin loading instruction when the plugin processing instruction obtained from the target bit in the target plugin loading queue is a plugin loading instruction. The target plugin loading queue is a mirror queue of the plugin loading queue.

[0044] The loading module is used to create a target URL class loader based on an instance of a class loader. The parent class loader of the target URL class loader is an instance of the class loader.

[0045] 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, and obtain the plugin loading result. The code package to be loaded is the plugin code package stored in the plugin loading instruction.

[0046] Thirdly, this application provides an electronic device, including: a processor and a memory communicatively connected to the processor;

[0047] The memory stores instructions that the computer executes;

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

[0049] Fourthly, this application provides a computer-readable storage medium, comprising: computer-executable instructions stored in the computer-readable storage medium, which, when executed by a processor, are used to implement the method of this application.

[0050] This application provides a plugin configuration method, apparatus, device, and storage medium. When the plugin processing instruction obtained from the target position in the target plugin loading queue is a plugin loading instruction, the plugin loader obtains a class loader and an instance of the class loader according to the plugin loading instruction. The target plugin loading queue is a mirror queue of the plugin loading queue. Based on the instance of the class loader, a target URL class loader is created, with the parent class loader of the target URL class loader being an instance of the class loader. Based on the target URL class loader, the code package to be loaded is loaded into the Java Virtual Machine to obtain the plugin loading result. The code package to be loaded is the plugin code package stored in the means corresponding to the plugin loading instruction. By setting a loading queue, the user's plugin loading and unloading instructions are sorted to avoid plugin dependency logic confusion. By performing disk mirroring on the memory image, unloaded data is retained, avoiding inefficiency caused by data loss due to system restarts or abnormal exits. Simultaneously, the use of a custom URL class loader improves system security. Furthermore, this application uses a hot-swappable service framework, allowing the system to dynamically load or unload plugins at runtime, achieving flexible system expansion and dynamic function updates. This makes the invention suitable for hot-updating scenarios of componentized programs such as automatic inspection. Attached Figure Description

[0051] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0052] Figure 1 A schematic diagram illustrating a scenario for the plugin configuration method provided in an embodiment of this application;

[0053] Figure 2 A flowchart illustrating the plug-in configuration method provided in this application embodiment;

[0054] Figure 3 A flowchart illustrating another plugin configuration method provided in an embodiment of this application;

[0055] Figure 4 This is a schematic diagram of the plug-in configuration device provided in the embodiments of this application;

[0056] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.

[0057] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation

[0058] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0059] Existing technologies, when performing hot updates, start an Arthas process under the same user permissions 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 (JVM) via the Attach API (Application Programming Interface). It 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 javaagent MANIFEST.MF to complete the JVM hot update process. However, because the Attach API is not a standard JVM API, it is not compatible with all JVMs. Furthermore, existing technologies are not suitable for hot updates of componentized programs, such as automated inspections, reconciliation, and testing. Multiple users updating plugins may lead to plugin dependency logic confusion, service process restarts can cause data loss, resulting in inefficiency. Existing technologies require starting third-party applications, creating vulnerabilities in the business system and increasing the risk of information leakage.

[0060] Addressing the shortcomings of existing technologies in hot updates, this application establishes a loading queue to sort user plugin loading and unloading commands, avoiding plugin dependency logic confusion. By mapping memory images to disk images, unloaded data is retained, preventing inefficiencies caused by data loss due to system restarts or abnormal exits. Furthermore, a custom URL class loader enhances system security. Additionally, this application employs a hot-swappable service framework, allowing the system to dynamically load or unload plugins at runtime, enabling flexible system expansion and dynamic function updates. This makes the invention suitable for hot update scenarios in component-based programs such as automated inspection.

[0061] The plugin configuration method provided in this application aims to solve the above-mentioned technical problems in the prior art.

[0062] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.

[0063] Figure 1 This is a schematic diagram illustrating an application scenario of the plug-in configuration method provided in an embodiment of this application. For example... Figure 1 As shown, the execution entity of this plugin configuration method can be a plugin configuration system, which includes: a web console, a server, a loading library, and a database.

[0064] A web console is a tool used for debugging and monitoring web browsers and web applications. It typically provides an interactive interface that allows developers to enter JavaScript code to inspect the state of a webpage, debug errors, and monitor performance. In the plugin configuration system of this application, the web console includes the following functional entry points: plugin upload, plugin loading, plugin uninstallation, plugin invocation, and execution status.

[0065] The server side refers to software running on a server, typically used to provide some kind of network service. This service can refer to providing resources to clients, storing client data, etc. The client can be an ordinary computer; as long as it has a connection to the server and is authorized by the server, it can use the server's services. In the plugin configuration system of this application, the server side uses 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, which avoids dependency chaos. The plugin loader core is used to implement plugin loading and unloading and is the core controller for loading plugins into and removing plugins from the system. The task scheduler is used to manage the plugin call execution cycle and trigger plugin call execution. The plugin call core is used to implement dynamic plugin calls.

[0066] A 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 a program runs, it can load and use these libraries by calling functions provided by the system's dynamic linker. Furthermore, environment variables and other methods can be used to specify which shared libraries need to be pre-loaded and to change the search path for shared libraries. In the plugin configuration system of this application, library loading categorizes and manages plugin resources into three stages: pending loading, loaded, and unloaded.

[0067] A database is a repository for organizing, storing, and managing data according to a data structure. It is a large, organized, shareable, and uniformly managed collection of data stored permanently on a computer. It provides fast access and manipulation of the stored large amounts of data. A database typically consists of one or more tables, each containing multiple rows and columns. Each row represents a record, and each column represents an attribute. In this application, the database is primarily used to store data information within the plugin file package.

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

[0069] In some embodiments, the execution subject of the plugin configuration method provided in this application can also be a server. The server can be a device such as a mobile phone, computer, or tablet. This embodiment does not impose any particular restrictions on the implementation method of the execution subject, as long as the execution subject can, when the plugin processing instruction obtained from the target bit in the target plugin loading queue is a plugin loading instruction, obtain the class loader and an instance of the class loader according to the plugin loading instruction, and the target plugin loading queue is a mirror queue of the plugin loading queue; 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 an instance of the class loader; and load the code package to be loaded into the Java Virtual Machine according to the target URL class loader to obtain the plugin loading result.

[0070] The plugin loading queue refers to a queue waiting for plugin configuration, containing a list of plugins to be loaded, a list of plugins to be uninstalled, and so on. When the plugin loader begins loading plugins, it removes the plugin from the queue and loads it into the runtime environment. If a plugin depends on other plugins, its loading is deferred until the dependent plugins are loaded. In this embodiment, the plugin loading queue manages the order of all plugin loading and unloading processes through a Java Queue object. Its first-in-first-out (FIFO) characteristic ensures that plugins that initiate loading or unloading first are processed first.

[0071] Figure 2 This is a flowchart illustrating the plugin configuration method provided in this embodiment. The executing entity of this method can be a server or other servers; this embodiment does not impose any special limitations here. Figure 2 As shown, the method may include:

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

[0073] Plugin processing commands refer to instructions that operate on plugins, including plugin loading, plugin unloading, and plugin invocation. These commands can be transmitted via command line, configuration files, or graphical interfaces.

[0074] The class loader is a crucial component of the Java Virtual Machine (JVM). It is responsible for loading the bytecode of Java classes into the JVM and dynamically linking and initializing classes at runtime. The class loader employs a parent delegation model, meaning that when a class loader needs to load a class, it first delegates the task to its parent class loader. Only if the parent class loader cannot load the class will the class loader attempt to load it itself. This hierarchical relationship allows for class sharing and isolation, improving code security and reliability. A class loader instance refers to the object actually loaded by the class loader.

[0075] Upon receiving a plugin loading instruction, the task scheduler obtains the target plugin's ID, matches the target plugin's source file from the plugin set to be loaded in the loading library, matches the target plugin's configuration information from the database, obtains a class loader instance through the Java Virtual Machine's core class loader, creates a custom URL class loader, and uses the Java reflection mechanism to load the plugin code package to be installed using the addURL method, thus completing the plugin loading task.

[0076] Specifically, when obtaining a class loader instance through the core class loader of the Java Virtual Machine, if it is a Spring project, it is obtained using ClassUtils.getDefaultClassLoader().

[0077] The addURL method loads the plugin code package to be installed. It can pass in the method name and parameter types, obtain the method object through the getDeclareMethod of the Class object, modify the accessibility of the method object using setAccessible(true), and use the obtained class loader instance to execute its addURL method through invoke to load the code package to be loaded into the JVM, thereby completing the plugin loading task.

[0078] In this embodiment of the application, when the plugin processing instruction obtained from the target bit 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:

[0079] Determine the target plugin loading queue, which includes plugin loading instructions and plugin unloading instructions, and the plugin loading instructions and plugin unloading instructions are arranged in the order of instruction input.

[0080] In this application, when a service process restarts or exits abnormally, the data stored in the system memory image is lost and needs to be reloaded, resulting in low efficiency. Therefore, when it is detected that the system needs to restart or is about to exit abnormally, this embodiment first performs disk image mapping on the unloaded data. After the system process restarts or exits abnormally and logs back in, the unloaded queue data is retrieved from the disk image data and the loading task continues.

[0081] In this embodiment of the application, when the plugin processing instruction obtained from the target bit 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:

[0082] Obtain user request instructions;

[0083] The user's request instruction is sent to the task scheduling unit for task scheduling, and task arrangement information is obtained.

[0084] Based on the task scheduling information, obtain the plugin processing instructions from the target bit in the target plugin loading queue.

[0085] The user's required commands include plugin loading commands, plugin unloading commands, plugin uploading commands, plugin invocation commands, and execution status commands.

[0086] Specifically, the task scheduler matches tasks according to user requests. This can mean that when the user's request is a plugin loading or unloading command, the task scheduler controls the plugin loader core to read the plugin loading queue to complete the command; when the user's request is a plugin upload command, the task scheduler uploads the configuration information from the plugin package to the database and uploads the plugin files from the plugin package to the set of plugins to be loaded in the loading library; when the user's request is a plugin invocation command, the task scheduler obtains the user-written scheduled task and controls the plugin invocation core to complete the plugin execution according to the scheduled task; and when the user's request is an execution status command, the task scheduler retrieves the execution status of the target plugin from the loading library.

[0087] Specifically, based on the task arrangement information, the plugin processing instruction is obtained from the target position in the target plugin loading queue. The plugin loading queue can be specified and sent to the plugin loader. According to the task arrangement, user request instructions are added to the end of the plugin loading queue. The user request instructions include plugin loading instructions and plugin unloading instructions. Instructions are pulled from the head of the plugin loading queue to obtain the target position plugin processing instruction. The second user request instruction in the plugin loading queue is moved to the head of the queue to become the new target position plugin processing instruction, waiting for the plugin loader to read it.

[0088] The plugin loading and unloading instructions in the plugin loading queue follow the rules of the platform-level scheduled tasks. The platform-level scheduled tasks provide a fixed polling service to pull target-position plugin processing instructions from the plugin loading queue. When the target-position plugin processing instructions finish executing, the task scheduler controls the plugin loader to read new target-position plugin processing instructions from the plugin loading queue according to the scheduled task information of the user's request instructions.

[0089] Specifically, the system obtains user requests from the function entry point of the web console. These requests are then sent to the task scheduler via the server-side API interface. The task scheduler matches the user requests with task assignments. If the task assignment is a plugin loading or unloading command, the plugin processing command is obtained from the target position in the plugin loading queue.

[0090] In this embodiment of the application, when the task arrangement information is uploaded by a plugin, after sending the user request instruction to the task scheduling unit for task scheduling and obtaining the task arrangement information, the method includes:

[0091] Identify the plugin file package corresponding to the task scheduling information. The plugin file package includes plugin configuration information and plugin files.

[0092] Upload the plugin configuration information to the database;

[0093] Upload the plugin file to the loading library to get the plugin upload result;

[0094] Based on the plugin upload results, add a plugin loading instruction to the end of the target plugin loading queue.

[0095] In this process, users select information such as plugin package, plugin name, and entry point in a web form. Based on the user's input, the plugin upload command is imported into the task scheduler via the server-side API interface. The task scheduler determines the plugin's configuration information, plugin file, and plugin ID based on the plugin upload command, stores the target plugin's plugin ID, creates a plugin information record in the database, uploads the plugin's configuration information to the database, uploads the plugin file to the set of plugins to be loaded in the loading library, and pushes the plugin loading command to the end of the plugin loading queue, waiting for the platform-level scheduled task to poll the plugin loading queue and receive the command to start loading the plugin.

[0096] In this embodiment of the application, when the task arrangement information is a plugin call, after sending the user request instruction to the task scheduling unit for task scheduling and obtaining the task arrangement information, the method includes:

[0097] Retrieve user write operations;

[0098] Based on the user's write operation, the scheduled task information is determined. The scheduled task information includes the target time, target plugin, target method, and target operation.

[0099] Based on the target plugin in the scheduled task information, determine the class loader so that the class loader can load the target class, an instance of the target class, and an instance of the target method;

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

[0101] Specifically, the task scheduler receives the user's plugin invocation command through the web console and, based on the scheduled task information in the user's plugin invocation command, triggers subsequent execution operations at the target execution time.

[0102] The subsequent execution operations can refer to determining the target plugin from the loaded plugin set in the loading library based on the plugin ID in the plugin invocation instruction, controlling the plugin invocation core to find the corresponding custom class loader based on the target plugin, loading the target class through ClassLoader.loadClass(), obtaining the target class instance through Class.newInstance(), obtaining the target method instance through Class.getDeclaredMethod(), triggering plugin execution through the invoke method of the target method instance, receiving the plugin execution result object and sending it to the task scheduler, and completing the plugin execution.

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

[0104] In this embodiment of the application, when the task arrangement information is an execution status instruction, after sending the user request instruction to the task scheduling unit for task scheduling and obtaining the task arrangement information, the method includes:

[0105] Identify the target plugin in the user's requirements instructions;

[0106] Based on the target plugin in the user's request instructions, obtain the plugin information in the loading library;

[0107] Based on the plugin information, the execution status command results are obtained;

[0108] The plugin execution results are uploaded to the interactive interface for display via the task scheduling unit.

[0109] The execution status function entry point of the web console detects the user's write operation, imports the user's execution status command into the task scheduler through the server-side API interface, and the task scheduler retrieves the execution status of the target plugin from the loading library based on the plugin information in the execution status command, and uploads the execution status of the target plugin to the interactive interface of the web console execution status window.

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

[0111] Determine the memory image where the target plugin loading queue resides;

[0112] Create a local disk image of the target plugin loading queue based on the memory image where the target plugin loading queue is located;

[0113] Load incomplete queue data based on the local disk image of the target plugin's load queue.

[0114] Disk imaging refers to the process of completely copying all data from one disk to another. This process can be accomplished using specialized disk imaging software, such as OSDeployer. Disk imaging can be used to back up and restore operating systems, applications, data, etc., and can also be used to quickly deploy the same configuration across multiple computers.

[0115] Before restarting the server due to system process restart or abnormal exit, the unloaded data in the memory image is mapped to the local disk. After restarting the server, the task scheduler controls the plugin loader to read the data to be loaded from the local disk image.

[0116] In this embodiment of the application, according to the plugin loading instruction, the plugin loader obtains the class loader and an instance of the class loader, including:

[0117] According to the plugin loading instructions, the plugin loader obtains the class loader (ClassLoader).

[0118] Instantiate the ClassLoader class to obtain a ClassLoader instance.

[0119] In this embodiment of the application, the method further includes:

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

[0121] Clear the plugin entry class reference, plugin entry method reference, and plugin ClassLoader reference for the target uninstalled plugin;

[0122] After clearing the plugin entry class reference, plugin entry method reference, and plugin ClassLoader reference of the target uninstall plugin, the garbage collection mechanism is triggered to uninstall the target uninstall plugin from the Java Virtual Machine, thus obtaining the plugin uninstallation result.

[0123] When the user's request is a plugin disassembly command, the task scheduler receives the plugin disassembly command through the server-side API interface. Based on the plugin ID in the plugin disassembly command, it determines the target plugin from the set of loaded plugins in the loading library. Using the JVM garbage collection mechanism, it sets the reference to the target plugin's entry method and entry class to null, sets the URLClassLoader object of the corresponding plugin to null, and then triggers the System.gc() mechanism to unload the plugin from the JVM. The unloaded target plugin is then stored in the set of unloaded plugins in the loading library.

[0124] S202. Create the target URL class loader based on the class loader instance.

[0125] In this context, the parent class loader of the target URL class loader is an instance of the class loader.

[0126] Using a custom URL class loader can extend the functionality of the Java class loader, enabling custom class loading methods. A custom URL class loader can load class files from the local file system or from the network, thus achieving dynamic class loading. Furthermore, a custom URL class loader can also achieve class isolation, avoiding conflicts between different versions of class files. For example, when it's necessary to load different versions of class files within the same application, a custom URL class loader can be used to isolate classes, thereby avoiding conflicts and improving the security of the service process.

[0127] S203. Based on the target URL class loader, load the code package to be loaded into the Java Virtual Machine to obtain the plugin loading result.

[0128] The code package to be loaded is the plugin code package stored in the plugin loading instruction.

[0129] The plugin configuration method provided in this application uses a hot-swappable service framework and is managed via a web console. It isolates the plugin loading library outside the server, and plugin execution is hosted on a unified server-side service platform with unified scheduling and monitoring. This eliminates the need for server updates and restarts except in specific scenarios, and automatically restores the loading of the original plugins after a restart. By sorting the plugin loading and unloading commands entered by the user in the web console, a plugin loading queue is generated, ensuring that the loading and unloading process is controllable during multi-user collaborative operations. Furthermore, to prevent data loss due to server restarts or abnormal exits, this application maps memory images to store unloaded data on the local disk.

[0130] Figure 3 This is a flowchart illustrating another plugin configuration method provided in an embodiment of this application. Figure 3 As shown, the method includes:

[0131] S301, Obtain the user's request instructions.

[0132] Specifically, the user's request commands from the web console are sent to the task scheduler via the server-side API.

[0133] S302. Determine the task arrangement based on the user's requirements and instructions.

[0134] The task scheduler matches user requests with task assignments to determine the target plugin and the target task assignment.

[0135] S303, Control the plugin to execute tasks according to task schedule.

[0136] When the task is assigned as a plugin loading instruction, the task scheduler controls the plugin loader to read the plugin loading queue, determine the target plugin information, and the plugin loader core obtains the class loader ClassLoader based on the target plugin information. It then instantiates the class loader ClassLoader to obtain a class loader instance, creates a custom URLClassLoader based on the top-level class loader instance, and designates the top-level class loader instance as the parent class loader. It then obtains the native code package from the plugin set to be loaded in the loading library, loads the native code package into the JVM through the URLClassLoader, obtains the plugin loading result, and uploads the plugin loading result to the web console interactive interface through the task scheduler.

[0137] The `addURL` method of `URLClassLoader` cannot be called directly. Its scope modifier is `protected`, meaning it cannot be called directly by classes outside the target classpath that are not subclasses. This embodiment uses Java reflection to invoke the protected method.

[0138] When the task is assigned as a plugin unloading instruction, the task scheduler controls the plugin loader to read the plugin loading queue, determine the target unloading plugin information, clear the target unloading plugin's entry method, entry class reference, and URLClassLoader object loaded by the target unloading plugin, so that the clearing operation triggers the garbage collection mechanism, unloads the plugin from the JVM, and obtains the plugin unloading result.

[0139] When the task is scheduled as a plugin invocation command, the task scheduler obtains the scheduled task content written by the user in the plugin invocation command, determines the target plugin based on the scheduled task content written by the user, determines the custom ClassLoader based on the target plugin, loads the target class based on the custom ClassLoader, instantiates the target class instance based on the target class instance, determines the target method instance based on the target method instance, triggers the plugin to execute the scheduled task based on the target method instance, obtains the plugin execution result, and uploads the plugin execution result to the interactive interface of the web console through the task scheduler.

[0140] When the task is assigned as a plugin upload instruction, the task scheduler determines the plugin's file package, which includes the plugin's configuration information and plugin files. The plugin's configuration information is uploaded to the database, and the plugin files are uploaded to the loading library to obtain the plugin upload result.

[0141] When a task is assigned as an execution status instruction, the task scheduler determines the target plugin data in the execution status instruction, obtains the target plugin information from the loaded plugin set in the loading library based on the target plugin data, 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 This is a schematic diagram of the plug-in configuration device provided in the embodiments of this application, such as... Figure 4 As shown, the plug-in configuration device 40 includes: an acquisition module 401, a loading module 402, and an execution module 403. Wherein:

[0143] The acquisition module 401 is used to acquire the class loader and an instance of the class loader according to the plugin loading instruction when the plugin processing instruction acquired from the target bit in the target plugin loading queue is a plugin loading instruction. The target plugin loading queue is a mirror queue of the plugin loading queue.

[0144] Loading module 402 is used to create a target URL class loader based on an instance of a class loader, wherein the parent class loader of the target URL class loader is an instance of the class loader;

[0145] Execution module 403 is used to load the code package to be loaded into the Java Virtual Machine according to the target URL class loader, and obtain the plugin loading result, wherein the code package to be loaded is the plugin code package stored in the plugin loading instruction.

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

[0147] When the plugin processing instruction obtained from the target bit in the target plugin loading queue is a plugin loading instruction, the method further includes the following steps before the plugin loader obtains the class loader and an instance of the class loader according to the plugin loading instruction:

[0148] Determine the target plugin loading queue, which includes plugin loading instructions and plugin unloading instructions, and the plugin loading instructions and plugin unloading instructions are arranged in the order of instruction input.

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

[0150] Obtain user request instructions;

[0151] The user's request instruction is sent to the task scheduling unit for task scheduling, and task arrangement information is obtained.

[0152] Based on the task scheduling information, obtain the plugin processing instructions from the target bit in the target plugin loading queue.

[0153] In this embodiment of the application, the acquisition module 401 can also be specifically used for:

[0154] Identify the plugin file package corresponding to the task scheduling information. The plugin file package includes plugin configuration information and plugin files.

[0155] Upload the plugin configuration information to the database;

[0156] Upload the plugin file to the loading library to get the plugin upload result;

[0157] Based on the plugin upload results, add a plugin loading instruction to the end of the target plugin loading queue.

[0158] In this embodiment of the application, the acquisition module 401 can also be specifically used for:

[0159] Retrieve user write operations;

[0160] Based on the user's write operation, the scheduled task information is determined. The scheduled task information includes the target time, target plugin, target method, and target operation.

[0161] Based on the target plugin in the scheduled task information, determine the class loader so that the class loader can load the target class, an instance of the target class, and an instance of the target method;

[0162] Based on the target method instance, control the target plugin to execute the target operation at the target time and obtain the plugin call result.

[0163] In this embodiment of the application, the acquisition module 401 can also be specifically used for:

[0164] Identify the target plugin in the user's requirements instructions;

[0165] Based on the target plugin in the user's request instructions, obtain the plugin information in the loading library;

[0166] Based on the plugin information, the execution status command results are obtained;

[0167] The plugin execution results are uploaded to the interactive interface for display via the task scheduling unit.

[0168] In this embodiment of the application, the acquisition module 401 can also be specifically used for:

[0169] Determine the memory image where the target plugin loading queue resides;

[0170] Create a local disk image of the target plugin loading queue based on the memory image where the target plugin loading queue is located;

[0171] Load incomplete queue data based on the local disk image of the target plugin's load queue.

[0172] In this embodiment of the application, the acquisition module 401 can also be specifically used for:

[0173] According to the plugin loading instructions, the plugin loader obtains the class loader (ClassLoader).

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

[0175] In this embodiment of the application, the execution module 403 can also be specifically used for:

[0176] When the plugin processing instruction obtained from the target bit in the target plugin loading queue is a plugin unloading instruction, obtain the target unloading plugin, as well as the plugin entry class reference, plugin entry method reference, and plugin ClassLoader reference of the target unloading plugin;

[0177] Clear the plugin entry class reference, plugin entry method reference, and plugin ClassLoader reference for the target uninstalled plugin;

[0178] After clearing the plugin entry class reference, plugin entry method reference, and plugin ClassLoader reference of the target uninstall plugin, the garbage collection mechanism is triggered to uninstall the target uninstall plugin from the Java Virtual Machine, thus obtaining the plugin uninstallation result.

[0179] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 5 As 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. The processor 501, memory 502, and communication component 503 are connected via a bus 504.

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

[0182] The specific implementation process of processor 501 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.

[0183] In the above Figure 5In the illustrated embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.

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

[0185] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.

[0186] In some embodiments, a computer program product is also provided, comprising a computer program or instructions that, when executed by a processor, implement the steps in any of the plug-in configuration methods described above.

[0187] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.

[0188] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.

[0189] Therefore, embodiments of this application provide a computer-readable storage medium storing a plurality of instructions that can be loaded by a processor to execute the steps in any of the plug-in configuration methods provided in embodiments of this application.

[0190] The storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.

[0191] According to one aspect of this application, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium.

[0192] Since the instructions stored in the storage medium can execute the steps in any of the plug-in configuration methods provided in the embodiments of this application, the beneficial effects that any of the plug-in configuration methods provided in the embodiments of this application can achieve can be realized. For details, please refer to the previous embodiments, which will not be repeated here.

[0193] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.

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

Claims

1. A plugin configuration method, characterized in that, include: Obtain user request instructions; The user request instruction is sent to the task scheduling unit for task scheduling to obtain task arrangement information. Based on the task arrangement information, the user request instruction is added to the end of the plugin loading queue to obtain the target plugin loading queue. The target plugin loading queue includes plugin loading instructions and plugin unloading instructions, and the plugin loading instructions and the plugin unloading instructions are arranged in the order of instruction input. When the plugin processing instruction obtained from the target bit in the target plugin loading queue is a plugin loading instruction, the plugin loader obtains the class loader and an instance of the class loader according to the plugin loading instruction; Based on 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 the plugin loading result, wherein the code package to be loaded is the plugin code package stored in the plugin loading instruction; When a system restart or abnormal exit occurs during the service process, before the plugin loader obtains the class loader and an instance of the class loader according to the plugin loading instruction, and when the plugin processing instruction obtained from the target bit in the target plugin loading queue is a plugin loading instruction, the method further includes: Determine the memory image where the target plugin loading queue resides; Based on the memory image where the target plugin loading queue is located, create a local disk image of the target plugin loading queue; Load the incomplete queue data based on the local disk image of the target plugin loading queue.

2. The method according to claim 1, characterized in that, When the task arrangement information is a plugin upload, after sending the user request instruction to the task scheduling unit for task scheduling and obtaining the task arrangement information, the method includes: Determine the plugin file package corresponding to the task scheduling information, wherein the plugin file package includes plugin configuration information and plugin files; Upload the plugin configuration information to the database; Upload the plugin file to the loading library to obtain the plugin upload result; Based on the plugin upload results, add a plugin loading instruction to the end of the target plugin loading queue.

3. The method according to claim 1, characterized in that, When the task scheduling information is a plugin call, after sending the user request instruction to the task scheduling unit for task scheduling and obtaining the task scheduling information, the method includes: Retrieve user write operations; Based on the user's write operation, the scheduled task information is determined, including the target time, target plugin, target method, and target operation; Based on the target plugin in the scheduled task information, a class loader is determined so that the class loader loads the target class, an instance of the target class, and an instance of the target method. Based on the target method instance, the target plugin is controlled to perform the target operation at the target time, and the plugin call result is obtained.

4. The method according to claim 1, characterized in that, When the task arrangement information is an execution status instruction, after sending the user request instruction to the task scheduling unit for task scheduling and obtaining the task arrangement information, the method includes: Identify the target plugin in the user request instruction; Based on the target plugin in the user's request instruction, obtain the plugin information in the loading library; Based on the plugin information, the execution status instruction result is obtained; The execution status command results are uploaded to the interactive interface for display via the task scheduling unit.

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

6. The method according to claim 1, characterized in that, The method further includes: When the plugin processing instruction obtained from the target bit in the target plugin loading queue is a plugin disassembly instruction, obtain the target uninstall plugin, as well as the plugin entry class reference, plugin entry method reference, and plugin ClassLoader reference of the target uninstall plugin; Clear the plugin entry class reference, plugin entry method reference, and plugin ClassLoader reference of the target uninstall plugin; After clearing the plugin entry class reference, plugin entry method reference, and plugin ClassLoader reference of the target uninstall plugin, the garbage collection mechanism is triggered to uninstall the target uninstall plugin from the Java Virtual Machine, thus obtaining the plugin uninstallation result.

7. A plug-in configuration device, characterized in that, include: The acquisition module is used to acquire user request instructions; send the user request instructions to the task scheduling unit for task scheduling and obtain task arrangement information. Based on the task arrangement information, the user request instruction is added to the end of the plugin loading queue to obtain the target plugin loading queue. The target plugin loading queue includes plugin loading instructions and plugin unloading instructions, and the plugin loading instructions and the plugin unloading instructions are arranged in the order of instruction input. The acquisition module is further configured to, when the plugin processing instruction obtained from the target bit in the target plugin loading queue is a plugin loading instruction, obtain the class loader and an instance of the class loader according to the plugin loading instruction; A loading module is used to create a target URL class loader based on an instance of the class loader, wherein the parent class loader of the target URL class loader is an instance of the class loader; An execution module is used to load the code package to be loaded into the Java Virtual Machine according to the target URL class loader, and obtain the plugin loading result, wherein the code package to be loaded is the plugin code package stored in the plugin loading instruction; When a system restart or abnormal exit occurs during the service process, the acquisition module is also used to determine the memory image where the target plugin loading queue is located; create a local disk image of the target plugin loading queue based on the memory image where the target plugin loading queue is located; and load the incomplete queue data based on the local disk image of the target plugin loading queue.

8. An electronic device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the method as described in any one of claims 1 to 6.

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

10. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Hot-load method and device and information system

    CN102819438A

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

    CN109697103A

  • Instruction scheduling method, artificial intelligence chip, computer equipment and storage medium

    CN113590199A