Plug-in management method and device, electronic equipment and storage medium

By obtaining and using the unique identification code of the plug -in to obtain the implementation class in the code library, the problem of high plug -in development and maintenance costs is solved, the dynamic loading plug -in is achieved, and the development efficiency and flexibility are improved.

CN119376810APending Publication Date: 2025-01-28ZHUHAI KINGSOFT ONLINE GAME TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411229500.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-03
Publication Date
2025-01-28

AI Technical Summary

Technical Problem

As the number of plug-ins increases, the cost of development and maintenance of plug-ins increases. Multiple plug-ins need to maintain multiple code warehouses and code projects at the same time, and the code cannot be shared between plug-ins, resulting in high maintenance costs and low development efficiency.

Method used

By obtaining the unique identification code of the target plug -in, the dynamic loading plug -in is to obtain the implementation class of the target plug -in in the code library according to the unique identification code to obtain the implementation class of the target plug -in to improve the flexibility and adaptability of the plug -in.

Benefits of technology

It improves the efficiency of plug -in development, reduces errors that may occur during the development process, reduce maintenance costs, and make the system easier to maintain and expand.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119376810A_ABST
    Figure CN119376810A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a plug-in management method and device, electronic equipment and a storage medium, and belongs to the technical field of computers. The method comprises the following steps: acquiring a unique identification code of a target plug-in; and obtaining the implementation class of the target plug-in in the code library according to the unique identification code. According to the embodiment of the invention, the plug-in development efficiency can be improved, and the plug-in maintenance cost is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a plug-in management method and device, an electronic device, and a storage medium. Background Art

[0002] In the related art, DevOps platforms use plug-ins to integrate various tools. As the number of plug-ins increases, the development and maintenance costs of plug-ins are also rising. Multiple plug-ins need to maintain multiple code repositories and code projects at the same time, and plug-ins cannot share code, which leads to high maintenance costs and low development efficiency.

[0003] In summary, the technical problems existing in the relevant technologies need to be improved. Summary of the invention

[0004] The main purpose of the embodiments of the present application is to provide a plug-in management method and device, an electronic device and a storage medium, aiming to improve plug-in development efficiency and reduce maintenance costs.

[0005] To achieve the above object, an embodiment of the present application provides a plug-in management method, which includes the following steps:

[0006] Get the unique identification code of the target plug-in;

[0007] The implementation class of the target plug-in is obtained in a code library according to the unique identification code, wherein the code library includes a plurality of different types of plug-in codes.

[0008] In some embodiments, obtaining the implementation class of the target plug-in according to the unique identification code includes:

[0009] Get preset rules;

[0010] Obtaining a target path according to the preset rules and environment variables;

[0011] The target plug-in implementation class is loaded and obtained according to the target path.

[0012] In some embodiments, the preset rule includes a preset package name prefix and a preset class name, and obtaining the target path according to the preset rule and the environment variable includes:

[0013] The preset package name prefix, the unique identification code of the target plug-in and the preset class name are concatenated to obtain a target path.

[0014] In some embodiments, the method further comprises:

[0015] Call the target plug-in implementation class method to execute the target plug-in logic.

[0016] In some embodiments, obtaining the implementation class of the target plug-in according to the unique identification code includes:

[0017] Get the interface implementation class from the implementation class registration file;

[0018] Parsing the interface implementation class to obtain a unique identification code of the candidate plug-in according to a custom rule;

[0019] Determine whether the unique identification code of the candidate plug-in is the same as the unique identification code of the target plug-in of the target path;

[0020] If they are the same, the interface implementation class is used as the implementation class of the target plug-in.

[0021] In some embodiments, the unique identifier of the target plug-in includes a plug-in name.

[0022] In some embodiments, the method further comprises:

[0023] When configuring a plug-in, store the plug-in in the code base and store the plug-in interface implementation class in the implementation class registration file.

[0024] To achieve the above object, another aspect of an embodiment of the present application provides a plug-in management device, the device comprising:

[0025] The acquisition module is used to obtain the unique identification code of the target plug-in;

[0026] The positioning module is used to obtain the implementation class of the target plug-in in the code library according to the unique identification code, wherein the code library includes a plurality of different types of plug-in codes.

[0027] To achieve the above-mentioned purpose, another aspect of an embodiment of the present application provides an electronic device, the electronic device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the above-mentioned method when executing the computer program.

[0028] To achieve the above objective, another aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described above is implemented.

[0029] The embodiments of the present application include at least the following beneficial effects: the present application provides a plug-in management method and device, an electronic device and a storage medium, which obtains a unique identification code of a target plug-in; and obtains an implementation class of the target plug-in in a code library according to the unique identification code.

