WO2020063252A1 - Method and device for isolating multiple version dependency - Google Patents

Method and device for isolating multiple version dependency Download PDF

Info

Publication number
WO2020063252A1
WO2020063252A1 PCT/CN2019/103533 CN2019103533W WO2020063252A1 WO 2020063252 A1 WO2020063252 A1 WO 2020063252A1 CN 2019103533 W CN2019103533 W CN 2019103533W WO 2020063252 A1 WO2020063252 A1 WO 2020063252A1
Authority
WO
WIPO (PCT)
Prior art keywords
isolated
dependent
module
dependency
dependent package
Prior art date
Application number
PCT/CN2019/103533
Other languages
French (fr)
Chinese (zh)
Inventor
韩晓飞
Original Assignee
京东数字科技控股有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 京东数字科技控股有限公司 filed Critical 京东数字科技控股有限公司
Publication of WO2020063252A1 publication Critical patent/WO2020063252A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management

Definitions

  • the present invention relates to the field of computer technology, and in particular, to a method and device for implementing multi-version dependency isolation.
  • the embodiments of the present invention provide a method and device for implementing multi-version dependency isolation, which can solve the problem that the project appearing in the process of using dependency isolation for spring boot must be a spring boot project, and a spring plugin must be used to compile the plug-in and coupling. The problem is too high.
  • a method for implementing multi-version dependency isolation includes: adding a comment to a method to be isolated; and placing a dependency package to be referenced in the method to be isolated to In the reference directory file; the annotation corresponds to the reference directory one by one; when the method to be isolated is executed, the reference directory file in which the dependent package is placed is determined according to the annotation; and a custom class loader is used to load the reference directory file Describes the dependencies in a directory file.
  • a method for implementing multi-version dependency isolation includes: using a custom class loader to load a dependency package to obtain an object instance of the dependency package; starting a container and initializing the container.
  • the function processor registers the dependent package object instance into the functional processor; when executing the method to be isolated, if a reference needs to be referenced, the dependent package object instance is removed from the functional processor and executed.
  • a device for implementing multi-version dependency isolation including: an annotation module for adding annotations to a method to be isolated; and a placing module for: isolating the method to be isolated
  • the dependent packages that need to be referenced are placed in the reference directory file; the annotations correspond to the reference directories one by one; an execution module is configured to: when executing the method to be isolated, determine the placement of the dependent packages according to the annotations A reference directory file; a loading module, configured to: use a custom class loader to load a dependent package in the reference directory file.
  • a device for implementing multi-version dependency isolation including: a loading module, configured to: use a custom class loader to load a dependent package to obtain an object instance of the dependent package; a registration module For: starting a container and initializing a function processor in the container, registering the dependent package object instance in the function processor; a reference module, for: when executing a method to be isolated, if a dependency needs to be referenced, Then take out and execute the dependent package object instance from the function processor.
  • an electronic device including: one or more processors; a storage device for storing one or more programs, and when the one or more programs are used by the one Or multiple processors, so that the one or more processors implement the method for implementing multi-version dependency isolation as proposed in the embodiment of the present invention.
  • a computer-readable medium on which a computer program is stored, and when the program is executed by a processor, the method for implementing multi-version dependency isolation as proposed in the embodiment of the present invention is implemented.
  • An embodiment of the above invention has the following advantages or beneficial effects: Because the technical means of adding annotations are used, the projects that can be solved in the process of using spring boot for dependency isolation must be spring boot projects, and spring plugins must be used to compile plugins And the degree of coupling is too high, which achieves the technical effect of relying on coexistence of multiple versions without distinguishing project types and ensuring that the versions rely on normal provision of functions. At the same time, the running dependent version can be switched in real time to avoid system abduction without the upgrade function. upgrade.
  • FIG. 1 is a schematic diagram of a main process of a method for implementing multi-version dependency isolation according to an embodiment of the present invention
  • FIG. 2 is a schematic diagram of main modules of an apparatus for implementing multi-version dependent isolation according to an embodiment of the present invention
  • FIG. 3 is a schematic diagram of a real-time isolation model according to an embodiment of the present invention.
  • FIG. 4 is a schematic diagram of a module isolation model according to an embodiment of the present invention.
  • FIG. 5 is a schematic diagram of a real-time isolation processing process according to an embodiment of the present invention.
  • FIG. 6 is a schematic diagram of a module isolation processing process according to an embodiment of the present invention.
  • FIG. 7 is a schematic diagram of a telnet command processing model according to an embodiment of the present invention.
  • FIG. 8 is a schematic diagram of combining and packaging multiple web modules into a dependent plug-in according to an embodiment of the present invention.
  • FIG. 9 is a system architecture diagram according to an embodiment of the present invention.
  • FIG. 10 is a schematic diagram of a service deployment workflow according to an embodiment of the present invention.
  • FIG. 11 is an exemplary system architecture diagram to which embodiments of the present invention can be applied.
  • FIG. 12 is a schematic structural diagram of a computer system suitable for implementing a terminal device or a server according to an embodiment of the present invention.
  • Maven is a software project management and understanding tool. Based on the concept of the Project Object Model (POM), Maven can manage project construction, reporting, and documentation from a central information. Is an open source component of the Apache community.
  • POM Project Object Model
  • Parental delegation Refers to the Java class loading model. The higher the class loader is, the earlier the class loader loads the classes under its loading path.
  • Spring boot for dependency isolation must require that the project is a spring boot project and must be compiled with the spring boot compilation plugin to take effect. Just separating conflicting dependencies into different file directories guarantees that there are no dependency conflicts. It does not substantially resolve dependency conflicts and allows conflicting dependencies to provide functions at the same time. Spring itself is a third-party dependency, and it has many indirect dependencies that are not conducive to the upgrade and maintenance of later business systems, and the coupling is too tight.
  • FIG. 1 is a schematic diagram of a main process of a method for implementing multi-version dependency isolation according to an embodiment of the present invention. As shown in FIG. 1, an embodiment of the present invention provides a method for implementing multi-version dependency isolation, including:
  • Step S101 Add a comment to the method to be isolated
  • Step S102 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;
  • Step S103 When the method to be isolated is executed, determine a reference directory file placed by the dependent package according to the annotation;
  • Step S104 Use a custom class loader to load the dependent packages in the reference directory file.
  • the project must be a spring boot project
  • the plugin must be compiled using spring boot, and the degree of coupling is too high, thereby achieving no distinction between project types. Realize the coexistence of multiple versions and ensure that each version depends on the normal provision of functions. At the same time, it can switch the running dependent version in real time to avoid the technical effects of upgrading the system without using the upgrade function.
  • the method further includes: receiving a telnet command; and performing at least one of the following dependent packages on the dependent package according to the telnet command.
  • the method before executing the method to be isolated, the method further includes: monitoring a service request, and determining a redirect address according to the service request; and determining the method to be isolated according to a domain name of the redirect address.
  • Multiple web modules can be implemented as a dependency plug-in, and cross-server calls are turned into internal calls for calls between internal systems.
  • An embodiment of the present invention provides a method for implementing multi-version dependency isolation, which includes: 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 The dependent package object instance is registered in the function processor; when the method to be isolated is executed, if the dependency needs to be referenced, the dependent package object instance is taken from the function processor and executed.
  • the embodiments of the present invention can solve the problem that the project that appears in the process of dependency isolation using spring boot must be a spring boot project, spring plugin must be used to compile plugins, and the degree of coupling is too high, so as to achieve the distinction of project types and achieve multi-version coexistence. It also guarantees that each version depends on the normal provision of functions, and at the same time, it can switch the running dependent version in real time to the technical effect, and avoid the abduction and upgrade of the system that does not use the upgrade function.
  • 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: Select, traverse, add, delete, move to the backup area. Users can use the telnet command to perform dependent isolation related operations, which has greater maneuverability.
  • the method before executing the method to be isolated, the method further includes: monitoring a service request, determining a redirection address according to the service request, and determining the method to be isolated according to a domain name of the redirection address.
  • Multiple web modules can be implemented as a dependency plug-in, and cross-server calls are turned into internal calls for calls between internal systems.
  • FIG. 2 is a schematic diagram of main modules of an apparatus for implementing multi-version dependent isolation according to an embodiment of the present invention. As shown in FIG. 2, an embodiment of the present invention provides a device 200 for implementing multi-version dependency isolation, including:
  • Annotation module 201 configured to: add annotations to the method to be isolated;
  • a placing module 202 is configured to: place the dependent packages to be referenced in the method to be isolated into a reference directory file; the annotations correspond to the reference directory one by one;
  • An execution module 203 is configured to: when executing the method to be isolated, determine a reference directory file placed by the dependent package according to the annotation;
  • a loading module 204 is configured to load a dependent package in the reference directory file by using a custom class loader.
  • the placing module 202 is further configured to: receive a telnet command; and perform 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.
  • the execution module 204 is further configured to monitor a service request, determine a redirection address according to the service request, and determine the method to be isolated based on a domain name of the redirection address.
  • An embodiment of the present invention provides a device for implementing multi-version dependency isolation, including: a loading module for loading a dependent package using a custom class loader to obtain an object instance of the dependent package; and a registration module for: starting a container And initialize the 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 the dependency needs to be referenced, the function is processed from the function The processor fetches and executes the dependent package object instance.
  • the registration module is further configured to: receive a telnet command; perform at least one of the following operations on the dependent package object instance according to the telne command: select, traverse, add, delete, move to a backup area .
  • the reference module is further configured to: monitor a service request, determine a redirection address according to the service request, and determine the method to be isolated according to a domain name of the redirection address.
  • the device of the present invention provides two isolation schemes through a custom class loader: real-time isolation and module isolation for different business scenario requirements.
  • FIG. 3 is a schematic diagram of a real-time isolation model according to an embodiment of the present invention.
  • a tool kit is provided for real-time isolation of the device.
  • the user needs to add a @isolation annotation to the method to be isolated and refer to the method by a third party Dependency packages are placed in the src / resources / isolation directory file, and URLClassLoader in the toolkit will load reference dependencies from this directory during execution.
  • FIG. 4 is a schematic diagram of a module isolation model according to an embodiment of the present invention.
  • a module plug-in is provided for the module isolation of the device, and the plug-in module is separately packaged into modules requiring special processing through Fat, Plugin and Facade A jar package, the original business system only needs to reference the jar.
  • 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 business service instances in each function processor. When referencing directly from The module fetches the object instance.
  • FIG. 5 is a schematic diagram of a real-time isolation processing process according to an embodiment of the present invention.
  • a Java class is loaded by an instance of java.lang.ClassLoader.
  • 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 to be executed. It mainly loads jars in the $ JAVA_HOME / jre / lib directory. Then there are Extension ClassLoader and SystemClassLoader. Since java is a parent-delegated loading mode, the subclass loader will only be called if the appealing class loader cannot load.
  • 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 For the plug-in release
  • FacadeDeployService is used to release the RegistryService for service registration.
  • Each plug-in is a business module to maintain a dependency list.
  • InjectionService is used to inject reference instances into the service.
  • TelnetServerService is used to implement telnet commands and receive operation instructions.
  • FIG. 7 is a schematic diagram of a telnet command processing model according to an embodiment of the present invention. As shown in FIG. 7, the present invention implements a JVM-based socket and an IO package to implement a telnet command for a runtime dependent plug-in.
  • Fat completes the initialization of the built-in telnet processor in 1, a telnet port will be opened for monitoring and plugging the container and the plug-in in the container.
  • the container of this device is implemented based on the java SET set.
  • the user can send the show / stop–fat–name_version.jar / start–fat–name_version.jar command to implement the instruction operation on the container.
  • the Fat module receives instructions, it will choose to traverse, add, and delete (move to the backup area) services according to different instructions.
  • FIG. 8 is a schematic diagram of combining and packaging multiple web modules into dependent plugins according to an embodiment of the present invention; as shown in FIG. 8, multiple web modules are merged and coexist.
  • the device of the present invention implements the integration and packaging of multiple web modules into a dependent plug-in through a built-in web server.
  • the Fat module needs to weave the interceptor APIGetwayFilter to the isolation module when it initializes the ClassLoader, and publish it as a web application after the container initialization is complete.
  • the loader listens to the business request, it redirects the request to the isolation module according to the port. All requests are forwarded to the loader, and the loader is configured with a redirection address.
  • the domain name of the address is the domain name of the server where the module is isolated, and different module services are distinguished by ports.
  • FIG. 9 is a system architecture diagram according to an embodiment of the present invention. As shown in FIG. 9:
  • Plug-in container which is responsible for the management of the plug-in package when it is started; the container has the function of managing plug-ins and applications; after the container is successfully started, it will automatically resolve the Plugin and facade dependencies contained in the classpath, complete the isolation load, and start them in order of priority;
  • Plugin Built-in plug-in, FatJar that meets the requirements of a specific directory format, can package one or more ordinary Java jars into a standard format FatPlugin; FatPlugin will include a configuration file, usually including plug-in class import and export configuration, Resource import and export configuration, plug-in startup priority, etc .; at runtime, the container will use a separate PluginClassLoader to load the plug-in, and build a class load index table and resource load index table based on the plug-in configuration, so that plug-ins and plug-ins, and between plug-ins and applications Isolated from each other
  • An application module is an organizational unit of an engineering application and its dependent packages. It contains all dependencies and configurations required for application startup.
  • FIG. 10 is a schematic diagram of a service deployment workflow according to an embodiment of the present invention. As shown in FIG. 10, the service deployment workflow is as follows:
  • This block mainly contains 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 it will be run locally They are added to the classpath of the SystemClassloader, and these classes may be put into some three-party toolkits, such as sun.tools.attach.BsdVirtualMachine in tool.jar. This part is also mainly derived from engineering practices to avoid classes being Loaded more than once, which caused an error.
  • An embodiment of the present invention provides an electronic device including: one or more processors; a storage device configured to store one or more programs, and when the one or more programs are executed by the one or more processors , So that the one or more processors implement the method for implementing multi-version dependency isolation provided by the embodiment of the present invention.
  • An embodiment of the present invention provides a computer-readable medium on which a computer program is stored.
  • the program is executed by a processor, the method for implementing multi-version dependency isolation provided by the embodiment of the present invention is implemented.
  • FIG. 11 illustrates an exemplary system architecture 1100 of a method or apparatus for implementing multi-version dependency isolation to which embodiments of the present invention can be applied.
  • the system architecture 1100 may include terminal devices 1101, 1102, 1103, a network 1104, and a server 1105.
  • the network 1104 is used to provide a medium for a communication link between the terminal devices 1101, 1102, 1103 and the server 1105.
  • the network 1104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, and so on.
  • the user can use the terminal devices 1101, 1102, 1103 to interact with the server 1105 through the network 1104 to receive or send messages and the like.
  • Various communication client applications can be installed on the terminal devices 1101, 1102, and 1103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, and the like (only examples).
  • the terminal devices 1101, 1102, 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.
  • the server 1105 may be a server that provides various services, for example, a background management server that provides support for a shopping website browsed by the user using the terminal devices 1101, 1102, and 1103 (for example only).
  • the background management server can analyze and process the received product information query request and other data, and feed back the processing results (such as target push information and product information-just examples) to the terminal device.
  • the method for implementing multi-version dependency isolation provided by the embodiment of the present invention is generally executed by the server 1105, and accordingly, a device for implementing multi-version dependency isolation is generally provided in the server 1105.
  • terminal devices, networks, and servers in FIG. 11 are merely exemplary. According to implementation needs, there can be any number of terminal devices, networks, and servers.
  • FIG. 12 shows a schematic structural diagram of a computer system 1200 suitable for implementing a terminal device according to an embodiment of the present invention.
  • the terminal device shown in FIG. 12 is only an example, and should not impose any limitation on the functions and scope of use of the embodiments of the present invention.
  • the computer system 1200 includes a central processing unit (CPU) 1201, which can be loaded into a random access memory (RAM) 1203 according to a program stored in a read-only memory (ROM) 1202 or loaded from a storage portion 1208. Instead, perform various appropriate actions and processes.
  • RAM random access memory
  • ROM read-only memory
  • 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 through a bus 1204.
  • An input / output (I / O) interface 1205 is also connected to the bus 1204.
  • the following components are connected to the I / O interface 1205: an input portion 1206 including a keyboard, a mouse, and the like; an output portion 1207 including a cathode ray tube (CRT), a liquid crystal display (LCD), and the speaker; a storage portion 1208 including a hard disk and the like And a communication section 1209 including a network interface card such as a LAN card, a modem, and the like.
  • the communication section 1209 performs communication processing via a network such as the Internet.
  • the driver 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.
  • the process described above with reference to the flowchart may be implemented as a computer software program.
  • the disclosed embodiments include a computer program product including a computer program carried on a computer-readable medium, the computer program containing program code for performing the method shown in the flowchart.
  • the computer program may be downloaded and installed from a network through the communication portion 1209, and / or installed from a removable medium 1211.
  • CPU central processing unit
  • 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 foregoing.
  • the computer-readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable Programming read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the foregoing.
  • a computer-readable storage medium may be any tangible medium containing or storing a program, and the program may be used by or in combination with an instruction execution system, apparatus, or device.
  • the computer-readable signal medium may include a data signal transmitted in baseband or transmitted as a part of a carrier wave, in which a computer-readable program code is carried. Such a propagated data signal may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing.
  • the computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, and the computer-readable medium may send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device .
  • Program code embodied on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
  • each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, which contains one or more of the logic functions used to implement the specified logic.
  • Executable instructions may also occur in a different order than those marked in the drawings. For example, two successively represented boxes may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved.
  • each block in the block diagram or flowchart, and combinations of blocks in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with A combination of dedicated hardware and computer instructions.
  • the modules described in the embodiments of the present invention may be implemented by software or hardware.
  • the described module may also be provided in the processor, for example, it 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 any way constitute a limitation on the module itself.
  • the annotation module can also be described as a "module for adding annotations”.
  • the present invention also provides a computer-readable medium.
  • the computer-readable medium may be included in the device described in the foregoing embodiments, or may exist alone without being assembled into the device.
  • the computer-readable medium carries one or more programs.
  • the device includes: adding a comment to the method to be isolated; and quoting the method to be isolated.
  • the dependent package is placed in the reference directory file; the annotation corresponds to the reference directory one by one; when the method to be isolated is executed, the reference directory file placed by the dependent package is determined according to the annotation; and a custom class is used for loading A loader that loads the dependent packages in the reference directory file.
  • the projects that can be resolved in the process of using spring boot for dependency isolation must be spring boot projects, spring plugins must be compiled, and the degree of coupling is too high.
  • the running dependent versions can be switched in real time to avoid the system abduction upgrade without using the upgrade function.

