A method and device for realizing multi-version dependency isolation

By using annotations and custom class loaders to manage dependency packages in spring boot dependency isolation, the problem of project type limitation and high coupling is solved, multi-version coexistence and version switching are achieved, and the risk of system upgrade is reduced.

CN110968340BActive Publication Date: 2024-11-15JINGDONG TECH HLDG CO LTD
View PDF 11 Cites 0 Cited by

Patent Information

Application Number
CN201811151298.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2018-09-29
Publication Date
2024-11-15
Estimated Expiration
2038-09-29

AI Technical Summary

Technical Problem

When using spring boot for dependency isolation in the prior art, the project must be a spring boot project, and the coupling degree is high, making it difficult to achieve multi-version coexistence and version switching of different types of projects, and it is difficult to upgrade and maintain external dependencies.

Method used

By adding annotations to the method to be isolated, the dependency package is placed in the reference directory file, and the dependency package is loaded using a custom class loader to realize dynamic management and switching of the dependency package, and the telnet command is supported for the operation of the dependency package.

Benefits of technology

Multi-version coexistence of different types of projects is realized, which reduces the coupling degree, allows real-time switching of running dependent versions, and avoids the unused system of systems that are kidnapped by upgrades.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110968340B_ABST
    Figure CN110968340B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for implementing multi-version dependency isolation, and relates to the field of computer technology. A specific implementation of the method includes: adding annotations to the method to be isolated; placing the dependency packages that need to be referenced in the method to be isolated into a reference directory file; the annotations correspond to the reference directory one by one; when executing the method to be isolated, determining the reference directory file where the dependency package is placed according to the annotations; and using a custom class loader to load the dependency packages in the reference directory file. This implementation can solve the problem of too high coupling degree in the process of using spring boot for dependency isolation, and thus achieve the coexistence of multiple versions of dependencies without distinguishing project types and ensuring that each version of dependency provides normal functions. At the same time, the running dependency version can be switched in real time, avoiding the system kidnapping upgrade that does not use the upgrade function.
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 method and device for implementing multi-version dependency isolation. Background Art

[0002] In large and complex business systems, in order to improve the simplicity, commonality, and reuse of the code, the common functional parts will be packaged into jar packages for reference by systems with the same business functions. This can effectively avoid repeated development and reduce R&D investment. This is called third-party dependency. Another type of dependency is that with the promotion of microservices and SOA, each system is cut from multiple dimensions such as functions, responsibilities, business attributes, and domain models. A complete functional closed loop requires the collaboration of multiple systems. At this time, each business system needs to expose its own API jar as the calling entry for its own external output function, so that a complete function can be completed. This is an internal dependency. Whether it is an internal dependency or an external dependency, the referenced jar needs to be versioned, and spring boot is usually used for dependency isolation.