[0030] The technical solution according to this embodiment is conducive to improving the efficiency of plug-in development, reducing errors that may occur during the development process, reducing maintenance costs, realizing dynamic loading of plug-ins, improving the flexibility and adaptability of plug-ins, and making the system easier to maintain and expand. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 is a flowchart of a plug-in management method provided in an embodiment of the present application;

[0032] Figure 2 is a flowchart of a plug-in management method provided in an embodiment of the present application;

[0033] Figure 3 yes Figure 1 Another flow chart of step S102 in ;

[0034] Figure 4 yes Figure 3 Another flow chart of step S302 in ;

[0035] Figure 5 is a flowchart of predefined steps of the plug-in management method provided in an embodiment of the present application;

[0036] Figure 6 is a flow chart of the plug-in management method provided in an embodiment of the present application applied to a plug-in directory;

[0037] Figure 7 This is a schematic diagram of the code directory structure of multiple plug-ins before applying this solution provided in an embodiment of the present application;

[0038] Figure 8 This is a schematic diagram of the code directory structure of multiple plug-ins after applying the solution provided in the embodiment of the present application;

[0039] Fig. 9 is a schematic diagram of the structure of a plug-in management device provided in an embodiment of the present application;

[0040] Fig.10 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION

[0041] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. When the following description refers to the 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 embodiments of the present application. They are only examples of devices and methods consistent with some aspects of the embodiments of the present application as detailed in the attached claims.

[0042] It is understood that the terms "first", "second", etc. used in this application can be used to describe various concepts in this article, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another concept. For example, without departing from the scope of the embodiment of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" and "if" as used herein can be interpreted as "at the time of" or "when" or "in response to determination".

[0043] The terms "at least one", "multiple", "each", "any", etc. used in this application, at least one includes one, two or more, multiple includes two or more, each refers to each of the corresponding multiple, and any refers to any one of the multiple.

[0044] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0045] Before describing the embodiments of the present application in detail, some nouns and terms involved in the embodiments of the present application are first described. The nouns and terms involved in the embodiments of the present application are subject to the following explanations.

[0046] 1) Plugin SDK (Plugin Software Development Kit), which is a set of tools, libraries, and documentation for developing software plugins. The SDK provides developers with various resources needed to create these plugins.

[0047] 2) DevOps platform, which helps developers and operations personnel automate and standardize software development, testing, deployment and operations by providing a series of tools and processes.

[0048] 3) properties file is a property file that stores content in the format of key=value. The properties file is mainly used to store configuration information, such as database connection information, application settings, etc., making the code more flexible and configurable.

[0049] 4) System.getenv() is a method in the Java programming language, belonging to the java.lang.System class. The System.getenv method is used to obtain the value of the environment variable of the current operating system.

[0050] 5) Plug-in implementation class (entry class) is a key concept in the plug-in system. The plug-in implementation class refers to the specific class that implements the functions required by the plug-in.

[0051] 6) jar (Java Archive) package is a packaging file format under the Java platform, which is used to package multiple Java class files, related metadata and resource files (such as text, pictures, etc.) into one file for easy distribution, deployment and version control.

[0052] In the related art, DevOps platforms use plug-ins to integrate various tools. As the number of plug-ins increases, the development and maintenance costs of plug-ins are also rising. Multiple plug-ins need to maintain multiple code repositories and code projects at the same time, and plug-ins cannot share code, which leads to high maintenance costs and low development efficiency.

[0053] In summary, the technical problems existing in the relevant technologies need to be improved.

[0054] In view of this, the embodiments of the present application provide a plug-in management method, device, equipment and medium, which obtains the unique identification code of the target plug-in and obtains the implementation class of the target plug-in in the code library according to the unique identification code. The technical solution of this embodiment is conducive to improving the efficiency of plug-in development, reducing the errors that may occur during the development process, reducing maintenance costs, realizing dynamic loading of plug-ins, improving the flexibility and adaptability of plug-ins, and making the system easier to maintain and expand.

[0055] The plug-in management method provided in the embodiment of the present application relates to the field of computer technology. The plug-in management method provided in the embodiment of the present application can be applied to a terminal, can be applied to a server, or can be software running in a terminal or a server. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, and a car terminal, etc., but is not limited to this; the server side can be configured as an independent physical server, or it can be configured as a server cluster or a distributed system composed of multiple physical servers, and can also be configured to provide cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and cloud servers for basic cloud computing services such as big data and artificial intelligence platforms. The server can also be a node server in a blockchain network; the software can be an application that implements the plug-in management method, etc., but is not limited to the above forms.

[0056] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.

[0057] It should be noted that in each specific implementation of the present application, when it comes to the need to perform relevant processing based on data related to user identity or characteristics such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first, and the collection, use, and processing of these data will comply with relevant laws, regulations, and standards. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the user's separate permission or consent, the necessary user-related data for the normal operation of the embodiment of the present application will be obtained.

