Program plug-in loading method, device and computer equipment

Through unified compression and merge management of plug-in packages and on-demand loading of custom class loaders, the problem of repeated dependency packages occupying a large amount of memory in plug-in dependencies is solved, achieving a balance between the efficiency of plug-in package dependencies and memory usage, and ensuring that plug-ins stability and multi-version coexistence capabilities.

CN116991491BActive Publication Date: 2024-10-25CHONGQING COMM CONSTR CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210741427.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-28
Publication Date
2024-10-25
Estimated Expiration
2042-06-28

AI Technical Summary

Technical Problem

In the traditional program plug-in loading method, the dependencies between plug-ins are independent, resulting in repeated dependent packages occupying a large amount of memory space, and the loading method of the parent delegation mechanism may cause package conflicts, affecting the stability of the plug-in and multi-version co-compatibility.

Method used

Through unified compression and merger management of plug-in packages, a second program package is generated, and a custom class loader is used to load dependent packages on demand when the application is running, establishing dependency links between plug-ins and dependent packages to avoid duplicate file name conflicts. , to achieve a balance between the efficiency of plug-in package dependencies and memory usage.

Benefits of technology

Effectively save disk space, improve plug-in loading efficiency, reduce memory usage, and ensure plug-in stability and multi-version coexistence capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116991491B_ABST
    Figure CN116991491B_ABST
Patent Text Reader

Abstract

The present invention provides a program plug-in loading method, device, computer equipment and computer program, wherein the loading method comprises: S1: defining a plug-in package and a dependent package of an application; S2: completing the deployment of the plug-in package and the dependent package; S3: establishing a dependent link between the plug-in and the corresponding dependent package; S4: establishing a plug-in description file under each plug-in position, wherein the plug-in description file contains plug-in description information; S5: uploading the plug-in description information to a metadata repository; S6: when the application is running, using a custom class loader to load the target plug-in on demand. The present invention solves the problem of dependent package conflicts that are prone to occur during the JAVA plug-in loading process in the prior art, and can effectively save disk space.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a program plug-in loading method, device and computer equipment. Background Art

[0002] The plug-in loading method of traditional programs uses a loading method based on the parent delegation model, which often has some problems. For example, when different plug-in modules or different versions of a program have dependencies corresponding to a specific version of a program package, if the same version packages of the same plug-in are loaded using the parent delegation mechanism, package conflicts may occur. At this time, the plug-ins hope to have an independent loader to load the packages they need. Therefore, a loading method that breaks the parent delegation mechanism has emerged. The plug-in first loads and searches for the required package. If it cannot find the package, it searches upward to ensure the stability of the plug-in and the compatibility of multiple plug-ins or multiple versions of plug-ins.

[0003] But this also caused some new problems. For example, the dependencies between plug-ins are independent of each other. When some plug-ins have common dependency packages, the duplicate dependency packages will take up a lot of space. This problem will become more and more obvious as the number of plug-ins increases.

[0004] The purpose of the present invention is to provide a method to uniformly compress and merge plug-in package dependencies during program installation, and to implement a class loading method based on breaking parent delegation, so as to load the plug-in on demand when it is used, thereby achieving a balance between the efficiency of plug-in package dependency loading and memory usage, and reducing the volume occupied by software installation. Summary of the invention

[0005] In view of the deficiencies in the prior art, according to an embodiment of the present invention, a method, apparatus and computer device for loading a program plug-in are provided, which solve the problem in the prior art that common dependencies in the plug-in loading process will occupy a large amount of memory space.

[0006] According to an embodiment of the present invention, in a first aspect, a program plug-in loading method is proposed, and the main steps include S1: defining a plug-in package and a dependency package of an application; the plug-in package includes a plurality of plug-ins, and each plug-in includes a plurality of first program packages.

[0007] S2: Complete the deployment of the plug-in package and dependent packages.

[0008] S21: renaming all first program packages in the plug-in package with their own file storage verification code information to generate second program packages.

[0009] S22: Move the second program package to the directory where the dependent package is located, and replace files with duplicate file names when they appear.

[0010] S3: Establish dependency links between plugins and corresponding dependent packages.

[0011] S4: Create a plug-in description file under each plug-in location, where the plug-in description file contains plug-in description information.

[0012] S5: Upload the plug-in description information to the metadata database.

[0013] S6: When the application is running, use the custom class loader to load the target plug-in on demand.

[0014] In one embodiment, step S3 includes S31: creating a link file pointing to the generated second program package at the original location of the first program package of the plug-in.

[0015] S32: Rename the link file with the original name of the first program package.