[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:

[0004] 1. Using spring boot for dependency isolation requires that the project must be a spring boot project and must be compiled using the spring boot compilation plug-in to take effect.

[0005] 2. Spring itself is a third-party dependency and has many indirect dependencies, which is not conducive to the upgrade and maintenance of the subsequent business system and is too tightly coupled.

[0006] 3. Each upgrade of internal dependencies needs to be notified to all dependent parties, even if the party does not use the upgraded function, it needs to be upgraded synchronously.

[0007] 4. It is impossible to change the indirect dependencies within external (third-party) dependencies and to strip or ignore the upgrade functions, making it difficult to ensure the normal functions of the previous system. Summary of the invention

[0008] In view of this, an embodiment of the present invention provides a method and device for implementing multi-version dependency isolation, which can solve the problems that the project must be a spring boot project, the spring boot compilation plug-in must be used, and the coupling degree is too high when using spring boot for dependency isolation.

[0009] To achieve the above-mentioned purpose, according to one aspect of an embodiment of the present invention, a method for implementing multi-version dependency isolation is provided, comprising: adding annotations in the method to be isolated; placing the dependency packages that need to be referenced in the method to be isolated into a reference directory file; the annotations correspond one-to-one with the reference directories; when executing the method to be isolated, determining the reference directory file where the dependency packages are placed according to the annotations; and using a custom class loader to load the dependency packages in the reference directory file.

[0010] Optionally, after placing the dependent package that needs to be referenced in the method to be isolated into the reference directory file, it also includes: receiving a telnet command; performing at least one of the following operations on the dependent package according to the telnet command: selecting, traversing, adding, deleting, and moving to a backup area.

[0011] Optionally, before executing the method to be isolated, it also includes: monitoring a service request, and determining a redirection address according to the service request; and determining the method to be isolated to be executed according to the domain name of the redirection address.

[0012] According to another aspect of an embodiment of the present invention, a method for implementing multi-version dependency isolation is provided, including: using a custom class loader to load a dependency package to obtain an object instance of the dependency package; starting a container and initializing a function processor in the container, and registering the dependency package object instance in the function processor; when executing the method to be isolated, if a dependency needs to be referenced, then taking out and executing the dependency package object instance from the function processor.

[0013] Optionally, after registering the dependent package object instance into the functional processor, the method further includes: receiving a telnet command; and performing at least one of the following operations on the dependent package object instance according to the telnet command: selecting, traversing, adding, deleting, and moving to a backup area.

[0014] Optionally, before executing the method to be isolated, it also includes: monitoring a service request, and determining a redirection address according to the service request; and determining the method to be isolated to be executed according to the domain name of the redirection address.

[0015] According to another aspect of an embodiment of the present invention, a device for implementing multi-version dependency isolation is provided, including: an annotation module, used to add annotations to a method to be isolated; a placement module, used to place dependency packages that need to be referenced in the method to be isolated into a reference directory file; the annotations correspond one-to-one with the reference directories; an execution module, used to determine the reference directory file where the dependency packages are placed according to the annotations when executing the method to be isolated; and a loading module, used to load the dependency packages in the reference directory file using a custom class loader.

[0016] Optionally, the placement module is further used to: receive a telnet command; and perform at least one of the following operations on the dependent package according to the telnet command: select, traverse, add, delete, and move to a backup area.

[0017] Optionally, the execution module is further used to: monitor a service request, and determine a redirection address according to the service request; and determine the isolation method to be executed according to a domain name of the redirection address.

[0018] According to another aspect of an embodiment of the present invention, a device for implementing multi-version dependency isolation is provided, including: a loading module, used to: load a dependency package using a custom class loader to obtain an object instance of the dependency package; a registration module, used to: start a container and initialize a function processor in the container, and register the dependency package object instance in the function processor; a reference module, used to: when executing a method to be isolated, if a dependency needs to be referenced, then the dependency package object instance is retrieved from the function processor and executed.

[0019] Optionally, the registration module is further used to: receive a telnet command; and perform at least one of the following operations on the dependent package object instance according to the telnet command: select, traverse, add, delete, and move to a backup area.

[0020] Optionally, the reference module is further used to: monitor a service request, and determine a redirection address according to the service request; and determine the isolation method to be executed according to a domain name of the redirection address.

[0021] According to another aspect of an embodiment of the present invention, an electronic device is provided, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method for implementing multi-version dependency isolation as proposed in an embodiment of the present invention.

[0022] According to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the method for implementing multi-version dependency isolation as proposed in an embodiment of the present invention is implemented.

[0023] An embodiment of the above invention has the following advantages or beneficial effects: because of the technical means of adding annotations, it can solve the problems that the project must be a springboot project, the spring boot compilation plug-in must be used, and the coupling degree is too high in the process of using spring boot for dependency isolation, thereby achieving the technical effect of realizing the coexistence of multiple versions of dependencies without distinguishing between project types and ensuring that each version of dependency provides normal functions. At the same time, the running dependency version can be switched in real time, avoiding the system hijacking upgrade that does not use the upgrade function.

[0024] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0026] Figure 1 It is a schematic diagram of the main process of a method for implementing multi-version dependency isolation according to an embodiment of the present invention;

[0027] Figure 2 is a schematic diagram of main modules of a device for implementing multi-version dependency isolation according to an embodiment of the present invention;

[0028] Figure 3 is a schematic diagram of a real-time isolation model according to an embodiment of the present invention;

[0029] Figure 4 is a schematic diagram of a module isolation model according to an embodiment of the present invention;