[0058] Figure 1 is an optional flowchart of the plug-in management method provided in an embodiment of the present application. Figure 1The method may include but is not limited to steps S101 to S102.

[0059] Step S101, obtaining a unique identification code of a target plug-in.

[0060] In some embodiments, an environment variable is obtained, and a unique identification code of the target plug-in is determined according to the environment variable.

[0061] The unique identification code of the target plug-in can uniquely identify the target plug-in, and the unique identification code may be an ID code, such as a letter and / or number code, or a plug-in name, etc.

[0062] Step S102: Obtain the implementation class of the target plug-in in the code library according to the unique identification code.

[0063] Specifically, the code base includes multiple different types of plug-in codes.

[0064] In some embodiments, the implementation class of the target plug-in is obtained in a single code base according to the unique identification code of the target plug-in.

[0065] Further, a preset rule is obtained, a target path is obtained according to the preset rule and the unique identification code of the target plug-in, and an implementation class of the target plug-in is obtained according to the target path. The preset rule includes constituent elements of the unique identification code of the target plug-in and splicing rules of the constituent elements.

[0066] Specifically, the constituent elements of the unique identification code of the target plug-in include a preset package name prefix and a preset class name.

[0067] It can be understood that the preset package name prefix and the preset class name are obtained, the preset package name prefix, the unique identification code of the target plug-in and the preset class name are concatenated according to preset rules to obtain the target path, and the target plug-in is loaded according to the target path.

[0068] Optionally, call the target plug-in implementation class method to execute the target plug-in logic.

[0069] In some embodiments, an interface implementation class is obtained from an implementation class registration file, and a unique identification code of a candidate plug-in is parsed from the interface implementation class according to custom rules. It is determined whether the unique identification code of the candidate plug-in is the same as the unique identification code of the target plug-in of the target path. If they are the same, the interface implementation class is used as the implementation class of the target plug-in.

[0070] It should be noted that when configuring a plug-in, the plug-in is stored in a single code base, and the plug-in interface implementation class is stored in the implementation class registration file.

[0071] Figure 2 is an optional flowchart of the plug-in management method provided in an embodiment of the present application. Figure 1The method may include but is not limited to steps S201 to S204.

[0072] Step S201, obtaining a preset package name prefix, environment variables and a preset class name.

[0073] Specifically, the environment variable is used to specify the unique identification code of the target plug-in to be loaded, and the constituent elements of the unique identification code of the target plug-in include a preset package name prefix, an environment variable, and a preset class name.

[0074] In some embodiments, a preset package name prefix is ​​defined, a preset class name is defined, and the preset package name prefix and the preset class name are stored.

[0075] It is understandable that the preset package name prefix and the preset class name can be fixed information defined by the plug-in developer, or dynamic information dynamically specified through a configuration file.

[0076] Optionally, define a preset package name prefix and a preset class name in the code through a configuration file or hard coding, and use system environment variables or configuration files to specify the loaded plug-in ID or other parameters.

[0077] In this embodiment, a preset package name prefix, environment variables, and preset class name are obtained. The unified package name prefix and class name specifications can improve the readability and maintainability of the code, simplify the configuration and loading process of the plug-in, and improve development efficiency.

[0078] Step S202: determining a unique identification code of the target plug-in according to the environment variable.

[0079] Specifically, the unique identification code of the target plug-in includes the plug-in name.

[0080] In some embodiments, the environment variables are read to determine the unique identification code of the target plug-in according to different environment settings.

[0081] Optionally, implement dynamic updating of environment variables to improve the flexibility of the plugin.

[0082] In this embodiment, the unique identification code of the target plug-in is determined according to the environment variable, and different plug-ins can be dynamically loaded according to different deployment environments, thereby improving the adaptability and flexibility of the system.

[0083] Step S203, concatenate the preset package name prefix, the unique identification code of the target plug-in and the preset class name according to a preset rule to obtain a target path.

[0084] Specifically, the preset rules include splicing rules of constituent elements, and the splicing rules of constituent elements include a splicing method and a splicing order of a preset package name prefix, a unique identification code of a target plug-in, and a preset class name, and the target path is used to determine the target plug-in.

[0085] Optionally, the preset rule may be predetermined by a user.

[0086] In some embodiments, preset rules are predefined and stored.

[0087] It is worth noting that this application does not specifically limit the splicing method of the preset package name prefix, the unique identification code of the target plug-in, and the preset class name, which can be flexibly selected in combination with actual detection needs. For example, the splicing method can be string splicing, and path splicing tools can also be used for path splicing.

[0088] Optionally, a concatenation order of a preset package name prefix+a unique identification code of a target plug-in+a preset class name may be used.