Abstract

The present invention relates to the technical field of computers, and disclosed thereby are a method and device for isolating multiple version dependency. A specific embodiment of the method comprises: adding an annotation in a method to be isolated; placing a dependency package that must be referenced in the method to be isolated into a reference directory file, the annotation corresponding one-to-one to a reference directory; determining the reference directory file in which the dependency package is placed according to the annotation when executing the method to be isolated; loading the dependency package in the reference directory file by using a custom class loader. The specific embodiment is capable of solving problems such as the degree of coupling being too high which occurs when carrying out dependency isolation by using spring boot, thereby achieving the the technical effect of multiple dependent versions coexisting without distinguishing item type and guaranteeing that each version dependency normally provides functions, while a run dependent version may be switched in real time to prevent a system not using an upgrade function from hijacking an upgrade.

Description

一种实现多版本依赖隔离的方法和装置Method and device for implementing multi-version dependency isolation 技术领域Technical field
本发明涉及计算机技术领域,尤其涉及一种实现多版本依赖隔离的方法和装置。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 technique
在大型、复杂的业务系统中为了提高代码的简洁、通用、复用等特性会把通用的功能部分打成jar包以供有相同业务功能的系统引用,这样可以有效规避重复开发,缩减研发投入,这称为第三方依赖。另一种依赖随着微服务和SOA化的推广,各个系统从功能、职责、业务属性、领域模型等多维度进行切割,而一个完整的功能闭环就需要多个系统协作完成,此时各业务系统需要暴露自己的API jar作为己方的对外输出功能的调用入口,如此才能完成一个完整的功能,这是内部依赖。无论是内部依赖还是外部依赖都需要对引用的jar进行版本维护,通常使用spring boot进行依赖隔离。In large and complex business systems, in order to improve the conciseness, generality, and reuse of the code, the common functional parts are 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 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 multiple systems to cooperate to complete. The system needs to expose its own API jar as its own entry point for external output functions, so as to complete a complete function, which is an internal dependency. Both internal and external dependencies require version maintenance of the referenced jars, and usually spring isolation is used for dependency isolation.
在实现本发明过程中,发明人发现现有技术中至少存在如下问题:In the process of implementing the present invention, the inventors found that at least the following problems exist in the prior art:
1.使用spring boot进行依赖隔离必须要求项目是spring boot项目并必须使用spring boot编译插件编译才能生效。1. Dependency isolation using spring boot must require that the project is a spring boot project and must be compiled with the spring boot compilation plugin to take effect.
2.spring本身属于第三方依赖,自身有许多间接依赖不利于后期业务系统的升级维护,耦合太紧。2.Spring itself is a third-party dependency, and it has many indirect dependencies that are not conducive to the upgrade and maintenance of later business systems, and the coupling is too tight.
3.针对内部依赖每次的升级需要通知到所有的依赖方,即便该方未使用本次升级的功能也需要协同进行同步升级。3. For each update of internal dependencies, all the relying parties need to be notified. Even if the party does not use the function of this upgrade, it needs to synchronize the upgrade.
4.针对外部(第三方)的依赖无法更改其依赖内部的间接依赖以及升级功能的剥离或者忽略,难以保证以往系统功能的正常。4. Dependence on external (third party) cannot change its internal indirect dependency and the stripping or neglect of the upgrade function, and it is difficult to guarantee the normal function of the previous system.
发明内容Summary of the Invention
有鉴于此,本发明实施例提供一种实现多版本依赖隔离的方法和 装置,能够解决在使用spring boot进行依赖隔离的过程中出现的项目必须是spring boot项目、必须使用spring boot编译插件和耦合度太高的问题。In view of this, the embodiments of the present invention provide a method and device for implementing multi-version dependency isolation, which can solve the problem that the project appearing in the process of using dependency isolation for spring boot must be a spring boot project, and a spring plugin must be used to compile the plug-in and coupling. The problem is too high.
为实现上述目的,根据本发明实施例的一个方面,提供了一种实现多版本依赖隔离的方法,包括:在待隔离方法中添加注解;将所述待隔离方法中需要引用的依赖包放置到引用目录文件中;所述注解与所述引用目录一一对应;执行所述待隔离方法时,根据所述注解确定所述依赖包放置的引用目录文件;利用自定义的类加载器,加载所述引用目录文件中的依赖包。To achieve the above object, according to an aspect of the embodiment of the present invention, a method for implementing multi-version dependency isolation is provided, which includes: adding a comment to a method to be isolated; and placing a dependency package to be referenced in the method to be isolated to In the reference directory file; the annotation corresponds to the reference directory one by one; when the method to be isolated is executed, the reference directory file in which the dependent package is placed is determined according to the annotation; and a custom class loader is used to load the reference directory file Describes the dependencies in a directory file.
根据本发明实施例的另一个方面,提供了一种实现多版本依赖隔离的方法,包括:利用自定义的类加载器加载依赖包,得到依赖包的对象实例;启动容器并初始化所述容器内的功能处理器,将所述依赖包对象实例注册到所述功能处理器内;执行待隔离方法时,若需要引用依赖,则从所述功能处理器中取出并执行所述依赖包对象实例。According to another aspect of the embodiments of the present invention, a method for implementing multi-version dependency isolation is provided, which includes: using a custom class loader to load a dependency package to obtain an object instance of the dependency package; starting a container and initializing the container. The function processor registers the dependent package object instance into the functional processor; when executing the method to be isolated, if a reference needs to be referenced, the dependent package object instance is removed from the functional processor and executed.
根据本发明实施例的再一个方面,提供了一种实现多版本依赖隔离的装置,包括:注解模块,用于:在待隔离方法中添加注解;放置模块,用于:将所述待隔离方法中需要引用的依赖包放置到引用目录文件中;所述注解与所述引用目录一一对应;执行模块,用于:执行所述待隔离方法时,根据所述注解确定所述依赖包放置的引用目录文件;加载模块,用于:利用自定义的类加载器,加载所述引用目录文件中的依赖包。According to still another aspect of the embodiments of the present invention, a device for implementing multi-version dependency isolation is provided, including: an annotation module for adding annotations to a method to be isolated; and a placing module for: isolating the method to be isolated The dependent packages that need to be referenced are placed in the reference directory file; the annotations correspond to the reference directories one by one; an execution module is configured to: when executing the method to be isolated, determine the placement of the dependent packages according to the annotations A reference directory file; a loading module, configured to: use a custom class loader to load a dependent package in the reference directory file.
根据本发明实施例的再一个方面,提供了一种实现多版本依赖隔离的装置,包括:加载模块,用于:利用自定义的类加载器加载依赖包,得到依赖包的对象实例;注册模块,用于:启动容器并初始化所述容器内的功能处理器,将所述依赖包对象实例注册到所述功能处理器内;引用模块,用于:执行待隔离方法时,若需要引用依赖,则从 所述功能处理器中取出并执行所述依赖包对象实例。According to still another aspect of the embodiments of the present invention, a device for implementing multi-version dependency isolation is provided, including: a loading module, configured to: use a custom class loader to load a dependent package to obtain an object instance of the dependent package; a registration module For: starting a container and initializing a function processor in the container, registering the dependent package object instance in the function processor; a reference module, for: when executing a method to be isolated, if a dependency needs to be referenced, Then take out and execute the dependent package object instance from the function processor.
根据本发明实施例的再一个方面,提供了一种电子设备,包括:一个或多个处理器;存储装置,用于存储一个或多个程序,当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如本发明实施例提出的实现多版本依赖隔离的方法。According to still another aspect of the embodiments of the present invention, there is provided an electronic device including: one or more processors; a storage device for storing one or more programs, and when the one or more programs are used by the one Or multiple processors, so that the one or more processors implement the method for implementing multi-version dependency isolation as proposed in the embodiment of the present invention.
根据本发明实施例的再一个方面,提供了一种计算机可读介质,其上存储有计算机程序,所述程序被处理器执行时实现如本发明实施例提出的实现多版本依赖隔离的方法。According to still another aspect of the embodiments of the present invention, there is provided a computer-readable medium on which a computer program is stored, and when the program is executed by a processor, the method for implementing multi-version dependency isolation as proposed in the embodiment of the present invention is implemented.
上述发明中的一个实施例具有如下优点或有益效果:因为采用添加注解的技术手段,所以能够解决在使用spring boot进行依赖隔离的过程中出现的项目必须是spring boot项目、必须使用spring boot编译插件和耦合度太高的问题,进而达到不区分项目类型实现依赖多版本共存并保证各版本依赖正常提供功能,同时可以实时对运行的依赖版本进行切换的技术效果,避免未使用升级功能的系统绑架升级。An embodiment of the above invention has the following advantages or beneficial effects: Because the technical means of adding annotations are used, the projects that can be solved in the process of using spring boot for dependency isolation must be spring boot projects, and spring plugins must be used to compile plugins And the degree of coupling is too high, which achieves the technical effect of relying on coexistence of multiple versions without distinguishing project types and ensuring that the versions rely on normal provision of functions. At the same time, the running dependent version can be switched in real time to avoid system abduction without the upgrade function. upgrade.
上述的非惯用的可选方式所具有的进一步效果将在下文中结合具体实施方式加以说明。Further effects of the above-mentioned non-conventional alternative manners will be described below in conjunction with specific embodiments.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
附图用于更好地理解本发明,不构成对本发明的不当限定。其中:The drawings are for better understanding of the present invention, and do not constitute an improper limitation on the present invention. among them:
图1是根据本发明实施例的实现多版本依赖隔离的方法的主要流程的示意图;1 is a schematic diagram of a main process of a method for implementing multi-version dependency isolation according to an embodiment of the present invention;
图2是根据本发明实施例的实现多版本依赖隔离的装置的主要模块的示意图;2 is a schematic diagram of main modules of an apparatus for implementing multi-version dependent isolation according to an embodiment of the present invention;
图3是根据本发明实施例的实时隔离模型的示意图;3 is a schematic diagram of a real-time isolation model according to an embodiment of the present invention;
图4是根据本发明实施例的模块隔离模型的示意图;4 is a schematic diagram of a module isolation model according to an embodiment of the present invention;
图5是根据本发明实施例的实时隔离的处理过程示意图;5 is a schematic diagram of a real-time isolation processing process according to an embodiment of the present invention;
图6是根据本发明实施例的模块隔离的处理过程示意图;6 is a schematic diagram of a module isolation processing process according to an embodiment of the present invention;
图7是根据本发明实施例的telnet命令处理模型的示意图;7 is a schematic diagram of a telnet command processing model according to an embodiment of the present invention;
图8是根据本发明实施例的多web模块合并打包为依赖插件的示意图;FIG. 8 is a schematic diagram of combining and packaging multiple web modules into a dependent plug-in according to an embodiment of the present invention; FIG.
图9是根据本发明实施例的系统架构图;FIG. 9 is a system architecture diagram according to an embodiment of the present invention;
图10是根据本发明实施例的服务部署工作流程的示意图;10 is a schematic diagram of a service deployment workflow according to an embodiment of the present invention;
图11是本发明实施例可以应用于其中的示例性系统架构图;11 is an exemplary system architecture diagram to which embodiments of the present invention can be applied;
图12是适于用来实现本发明实施例的终端设备或服务器的计算机系统的结构示意图。FIG. 12 is a schematic structural diagram of a computer system suitable for implementing a terminal device or a server according to an embodiment of the present invention.
具体实施方式detailed description
以下结合附图对本发明的示范性实施例做出说明,其中包括本发明实施例的各种细节以助于理解,应当将它们认为仅仅是示范性的。因此,本领域普通技术人员应当认识到,可以对这里描述的实施例做出各种改变和修改,而不会背离本发明的范围和精神。同样,为了清楚和简明,以下的描述中省略了对公知功能和结构的描述。The following describes exemplary embodiments of the present invention with reference to the accompanying drawings, which include various details of the embodiments of the present invention to facilitate understanding, and they should be considered as merely exemplary. Accordingly, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the invention. Also, for clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
技术术语的名词解释Glossary of technical terms
Maven:是一个软件项目管理和理解工具。基于项目对象模型(POM)的概念,Maven可以从一个中心信息管理项目的构建,报告和文档。是Apache社区的一个开源组件。Maven: is a software project management and understanding tool. Based on the concept of the Project Object Model (POM), Maven can manage project construction, reporting, and documentation from a central information. Is an open source component of the Apache community.
双亲委派:指java类加载的模型,层级越高的类加载器越先加载其加载路径下的类。Parental delegation: Refers to the Java class loading model. The higher the class loader is, the earlier the class loader loads the classes under its loading path.
现有技术中,无论是内部依赖还是外部依赖都需要对引用的jar进行版本维护。针对内部依赖每次的升级需要通知到所有的依赖方,即便该方未使用本次升级的功能也需要协同进行同步升级,这通常有编译规则的约束。针对外部(第三方)的依赖无法更改其依赖内部的间接依赖以及升级功能的剥离或者忽略,而如果的业务系统是一个庞大的系统如果此时贸然的进行高(低)版本的忽略则难以保证以往功能的 正常。In the prior art, whether it is an internal dependency or an external dependency, it is necessary to perform version maintenance on the referenced jar. Each update for internal dependencies needs to be notified to all relying parties. Even if the party does not use the function of this upgrade, it needs to synchronize the upgrade. This is usually subject to compilation rules. For external (third-party) dependencies, you cannot change its internal indirect dependencies and the stripping or neglect of the upgrade function. If the business system is a large system, it is difficult to guarantee if the high (low) version is ignored at this time. The previous function is normal.
现有技术中使用spring boot基于maven的多版本依赖管理:Maven-based multi-version dependency management using spring boot in the prior art:
1.引入版本管理工具并在POM中声明所有依赖项。2.判断当前引用是否声明在于版本依赖管理(dependencyManagement)里面,如果存在则加载声明版本。3.如果2不成立,则计算依赖路径,找出共存位于依赖树中最短路径的版本加载。4.如果3不存在最短路径则根据依赖项的声明先后进行加载。5.执行编译、加载。6.重复2-5。1. Introduce version management tools and declare all dependencies in the POM. 2. Determine whether the current reference is declared in version dependency management, and if it exists, load the declared version. 3. If 2 is not true, calculate the dependency path to find the version of the shortest path coexisting in the dependency tree. 4. If 3 does not have the shortest path, then load according to the declaration of the dependency. 5. Perform compilation and loading. 6. Repeat 2-5.
使用spring boot进行依赖隔离必须要求项目是spring boot项目并必须使用spring boot编译插件编译才能生效。只是将冲突的依赖分置于不同的文件目录保证没有依赖冲突,并不能实质上解决依赖冲突,让冲突的依赖项同时提供功能。spring本身属于第三方依赖,自身有许多间接依赖不利于后期业务系统的升级维护,耦合太紧。Using spring boot for dependency isolation must require that the project is a spring boot project and must be compiled with the spring boot compilation plugin to take effect. Just separating conflicting dependencies into different file directories guarantees that there are no dependency conflicts. It does not substantially resolve dependency conflicts and allows conflicting dependencies to provide functions at the same time. Spring itself is a third-party dependency, and it has many indirect dependencies that are not conducive to the upgrade and maintenance of later business systems, and the coupling is too tight.
图1是根据本发明实施例的实现多版本依赖隔离的方法的主要流程的示意图。如图1所示,本发明实施例提供了一种实现多版本依赖隔离的方法,包括:FIG. 1 is a schematic diagram of a main process of a method for implementing multi-version dependency isolation according to an embodiment of the present invention. As shown in FIG. 1, an embodiment of the present invention provides a method for implementing multi-version dependency isolation, including:
步骤S101.在待隔离方法中添加注解;Step S101. Add a comment to the method to be isolated;
步骤S102.将所述待隔离方法中需要引用的依赖包放置到引用目录文件中;所述注解与所述引用目录一一对应;Step S102. 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;
步骤S103.执行所述待隔离方法时,根据所述注解确定所述依赖包放置的引用目录文件;Step S103. When the method to be isolated is executed, determine a reference directory file placed by the dependent package according to the annotation;
步骤S104.利用自定义的类加载器,加载所述引用目录文件中的依赖包。Step S104. Use a custom class loader to load the dependent packages in the reference directory file.
因为采用添加注解的技术手段,所以能够解决在使用spring boot进行依赖隔离的过程中出现的项目必须是spring boot项目、必须使用spring boot编译插件和耦合度太高的问题,进而达到不区分项目类型实现依赖多版本共存并保证各版本依赖正常提供功能,同时可以实时对运行的依赖版本进行切换的技术效果,避免未使用升级功能的系统绑架升级。Because the technical means of adding annotations can be used to solve the problems that occur in the process of using spring boot for dependency isolation, the project must be a spring boot project, the plugin must be compiled using spring boot, and the degree of coupling is too high, thereby achieving no distinction between project types. Realize the coexistence of multiple versions and ensure that each version depends on the normal provision of functions. At the same time, it can switch the running dependent version in real time to avoid the technical effects of upgrading the system without using the upgrade function.
本发明实施例中,所述将所述待隔离方法中需要引用的依赖包放置到引用目录文件中之后,还包括:接收telnet命令;根据所述telnet命令对所述依赖包进行以下至少之一的操作:选择、遍历、增加、删除、移动到备份区。开放一个telnet端口用于对依赖的监控和插拔,可以使用户通过telnet命令来进行依赖隔离相关操作,有更大的可操控性。In the embodiment of the present invention, after the placing the dependent package to be referenced in the method to be isolated into a reference directory file, the method further includes: receiving a telnet command; and performing at least one of the following dependent packages on the dependent package according to the telnet command. Operations: select, traverse, add, delete, move to the backup area. Opening a telnet port for monitoring and plugging in dependencies can enable users to perform dependency isolation related operations through telnet commands, which has greater maneuverability.
本发明实施例中,执行所述待隔离方法之前,还包括:监听到业务请求,根据所述业务请求确定重定向地址;根据所述重定向地址的域名,确定要执行的所述待隔离方法。可以实现多个web模块打成一个依赖插件,对于内部系统之间的调用跨服务器调用转为内部调用。In the embodiment of the present invention, before executing the method to be isolated, the method further includes: monitoring a service request, and determining a redirect address according to the service request; and determining the method to be isolated according to a domain name of the redirect address. . Multiple web modules can be implemented as a dependency plug-in, and cross-server calls are turned into internal calls for calls between internal systems.
本发明实施例提供了一种实现多版本依赖隔离的方法,包括:利用自定义的类加载器加载依赖包,得到依赖包的对象实例;启动容器并初始化所述容器内的功能处理器,将所述依赖包对象实例注册到所述功能处理器内;执行待隔离方法时,若需要引用依赖,则从所述功能处理器中取出并执行所述依赖包对象实例。本发明实施例能够解决在使用spring boot进行依赖隔离的过程中出现的项目必须是spring boot项目、必须使用spring boot编译插件和耦合度太高的问题,进而达到不区分项目类型实现依赖多版本共存并保证各版本依赖正常提供功能,同时可以实时对运行的依赖版本进行切换的技术效果,避免未使用升级功能的系统绑架升级。An embodiment of the present invention provides a method for implementing multi-version dependency isolation, which includes: 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 The dependent package object instance is registered in the function processor; when the method to be isolated is executed, if the dependency needs to be referenced, the dependent package object instance is taken from the function processor and executed. The embodiments of the present invention can solve the problem that the project that appears in the process of dependency isolation using spring boot must be a spring boot project, spring plugin must be used to compile plugins, and the degree of coupling is too high, so as to achieve the distinction of project types and achieve multi-version coexistence. It also guarantees that each version depends on the normal provision of functions, and at the same time, it can switch the running dependent version in real time to the technical effect, and avoid the abduction and upgrade of the system that does not use the upgrade function.
本发明实施例中,所述将依赖包对象实例注册到所述功能处理器内之后,还包括:接收telnet命令;根据所述telnet命令对所述依赖包对象实例进行以下至少之一的操作:选择、遍历、增加、删除、移动到备份区。可以使用户通过telnet命令来进行依赖隔离相关操作,有更大的可操控性。In the embodiment of the present invention, after registering the dependent package object instance in the function 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: Select, traverse, add, delete, move to the backup area. Users can use the telnet command to perform dependent isolation related operations, which has greater maneuverability.
本发明实施例中,执行待隔离方法之前,还包括:监听到业务请求,根据所述业务请求确定重定向地址;根据所述重定向地址的域名,确定要执行的所述待隔离方法。可以实现多个web模块打成一个依赖插件,对于内部系统之间的调用跨服务器调用转为内部调用。In the embodiment of the present invention, before executing the method to be isolated, the method further includes: monitoring a service request, determining a redirection address according to the service request, and determining the method to be isolated according to a domain name of the redirection address. Multiple web modules can be implemented as a dependency plug-in, and cross-server calls are turned into internal calls for calls between internal systems.
图2是根据本发明实施例的实现多版本依赖隔离的装置的主要模块的示意图。如图2所示,本发明实施例提供了一种实现多版本依赖隔离的装置200,包括:FIG. 2 is a schematic diagram of main modules of an apparatus for implementing multi-version dependent isolation according to an embodiment of the present invention. As shown in FIG. 2, an embodiment of the present invention provides a device 200 for implementing multi-version dependency isolation, including:
注解模块201,用于:在待隔离方法中添加注解; Annotation module 201, configured to: add annotations to the method to be isolated;
放置模块202,用于:将所述待隔离方法中需要引用的依赖包放置到引用目录文件中;所述注解与所述引用目录一一对应;A placing module 202 is configured to: place the dependent packages to be referenced in the method to be isolated into a reference directory file; the annotations correspond to the reference directory one by one;
执行模块203,用于:执行所述待隔离方法时,根据所述注解确定所述依赖包放置的引用目录文件;An execution module 203 is configured to: when executing the method to be isolated, determine a reference directory file placed by the dependent package according to the annotation;
加载模块204,用于:利用自定义的类加载器,加载所述引用目录文件中的依赖包。A loading module 204 is configured to load a dependent package in the reference directory file by using a custom class loader.
本发明实施例中,所述放置模块202还用于:接收telnet命令;根据所述telnet命令对所述依赖包进行以下至少之一的操作:选择、遍历、增加、删除、移动到备份区。In the embodiment of the present invention, the placing module 202 is further configured to: receive a telnet command; and perform 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.
本发明实施例中,所述执行模块204,还用于:监听到业务请求,根据所述业务请求确定重定向地址;根据所述重定向地址的域名,确定要执行的所述待隔离方法。In the embodiment of the present invention, the execution module 204 is further configured to monitor a service request, determine a redirection address according to the service request, and determine the method to be isolated based on a domain name of the redirection address.
本发明实施例提供了一种实现多版本依赖隔离的装置,包括:加载模块,用于:利用自定义的类加载器加载依赖包,得到依赖包的对象实例;注册模块,用于:启动容器并初始化所述容器内的功能处理器,将所述依赖包对象实例注册到所述功能处理器内;引用模块,用于:执行待隔离方法时,若需要引用依赖,则从所述功能处理器中取出并执行所述依赖包对象实例。An embodiment of the present invention provides a device for implementing multi-version dependency isolation, including: a loading module for loading a dependent package using a custom class loader to obtain an object instance of the dependent package; and a registration module for: starting a container And initialize the 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 the dependency needs to be referenced, the function is processed from the function The processor fetches and executes the dependent package object instance.
本发明实施例中,所述注册模块还用于:接收telnet命令;根据所述telne命令对所述依赖包对象实例进行以下至少之一的操作:选择、遍历、增加、删除、移动到备份区。In the embodiment of the present invention, the registration module is further configured to: receive a telnet command; perform at least one of the following operations on the dependent package object instance according to the telne command: select, traverse, add, delete, move to a backup area .
本发明实施例中,所述引用模块还用于:监听到业务请求,根据所述业务请求确定重定向地址;根据所述重定向地址的域名,确定要执行的所述待隔离方法。In the embodiment of the present invention, the reference module is further configured to: monitor a service request, determine a redirection address according to the service request, and determine the method to be isolated according to a domain name of the redirection address.
本发明装置通过自定义类加载器提供两种隔离方案:实时隔离、模块隔离,以供不同的业务场景需求。The device of the present invention provides two isolation schemes through a custom class loader: real-time isolation and module isolation for different business scenario requirements.
图3是根据本发明实施例的实时隔离模型的示意图,如图3所示,针对实时隔离本装置提供工具包,用户需要在需隔离的方法上添加@isolation注解并将该方法引用的第三方依赖包放置到src/resources/isolation目录文件下,执行时工具包内的URLClassLoader会从此目录下加载引用依赖。FIG. 3 is a schematic diagram of a real-time isolation model according to an embodiment of the present invention. As shown in FIG. 3, a tool kit is provided for real-time isolation of the device. The user needs to add a @isolation annotation to the method to be isolated and refer to the method by a third party Dependency packages are placed in the src / resources / isolation directory file, and URLClassLoader in the toolkit will load reference dependencies from this directory during execution.
图4是根据本发明实施例的模块隔离模型的示意图;如图4所示,针对模块隔离本装置提供编译插件,该插件通过Fat、Plugin、Facade三个模块将需特殊处理的模块单独打包成一个jar包,原业务系统只需要引用该jar即可。执行时Plugin模块需要启动容器Fat,Fat会初始化内置的各个功能处理器,并将其注册到容器内,Facade模块会将业务service实例注册到各个功能处理器内。引用时直接从
Figure PCTCN2019103533-appb-000001
模块取出对象实例。
FIG. 4 is a schematic diagram of a module isolation model according to an embodiment of the present invention; as shown in FIG. 4, a module plug-in is provided for the module isolation of the device, and the plug-in module is separately packaged into modules requiring special processing through Fat, Plugin and Facade A jar package, the original business system only needs to reference the jar. During execution, 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 business service instances in each function processor. When referencing directly from
Figure PCTCN2019103533-appb-000001
The module fetches the object instance.
图5是根据本发明实施例的实时隔离的处理过程示意图;如图5所示,Java类由java.lang.ClassLoader的实例加载。但是,类加载器本身就是类所以Bootstrap类加载器充当引导类加载器是所有其他ClassLoader实例的父级。是最先执行的加载器,主要加载 $JAVA_HOME/jre/lib目录下的jar。而后是Extension Class Loader和System Class Loader,由于java是双亲委托的加载模式,所以只有在上诉类加载器都无法加载的情况下才会去调用子类加载器。由于有专属的注解解析器,所以在多版本依赖共存的环境下会对赋值后类实例进行重构。大部分情况下需要特殊处理的jar是放在固定的自定义目录下的,系统自有的类加载器通常无法加载会直接调用自定义的类加载器进行加载。FIG. 5 is a schematic diagram of a real-time isolation processing process according to an embodiment of the present invention; as shown in FIG. 5, a Java class is loaded by an instance 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 to be executed. It mainly loads jars in the $ JAVA_HOME / jre / lib directory. Then there are Extension ClassLoader and SystemClassLoader. Since java is a parent-delegated loading mode, the subclass loader will only be called if the appealing class loader cannot load. Due to the exclusive annotation parser, the class instance after the assignment is refactored in the environment where multiple versions rely on coexistence. In most cases, jars that require special processing are placed in a fixed custom directory. The system's own class loader usually cannot load and will directly call the custom class loader to load.
图6是根据本发明实施例的模块隔离的处理过程示意图;PluginManagerService用于协调多模块共存情境下的插件管理,FacadeManagerService用于管理业务服务引用的实例管理,ClassloaderService用于实例化依赖对象,PluginDeployService用于插件的发布,FacadeDeployService用于依赖发布RegistryService用于服务注册,每个插件即业务模块维护一个依赖列表,InjectionService用于向服务注入引用实例,TelnetServerService用于实现telnet命令和接收操作指令。6 is a schematic diagram of a module isolation process 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, and PluginDeployService is used For the plug-in release, FacadeDeployService is used to release the RegistryService for service registration. Each plug-in is a business module to maintain a dependency list. InjectionService is used to inject reference instances into the service. TelnetServerService is used to implement telnet commands and receive operation instructions.
图7是根据本发明实施例的telnet命令处理模型的示意图;如图7所示,本发明实现基于JVM的socket和IO包实现针对运行时依赖插件的telnet命令。当1中Fat完成内置telnet处理器初始化后会开放一个telnet端口用于对容器和容器内插件的监控和插拔。本装置的容器基于java SET集合实现,用户通过telnet命令握手成功后通过发送show/stop–fat–name_version.jar/start–fat–name_version.jar命令实现对容器的指令操作。当Fat模块收到指令时会根据不同的指令选择遍历、增加、删除(移动到备份区)服务。FIG. 7 is a schematic diagram of a telnet command processing model according to an embodiment of the present invention; as shown in FIG. 7, the present invention implements a JVM-based socket and an IO package to implement a telnet command for a runtime dependent plug-in. When Fat completes the initialization of the built-in telnet processor in 1, a telnet port will be opened for monitoring and plugging the container and the plug-in in the container. The container of this device is implemented based on the java SET set. After the user successfully handshake through the telnet command, the user can send the show / stop–fat–name_version.jar / start–fat–name_version.jar command to implement the instruction operation on the container. When the Fat module receives instructions, it will choose to traverse, add, and delete (move to the backup area) services according to different instructions.
图8是根据本发明实施例的多web模块合并打包为依赖插件的示意图;如图8所示,多web模块合并共存。本发明装置通过内置web服务器实现多web模块合并打包为依赖插件。当用户指定当前模块为web模块时,Fat模块初始化ClassLoader的时候需要对隔离模块织入 拦截器APIGetwayFilter,当容器初始化完成后将其发布为一个web应用。如果业务要求每个模块的域名都不同那么需要配合负载机使用,负载机监听到业务请求时将该请求重定向到隔离模块上根据端口区分。将所有的请求都转发到负载机,负载机配置重定向地址,该地址域名是隔离模块运行服务器域名,通过端口区分不同的模块服务。FIG. 8 is a schematic diagram of combining and packaging multiple web modules into dependent plugins according to an embodiment of the present invention; as shown in FIG. 8, multiple web modules are merged and coexist. The device of the present invention implements the integration and packaging of multiple web modules into a dependent plug-in 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 to the isolation module when it initializes the ClassLoader, and publish it as a web application after the container initialization is complete. If the business requires that the domain name of each module is different, then it needs to be used with the loader. When the loader listens to the business request, it redirects the request to the isolation module according to the port. All requests are forwarded to the loader, and the loader is configured with a redirection address. The domain name of the address is the domain name of the server where the module is isolated, and different module services are distinguished by ports.
图9是根据本发明实施例的系统架构图;如图9所示:FIG. 9 is a system architecture diagram according to an embodiment of the present invention; as shown in FIG. 9:
Container:插件容器,负责插件包启动运行时的管理;容器具备管理插件和应用的功能;容器启动成功后,会自动解析classpath包含的Plugin和facade依赖,完成隔离加载并按优先级依次启动之;Container: Plug-in container, which is responsible for the management of the plug-in package when it is started; the container has the function of managing plug-ins and applications; after the container is successfully started, it will automatically resolve the Plugin and facade dependencies contained in the classpath, complete the isolation load, and start them in order of priority;
Plugin:内置插件,满足特定目录格式要求的Fat Jar,可以将一个或多个普通的Java jar打包成一个标准格式的Fat Plugin;Fat Plugin会包含一份配置文件,通常包括插件类导入导出配置、资源导入导出配置、插件启动优先级等;运行时,容器会使用独立的PluginClassLoader加载插件,并根据插件配置构建类加载索引表、资源加载索引表,使插件和插件之间、插件和应用之间相互隔离;Plugin: Built-in plug-in, FatJar that meets the requirements of a specific directory format, can package one or more ordinary Java jars into a standard format FatPlugin; FatPlugin will include a configuration file, usually including plug-in class import and export configuration, Resource import and export configuration, plug-in startup priority, etc .; at runtime, the container will use a separate PluginClassLoader to load the plug-in, and build a class load index table and resource load index table based on the plug-in configuration, so that plug-ins and plug-ins, and between plug-ins and applications Isolated from each other
Facade:应用模块,是工程应用以及其依赖包的组织单元,包含应用启动所需的所有依赖和配置。Facade: An application module is an organizational unit of an engineering application and its dependent packages. It contains all dependencies and configurations required for application startup.
图10是根据本发明实施例的服务部署工作流程的示意图;如图10所示,服务部署工作流程如下:FIG. 10 is a schematic diagram of a service deployment workflow according to an embodiment of the present invention; as shown in FIG. 10, the service deployment workflow is as follows:
1.如果是加载反射生成的字节码,那么会直接抛出ClassNotFoundException,终止类加载。本装置只加载指定目录下的jar。1. If it is loading the bytecode generated by reflection, it will directly throw a ClassNotFoundException and terminate the class loading. This device loads only jars in the specified directory.
2.查找已经被加载过的类:2. Find the classes that have been loaded:
2.1如果未被加载,查找JDK中的类,这一块主要包含两部分:第一部分是ExtClassloader负责加载的类;第二部分是JDK提供的类但从ExtClassloader中加载不到,但在本地运行时会被加入到SystemClassloader的classpath中,同时这些类可能会被放到一些三方工具包中,典型的如tool.jar中sun.tools.attach.BsdVirtualMachine,这一部分也主要来源于的工程实践,避免类被加载超过一次,从而引发 报错。2.1 If it is not loaded, look for the class in the JDK. This block mainly contains 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 it will be run locally They are added to the classpath of the SystemClassloader, and these classes may be put into some three-party toolkits, such as sun.tools.attach.BsdVirtualMachine in tool.jar. This part is also mainly derived from engineering practices to avoid classes being Loaded more than once, which caused an error.
2.2如果2.1不满足,委托给本发明的自定义类加载器加载。2.2 If 2.1 is not satisfied, delegate to the custom class loader of the present invention to load it.
3.初始化容器,将个功能handler放到SET集合中。3. Initialize the container and place a function handler in the SET collection.
4.对SET中的handler进行实例化。4. Instantiate the handler in SET.
5.将被引用的对象实例注入到业务service中。5. Inject the referenced object instance into the business service.
6.重复1-5。6. Repeat 1-5.
本发明实施例提供了一种电子设备,包括:一个或多个处理器;存储装置,用于存储一个或多个程序,当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如本发明实施例提供的实现多版本依赖隔离的方法。An embodiment of the present invention provides an electronic device including: one or more processors; a storage device configured to store one or more programs, and when the one or more programs are executed by the one or more processors , So that the one or more processors implement the method for implementing multi-version dependency isolation provided by the embodiment of the present invention.
本发明实施例提供了一种计算机可读介质,其上存储有计算机程序,所述程序被处理器执行时实现如本发明实施例提供的实现多版本依赖隔离的方法。An embodiment of the present invention provides a computer-readable medium on which a computer program is stored. When the program is executed by a processor, the method for implementing multi-version dependency isolation provided by the embodiment of the present invention is implemented.
图11示出了可以应用本发明实施例的实现多版本依赖隔离的方法或装置的示例性系统架构1100。FIG. 11 illustrates an exemplary system architecture 1100 of a method or apparatus for implementing multi-version dependency isolation to which embodiments of the present invention can be applied.
如图11所示,系统架构1100可以包括终端设备1101、1102、1103,网络1104和服务器1105。网络1104用以在终端设备1101、1102、1103和服务器1105之间提供通信链路的介质。网络1104可以包括各种连接类型,例如有线、无线通信链路或者光纤电缆等等。As shown in FIG. 11, the system architecture 1100 may include terminal devices 1101, 1102, 1103, a network 1104, and a server 1105. The network 1104 is used to provide a medium for a communication link between the terminal devices 1101, 1102, 1103 and the server 1105. The network 1104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, and so on.
用户可以使用终端设备1101、1102、1103通过网络1104与服务器1105交互,以接收或发送消息等。终端设备1101、1102、1103上可以安装有各种通讯客户端应用,例如购物类应用、网页浏览器应用、搜索类应用、即时通信工具、邮箱客户端、社交平台软件等(仅为示例)。The user can use the terminal devices 1101, 1102, 1103 to interact with the server 1105 through the network 1104 to receive or send messages and the like. Various communication client applications can be installed on the terminal devices 1101, 1102, and 1103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, and the like (only examples).
终端设备1101、1102、1103可以是具有显示屏并且支持网页浏览的各种电子设备,包括但不限于智能手机、平板电脑、膝上型便携计算机和台式计算机等等。The terminal devices 1101, 1102, 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.
服务器1105可以是提供各种服务的服务器,例如对用户利用终端设备1101、1102、1103所浏览的购物类网站提供支持的后台管理服务器(仅为示例)。后台管理服务器可以对接收到的产品信息查询请求等数据进行分析等处理,并将处理结果(例如目标推送信息、产品信息--仅为示例)反馈给终端设备。The server 1105 may be a server that provides various services, for example, a background management server that provides support for a shopping website browsed by the user using the terminal devices 1101, 1102, and 1103 (for example only). The background management server can analyze and process the received product information query request and other data, and feed back the processing results (such as target push information and product information-just examples) to the terminal device.
需要说明的是,本发明实施例所提供的实现多版本依赖隔离的方法一般由服务器1105执行,相应地,实现多版本依赖隔离的装置一般设置于服务器1105中。It should be noted that the method for implementing multi-version dependency isolation provided by the embodiment of the present invention is generally executed by the server 1105, and accordingly, a device for implementing multi-version dependency isolation is generally provided in the server 1105.
应该理解,图11中的终端设备、网络和服务器的数目仅仅是示意性的。根据实现需要,可以具有任意数目的终端设备、网络和服务器。It should be understood that the numbers of terminal devices, networks, and servers in FIG. 11 are merely exemplary. According to implementation needs, there can be any number of terminal devices, networks, and servers.
下面参考图12,其示出了适于用来实现本发明实施例的终端设备的计算机系统1200的结构示意图。图12示出的终端设备仅仅是一个示例,不应对本发明实施例的功能和使用范围带来任何限制。Reference is now made to FIG. 12, which shows a schematic structural diagram of a computer system 1200 suitable for implementing a terminal device according to an embodiment of the present invention. The terminal device shown in FIG. 12 is only an example, and should not impose any limitation on the functions and scope of use of the embodiments of the present invention.
如图12所示,计算机系统1200包括中央处理单元(CPU)1201,其可以根据存储在只读存储器(ROM)1202中的程序或者从存储部分1208加载到随机访问存储器(RAM)1203中的程序而执行各种适当的动作和处理。在RAM 1203中,还存储有系统1200操作所需的各种程序和数据。CPU 1201、ROM 1202以及RAM 1203通过总线1204彼此相连。输入/输出(I/O)接口1205也连接至总线1204。As shown in FIG. 12, the computer system 1200 includes a central processing unit (CPU) 1201, which can be loaded into a random access memory (RAM) 1203 according to a program stored in a read-only memory (ROM) 1202 or loaded from a storage portion 1208. Instead, perform various appropriate actions and processes. 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 through a bus 1204. An input / output (I / O) interface 1205 is also connected to the bus 1204.
以下部件连接至I/O接口1205:包括键盘、鼠标等的输入部分1206;包括诸如阴极射线管(CRT)、液晶显示器(LCD)等以及扬声器等的 输出部分1207;包括硬盘等的存储部分1208;以及包括诸如LAN卡、调制解调器等的网络接口卡的通信部分1209。通信部分1209经由诸如因特网的网络执行通信处理。驱动器1210也根据需要连接至I/O接口1205。可拆卸介质1211,诸如磁盘、光盘、磁光盘、半导体存储器等等,根据需要安装在驱动器1210上,以便于从其上读出的计算机程序根据需要被安装入存储部分1208。The following components are connected to the I / O interface 1205: an input portion 1206 including a keyboard, a mouse, and the like; an output portion 1207 including a cathode ray tube (CRT), a liquid crystal display (LCD), and the speaker; a storage portion 1208 including a hard disk and the like And a communication section 1209 including a network interface card such as a LAN card, a modem, and the like. The communication section 1209 performs communication processing via a network such as the Internet. The driver 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.
特别地,根据本发明公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本发明公开的实施例包括一种计算机程序产品,其包括承载在计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信部分1209从网络上被下载和安装,和/或从可拆卸介质1211被安装。在该计算机程序被中央处理单元(CPU)1201执行时,执行本发明的系统中限定的上述功能。In particular, according to the disclosed embodiments of the present invention, the process described above with reference to the flowchart may be implemented as a computer software program. For example, the disclosed embodiments include a computer program product including a computer program carried on a computer-readable medium, the computer program containing program code for performing the method shown in the flowchart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication portion 1209, and / or installed from a removable medium 1211. When the computer program is executed by a central processing unit (CPU) 1201, the above-mentioned functions defined in the system of the present invention are executed.
需要说明的是,本发明所示的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本发明中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本发明中,计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读的信号介质还可以是计算机可读存储介质以外的任何 计算机可读介质,该计算机可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:无线、电线、光缆、RF等等,或者上述的任意合适的组合。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 foregoing. The computer-readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable Programming read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program, and the program may be used by or in combination with an instruction execution system, apparatus, or device. In the present invention, the computer-readable signal medium may include a data signal transmitted in baseband or transmitted as a part of a carrier wave, in which a computer-readable program code is carried. Such a propagated data signal may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. The computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, and the computer-readable medium may send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device . Program code embodied on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
附图中的流程图和框图,图示了按照本发明各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,上述模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图或流程图中的每个方框、以及框图或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, which contains one or more of the logic functions used to implement the specified logic. Executable instructions. It should also be noted that in some alternative implementations, the functions noted in the blocks may also occur in a different order than those marked in the drawings. For example, two successively represented boxes may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram or flowchart, and combinations of blocks in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with A combination of dedicated hardware and computer instructions.
描述于本发明实施例中所涉及到的模块可以通过软件的方式实现,也可以通过硬件的方式来实现。所描述的模块也可以设置在处理器中,例如,可以描述为:一种处理器,包括注解模块、放置模块、执行模块、加载模块。其中,这些模块的名称在某种情况下并不构成对该模块本身的限定,例如,注解模块还可以被描述为“用于添加注解的模块”。The modules described in the embodiments of the present invention may be implemented by software or hardware. The described module may also be provided in the processor, for example, it may be described as: a processor including an annotation module, a placement module, an execution module, and a loading module. Among them, the names of these modules do not in any way constitute a limitation on the module itself. For example, the annotation module can also be described as a "module for adding annotations".
作为另一方面,本发明还提供了一种计算机可读介质,该计算机可读介质可以是上述实施例中描述的设备中所包含的;也可以是单独存在,而未装配入该设备中。上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被一个该设备执行时,使得该设备包括:在待隔离方法中添加注解;将所述待隔离方法中需要引用的依赖包放置到引用目录文件中;所述注解与所述引用目录一一对应;执 行所述待隔离方法时,根据所述注解确定所述依赖包放置的引用目录文件;利用自定义的类加载器,加载所述引用目录文件中的依赖包。As another aspect, the present invention also provides a computer-readable medium. The computer-readable medium may be included in the device described in the foregoing embodiments, or may exist alone without being assembled into the device. The computer-readable medium carries one or more programs. When the one or more programs are executed by one device, the device includes: adding a comment to the method to be isolated; and quoting the method to be isolated. The dependent package is placed in the reference directory file; the annotation corresponds to the reference directory one by one; when the method to be isolated is executed, the reference directory file placed by the dependent package is determined according to the annotation; and a custom class is used for loading A loader that loads the dependent packages in the reference directory file.
根据本发明实施例的技术方案,因为采用添加注解的技术手段,所以能够解决在使用spring boot进行依赖隔离的过程中出现的项目必须是spring boot项目、必须使用spring boot编译插件和耦合度太高的问题,进而达到不区分项目类型实现依赖多版本共存并保证各版本依赖正常提供功能,同时可以实时对运行的依赖版本进行切换的技术效果,避免未使用升级功能的系统绑架升级。According to the technical solution of the embodiment of the present invention, because the technical means of adding annotations are used, the projects that can be resolved in the process of using spring boot for dependency isolation must be spring boot projects, spring plugins must be compiled, and the degree of coupling is too high. In order to achieve the technical effect of relying on coexistence of multiple versions without distinguishing project types, and ensuring that the versions rely on normal provision of functions, at the same time, the running dependent versions can be switched in real time to avoid the system abduction upgrade without using the upgrade function.
上述具体实施方式,并不构成对本发明保护范围的限制。本领域技术人员应该明白的是,取决于设计要求和其他因素,可以发生各种各样的修改、组合、子组合和替代。任何在本发明的精神和原则之内所作的修改、等同替换和改进等,均应包含在本发明保护范围之内。The foregoing specific implementation manners 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 replacement and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims (14)

  1. 一种实现多版本依赖隔离的方法,其特征在于,包括:A method for implementing multi-version dependency isolation, which is characterized by:
    在待隔离方法中添加注解;Add annotations to the method to be isolated;
    将所述待隔离方法中需要引用的依赖包放置到引用目录文件中;所述注解与所述引用目录一一对应;Placing the dependent packages to be referenced in the method to be isolated into a reference directory file; the annotations correspond to the reference directory in a one-to-one manner;
    执行所述待隔离方法时,根据所述注解确定所述依赖包放置的引用目录文件;When the method to be isolated is executed, determining a reference directory file where the dependent package is placed according to the annotation;
    利用自定义的类加载器,加载所述引用目录文件中的依赖包。Use a custom class loader to load the dependent packages in the reference directory file.
  2. 根据权利要求1所述的方法,其特征在于,所述将所述待隔离方法中需要引用的依赖包放置到引用目录文件中之后,还包括:The method according to claim 1, wherein after placing the dependent packages to be referenced in the method to be isolated into a reference directory file, the method further comprises:
    接收telnet命令;Receive telnet commands;
    根据所述telnet命令对所述依赖包进行以下至少之一的操作:选择、遍历、增加、删除、移动到备份区。Perform 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.
  3. 根据权利要求1所述的方法,其特征在于,执行所述待隔离方法之前,还包括:The method according to claim 1, before executing the method to be isolated, further comprising:
    监听到业务请求,并根据所述业务请求确定重定向地址;Monitor a service request, and determine a redirection address according to the service request;
    根据所述重定向地址的域名,确定要执行的所述待隔离方法。Determining the to-be-isolated method to be executed according to a domain name of the redirection address.
  4. 一种实现多版本依赖隔离的方法,其特征在于,包括:A method for implementing multi-version dependency isolation, which is characterized by:
    利用自定义的类加载器加载依赖包,得到依赖包的对象实例;Use the custom class loader to load the dependent package to get 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 the method to be isolated is executed, if the reference needs to be referenced, the dependent package object instance is taken out from the function processor and executed.
  5. 根据权利要求4所述的方法,其特征在于,所述将依赖包对象 实例注册到所述功能处理器内之后,还包括:The method according to claim 4, wherein after registering the dependent package object instance in the function processor, the method further comprises:
    接收telnet命令;Receive telnet commands;
    根据所述telnet命令对所述依赖包对象实例进行以下至少之一的操作:选择、遍历、增加、删除、移动到备份区。Perform 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.
  6. 根据权利要求4所述的方法,其特征在于,执行待隔离方法之前,还包括:The method according to claim 4, wherein before executing the method to be isolated, further comprising:
    监听到业务请求,根据所述业务请求确定重定向地址;Monitoring a service request, and determining a redirection address according to the service request;
    根据所述重定向地址的域名,确定要执行的所述待隔离方法。Determining the to-be-isolated method to be executed according to a domain name of the redirection address.
  7. 一种实现多版本依赖隔离的装置,其特征在于,包括:A device for implementing multi-version dependency isolation is characterized in that it includes:
    注解模块,用于:在待隔离方法中添加注解;Annotation module, used to: add annotations to the method to be isolated;
    放置模块,用于:将所述待隔离方法中需要引用的依赖包放置到引用目录文件中;所述注解与所述引用目录一一对应;A placing module, configured to place the dependent packages to be referenced in the method to be isolated into a reference directory file; the annotations correspond to the reference directory one by one;
    执行模块,用于:执行所述待隔离方法时,根据所述注解确定所述依赖包放置的引用目录文件;An execution module, configured to: when executing the method to be isolated, determine a reference directory file placed by the dependent package according to the annotation;
    加载模块,用于:利用自定义的类加载器,加载所述引用目录文件中的依赖包。A loading module, configured to: use a custom class loader to load a dependent package in the reference directory file.
  8. 根据权利要求7所述的装置,其特征在于,所述放置模块还用于:The apparatus according to claim 7, wherein the placing module is further configured to:
    接收telnet命令;Receive telnet commands;
    根据所述telnet命令对所述依赖包进行以下至少之一的操作:选择、遍历、增加、删除、移动到备份区。Perform 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.
  9. 根据权利要求7所述的装置,其特征在于,所述执行模块,还用于:The apparatus according to claim 7, wherein the execution module is further configured to:
    监听到业务请求,根据所述业务请求确定重定向地址;Monitoring a service request, and determining a redirection address according to the service request;
    根据所述重定向地址的域名,确定要执行的所述待隔离方法。Determining the to-be-isolated method to be executed according to a domain name of the redirection address.
  10. 一种实现多版本依赖隔离的装置,其特征在于,包括:A device for implementing multi-version dependency isolation is characterized in that it includes:
    加载模块,用于:利用自定义的类加载器加载依赖包,得到依赖包的对象实例;A loading module for loading a dependent package with a custom class loader to obtain an object instance of the dependent package;
    注册模块,用于:启动容器并初始化所述容器内的功能处理器,将所述依赖包对象实例注册到所述功能处理器内;A registration module, configured to start a container and initialize a function processor in the container, and register the dependent package object instance in the function processor;
    引用模块,用于:执行待隔离方法时,若需要引用依赖,则从所述功能处理器中取出并执行所述依赖包对象实例。A reference module is configured to: when executing a method to be isolated, if a reference dependency is required, take out and execute the dependent package object instance from the function processor.
  11. 根据权利要求10所述的装置,其特征在于,所述注册模块还用于:The apparatus according to claim 10, wherein the registration module is further configured to:
    接收telnet命令;Receive telnet commands;
    根据所述telnet命令对所述依赖包对象实例进行以下至少之一的操作:选择、遍历、增加、删除、移动到备份区。Perform 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.
  12. 根据权利要求10所述的装置,其特征在于,所述引用模块还用于:The apparatus according to claim 10, wherein the reference module is further configured to:
    监听到业务请求,根据所述业务请求确定重定向地址;Monitoring a service request, and determining a redirection address according to the service request;
    根据所述重定向地址的域名,确定要执行的所述待隔离方法。Determining the to-be-isolated method to be executed according to a domain name of the redirection address.
  13. 一种电子设备,其特征在于,包括:An electronic device, comprising:
    一个或多个处理器;One or more processors;
    存储装置,用于存储一个或多个程序,A storage device for storing one or more programs,
    当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如权利要求1-6中任一所述的方法。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-6.
  14. 一种计算机可读介质,其上存储有计算机程序,其特征在于,所述程序被处理器执行时实现如权利要求1-6中任一所述的方法。A computer-readable medium having a computer program stored thereon, characterized in that when the program is executed by a processor, the method according to any one of claims 1-6 is implemented.