[0030] Figure 5 is a schematic diagram of a processing process of real-time isolation according to an embodiment of the present invention;

[0031] Figure 6 is a schematic diagram of a module isolation processing process according to an embodiment of the present invention;

[0032] Figure 7 is a schematic diagram of a telnet command processing model according to an embodiment of the present invention;

[0033] Figure 8 is a schematic diagram of merging and packaging multiple web modules into dependent plug-ins according to an embodiment of the present invention;

[0034] Fig. 9 is a system architecture diagram according to an embodiment of the present invention;

[0035] Fig.10 is a schematic diagram of a service deployment workflow according to an embodiment of the present invention;

[0036] Fig.11 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0037] Fig.12 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0038] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0039] Glossary of technical terms

[0040] Maven: is a software project management and understanding tool. Based on the concept of Project Object Model (POM), Maven can manage project builds, reports, and documents from a central information source. It is an open source component of the Apache community.

[0041] Parent delegation: refers to the Java class loading model, where the class loader with a higher level loads the classes under its loading path first.

[0042] In the prior art, both internal and external dependencies need to maintain the version of the referenced jar. Each upgrade of internal dependencies needs to be notified to all dependent parties, and even if the party does not use the upgraded function, it needs to be upgraded synchronously, which is usually constrained by compilation rules. For external (third-party) dependencies, it is impossible to change the indirect dependencies within the dependencies and the stripping or ignoring of the upgraded functions. If the business system is a huge system, it is difficult to ensure the normal function of the previous functions if the high (low) version is ignored rashly at this time.

[0043] In the prior art, Spring Boot uses Maven-based multi-version dependency management:

[0044] 1. Introduce version management tools and declare all dependencies in POM. 2. Determine whether the current reference is declared in the version dependency management (dependencyManagement). If so, load the declared version. 3. If 2 is not true, calculate the dependency path and find the version with the shortest path in the dependency tree to load. 4. If 3 does not have the shortest path, load them in order according to the declaration of the dependencies. 5. Execute compilation and loading. 6. Repeat 2-5.

[0045] Using spring boot for dependency isolation requires that the project must be a spring boot project and must be compiled using the spring boot compilation plug-in to take effect. Simply placing conflicting dependencies in different file directories to ensure that there are no dependency conflicts cannot actually solve dependency conflicts and allow conflicting dependencies to provide functions at the same time. Spring itself is a third-party dependency and has many indirect dependencies that are not conducive to the upgrade and maintenance of the later business system, and the coupling is too tight.

[0046] Figure 1 FIG. 1 is a schematic diagram of the main process of a method for implementing multi-version dependency isolation according to an embodiment of the present invention. Figure 1 As shown, an embodiment of the present invention provides a method for implementing multi-version dependency isolation, including:

[0047] Step S101. Add annotations to the method to be isolated;

[0048] Step S102: placing the dependent packages that need to be referenced in the method to be isolated into a reference directory file; the annotations correspond to the reference directory one by one;

[0049] Step S103. When executing the method to be isolated, determine the reference directory file where the dependent package is placed according to the annotation;

[0050] Step S104: Use a custom class loader to load the dependent packages in the reference directory file.

[0051] Because of the technical means of adding annotations, it is able to solve the problems that the project must be a spring boot project, must use the spring boot compilation plug-in, and the coupling degree is too high when using spring boot for dependency isolation, thereby achieving the coexistence of multiple versions of dependencies without distinguishing between project types and ensuring that each version of the dependency provides normal functions. At the same time, the running dependency version can be switched in real time to avoid system-locked upgrades that do not use the upgrade function.

[0052] In an embodiment of the present invention, after placing the dependency package to be referenced in the method to be isolated into the reference directory file, the process further includes: receiving a telnet command; performing at least one of the following operations on the dependency package according to the telnet command: selecting, traversing, adding, deleting, and moving to a backup area. Opening a telnet port for monitoring and plugging in dependencies allows users to perform dependency isolation-related operations through telnet commands, which is more controllable.

[0053] In an embodiment of the present invention, before executing the method to be isolated, it also includes: monitoring a business request, determining a redirection address according to the business request; and determining the method to be isolated to be executed according to the domain name of the redirection address. It can be realized that multiple web modules are packaged into a dependent plug-in, and the cross-server calls between internal systems are converted into internal calls.