[0089] In some embodiments, the preset package name prefix, the unique identification code of the target plug-in, and the preset class name are string concatenated in the concatenation order of preset package name prefix+the unique identification code of the target plug-in+the preset class name to obtain the target path.

[0090] In this embodiment, the preset package name prefix, the unique identification code of the target plug-in and the preset class name are spliced ​​according to preset rules to obtain the target path, which is conducive to obtaining a standardized path, can reduce errors and duplicate code, improve the maintainability and consistency of the code, and facilitate developers to manage and maintain the plug-in.

[0091] Step S204: load the implementation class of the target plug-in according to the target path.

[0092] In some embodiments, the implementation class of the target plug-in is obtained according to the target path, and the target plug-in is loaded.

[0093] Optionally, when configuring the plug-in, the implementation class of the plug-in is stored in the implementation class registration file.

[0094] Further, the target plug-in is loaded according to the implementation class registration file and the target path.

[0095] The original plug-in software development kit calling logic is modified to obtain a customized plug-in software development kit.

[0096] Further, the custom plug-in software development kit is called to load the target plug-in according to the implementation class registration file and the target path.

[0097] Among them, the interface implementation class in the implementation class registration file is obtained through the customized plug-in software development toolkit; the unique identification code of the candidate plug-in is parsed from the interface implementation class according to the custom rules; it is determined whether the unique identification code of the candidate plug-in is the same as the unique identification code of the target plug-in of the target path; if they are the same, the interface implementation class is used as the implementation class of the target plug-in.

[0098] It is understandable that the target path is used to determine the target plug-in, but the target plug-in does not necessarily actually exist, and loading the target plug-in according to the target path may fail.

[0099] It is worth noting that if the project is compiled, copy the plug-in configuration file to the same directory as the compiled jar package file.

[0100] In this embodiment, the target plug-in is loaded according to the target path, which is beneficial to dynamic loading of the plug-in, makes the system easier to maintain and expand, and improves the flexibility and availability of the plug-in.

[0101] Steps S201 to S204 shown in the embodiment of the present application, by obtaining the unique identification code of the target plug-in; obtaining the implementation class of the target plug-in in the code library according to the unique identification code, is conducive to improving the efficiency of plug-in development, reducing errors that may occur during the development process, reducing maintenance costs, realizing dynamic loading of plug-ins, improving plug-in flexibility and adaptability, and making the system easier to maintain and expand.

[0102] See also Figure 3 In some embodiments, step S102 may include but is not limited to steps S301 to S302:

[0103] Step S301, when configuring a plug-in, the interface implementation class of the plug-in is stored in an implementation class registration file.

[0104] Specifically, when configuring a plug-in, the plug-in is stored in a single code base, and the interface implementation class of the plug-in is stored in an implementation class registration file.

[0105] It is worth noting that the implementation class registration file also supports multi-version plug-in management to improve the compatibility and updateability of the plug-in.

[0106] Optionally, the implementation class registration file also supports dependencies between plugins so that required dependent plugins can be correctly loaded and used.

[0107] Step S302: Obtain the implementation class of the target plug-in from the implementation class registration file according to the unique identification code.

[0108] In some embodiments, the target plug-in is loaded by a plug-in software development kit according to an implementation class registration file and a target path.

[0109] It is worth noting that the original plugin SDK can only obtain the unique plugin implementation class in the class registration file.

[0110] Further, the original plug-in software development toolkit calling logic is modified to obtain a customized plug-in software development toolkit, and the customized plug-in software development toolkit is called to load the target plug-in according to the implementation class registration file and the target path.

[0111] See also Figure 4 In some embodiments, step S302 may include but is not limited to steps S401 to S402:

[0112] Step S401, modifying the original plug-in software development kit calling logic to obtain a customized plug-in software development kit.

[0113] Specifically, a custom plug-in software development kit is used for plug-in implementation class loading.

[0114] Step S402: calling the custom plug-in software development toolkit to obtain the implementation class of the target plug-in according to the implementation class registration file and the unique identification code of the target plug-in.

[0115] Specifically, the target plug-in includes a plug-in implementation class.

[0116] In some embodiments, a customized plug-in software development kit is used to obtain an interface implementation class from an implementation class registration file; parse the interface implementation class to obtain a unique identification code of a candidate plug-in according to custom rules; determine whether the unique identification code of the candidate plug-in is the same as the unique identification code of the target plug-in of the target path; if they are the same, use the interface implementation class as the implementation class of the target plug-in.

[0117] It is worth noting that the original plug-in SDK only loads the plug-in implementation class through the implementation class registration file, while the customized plug-in SDK loads the plug-in implementation class according to the implementation class registration file and the target path.

[0118] Exemplarily, the custom rule may adopt a rule for intercepting the last package name.