PCT/CN2019/103533 2018-09-29 2019-08-30 Method and device for isolating multiple version dependency WO2020063252A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201811151298.0A CN110968340A (en) 2018-09-29 2018-09-29 Method and device for realizing multi-version dependence isolation
CN201811151298.0 2018-09-29

Publications (1)

Publication Number Publication Date
WO2020063252A1 true WO2020063252A1 (en) 2020-04-02

Family

ID=69949296

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/103533 WO2020063252A1 (en) 2018-09-29 2019-08-30 Method and device for isolating multiple version dependency

Country Status (2)

Country Link
CN (1) CN110968340A (en)
WO (1) WO2020063252A1 (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112181470A (en) * 2020-09-22 2021-01-05 京东数字科技控股股份有限公司 Method and device for deploying patch
CN112416459B (en) * 2020-11-23 2024-03-01 杭州当虹科技股份有限公司 System for solving version strong dependence among micro services
CN112486512A (en) * 2020-11-25 2021-03-12 湖南麒麟信安科技股份有限公司 Linux general software adaptation method and system based on container and stacked file system
CN115794416B (en) * 2023-02-02 2023-04-07 徐工汉云技术股份有限公司 Data hot switching method and device based on Storm and Nacos

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080301662A1 (en) * 2007-05-31 2008-12-04 International Business Machines Corporation Method for versioning classes loaded in an osgi-enabled j2ee environment
US20140059527A1 (en) * 2012-08-24 2014-02-27 Ca, Inc. Injection of updated classes for a java agent
CN107656775A (en) * 2017-10-18 2018-02-02 国云科技股份有限公司 A kind of self defined class lookup method based on ClassLoader
CN108304175A (en) * 2018-01-29 2018-07-20 口碑(上海)信息技术有限公司 Packaging method and device is isolated in code file

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8997075B2 (en) * 2013-07-23 2015-03-31 Red Hat, Inc. System and method for dynamic class management
CN105404524B (en) * 2014-09-15 2019-01-15 阿里巴巴集团控股有限公司 Class load partition method and device in Java application
CN107608677B (en) * 2017-09-05 2020-11-03 腾讯科技(深圳)有限公司 Compiling processing method and device and electronic equipment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080301662A1 (en) * 2007-05-31 2008-12-04 International Business Machines Corporation Method for versioning classes loaded in an osgi-enabled j2ee environment
US20140059527A1 (en) * 2012-08-24 2014-02-27 Ca, Inc. Injection of updated classes for a java agent
CN107656775A (en) * 2017-10-18 2018-02-02 国云科技股份有限公司 A kind of self defined class lookup method based on ClassLoader
CN108304175A (en) * 2018-01-29 2018-07-20 口碑(上海)信息技术有限公司 Packaging method and device is isolated in code file

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
BARACKHUSSEINOBAMA, THE WAY OF JAVA CUSTOM CLASSLOADER TO IMPLEMENT ISOLATE RUNNING OF DIFFERENT VERSIONS OF JAR PACKAGES, 14 June 2017 (2017-06-14), pages 1 - 5, Retrieved from the Internet <URL:https://blog.csdn.net/t894690230/article/details/73252331.> *

Also Published As

Publication number Publication date
CN110968340A (en) 2020-04-07

Similar Documents

Publication Publication Date Title
WO2020063252A1 (en) Method and device for isolating multiple version dependency
US10481884B2 (en) Systems and methods for dynamically replacing code objects for code pushdown
US11429365B2 (en) Systems and methods for automated retrofitting of customized code objects
US20110078667A1 (en) Static code analysis for packaged application customization
US20180336021A1 (en) Package installation on a host file system using a container
CN110865889B (en) Method and device for transmitting event between components
CN110716720A (en) Method and device for realizing application hot deployment
US8887122B2 (en) Find and track information of interface usage of software libraries by other software
CN109670299A (en) A kind of method and electronic equipment creating Python sandbox environment
WO2014056371A1 (en) Method and apparatus for determining range of files to be migrated
US20230259358A1 (en) Documentation enforcement during compilation
US8516455B2 (en) Dynamic loading of kernel extensions
EP3799697A1 (en) Virtual machine container for applications
CN108376074B (en) RancherOS ros core module transplanting method based on embedded system
US20140007053A1 (en) Dynamically configuring an integrated development environment
CN114840195B (en) Privatization method for iOS SDK static library
CN113778388A (en) Program development method and device
US20070277170A1 (en) Merger driven application installation
WO2022183810A1 (en) Plug-in updating method and apparatus, electronic device, system, and storage medium
CN113495747B (en) Gray scale release method and device
CN117093286B (en) Plug-in generation method, device, equipment and computer readable storage medium
EP4102357A1 (en) Development environment organizer with enhanced state switching and sharing
CN117056317B (en) Data processing method, device, equipment and computer readable storage medium
US20230074580A1 (en) Runtime-tailored security policies for applications
Kiss Build automation systems against CI lock-in-A comparative study of Dagger and Mage

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19865522

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19865522

Country of ref document: EP

Kind code of ref document: A1