[0054] The embodiment of the present invention provides a method for implementing multi-version dependency isolation, including: using a custom class loader to load a dependency package to obtain an object instance of the dependency package; starting a container and initializing a function processor in the container, registering the dependency package object instance in the function processor; when executing the method to be isolated, if a dependency needs to be referenced, then taking out and executing the dependency package object instance from the function processor. The embodiment of the present invention can solve the problems that the project must be a spring boot project, must use a spring boot compilation plug-in, and the coupling degree is too high in the process of using springboot for dependency isolation, thereby achieving the coexistence of multiple versions of dependencies without distinguishing project types and ensuring that each version of dependency provides normal functions, and at the same time can switch the running dependency version in real time, avoiding the system hijacking upgrade that does not use the upgrade function.

[0055] In the embodiment of the present invention, after registering the dependency package object instance in the function processor, the process further includes: receiving a telnet command; and performing at least one of the following operations on the dependency package object instance according to the telnet command: selecting, traversing, adding, deleting, and moving to a backup area. This allows users to perform dependency isolation related operations through telnet commands, which is more controllable.

[0056] In the embodiment of the present invention, before executing the method to be isolated, it also includes: monitoring a business request, determining a redirection address according to the business request; and determining the method to be isolated to be executed according to the domain name of the redirection address. It can be realized that multiple web modules are packaged into a dependent plug-in, and the cross-server calls between internal systems are converted into internal calls.

[0057] Figure 2 Schematic diagram of the main modules of the device for implementing multi-version dependency isolation according to an embodiment of the present invention. Figure 2 As shown, an embodiment of the present invention provides a device 200 for implementing multi-version dependency isolation, including:

[0058] Annotation module 201, used to: add annotations to the method to be isolated;

[0059] The placement module 202 is used to: place the dependent packages that need to be referenced in the method to be isolated into a reference directory file; the annotations correspond to the reference directory one by one;

[0060] The execution module 203 is used to: when executing the method to be isolated, determine the reference directory file where the dependent package is placed according to the annotation;

[0061] The loading module 204 is used to load the dependent packages in the reference directory file using a custom class loader.

[0062] In the embodiment of the present invention, the placement module 202 is further used to: receive a telnet command; and perform at least one of the following operations on the dependent package according to the telnet command: select, traverse, add, delete, and move to a backup area.

[0063] In the embodiment of the present invention, the execution module 204 is further used to: monitor a service request, determine a redirection address according to the service request; and determine the isolation method to be executed according to the domain name of the redirection address.

[0064] An embodiment of the present invention provides a device for implementing multi-version dependency isolation, including: a loading module, used to: use a custom class loader to load a dependency package to obtain an object instance of the dependency package; a registration module, used to: start a container and initialize a function processor in the container, and register the dependency package object instance in the function processor; a reference module, used to: when executing a method to be isolated, if a dependency needs to be referenced, then the dependency package object instance is retrieved from the function processor and executed.

[0065] In the embodiment of the present invention, the registration module is further used to: receive a telnet command; and perform at least one of the following operations on the dependent package object instance according to the telnet command: select, traverse, add, delete, and move to a backup area.

[0066] In the embodiment of the present invention, the reference module is further used to: monitor a service request, determine a redirection address according to the service request; and determine the isolation method to be executed according to the domain name of the redirection address.

[0067] The device of the present invention provides two isolation solutions through a custom class loader: real-time isolation and module isolation to meet the needs of different business scenarios.

[0068] Figure 3 is a schematic diagram of a real-time isolation model according to an embodiment of the present invention, such as Figure 3 As shown, this device provides a toolkit for real-time isolation. The user needs to add the @isolation annotation to the method to be isolated and place the third-party dependency package referenced by the method in the src / resources / isolation directory file. During execution, the URLClassLoader in the toolkit will load the referenced dependency from this directory.