[0119] Specifically, the code for loading the plug-in implementation class (entry class) atomFullClassName is as follows:

[0120] TaskAtom atom=ServiceLoader.load(TaskAtom.cl ass,atomFu l lClassName);

[0121] Among them, atom is the plug-in implementation class, ServiceLoader.load is the custom plug-in software development kit, and the code here in the original plug-in SDK is:

[0122] TaskAtom atom=ServiceLoader.load(TaskAtom.cl ass)

[0123] The original plug-in SDK can only obtain the unique plug-in implementation class in the com.tencent.bk.devops.atom.spi.TaskAtom file.

[0124] It can be understood that all interface implementation classes of the implementation class registration file in the jar are obtained through the customized plug-in SDK; the unique identification codes of all candidate plug-ins are parsed from all interface implementation classes according to the specification of intercepting the last package name; it is determined whether the unique identification code of each candidate plug-in is the same as the unique identification code of the target plug-in of the target path; if they are the same, the interface implementation class is used as the implementation class of the target plug-in; if they are different, the step of determining whether the unique identification code of each candidate plug-in is the same as the unique identification code of the target plug-in of the target path is returned, until the implementation class of the target plug-in is obtained or the unique identification codes of all candidate plug-ins are different from the unique identification code of the target plug-in of the target path.

[0125] It can be understood that it is determined whether the unique identification code of the candidate plug-in is the same as the unique identification code of the target plug-in of the target path; if they are the same, the target plug-in is loaded successfully; if the unique identification codes of all candidate plug-ins are not the same as the unique identification code of the target plug-in of the target path, the target plug-in fails to load.

[0126] If the loading fails, the user is prompted that the target plug-in does not exist.

[0127] Optionally, when plugin loading fails, catch the exception and display a friendly error message to the user, explaining why the target plugin does not exist or failed to load.

[0128] It is understandable that the user may be prompted that the target plug-in does not exist through a prompt page, a prompt message, or an error message.

[0129] Furthermore, an automatic repair function may be provided to try to re-download or update the target plug-in from an alternative source, thereby improving the reliability and availability of the system.

[0130] In this embodiment, if the target plug-in fails to load, the user is prompted that the target plug-in does not exist, providing clear feedback and guidance, which helps the user to promptly perceive and solve the plug-in loading problem and reduce system crashes or runtime errors caused by abnormal plug-ins.

[0131] It is understandable that the user may be prompted that the target plug-in does not exist through a prompt page, a prompt message, or an error message.

[0132] If the loading is successful, the implementation class of the target plug-in is obtained. The plug-in logic is executed by calling the entry method through the implementation class of the target plug-in. The plug-in implementation class includes an entry method, and the entry method of the plug-in implementation class is used to initialize the plug-in, execute plug-in specific functions or plug-in logic.

[0133] In some embodiments, whether the target plug-in is loaded successfully is determined by capturing a class loading exception.

[0134] Optionally, you can determine whether the target plug-in is loaded successfully by checking the error log, by testing the plug-in function, or by using an application debugging tool.

[0135] Furthermore, the plug-in implementation class executes the plug-in logic by calling the entry method.

[0136] See also Figure 5 In some embodiments, the constituent elements of the unique identification code of the target plug-in include a preset package name prefix, an environment variable, and a preset class name. The plug-in management method provided in the embodiment of the present application also includes predefined steps, which may include but are not limited to steps S501 to S504:

[0137] Step S501, defining a preset package name prefix.

[0138] Specifically, the preset package name prefix may be defined by a user or a developer.

[0139] Furthermore, a preset package name prefix may be defined in a configuration file.

[0140] Optionally, a preset package name prefix may also be defined in the database.

[0141] In step S501 of some embodiments, the preset package name prefix can be defined in the code by defining a constant or an enumeration class. It is worth noting that the preset package name prefix supports dynamic update, and the preset package name prefix can be modified at runtime.

[0142] In this embodiment, defining a preset package name prefix is ​​conducive to using a unified package name prefix, reducing confusion and errors, facilitating unified management and modification of package names, and reducing the possibility of manual operations and errors.

[0143] Step S502, defining a preset class name.

[0144] In step S502 of some embodiments, the preset class name is defined by defining constants in the code.

[0145] Optionally, use a configuration file to define preset class names.

[0146] It is understandable that the preset class name can be defined by a user or a developer through a specific naming convention.

[0147] Furthermore, a class name generator tool may be used to automatically generate a preset class name according to certain rules.

[0148] Specifically, the template can be used to customize the generation rules according to different requirements, and the preset class name can be generated according to the generation rules.

[0149] In this embodiment, defining a preset class name is conducive to using a unified and standardized class name, improving the readability and maintainability of the code, and realizing automatic generation of class names that comply with preset rules, thereby reducing manual input and errors.