[0016] In one embodiment, the plug-in description information includes a plug-in name, a plug-in icon, a plug-in category, a plug-in location information and / or a plug-in version.

[0017] In one embodiment, the step S6 includes S61: finding a target plug-in to be loaded through a metadata database.

[0018] S62: Load the plug-in description information of the target plug-in into the memory of the application.

[0019] S63: Obtain plug-in location information of the target plug-in.

[0020] S64: Load the second program package pointed to by the link file under the target plug-in location through the custom class loader.

[0021] In one embodiment, before step S6, the method further includes: displaying plug-in description information of all available plug-ins through a display interface.

[0022] In a second aspect, in one embodiment, a program plug-in loading device is provided, comprising: a plug-in installation module, a metadata library, and a plug-in loading and running module.

[0023] The plug-in installation module is used to analyze and process the plug-in package of the target plug-in and the corresponding dependent package when the application is installed, so as to compress, store and install the target plug-in.

[0024] The plug-in loading and running module is used to use a custom class loader to load the target plug-in on demand when the application calls the target plug-in.

[0025] In one embodiment, the plug-in installation module includes: a definition module, used to define a plug-in package and a dependency package of an application.

[0026] The deployment module is used to complete the deployment of plug-in packages and dependent packages.

[0027] The deployment module includes a renaming unit and a moving unit.

[0028] The renaming unit is used to rename all first program packages in the plug-in package with file storage verification code information to generate a second program package; the moving unit is used to move the second program package to the directory where the dependent package is located and replace files with duplicate file names when they appear.

[0029] The link relationship establishment module is used to establish the dependency link between the plug-in and the corresponding dependent package.

[0030] The link relationship establishment module includes a link file establishment module and a link file renaming module.

[0031] The link file creation module is used to create a link file pointing to the generated second program package at the original position of the first program package of the plug-in; the link file renaming module is used to rename the link file with the original name of the first program package.

[0032] The plug-in description file creation module is used to create a plug-in description file under each plug-in location, and the plug-in description file contains plug-in description information.

[0033] The data uploading module is used to upload the plug-in description information to the metadata database.

[0034] In one embodiment, the plug-in loading and running module includes: a plug-in search module, which is used to find the target plug-in to be loaded through the metadata database.

[0035] The plug-in information loading module is used to load the plug-in description information of the target plug-in into the memory of the application.

[0036] The plug-in location information acquisition module is used to obtain the plug-in location information of the target plug-in.

[0037] The plug-in loading module is used to load the second program package pointed to by the connection file under the target plug-in location through a custom class loader.

[0038] In a third aspect, a computer device is proposed, comprising: a memory and a processor, wherein the memory stores a computer program, and the processor is used to call the computer program to execute any operation step in the program plug-in loading method provided by the present invention.

[0039] In a fourth aspect, a computer program is proposed, characterized in that when the program is called, it is used to execute any operation step in the program plug-in loading method provided by the present invention.

[0040] Compared with the prior art, the present invention has the following beneficial effects: 1. Before the plug-in is loaded, the program package in the plug-in is renamed using the file storage verification code information, and the renamed program package is migrated to the dependent package area, and a file with a duplicate file name is replaced when one appears, thereby preventing dependent package conflicts. Since only one copy of the same program package is retained in the end, disk space can also be effectively saved.

[0041] 2. Before loading the plug-in, establish a dependency link between the plug-in and the corresponding dependent package, and use a custom class loader to load the dependency link and the corresponding dependent package on disk on demand when the plug-in needs to be loaded, which improves the efficiency of plug-in loading and reduces the memory space occupied when the plug-in is installed. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 The following is a basic flow chart of a program plug-in loading method according to an embodiment of the present invention.

[0043] Figure 2 4 is a basic flow chart of step S3 of an embodiment of the present invention.

[0044] Figure 3 FIG. 4 is a basic flow chart of step S6 of an embodiment of the present invention.

[0045] Figure 4 It is a structural diagram of a program plug-in loading device according to another embodiment of the present invention. DETAILED DESCRIPTION

[0046] The technical solution of the present invention is further described below in conjunction with the accompanying drawings and embodiments.

[0047] like Figure 1 As shown, according to an embodiment of the present invention, in the first aspect, a program plug-in loading method is proposed, and the main steps include S1: defining a plug-in package and a dependency package of an application; the plug-in package contains several plug-ins, and each plug-in contains several first program packages.

[0048] S2: Complete the deployment of the plug-in package and dependent packages.

[0049] Create a plug-in installation directory, which includes a dependency package storage subdirectory and a plug-in directory. The plug-in directory also includes a dependency directory. When the application receives a plug-in installation instruction request from the user, the target plug-in is decompressed into a temporary directory.