[0069] Figure 4 is a schematic diagram of a module isolation model according to an embodiment of the present invention; Figure 4 As shown, for module isolation, this device provides a compilation plug-in. The plug-in uses the three modules of Fat, Plugin, and Facade to package the modules that need special processing into a jar package separately. The original business system only needs to reference this jar. When executing, the Plugin module needs to start the container Fat. Fat will initialize the built-in function processors and register them in the container. The Facade module will register the business service instance in each function processor. When referencing, directly from The module retrieves the object instance.

[0070] Figure 5 Schematic diagram of the real-time isolation process according to an embodiment of the present invention; Figure 5 As shown, Java classes are loaded by instances of java.lang.ClassLoader. However, the class loader itself is a class, so the Bootstrap class loader acts as the bootstrap class loader and is the parent of all other ClassLoader instances. It is the first loader executed, mainly loading the jar in the $JAVA_HOME / jre / lib directory. Then comes the Extension Class Loader and System Class Loader. Since java is a parent-delegated loading mode, the child class loader will only be called when none of the above class loaders can load. Since there is a dedicated annotation parser, the assigned class instance will be reconstructed in an environment where multiple versions of dependencies coexist. In most cases, the jars that require special treatment are placed in a fixed custom directory. The system's own class loader usually cannot load and will directly call the custom class loader for loading.

[0071] Figure 6 It is a schematic diagram of the processing process of module isolation according to an embodiment of the present invention; PluginManagerService is used to coordinate plug-in management in a multi-module coexistence scenario, FacadeManagerService is used to manage instance management of business service references, ClassloaderService is used to instantiate dependent objects, PluginDeployService is used to publish plug-ins, FacadeDeployService is used for dependency publishing RegistryService is used for service registration, each plug-in, i.e. business module, maintains a dependency list, InjectionService is used to inject reference instances into services, and TelnetServerService is used to implement telnet commands and receive operation instructions.

[0072] Figure 7 Schematic diagram of a telnet command processing model according to an embodiment of the present invention; Figure 7 As shown, the present invention implements telnet commands for runtime dependent plug-ins based on JVM socket and IO packages. When Fat in 1 completes the initialization of the built-in telnet processor, a telnet port will be opened for monitoring and plugging and unplugging the container and the plug-in in the container. The container of this device is implemented based on the java SET collection. After the user successfully shakes hands with the telnet command, the command operation on the container is implemented by sending the show / stop-fat-name_version.jar / start-fat-name_version.jar command. When the Fat module receives the instruction, it will choose to traverse, add, and delete (move to the backup area) services according to different instructions.

[0073] Figure 8 is a schematic diagram of merging and packaging multiple web modules into dependent plug-ins according to an embodiment of the present invention; Figure 8 As shown, multiple web modules are merged and coexist. The device of the present invention realizes the merging and packaging of multiple web modules as dependent plug-ins through a built-in web server. When the user specifies that the current module is a web module, the Fat module needs to weave the interceptor APIGetwayFilter into the isolation module when initializing the ClassLoader, and publish it as a web application after the container is initialized. If the business requires that the domain name of each module is different, it needs to be used in conjunction with the load machine. When the load machine monitors the business request, it redirects the request to the isolation module and distinguishes it according to the port. All requests are forwarded to the load machine, and the load machine is configured with a redirection address. The domain name of the address is the domain name of the isolation module running server, and different module services are distinguished by the port.

[0074] Fig. 9 is a system architecture diagram according to an embodiment of the present invention; Fig. 9 As shown:

[0075] Container: plugin container, responsible for the management of plugin package startup and runtime; the container has the function of managing plugins and applications; after the container is successfully started, it will automatically parse the plugin and facade dependencies contained in the classpath, complete the isolated loading and start them in order of priority;

[0076] Plugin: A built-in plug-in that meets the requirements of a specific directory format. It can package one or more ordinary Java jars into a standard format Fat Plugin. A Fat Plugin will contain a configuration file, which usually includes plug-in class import and export configuration, resource import and export configuration, plug-in startup priority, etc. At runtime, the container will use an independent PluginClassLoader to load the plug-in, and build a class loading index table and a resource loading index table according to the plug-in configuration, so that plug-ins and plug-ins, plug-ins and applications are isolated from each other.

[0077] Facade: Application module, which is the organizational unit of the engineering application and its dependent packages, contains all the dependencies and configurations required for application startup.