[0150] Step S503: define preset rules.

[0151] Specifically, the preset rules include a preset package name prefix, a unique identification code of a target plug-in, and a concatenation method and concatenation order of preset class names.

[0152] Optionally, the preset rule may be predetermined by a user.

[0153] Among them, comments or tags are used in the code to explain the preset rules, which is convenient for developers to check and follow.

[0154] In this embodiment, a preset rule is defined to prepare for subsequent splicing to obtain a target path, which is conducive to obtaining an accurate and standardized target path.

[0155] Step S504, storing the preset package name prefix, the preset class name and the preset rule.

[0156] Optionally, the preset package name prefix, the preset class name, and the preset rule are stored in a configuration file.

[0157] Exemplarily, the configuration file may be a JSON file, an XML file, or a properties file.

[0158] Furthermore, the preset package name prefix, preset class name and preset rules are stored in a database, and the preset package name prefix, preset class name and preset rules are managed through database query and update.

[0159] In this embodiment, storing the preset package name prefix, preset class name and preset rules is conducive to centralized management and maintenance of preset information, prepares for subsequent acquisition of the preset package name prefix, preset class name and preset rules, and is conducive to subsequent target path splicing.

[0160] In practical applications, for example, the code directory structure diagram of multiple plug-ins before applying this solution is as follows Figure 7Among them, the relationship between the main file functions and the number of plug-ins is shown in Table 1:

[0161] Table 1

[0162]

[0163] See also Figure 6 In some embodiments, the plug-in management method provided in the embodiments of the present application is applied to a plug-in directory. Figure 6 The method includes but is not limited to steps S601 to S614:

[0164] Step S601, when configuring a plug-in, storing the implementation class of the plug-in into the implementation class registration file.

[0165] In step S601 of some embodiments, TaskAtom is the implementation class registration file, and the full path of the current plug-in implementation class is filled in.

[0166] Step S602, defining a preset package name prefix.

[0167] In step S602 of some embodiments, a preset package name prefix is ​​predefined by a user. Exemplarily, the preset package name prefix is ​​com.sample.bk.devops.atom.task.

[0168] Step S603, defining a preset class name.

[0169] In step S603 of some embodiments, a preset class name is predefined by a user. Exemplarily, the preset class name uses Atom.

[0170] It is understandable that Atom is the class name, and it can also be other names, such as the first letter of atomCode converted to uppercase and then added to Atom. For ease of description and understanding, the example is simplified to a fixed Atom, which is the minimum dependency.

[0171] Step S604, defining preset rules.

[0172] In step S604 of some embodiments, the preset rule is predefined as a preset package name prefix + plug-in ID + preset class name. For example, the preset rule adopts com.sample.bk.devops.atom.task. <atomcode>.Atom format, where com.sample.bk.devops.atom.task is the package name prefix, atomCode is the plug-in ID, all files related to this plug-in are placed in this directory, and Atom is the class name.

[0173] Step S605, storing the preset package name prefix, the preset class name and the preset rule.

[0174] In step S605 of some embodiments, the preset package name prefix, the preset class name and the preset rule are stored via a configuration file.

[0175] Step S606, obtaining a preset package name prefix, environment variables and a preset class name.

[0176] In step S606 of some embodiments, a preset package name prefix, environment variables, and preset class name are obtained from a configuration file.

[0177] It is understandable that step S602, step S603, step S604 and step S605 need to be performed before step S606.

[0178] Step S607: determine the unique identification code of the target plug-in according to the environment variable.

[0179] In step S607 of some embodiments, the plug-in ID (ie, atomCode) is identified based on the environment variable, which is the minimum dependency.

[0180] For example, the code for obtaining atomCode (i.e., the unique identification code of the target plug-in) through System.getenv is as follows:

[0181] Str ing atomCode=System.getenv("BK_CI_ATOM_CODE");

[0182] Among them, "BK_CI_ATOM_CODE" is an environment variable.

[0183] Step S608: Concatenate the preset package name prefix, the unique identification code of the target plug-in, and the preset class name according to preset rules to obtain a target path.

[0184] In step S608 of some embodiments, according to atomCode, the code of concatenating the complete plug-in implementation class (entry class) name atomFullClassName according to the specification is as follows:

[0185] Str ing atomFu l lCl assName="com.samp le.bk.devops.atom.task."+atomCode+".Atom";

[0186] It is understandable that the complete class name (ie, target path) is directly concatenated according to the rules (ie, preset rules), but it cannot ensure that the class exists. If it does not exist, an error will be reported during subsequent loading.

[0187] It is worth noting that no matter what rules are adopted, no matter whether one or more context environment variables are relied on, as long as the complete path of the plug-in implementation class can be spliced ​​out by relying only on the context environment variables passed when the plug-in is executed, it belongs to the method described in this solution.