[0050] S21: renaming all first program packages in the plug-in package with their own file storage verification code information to generate second program packages.

[0051] S22: Move the second program package to the directory where the dependent package is located, and replace files with duplicate file names when they appear.

[0052] Specifically, read the plug-ins and all the first program packages in the plug-in installation directory, obtain the MD5 information of each first program package, and rename each first program package with the MD5 information with the MD5 information and move it to the dependent package storage subdirectory in the plug-in installation main directory; if there is a file with the same name in the target directory, replace the file.

[0053] S3: Establish dependency links between plugins and corresponding dependent packages.

[0054] S4: Create a plug-in description file under each plug-in location, where the plug-in description file contains plug-in description information.

[0055] S5: Upload the plug-in description information to the metadata database.

[0056] S6: When the application is running, use the custom class loader to load the target plug-in on demand.

[0057] In the above embodiment, before the plug-in is loaded, the program package in the plug-in is renamed using the file storage verification code information, and the renamed program package is migrated to the dependent package area, and is replaced when a file with a duplicate file name appears, thereby preventing dependent package conflicts. Since only one copy of the same program package is retained in the end, even if new plug-ins with the same dependencies are continuously installed, it will not take up too much space on the machine.

[0058] In addition, when a plug-in application needs to be uninstalled, metadata query can be used to determine whether the dependent files of the current plug-in application are dependent on other plug-ins, and finally a logical judgment decision is made to delete the real dependent files or just delete the plug-in directory.

[0059] In one embodiment, the step S3 includes S31: creating a link file pointing to the generated second program package at the original location of the first program package of the plug-in.

[0060] S32: Rename the link file with the original name of the first program package.

[0061] Specifically, a new link file is created in the dependency directory corresponding to the new storage location of the plug-in package. The file name is the full original name of the first program package, the file suffix is ​​link, and the information in the file is the md5 information value of the dependency package.

[0062] In one embodiment, the plug-in description information includes a plug-in name, a plug-in icon, a plug-in category, a plug-in location information and / or a plug-in version.

[0063] In one embodiment, the step S6 includes S61: finding a target plug-in to be loaded through a metadata database.

[0064] S62: Load the plug-in description information of the target plug-in into the memory of the application.

[0065] When the application starts, or a plug-in needs to be loaded after installation, the target plug-in to be loaded is first read from the metadata database, and the plug-in description information stored when the plug-in is installed is loaded into the application memory. At this time, the plug-in and its dependent packages are not actually loaded into the memory.

[0066] S63: Obtain plug-in location information of the target plug-in.

[0067] S64: Load the second program package pointed to by the link file under the target plug-in location through the custom class loader.

[0068] The application will use a custom class loader to load the plug-in and its dependent packages in sequence. When the plug-in is loaded and the dependent packages are loaded, this type of loader will first determine the suffix information. When the dependent directory and link suffix file are identified, the md5 information in the link file will be directly read and added to the set dependency storage path as the new path and put into the class loader for loading. In this way, the plug-in application can be loaded successfully.

[0069] In the above embodiment, before the plug-in is loaded, a dependency link is established between the plug-in and the corresponding dependent package, and when the plug-in needs to be loaded, a custom class loader is used to load the dependent link and the dependent package on disk on demand, which can reduce the memory space occupied when the plug-in is installed.

[0070] In one embodiment, before step S6, the method further includes: displaying plug-in description information of all available plug-ins through a display interface.

[0071] In a second aspect, in one embodiment, a program plug-in loading device is provided, comprising: a plug-in installation module, a metadata library, and a plug-in loading and running module.

[0072] The plug-in installation module is used to analyze and process the plug-in package of the target plug-in and the corresponding dependent package when the application is installed, so as to compress, store and install the target plug-in.

[0073] The plug-in loading and running module is used to use a custom class loader to load the target plug-in on demand when the application calls the target plug-in.

[0074] In one embodiment, the plug-in installation module includes: a definition module, used to define a plug-in package and a dependency package of an application.

[0075] The deployment module is used to complete the deployment of plug-in packages and dependent packages.

[0076] The deployment module includes a renaming unit and a moving unit.

[0077] The renaming unit is used to rename all first program packages in the plug-in package with file storage verification code information to generate a second program package; the moving unit is used to move the second program package to the directory where the dependent package is located and replace files with duplicate file names when they appear.

[0078] The link relationship establishment module is used to establish the dependency link between the plug-in and the corresponding dependent package.

[0079] The link relationship establishment module includes a link file establishment module and a link file renaming module.