[0078] Fig.10 is a schematic diagram of a service deployment workflow according to an embodiment of the present invention; Fig.10 As shown, the service deployment workflow is as follows:

[0079] 1. If the bytecode generated by reflection is loaded, ClassNotFoundException will be thrown directly to terminate the class loading. This device only loads the jar in the specified directory.

[0080] 2. Find the class that has been loaded:

[0081] 2.1 If it is not loaded, search for classes in JDK. This part mainly includes two parts: the first part is the class that ExtClassloader is responsible for loading; the second part is the class provided by JDK but cannot be loaded from ExtClassloader, but will be added to the classpath of SystemClassloader when running locally. At the same time, these classes may be placed in some third-party toolkits, such as sun.tools.attach.BsdVirtualMachine in tool.jar. This part is also mainly derived from engineering practice to avoid classes being loaded more than once, which will cause errors.

[0082] 2.2 If 2.1 is not satisfied, entrust the loading to the custom class loader of the present invention.

[0083] 3. Initialize the container and put each function handler into the SET collection.

[0084] 4. Instantiate the handler in SET.

[0085] 5. Inject the referenced object instance into the business service.

[0086] 6. Repeat 1-5.

[0087] An embodiment of the present invention provides an electronic device, comprising: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement a method for implementing multi-version dependency isolation as provided in an embodiment of the present invention.

[0088] An embodiment of the present invention provides a computer-readable medium having a computer program stored thereon, and when the program is executed by a processor, the method for implementing multi-version dependency isolation as provided in the embodiment of the present invention is implemented.

[0089] Fig.11 An exemplary system architecture 1100 is shown to which a method or apparatus for implementing multi-version dependency isolation according to an embodiment of the present invention can be applied.

[0090] like Fig.11 As shown, system architecture 1100 may include terminal devices 1101, 1102, 1103, a network 1104, and a server 1105. Network 1104 is used to provide a medium for communication links between terminal devices 1101, 1102, 1103 and server 1105. Network 1104 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.

[0091] Users can use terminal devices 1101, 1102, 1103 to interact with server 1105 through network 1104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 1101, 1102, 1103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).

[0092] The terminal devices 1101 , 1102 , and 1103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.

[0093] The server 1105 may be a server that provides various services, such as a backend management server (only an example) that provides support for shopping websites browsed by users using the terminal devices 1101, 1102, and 1103. The backend management server may analyze and process the received data such as product information query requests, and feed back the processing results (such as target push information, product information - only an example) to the terminal device.

[0094] It should be noted that the method for implementing multi-version dependency isolation provided in the embodiment of the present invention is generally executed by the server 1105 , and accordingly, the device for implementing multi-version dependency isolation is generally set in the server 1105 .

[0095] It should be understood that Fig.11 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0096] Reference below Fig.12 , which shows a schematic diagram of the structure of a computer system 1200 of a terminal device suitable for implementing an embodiment of the present invention. Fig.12 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0097] like Fig.12 As shown, the computer system 1200 includes a central processing unit (CPU) 1201, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1202 or a program loaded from a storage part 1208 into a random access memory (RAM) 1203. In the RAM 1203, various programs and data required for the operation of the system 1200 are also stored. The CPU 1201, the ROM 1202, and the RAM 1203 are connected to each other via a bus 1204. An input / output (I / O) interface 1205 is also connected to the bus 1204.

[0098] The following components are connected to the I / O interface 1205: an input section 1206 including a keyboard, a mouse, etc.; an output section 1207 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1208 including a hard disk, etc.; and a communication section 1209 including a network interface card such as a LAN card, a modem, etc. The communication section 1209 performs communication processing via a network such as the Internet. A drive 1210 is also connected to the I / O interface 1205 as needed. A removable medium 1211, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1210 as needed, so that a computer program read therefrom is installed into the storage section 1208 as needed.

[0099] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1209, and / or installed from the removable medium 1211. When the computer program is executed by the central processing unit (CPU) 1201, the above-mentioned functions defined in the system of the present invention are executed.

[0100] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0101] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0102] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor, for example, may be described as: a processor including an annotation module, a placement module, an execution module, and a loading module. The names of these modules do not, in some cases, constitute limitations on the modules themselves, for example, the annotation module may also be described as a "module for adding annotations".