[0188] It is understandable that this solution constrains the full path of the plug-in implementation class, that is, it must be spliced ​​out only by relying on the context environment variables passed when the plug-in is executed. It cannot be placed in any directory like the original plug-in, so that the full path of the implementation class can be spliced ​​out according to the rules.<package_prefix> . <atomcode> . <atomclassname>form.

[0189] Step S609: Acquire the implementation class of the target plug-in according to the target path.

[0190] It is worth noting that if there is only one candidate plug-in with the same unique identification code as the target plug-in in the target path, the loading is successful and the implementation class of the target plug-in is obtained.

[0191] Step S610, modify the original plug-in SDK call logic to obtain a customized plug-in SDK.

[0192] Specifically, the original plug-in SDK is an original plug-in software development kit, and the customized plug-in SDK is a customized plug-in software development kit.

[0193] In step S610 of some embodiments, the plug-in SDK is customized and its calling logic is modified to support class loading through a specific plug-in.

[0194] Furthermore, when the plug-in is executed, by obtaining the passed atomCode from the environment variable, the program can piece together the complete path of the plug-in implementation class, and then load and execute it.

[0195] Step S611, obtaining a unique identification code of the target plug-in.

[0196] Specifically, a unique identification code of the target plug-in input by the user is obtained.

[0197] Step S612: calling the custom plug-in SDK to obtain the interface implementation class from the implementation class registration file.

[0198] Step S613, calling the custom plug-in SDK to parse the interface implementation class according to the custom rule to obtain the unique identification code of the candidate plug-in.

[0199] Among them, the custom rule adopts the rule of intercepting the last package name.

[0200] Step S614: calling the custom plug-in SDK to determine whether the unique identification code of the candidate plug-in is the same as the unique identification code of the target plug-in in the target path.

[0201] Step S615: If there is only one candidate plug-in whose unique identification code is the same as the unique identification code of the target plug-in in the target path, the implementation class of the target plug-in is obtained.

[0202] Step S616: If there is no candidate plug-in with the same unique identification code as the target plug-in in the target path, the user is prompted that the target plug-in does not exist.

[0203] In step S613 of some embodiments, in actual application, a user is prompted that the target plug-in does not exist through a visual warning message.

[0204] It is worth noting that if the unique identification codes of all candidate plug-ins are different from the unique identification code of the target plug-in in the target path, the loading fails, and a visual warning message prompts the user that the target plug-in does not exist.

[0205] Furthermore, if there are multiple candidate plug-ins with the same unique identification code as the target plug-in of the target path, the loading fails, and a visual warning message is provided to the user to remind them that there are multiple target plug-ins.

[0206] Step S617, calling the entry method through the implementation class of the target plug-in to execute the plug-in logic.

[0207] In step S617 of some embodiments, atom.execute() is called to execute the plug-in logic.

[0208] Among them, the execute method is the entry method for the plug-in to implement logic.

[0209] Step S618, if the project compilation is completed, the plug-in configuration file is copied to the same directory as the jar package file generated by the compilation, and the project includes the target plug-in.

[0210] In step S618 of some embodiments, the construction script process of pom.xml is modified, and the task.json file (ie, the plug-in configuration file) that is not in the root directory is copied to the same directory as the compiled jar package file to comply with the plug-in installation package specification.

[0211] In practical applications, for example, the code directory structure diagram of multiple plug-ins after applying this solution is as follows Figure 8 Among them, the relationship between the main file functions and the number of plug-ins is shown in Table 2:

[0212] Table 2

[0213]

[0214] In this embodiment, when obtaining a plug-in, context environment variables need to be passed, and then the complete path corresponding to the plug-in is spliced ​​according to the context environment variables, so as to obtain the corresponding plug-in according to the complete path. In addition, the plug-in needs to be stored in a regular manner in the corresponding directory and cannot be stored arbitrarily.

[0215] This solution customizes the plug-in software development kit, splices out the complete plug-in implementation class name according to the specification, and splices out the complete path corresponding to the plug-in implementation class from the environment variable, and then loads the plug-in implementation class name according to the complete path, thereby completing the loading of the plug-in.

[0216] It can be understood that this embodiment obtains the unique identification code of the target plug-in; obtains the implementation class of the target plug-in in the code library according to the unique identification code, which is conducive to improving the efficiency of plug-in development, reducing errors that may occur during the development process, reducing maintenance costs, realizing dynamic loading of plug-ins, improving plug-in flexibility and adaptability, and making the system easier to maintain and expand.

[0217] See also Fig. 9 The embodiment of the present application also provides a plug-in management device, which can implement the above plug-in management method, and the device includes:

[0218] Name acquisition module 901, used to obtain a unique identification code of a target plug-in;