[0080] The link file creation module is used to create a link file pointing to the generated second program package at the original position of the first program package of the plug-in; the link file renaming module is used to rename the link file with the original name of the first program package.

[0081] The plug-in description file creation module is used to create a plug-in description file under each plug-in location, and the plug-in description file contains plug-in description information.

[0082] The data uploading module is used to upload the plug-in description information to the metadata database.

[0083] In one embodiment, the plug-in loading and running module includes: a plug-in search module, which is used to find the target plug-in to be loaded through the metadata database.

[0084] The plug-in information loading module is used to load the plug-in description information of the target plug-in into the memory of the application.

[0085] The plug-in location information acquisition module is used to obtain the plug-in location information of the target plug-in.

[0086] The plug-in loading module is used to load the second program package pointed to by the connection file under the target plug-in location through a custom class loader.

[0087] In a third aspect, a computer device is proposed, comprising: a memory and a processor, wherein the memory stores a computer program, and the processor is used to call the computer program to execute any operation step in the program plug-in loading method provided by the present invention.

[0088] In a fourth aspect, a computer program is proposed, characterized in that when the program is called, it is used to execute any operation step in the program plug-in loading method provided by the present invention.

[0089] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the purpose and scope of the technical solution of the present invention, which should be included in the scope of the claims of the present invention.

Claims

1. A program plug-in loading method, characterized in that: The loading method comprises: S1: defines a plug-in package and dependency package of an application; The plug-in package includes a plurality of plug-ins, and each plug-in includes a plurality of first program packages; S2: Complete the deployment of plug-in packages and dependent packages; S21: renaming all first program packages in the plug-in package with their own file storage verification code information to generate second program packages; S22: Move the second program package to the directory where the dependent package is located, and replace files with duplicate file names when they appear; S3: Establish dependency links between plugins and corresponding dependent packages; S31: creating a link file pointing to the generated second program package at the original location of the first program package of the plug-in; S32: renaming the link file with the original name of the first program package; S4: Create a plug-in description file under each plug-in location, where the plug-in description file contains plug-in description information; S5: Upload the plug-in description information to the metadata database; S6: When the application is running, use the custom class loader to load the target plug-in on demand; S61: Find the target plug-in to be loaded through the metadata database; S62: Loading the plug-in description information of the target plug-in into the memory of the application program; S63: Obtaining the plug-in location information of the target plug-in; S64: Load the second program package pointed to by the link file under the target plug-in location through the custom class loader.

2. A program plug-in loading method as claimed in claim 1, characterized in that: The plug-in description information includes a plug-in name, a plug-in icon, a plug-in category, a plug-in location information and / or a plug-in version.

3. A program plug-in loading method according to claim 1, characterized in that: Before step S6, the following steps are also included: The plugin description information of all available plugins is displayed through the display interface.

4. A program plug-in loading device, characterized in that: include: Plug-in installation module, metadata library and plug-in loading and running module; The plug-in installation module is used to analyze and process the plug-in package of the target plug-in and the corresponding dependent package when the application is installed, so as to compress, store and install the target plug-in; The plug-in installation module includes: Definition module, used to define the plugin package and dependency package of an application; Deployment module, used to complete the deployment of plug-in packages and dependent packages; The deployment module includes a renaming unit and a moving unit; The renaming unit is used to rename all first program packages in the plug-in package with the file storage verification code information to generate a second program package; the moving unit is used to move the second program package to the directory where the dependent package is located, and replace the file with a duplicate file name when it appears; Link relationship establishment module, used to establish dependency links between plug-ins and corresponding dependent packages; The link relationship establishment module includes a link file establishment module and a link file renaming module; The link file creation module is used to create a link file pointing to the generated second program package at the original location of the first program package of the plug-in; the link file renaming module is used to rename the link file with the original name of the first program package; A plug-in description file creation module is used to create a plug-in description file under each plug-in location, and the plug-in description file contains plug-in description information; A data uploading module, used for uploading the plug-in description information to a metadata repository; The plug-in loading and running module is used to use a custom class loader to load the target plug-in on demand when the application calls the target plug-in; The plug-in loading and running module includes: The plug-in search module is used to find the target plug-in to be loaded through the metadata database; A plug-in information loading module is used to load the plug-in description information of the target plug-in into the memory of the application; A plug-in location information acquisition module is used to obtain the plug-in location information of the target plug-in; The plug-in loading module is used to load the second program package pointed to by the connection file under the target plug-in location through a custom class loader.

5. A computer device, characterized in that: include: A memory and a processor, wherein the memory stores a computer program, and the processor is used to call the computer program to execute the operation steps in the program plug-in loading method according to any one of claims 1 to 3.