[0103] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: adding annotations to the method to be isolated; placing the dependent packages that need to be referenced in the method to be isolated into a reference directory file; the annotations correspond one-to-one with the reference directory; when executing the method to be isolated, determining the reference directory file where the dependent package is placed according to the annotations; and using a custom class loader to load the dependent packages in the reference directory file.

[0104] According to the technical solution of the embodiment of the present invention, because of the technical means of adding annotations, it is possible to solve the problems that the project must be a spring boot project, the spring boot compilation plug-in must be used, and the coupling degree is too high in the process of using spring boot for dependency isolation, thereby achieving the technical effect of realizing the coexistence of multiple versions of dependencies without distinguishing between project types and ensuring that each version of the dependency provides normal functions. At the same time, the running dependency version can be switched in real time, avoiding the system hijacking upgrade that does not use the upgrade function.

[0105] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for implementing multi-version dependency isolation, It is characterized in that include: Monitoring a service request and determining a redirection address according to the service request; Determining the isolation method to be executed according to the domain name of the redirection address; Add annotations to the method to be isolated; Place the dependent packages that need to be referenced in the method to be isolated into the reference directory file; The annotations correspond one-to-one to the reference catalog; When executing the method to be isolated, determining the reference directory file where the dependent package is placed according to the annotation; The dependent packages in the reference directory file are loaded using a custom class loader.

2. The method according to claim 1, It is characterized in that After placing the dependent packages that need to be referenced in the to-be-isolated method into the reference directory file, the method further includes: Receive telnet commands; According to the telnet command, at least one of the following operations is performed on the dependent package: selection, traversal, addition, deletion, and movement to a backup area.

3. The method according to claim 1 or 2, It is characterized in that Also includes: Use a custom class loader to load the dependent package and obtain the object instance of the dependent package; Start a container and initialize a function processor in the container, and register the dependent package object instance in the function processor; When executing the method to be isolated, if a dependency needs to be referenced, the dependency package object instance is taken out from the function processor and executed.

4. The method according to claim 3, It is characterized in that After registering the dependent package object instance into the function processor, the method further includes: Receive telnet commands; According to the telnet command, at least one of the following operations is performed on the dependent package object instance: selection, traversal, addition, deletion, and movement to a backup area.

5. A device for implementing multi-version dependency isolation, It is characterized in that include: An execution module is used to: monitor a service request and determine a redirection address according to the service request; Determining the isolation method to be executed according to the domain name of the redirection address; Annotation module, used to: add annotations to the method to be isolated; A placement module, used to: place the dependent packages that need to be referenced in the method to be isolated into a reference directory file; the annotations correspond to the reference directories one by one; The execution module is further used to: when executing the method to be isolated, determine the reference directory file where the dependent package is placed according to the annotation; The loading module is used to: use a custom class loader to load the dependent packages in the reference directory file.

6. The device according to claim 5, It is characterized in that The placement module is also used to: Receive telnet commands; According to the telnet command, at least one of the following operations is performed on the dependent package: selection, traversal, addition, deletion, and movement to a backup area.

7. The device according to claim 5 or 6, It is characterized in that Also includes: Register modules and reference modules; The loading module is also used to: load the dependent package using a custom class loader to obtain the object instance of the dependent package; A registration module, used to: start a container and initialize a function processor in the container, and register the dependent package object instance in the function processor; The reference module is used to: when executing the method to be isolated, if a dependency needs to be referenced, fetch and execute the dependency package object instance from the function processor.

8. The device according to claim 7, It is characterized in that The registration module is also used to: Receive telnet commands; According to the telnet command, at least one of the following operations is performed on the dependent package object instance: selection, traversal, addition, deletion, and movement to a backup area.

9. An electronic device, It is characterized in that include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 4.

10. A computer readable medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Method and device for modularizing of open platform

    CN103984567A

  • Class loading and isolating method and apparatus in Java application

    CN105404524A

  • Docker mirror image generation method and Docker container

    CN106933635A

  • Compilation processing method and apparatus, and electronic device

    CN107608677A

  • User-defined searching method based on ClassLoader

    CN107656775A