[0219] The positioning module 902 is used to obtain the implementation class of the target plug-in in the code library according to the unique identification code.

[0220] It can be understood that the contents of the above method embodiments are all applicable to the present device embodiments, the functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0221] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above plug-in management method when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.

[0222] It can be understood that the contents of the above method embodiments are all applicable to the present device embodiments, the functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0223] See also Fig.10 , Fig.10 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:

[0224] The processor 1001 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;

[0225] The memory 1002 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1002 can store an operating system and other applications. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 1002, and the processor 1001 calls and executes the plug-in management method of the embodiment of this application;

[0226] Input / output interface 1003, used to implement information input and output;

[0227] The communication interface 1004 is used to realize the communication interaction between the device and other devices. The communication can be realized through a wired manner (such as USB, network cable, etc.) or a wireless manner (such as mobile network, WI FI, Bluetooth, etc.);

[0228] A bus 1005 , which transmits information between various components of the device (e.g., the processor 1001 , the memory 1002 , the input / output interface 1003 , and the communication interface 1004 );

[0229] The processor 1001 , the memory 1002 , the input / output interface 1003 and the communication interface 1004 are connected to each other in communication within the device via the bus 1005 .

[0230] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned plug-in management method is implemented.

[0231] It can be understood that the contents of the above method embodiments are all applicable to the present storage medium embodiments, the functions specifically implemented by the present storage medium embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0232] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0233] The plug-in management method, plug-in management device, electronic device and storage medium provided in the embodiments of the present application obtain the unique identification code of the target plug-in; obtain the implementation class of the target plug-in in the code library according to the unique identification code, which is conducive to improving the efficiency of plug-in development, reducing errors that may occur during the development process, reducing maintenance costs, realizing dynamic loading of plug-ins, improving the flexibility and adaptability of plug-ins, and making the system easier to maintain and expand.

[0234] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0235] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.

[0236] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0237] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.

[0238] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0239] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or plural.

[0240] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0241] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0242] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0243] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.

[0244] It will be appreciated by those skilled in the art that all or some of the steps and systems in the disclosed method above may be implemented as software, firmware, hardware and appropriate combinations thereof. Some physical components or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor or a microprocessor, or may be implemented as hardware, or may be implemented as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or a non-transitory medium) and a communication medium (or a temporary medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, disk storage or other magnetic storage devices, or any other medium that may be used to store desired information and may be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media typically include computer readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.

[0245] The above is a specific description of the preferred implementation of the present invention, but the present invention is not limited to the above-mentioned implementation mode. Technical personnel familiar with the field can also make various equivalent deformations or substitutions under the shared conditions without violating the spirit of the present invention. These equivalent deformations or substitutions are all included in the scope defined by the claims of the present invention.< / atomclassname> < / atomcode> < / atomcode>

Claims

1. A plug-in management method, characterized in that: The method comprises the following steps: Get the unique identification code of the target plug-in; The implementation class of the target plug-in is obtained in a code library according to the unique identification code, wherein the code library includes a plurality of different types of plug-in codes.

2. The method according to claim 1, characterized in that The step of obtaining the implementation class of the target plug-in according to the unique identification code includes: Get preset rules; Obtaining a target path according to the preset rules and environment variables; The target plug-in implementation class is loaded and obtained according to the target path.

3. The method according to claim 2, characterized in that The preset rule includes a preset package name prefix and a preset class name, and obtaining a target path according to the preset rule and environment variables includes: The preset package name prefix, the unique identification code of the target plug-in and the preset class name are concatenated to obtain a target path.

4. The method according to claim 1, characterized in that: The method further comprises: Call the target plug-in implementation class method to execute the target plug-in logic.

5. The method according to claim 1, characterized in that The step of obtaining the implementation class of the target plug-in according to the unique identification code includes: Get the interface implementation class from the implementation class registration file; Parsing the interface implementation class to obtain a unique identification code of the candidate plug-in according to a custom rule; Determine whether the unique identification code of the candidate plug-in is the same as the unique identification code of the target plug-in of the target path; If they are the same, the interface implementation class is used as the implementation class of the target plug-in.

6. The method according to claim 5, characterized in that The unique identification code of the target plug-in includes the plug-in name.

7. The method according to claim 5, characterized in that The method further comprises: When configuring a plug-in, store the plug-in in the code base and store the plug-in interface implementation class in the implementation class registration file.

8. A plug-in management device, characterized in that: The device comprises: The acquisition module is used to obtain the unique identification code of the target plug-in; The positioning module is used to obtain the implementation class of the target plug-in in the code library according to the unique identification code, wherein the code library includes a plurality of different types of plug-in codes.

9. An electronic device, characterized in that: The electronic device comprises a memory and a processor, the memory stores a computer program, and the processor implements the method according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.