An enclave-like method and programmable device

By building multiple JAR files for the Java program and service governance system and using a custom class loader to implement class isolation, the problem of class conflicts caused by inconsistent versions of third-party libraries in Java programs is solved, ensuring the normal operation and isolation of the system.

CN117407069BActive Publication Date: 2026-01-09HUAWEI CLOUD COMPUTING TECHNOLOGIES CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210801778.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-08
Publication Date
2026-01-09
Estimated Expiration
2042-07-08

AI Technical Summary

Technical Problem

In Java programs, class conflicts caused by inconsistent versions of third-party libraries can lead to unexpected results when the Java program or service governance system runs.

Method used

By building multiple JAR files for the pluggable system framework and using custom class loaders to achieve class isolation between Java programs and service governance plugins, including application class loaders, framework class loaders, and target class loaders, isolation between different class libraries is ensured.

Benefits of technology

It effectively avoids class conflicts, ensures the normal operation of Java programs and service governance systems, achieves class loader-level isolation, avoids the huge build artifacts generated by shade, and does not require modification of Java program code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117407069B_ABST
    Figure CN117407069B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a class isolation method and a programmable device, which are used for implementing class isolation of third-party class libraries for a java program and a service governance plug-in of a service governance system. A first jar package and a second jar package are built for a plug-in system framework, and a third jar package is built for the service governance plug-in. The first jar package corresponds to general capability interface definitions of the plug-in system framework, the second jar package corresponds to general capability interface implementations of the plug-in system framework, and the third jar package corresponds to bytecode enhancement logic in the service governance plug-in. The bytecode enhancement logic can call the general capability interface definitions, and the general capability interface definitions can call the general capability interface implementations. An application class loader loads the first jar package, a framework class loader (a subclass of the application class loader) loads the second jar package, and a target class loader (a class loader other than the framework class loader and its subclasses) loads the java program and the third jar package, so that class isolation of the third-party class libraries between the java program and the general capability interface implementations is implemented.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of computer programming, and in particular to a class isolation method and programmable device. BACKGROUND

[0002] Java is an object-oriented programming language, and Java has powerful and simple language features. Java can be used to write desktop applications, network applications, distributed systems and embedded system applications, etc. As a representative of static object-oriented programming languages, Java has implemented object-oriented theory very well.

[0003] In the 1.5 version of Java, a Java program can load a Javaagent program, so that when the Java program runs, the Javaagent program can be used to dynamically modify the Java program in terms of byte code, so as to achieve the purpose of dynamically enhancing the program logic of the Java program. For example, a service governance system is a Javaagent program, and the related functions of the service governance system can be dynamically loaded into the Java program, so that the business functions and governance functions of the Java program are decoupled.

[0004] A Java program can load a third-party class library, and a service governance system can also load a third-party class library. In a Java virtual machine, if the fully qualified class names of two classes are the same, and their class loaders are the same, they are considered to be the same class. If different versions of Jar packages in a third-party class library are loaded by a Java program or a service governance system, the Java program or the service governance system selects the wrong version in the loading process, so that the class loaded by the Java program or the service governance system is not the expected class, which causes the running behavior of the Java program or the service governance system to be inconsistent with the expectation, which is called class conflict. Class conflict will cause the Java program or the service governance system to produce different results from the expected results during running. SUMMARY

[0005] Embodiments of the present application provide a class isolation method and programmable device, which are used to implement class isolation of a third-party class library for a Java program and a service governance plug-in of a service governance system.

[0006] The first aspect of the application provides a class isolation method for a service governance system, the service governance system comprising a plug-in system framework and a service governance plug-in. In the application, two jar packages are first constructed for the plug-in system framework, which are a first jar package and a second jar package. The first jar package corresponds to a general capability interface definition of the plug-in system framework, and the second jar package corresponds to a general capability interface implementation of the plug-in system framework. The general capability interface definition is used to call the general capability interface implementation. A third jar package is constructed for the service governance plug-in. The third jar package corresponds to bytecode enhancement logic in the service governance plug-in, and the bytecode enhancement logic is used to call the general capability interface definition. Then, the first jar package can be loaded by an application class loader, and the second jar package can be loaded by a custom framework class loader. The framework class loader is a subclass of the application class loader. A target class loader is used to load a java program and the third jar package. The target class loader is a class loader other than the framework class loader and its subclasses. Class isolation is achieved between the third-party class library introduced by the java program and the third-party class library introduced by the general capability interface implementation.

[0007] In some possible implementation manners, the target class loader is the application class loader or a subclass thereof, so as to achieve class isolation between the third-party class library introduced by the java program and the third-party class library introduced by the general capability interface implementation.

[0008] In some possible implementation manners, the method further comprises: constructing a fourth jar package and a fifth jar package for the service governance plug-in. The fourth jar package corresponds to a service governance interface definition, and the fifth jar package corresponds to a service governance interface implementation in the service governance plug-in. The general capability interface definition is used to call the general capability interface implementation, and the bytecode enhancement logic is further used to call the general capability interface definition. The fourth jar package is loaded by the application class loader. The fifth jar package is loaded by a custom plug-in class loader. The plug-in class loader is a subclass of the application class loader. Class isolation is achieved between the third-party class library introduced by the java program and the third-party class library introduced by the service governance interface implementation in the service governance plug-in.

[0009] In some possible implementation manners, the method further includes: constructing a fourth jar package and a plurality of fifth jar packages for the service governance plug-in, wherein the fourth jar package corresponds to a service governance interface definition, the plurality of fifth jar packages correspond to a plurality of service governance interface implementations in the service governance plug-in in a one-to-one manner, the general capability interface definition is used to call the plurality of general capability interface implementations, and the bytecode enhancement logic is further used to call the general capability interface definition; loading the fourth jar package by using the application class loader; and loading the plurality of fifth jar packages by using a customized plug-in class loader, the plug-in class loader being a subclass of the application class loader, so that class isolation is implemented between a third-party class library introduced by a java program and a third-party class library introduced by a service governance interface implementation in the service governance plug-in, and class isolation is implemented between third-party class libraries introduced by a plurality of service governance interfaces in the service governance plug-in.

[0010] In some possible implementation manners, the service governance system is a gray release function, so that class isolation is implemented between a java program and a third-party class library introduced by the gray release function.

[0011] In a second aspect, the present application provides a programmable device configured to perform the method of any one of the preceding first aspect.

[0012] In a third aspect, the present application provides a computer-readable storage medium having stored therein instructions, which when executed on a computer, cause the computer to perform the method of any one of the preceding first aspect or the second aspect or the third aspect.

[0013] In a fourth aspect, the present application provides a computer program product, which includes computer-executable instructions stored in a computer-readable storage medium. At least one processor of a device can read the computer-executable instructions from the computer-readable storage medium, and the at least one processor executes the computer-executable instructions to cause the device to implement the method provided in the preceding first aspect or any possible implementation manner of the first aspect.

[0014] In a fifth aspect, the present application provides a communication apparatus, which can include at least one processor, a memory, and a communication interface. The at least one processor is coupled to the memory and the communication interface. The memory is configured to store instructions, and the at least one processor is configured to execute the instructions. The communication interface is configured to communicate with other communication apparatuses under control of the at least one processor. The instructions, when executed by the at least one processor, cause the at least one processor to perform the method in the first aspect or any possible implementation manner of the first aspect.

[0015] The sixth aspect of the present application provides a chip system, which comprises a processor for supporting the functions involved in the first aspect or any possible implementation manner of the first aspect.

[0016] In a possible design, the chip system can further comprise a memory for storing necessary program instructions and data. The chip system can be composed of a chip or can comprise the chip and other discrete devices.

[0017] The technical effects brought by the second to sixth aspects or any possible implementation manner thereof can refer to the technical effects brought by the first aspect or different possible implementation manners of the first aspect, which will not be repeated here. BRIEF DESCRIPTION OF DRAWINGS

[0018] Figure 1-1 A composition structure diagram of a programmable device provided in the embodiment of the present application is shown in the figure.

[0019] Figure 1-2 A diagram of the parent-child relationship of various loaders of tomcat in the present application is shown in the figure.

[0020] Figure 1-3 A diagram of the parent-child relationship of various loaders of skywalking in the present application is shown in the figure.

[0021] Figure 2-1 A flowchart of a class isolation method provided in the embodiment of the present application is shown in the figure.

[0022] Figure 2-2 A composition structure diagram of a gray release function in the embodiment of the present application is shown in the figure.

[0023] Figure 2-3 A diagram of loading a java program through a user-defined class loader in the embodiment of the present application is shown in the figure.

[0024] Figure 2-4 A diagram of loading a java program through an application class loader in the embodiment of the present application is shown in the figure.

[0025] Figure 2-5 A diagram of a class isolation method provided in the embodiment of the present application is shown in the figure.

[0026] Figure 2-6 A diagram of another class isolation method provided in the embodiment of the present application is shown in the figure.

[0027] Figure 2-7 A diagram of a gray release function provided in the embodiment of the present application is shown in the figure.

[0028] Figure 3 A structure diagram of a programmable device provided in the embodiment of the present application is shown in the figure.

[0029] Figure 4 A structural schematic diagram of a communication device provided by an embodiment of the present application is shown. DETAILED DESCRIPTION

[0030] Embodiments of the present application provide a class isolation method and a programmable device, which are used to implement class isolation of third-party class libraries for Java programs and service governance plug-ins of a service governance system.

[0031] The embodiments of the present application will be described below with reference to the accompanying drawings.

[0032] The terms "first", "second", etc. in the specification and claims of the present application and the above drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or sequence. It should be understood that the terms used in this way can be interchanged under appropriate circumstances, which is only a distinguishing way used in the description of the embodiments of the present application to describe the objects with the same properties. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, so that the processes, methods, systems, products or devices containing a series of units do not necessarily have to be limited to those units, but can include other units not clearly listed or inherent to these processes, methods, products or devices.

[0033] Embodiments of the present application can be applied to a programmable device 100 as shown in the following figure. Figure 1-1 The programmable device 100 includes a processing module 110, a display module 120, a storage module 130, a transceiver module 140 and an input module 150 (for example, a keyboard, a mouse, a touch screen, etc., which is not limited here).

[0034] The processing module 110 is the control center of the programmable device 100, which connects various parts of the programmable device 100 by using various interfaces and lines, executes software programs and / or modules stored in the storage module 130 and calls data stored in the storage module 130, performs various functions of the programmable device 100 and processes data, thereby monitoring the programmable device 100 as a whole. Optionally, the processing module 110 can include one or more processing units; preferably, the processing module 110 can integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, the user interface and the application program, etc., and the modem processor mainly processes wireless communication. It can be understood that the above-mentioned modem processor can also not be integrated into the processing module 110.

[0035] The display module 120 can be used to display information input by a user or provided to the user and various interfaces of the programmable device 100. The display module 120 can include a display panel, which can optionally be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like. Further, a touch panel can be overlaid on the display panel, which, when detecting a touch operation thereon or in the vicinity thereof, transmits to the processing module 110 to determine the type of touch event, and then the processing module 110 provides corresponding visual output on the display panel according to the type of touch event.

[0036] The storage module 130 can include read-only memory and random access memory, and provide instructions and data to the processing module 110. A portion of the storage module 130 can also include non-volatile random access memory (NVRAM). The storage module 130 stores processor and operating instructions, executable modules or data structures, or subsets thereof, or expanded sets thereof, wherein the operating instructions can include various operating instructions for implementing various operations.

[0037] The transceiver module 140 can be used to receive input digital or character information, and generate signal input related to the relevant settings and function control of the programmable device 100. The transceiver module 140 can be used to output digital or character information through the first interface; the transceiver module 140 can also be used to send instructions to the disk group through the first interface to modify data in the disk group; the transceiver module 140 can also include a display device such as a display screen.

[0038] The input module 150 can be configured to receive inputted digital or character information, and to generate key signal inputs related to user settings and function controls of the programmable device 100. Specifically, the input module 150 can include a touch panel and other input devices. The touch panel, also known as a touch screen, can collect touch operations of a user thereon or thereabout (such as operations of a user using a finger, a stylus, or any suitable object or accessory on or near the touch panel), and drive corresponding connection devices according to pre-set programs. Optionally, the touch panel can include two parts, a touch detection device and a touch controller. The touch detection device detects the touch position of a user and detects signals caused by touch operations, and transmits the signals to the touch controller; the touch controller receives touch information from the touch detection device, converts the touch information into touch coordinates, and sends the touch coordinates to the processing module 110, and can also receive commands from the processing module 110 and execute the commands. In addition, the touch panel can be implemented in various types, such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch panel, the input module 150 can also include other input devices. Specifically, the other input devices can include one or more of a physical keyboard, function keys (such as volume control keys, on-off keys, etc.), a trackball, a mouse, a joystick, etc.

[0039] In some possible implementations, the programmable device 100 can be a terminal device or a server, which is not limited herein.

[0040] In this embodiment, the server can be a standalone physical server, or a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDNs, and basic cloud computing services such as big data and artificial intelligence platforms. The terminal can be a smartphone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited thereto. The terminal and the server can be directly or indirectly connected through wired or wireless communication, and the terminal and the server can be connected to form a blockchain network, which is not limited herein.

[0041] The terminal device can be a mobile phone, a tablet computer (Pad), a computer with wireless transceiver function, a virtual reality (VR) terminal device, an augmented reality (AR) terminal device, a wireless terminal in industrial control, a wireless terminal in self driving, a wireless terminal in remote medical surgery, a wireless terminal in smart grid, a wireless terminal in transportation safety, a wireless terminal in smart city, a wireless terminal in smart home, and the like. Embodiments of the present application do not limit the specific technology and specific device form of the terminal device.

[0042] A program programmed based on Java is called a Java program, and the Java program runs in a Java virtual machine (JVM). The virtual machine is a complete computer system running in a completely isolated environment by software simulation, which has complete hardware system functions. Each virtual machine has an independent hard disk and operating system, and can be operated like a physical machine. It should be noted that the virtual machine can load data describing classes (class files) from a jar package to the memory through a class loader, and check, convert and parse the data, and finally form data that can be directly used by the virtual machine. It should be noted that the virtual machine can load the jar package through the class loader, and the jar package contains information such as version, creator, class search path (class-path), class attribute, method entry, etc.

[0043] It should be noted that the virtual machine provides a built-in 3-layer class loader, including: a bootstrap class loader for loading core libraries (java.lang.* and the like), an extension class loader for loading some extended jar packages under the jre / lib / ext directory, and an application class loader for loading the main function class of the application. Among them, the bootstrap class loader is the parent class of the extension class loader, and the extension class loader is the parent class of the application class loader, that is, the extension class loader is the child class of the bootstrap class loader, and the application class loader is the child class of the extension class loader. The class loader will first delegate its parent class to load the class in the process of loading the class, and if the parent class fails to load the class, it will be loaded by itself, which is to avoid the classes in the virtual machine from being loaded repeatedly. In addition, the classes loaded in the child class can use the classes loaded by the parent class, but the classes loaded in the parent class cannot use the classes loaded by the child class.

[0044] It should be noted that based on the aforementioned 3-layer class loader of the virtual machine, programmers can add other user-defined class loaders, which can realize various functions of java programs.

[0045] For example, as shown in Figure 1-2 , the 3-layer class loader based on the virtual machine can realize Tomcat. Tomcat is a web application container, and multiple applications will be deployed in the container. In addition to the 3-layer class loader, Tomacat adds other custom class loaders: a common class loader for loading common classes that can be accessed by the web application container and each application; a CatalinaClassloader, which is a private class loader of Tomcat, and the classes loaded by it are invisible to the application; a shared class loader, which is a class loader shared by each application, and the classes loaded by it are visible to all applications and invisible to the web application container; a web application class loader, which is a private class loader of each application, and the classes loaded by it are only visible to the current application; and a JasperLoader, which is mainly used for loading Jsp and realizing the function of hot loading. The parent-child relationship of each class loader is as shown in Figure 1-2 .

[0046] For another example, as shown in Figure 1-3As shown, skywalking based on 3-layer class loader implementation. Skywalking is a performance monitoring tool for distributed systems, providing distributed link tracking, service grid analysis and other functions. The framework core of Skywalking mainly includes the following parts: apm-agent, application configuration initialization, plug-in loading, customization of byte code enhancement framework required components, no business logic, loaded through the application class loader (appclassloader); apm-agent-core, contains most of the business function implementation, including service, class and method matcher, tool class, etc., loaded through the application class loader; apm-sdk-plugin, load all plug-in jar packages through the agent class loader (agentclassloader), but do not destroy the parent delegation mechanism; apm-agent-core-bootservice, provides some basic services (kafka management, grpc management, etc.), loaded through the agent class loader; ByteBuddyCoreClasses, provides the core annotation of the bytecode enhancement capability, needs to be injected into the startup class loader; HIGH_PROPERTITY_CLASSES, the core interface of bytecode enhancement in apm-agent-core, needs to be injected into the startup class loader. The parent relationship of various class loaders is shown in Figure 1-3 In the design of Skywalking, part of the important interface (ByteBuddyCoreClasses, HIGH_PROPERTITY_CLASSES) is loaded through the startup class loader, so that it is shared by apm-agent-core and apm-sdk-plugins, and apm-sdk-plugins and apm-agent-core-bootservice are loaded through AgentClassLoader but do not destroy the parent delegation relationship.

[0047] In version 1.5 of Java, Java programs can load Javaagent programs, so when Java programs run, Javaagent programs can be used to dynamically modify the bytecode of Java programs, thereby achieving the purpose of dynamically enhancing the program logic of Java programs. For example, the service governance system is a Javaagent program, and the related functions of the service governance system can be dynamically loaded into the Java program, so that the business functions and governance functions of the Java program are decoupled.

[0048] Based on the Javaagent program, a plug-in architecture can be implemented. The plug-in architecture is an extensible architecture that is split for function, and is usually used for a client application that has multiple versions and needs to be downloaded and installed to be used. The plug-in architecture includes two types of components: a core system and plug-in modules. The core system is responsible for general functions that are independent of specific business functions, such as module loading, inter-module communication, etc. The plug-in modules are responsible for implementing specific business logic, such as the xdebug extension in php extension that implements code debug function, and the openResty module of Nginx that is used to build a dynamic network application, network service, and dynamic gateway that can handle ultra-high concurrency and have high scalability.

[0049] Based on the plug-in architecture, a service governance system can be implemented. Service governance refers to the management and governance of microservices, such as service registration and discovery, load balancing, application routing, etc. The service governance system includes a plug-in system framework and service governance plug-ins. The plug-in system framework provides core components for basic capabilities such as logging, heartbeat, dynamic configuration, and bytecode enhancement templates. The service governance plug-ins rely on the basic capabilities provided by the plug-in system framework to provide pluggable units for service governance functions.

[0050] In a service governance system based on a 3-layer class loader of a virtual machine, an application class loader can load a Java program, and the Java program can load the service governance system. The Java program can load third-party class libraries, and the service governance system can also load third-party class libraries. In the Java virtual machine, if two classes have the same fully qualified class name and the same class loader, they are considered to be the same class. When different versions of Jar packages in the third-party class library cause the Java program or the service governance system to select the wrong version during loading, the class loaded by the Java program or the service governance system is not the expected class, resulting in inconsistent behavior with the expected behavior, which is called class conflict. Class conflict can cause the Java program or the service governance system to produce different results from the expected results at runtime.

[0051] In this application, two JAR files are first constructed for the pluggable system framework: a first JAR file and a second JAR file. The first JAR file corresponds to the definition of the general capability interface of the pluggable system framework, and the second JAR file corresponds to the implementation of the general capability interface. The definition of the general capability interface is used to call the implementation of the general capability interface. A third JAR file is then constructed for the service governance plugin. The third JAR file corresponds to the bytecode enhancement logic in the service governance plugin, and the bytecode enhancement logic is used to call the definition of the general capability interface. The first JAR file can then be loaded using an application class loader, and the second JAR file can be loaded using a custom framework class loader (a subclass of the application class loader). Finally, the Java program and the third JAR file are loaded using a target class loader (a class loader other than the framework class loader and its subclasses). This achieves class isolation between third-party libraries introduced by the Java program and third-party libraries introduced by the implementation of the general capability interface.

[0052] Please see Figure 2-1 As shown in the embodiments of this application, the class isolation method is used in a service governance system. The service governance system includes a plug-in system framework and service governance plug-ins. The method mainly includes the following steps:

[0053] 201. The virtual machine builds multiple JAR packages for the service governance system.

[0054] In this embodiment, the virtual machine can build two JAR files for the pluggable system framework: a first JAR file and a second JAR file. The first JAR file corresponds to the general capability interface definition of the pluggable system framework, and the second JAR file corresponds to the implementation of the general capability interface. The general capability interface definition is used to call the general capability interface implementation. The virtual machine can also build a third JAR file for the service governance plugin. The third JAR file corresponds to the bytecode enhancement logic in the service governance plugin, and the bytecode enhancement logic is used to call the general capability interface definition. The virtual machine can also build a fourth and a fifth JAR file for the service governance plugin. The fourth JAR file corresponds to the service governance interface definition, and the fifth JAR file corresponds to the service governance interface implementation in the service governance plugin. The general capability interface definition is used to call the general capability interface implementation, and the bytecode enhancement logic is also used to call the general capability interface definition.

[0055] It should be noted that the service governance system includes a plug-in system framework and one or more service governance plug-ins. In the embodiments of the present application, the virtual machine can be constructed into two jar packages based on the plug-in system framework, namely a first jar package and a second jar package, wherein the first jar package corresponds to the general capability interface definition, and the second jar package corresponds to the general capability interface implementation. The bytecode enhancement logic is used to call the general capability interface definition, and the general capability interface definition is used to call the general capability interface implementation.

[0056] In some possible implementations, the virtual machine can also construct three types of jar packages based on the one or more service governance plug-ins, namely a third jar package, a fourth jar package and a fifth jar package, wherein the third jar package corresponds to the bytecode enhancement logic, the fourth jar package corresponds to the service governance interface definition, and the fifth jar package corresponds to the one or more service governance interface implementations.

[0057] It should be noted that the bytecode enhancement logic and the java program are loaded by the same class loader, and are used to call the general capability interface definition, and the general capability interface definition is used to call the general capability interface implementation. In some possible implementations, the bytecode enhancement logic is also used to call the service governance interface definition, and the general capability interface definition is used to call the one or more service governance interface implementations.

[0058] For example, the service governance system is taken as a gray release function. It should be noted that the gray release function is used to distribute traffic to new and old features according to a proportion, gradually expand the proportion of traffic of the new feature, and finally achieve complete release of the new feature. For example, Figure 2-2As shown, in the construction process, the virtual machine can first construct 2 jar packages based on the plug-in system framework, which are a first jar package and a second jar package. The first jar package contains a general capability interface definition (i.e., DynamicConfigurationService), and the second jar package contains a general capability interface implementation (i.e., DynamicConfigurationImpl). Then, the virtual machine constructs 3 types of Jar packages based on one or more plug-ins of the gray release function, which are a third jar package, a fourth jar package and a fifth jar package. The third jar package corresponds to bytecode enhancement logic (gray-interceptor), the fourth jar package corresponds to a gray plug-in definition (gray-plugin-define), and the fifth jar package corresponds to one or more gray plug-in implementations (gray-plugin-implement). The bytecode enhancement logic is used to call the gray plug-in definition (gray-plugin-define), and the gray plug-in definition (gray-plugin-define) is used to call one or more gray plug-in implementations (gray-plugin-implement).

[0059] 202. The virtual machine loads the java program and the third jar package through a target class loader, which is a class loader other than the framework class loader and its subclasses.

[0060] In some possible implementation manners, the target class loader is an application class loader or a subclass thereof.

[0061] For example, as shown in Figure 2-3 As shown, the virtual machine can load the java program through the application class loader. For example, the jar package in which the file of the java program is located can be named demo.jar, and the virtual machine can load the java program through the application class loader by using the javaoption command. In some possible implementation manners, as shown in Figure 2-4 The virtual machine can also load the java program through a custom class loader, which is not limited here. It should be noted that the custom class loader is a subclass of the application class loader.

[0062] In the embodiment of the present application, when the java program is loaded, the virtual machine can load the third jar package in the service governance system, that is, load the bytecode enhancement logic. Since the bytecode enhancement logic can call the general capability interface definition, the general capability interface definition is used to call the general capability interface implementation, and the bytecode enhancement logic can also call the service governance interface definition, the general capability interface definition is used to call one or more service governance interface implementations, that is, the java program can use the service governance system through the bytecode enhancement logic is realized.

[0063] 203. The virtual machine loads the first jar file via the application class loader.

[0064] In the embodiments of the present application, the virtual machine can load the first jar file, i.e. the general capability interface definition, via the application class loader. Exemplarily, the file name of the general capability interface definition can be DynamicConfigurationService.class. Then, the virtual machine can create a ServiceManager.class instance, which is used to save the instance of the general capability interface implementation later.

[0065] 204. The virtual machine loads the second jar file via a custom framework class loader, which is a subclass of the application class loader.

[0066] In the embodiments of the present application, the virtual machine can create a framework class loader (FramworkClassLoader), which is a subclass of the application class loader. Then, the virtual machine loads the second jar file, i.e. the general capability interface implementation, via the framework class loader, and the file name of the general capability interface implementation is DynamicConfigurationImpl.class, so as to realize the function of the general capability interface definition. Thus, the general capability interface implementation is loaded via the FramworkClassLoder, so as to achieve the class loader level class isolation between the general capability of the plug-in system framework and the java program, and avoid class conflicts.

[0067] 205. The virtual machine loads the fourth jar file via the application class loader.

[0068] In the embodiments of the present application, the virtual machine can load the fourth jar file, i.e. the service governance interface definition, via the application class loader, and create a plug-in service management instance (exemplarily, the file name is PluginServiceManager.class), which is used to save the instance of the service governance capability interface implementation later. Exemplarily, if the service governance system is a gray release function, the file name of the service governance interface definition can be GrayService.Class.

[0069] 206. The virtual machine loads the fifth jar file via a custom plug-in class loader, which is a subclass of the application class loader.

[0070] In the embodiments of the present application, as Figure 2-5As shown, the virtual machine can first create a plugin class loader, which is a subclass of the application class loader, and then load the fifth jar package, i.e., the service governance interface implementation, through the plugin class loader. For example, if the service governance system is a gray release function, the file name of the service governance interface implementation can be GrayServiceImpl.class, thereby implementing the function of GrayService.class. By loading the plugin service governance function interface implementation through PluginClassLoader, class isolation at the class loader level between the function of the service governance system and the java program is achieved, and class conflicts are avoided.

[0071] Therefore, even if the service governance interface implementation needs to load third-party class libraries, the java program is loaded through the application class loader or the custom class loader, and the service governance interface implementation is loaded by the framework class loader, thereby avoiding class conflicts between the plugin and the java program.

[0072] In some possible implementation manners, the virtual machine can first create multiple plugin class loaders, and then load each service governance interface implementation in the fifth jar package through each part of the multiple plugin class loaders, the plugin class loader and the service governance interface implementation corresponding to each other. Therefore, as shown, Figure 2-6 Even if the service governance interface implementation needs to load third-party class libraries, each service governance interface implementation uses a separate class loader (PluginClassLoader), thereby avoiding class conflicts between the plugins. Different service governance plugins are loaded through different PluginClassLoader, and different service governance plugins are isolated at the class loader level, thereby avoiding class conflicts. Moreover, since the class isolation is performed in a non-shade manner, but in a class loader level, the development of the ecological contribution is more friendly, and the huge build product generated by shade is avoided.

[0073] In the embodiments of the present application, after the Javaagent program (the service governance system) is mounted on the java program, the code of the java program does not need to be modified, the function of the service governance system can be implemented, and class conflicts are avoided.

[0074] For example, if the service governance system is a gray release function, the gray release plugin is effective in the java program, and the java program does not need to be modified. The java program only needs to use the function of the general capability interface implementation through the general capability interface definition of the plugin system framework, and the gray release function can be implemented, and class conflicts are avoided.

[0075] AsFigure 2-7 As shown, the user-defined class loader can load the bytecode enhancement logic of the gray release function (i.e., grayinterceptor.class), the bytecode enhancement logic can call the general capability interface definition of the plug-in system framework (i.e., DynamicConfigurationService.class), the general capability interface definition can call the general capability interface implementation (i.e., DynamicConfigurationServiceImpl.class), and the general capability interface implementation (i.e., DynamicConfigurationServiceImpl.class) can update the configuration through the configuration center. The bytecode enhancement logic can also gray release the service governance interface definition of the function (i.e., GrayService.class), and the service governance interface definition of the function can call the service governance interface implementation (i.e., GrayServiceimpl.class). For example, the gray release function can assign value=A in the request to API-V1 and value=B in the request to API-V2 to implement the gray release function and achieve class isolation of the third-party class library between the java program and the general capability interface implementation and the service governance interface implementation.

[0076] It should be noted that, for the foregoing method embodiments, in order to simply describe, they are all expressed as a series of action combinations, but those skilled in the art should know that the present application is not limited to the action sequence described, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should know that the embodiments described in the specification all belong to preferred embodiments, and the actions and modules involved are not necessarily necessary for the present application.

[0077] In order to better implement the above scheme of the embodiments of the present application, the related device for implementing the above scheme is also provided below.

[0078] Please refer to Figure 3 As shown, the programmable device 300 provided by the embodiments of the present application is used for a service governance system, the service governance system includes a plug-in system framework and a service governance plug-in, and the programmable device includes:

[0079] The construction module 301 is configured to construct 2 jar packages for the plug-in system framework, which are a first jar package and a second jar package, wherein the first jar package corresponds to the general capability interface definition of the plug-in system framework, and the second jar package corresponds to the general capability interface implementation of the plug-in system framework, and the general capability interface definition is configured to call the general capability interface implementation.

[0080] The construction module 301 is further configured to construct a third jar package for the service governance plug-in, the third jar package corresponding to bytecode enhancement logic in the service governance plug-in, the bytecode enhancement logic being configured to invoke the general capability interface definition;

[0081] The loading module 302 is configured to load the first jar package by an application class loader;

[0082] The loading module 302 is further configured to load the second jar package by a custom framework class loader, the framework class loader being a subclass of the application class loader;

[0083] The loading module 302 is further configured to load the java program and the third jar package by a target class loader, the target class loader being a class loader other than the framework class loader and subclasses thereof.

[0084] In some possible implementation manners, the target class loader is an application class loader or a subclass thereof.

[0085] In some possible implementation manners, the construction module 301 is further configured to construct a fourth jar package and a fifth jar package for the service governance plug-in, the fourth jar package corresponding to a service governance interface definition, the fifth jar package corresponding to service governance interface implementation in the service governance plug-in, the general capability interface definition being configured to invoke the general capability interface implementation, and the bytecode enhancement logic being further configured to invoke the general capability interface definition.

[0086] The loading module 302 is further configured to load the fourth jar package by the application class loader;

[0087] The loading module 302 is further configured to load the fifth jar package by a custom plug-in class loader, the plug-in class loader being a subclass of the application class loader.

[0088] In some possible implementation manners, the construction module 301 is further configured to construct a fourth jar package and a plurality of fifth jar packages for the service governance plug-in, the fourth jar package corresponding to a service governance interface definition, the plurality of fifth jar packages corresponding to a plurality of service governance interface implementations in the service governance plug-in in a one-to-one manner, the general capability interface definition being configured to invoke the plurality of general capability interface implementations, and the bytecode enhancement logic being further configured to invoke the general capability interface definition.

[0089] The loading module 302 is further configured to load the fourth jar package by the application class loader;

[0090] The loading module 302 is further configured to load the plurality of fifth jar packages through a self-defined plug-in class loader, the plug-in class loader being a subclass of the application class loader.

[0091] In some possible implementation manners, the service governance system is a gray release function.

[0092] It should be noted that the information interaction and execution process between the modules / units of the apparatus are based on the same concept as the method embodiments of the present application, and the technical effects brought by the same are the same as those of the method embodiments of the present application. For details, refer to the description in the foregoing method embodiments of the present application, which will not be repeated here.

[0093] The embodiments of the present application further provide a computer storage medium, wherein the computer storage medium stores a program, and the program executes part or all of the steps recorded in the foregoing method embodiments.

[0094] Next, a communication apparatus provided by the embodiments of the present application is introduced. Figure 4 As shown in FIG. 4, the communication apparatus 400 includes:

[0095] The receiver 401, the transmitter 402, the processor 403 and the memory 404 can be connected through a bus or other means, wherein, Figure 4 In the embodiments of the present application, the connection through the bus is taken as an example.

[0096] The memory 404 can include a read-only memory and a random access memory, and provide the processor 403 with instructions and data. A part of the memory 404 can also include a non-volatile random access memory (NVRAM). The memory 404 stores an operating system and operation instructions, executable modules or data structures, or a subset thereof, or an extended set thereof, wherein the operation instructions can include various operation instructions for implementing various operations. The operating system can include various system programs for implementing various basic services and processing hardware-based tasks.

[0097] The processor 403 controls the operation of the communication apparatus, and the processor 403 can also be referred to as a central processing unit (CPU). In specific applications, various components of the communication apparatus are coupled together through a bus system, wherein the bus system can include a data bus, a power bus, a control bus and a status signal bus, etc. However, for the purpose of clear illustration, all kinds of buses are referred to as a bus system in the figure.

[0098] The method disclosed in the embodiments of the present application can be applied to the processor 403 or implemented by the processor 403. The processor 403 can be an integrated circuit chip having a signal processing capability. In the implementation process, each step of the above method can be completed by an integrated logic circuit or an instruction in the form of software in the processor 403. The processor 403 described above can be a general processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component. Each method, step and logic block diagram disclosed in the embodiments of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in combination with the embodiments of the present application can be directly embodied as a hardware code processor for execution, or a combination of hardware and software modules in the code processor for execution. The software module can be located in a random access memory, a flash memory, a read only memory, a programmable read only memory or an electrically erasable programmable memory, a register or other mature storage medium in the art. The storage medium is located in the memory 404, and the processor 403 reads the information in the memory 404 and combines the hardware to complete the steps of the above method.

[0099] The receiver 401 can be used to receive input digital or character information, and generate signal input related to relevant settings and function control. The transmitter 402 can include a display device such as a display screen, and the transmitter 402 can be used to output digital or character information through an external interface.

[0100] In the embodiments of the present application, the processor 403 is used to execute the above-mentioned communication device to execute the method of isolation.

[0101] In another possible design, when the programmable device and the communication device are chips, the chips include a processing unit, for example, a processor, and a communication unit, for example, an input / output interface, a pin, or a circuit, etc. The processing unit can execute computer-executed instructions stored in a storage unit, so that the chips in the terminal perform the wireless reporting information sending method in any one of the first aspect. Optionally, the storage unit is a storage unit in the chips, such as a register, a cache, etc. The storage unit can also be a storage unit outside the chips in the terminal, such as a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM), etc.

[0102] The processor mentioned in any one of the above can be a general central processor, a microprocessor, an ASIC, or one or more integrated circuits for controlling execution of programs of the above method.

[0103] It should be noted that the above-described apparatus embodiments are merely illustrative, and the units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, i.e., can be located in one place or distributed to multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the embodiment. In addition, the connection relationship between the modules in the apparatus embodiment provided in the present application indicates that there is a communication connection between them, which can be implemented as one or more communication buses or signal lines.

[0104] Through the above description of the embodiments, those skilled in the art can clearly understand that the present application can be implemented by means of software and necessary general hardware, and of course can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. Generally, functions completed by computer programs can be easily implemented by corresponding hardware, and specific hardware structures for implementing the same function can also be various, such as analog circuits, digital circuits, or special circuits, etc. However, for the present application, software program implementation is a better embodiment. Based on this understanding, the technical solutions of the present application can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer's floppy disk, U disk, mobile hard disk, ROM, RAM, magnetic disk or optical disk, etc., including a plurality of instructions for making a computer device (which can be a personal computer, a server, or a network device, etc.) execute the methods described in various embodiments of the present application.

[0105] In the above-described embodiments, all or some of the embodiments can be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or some of the embodiments can be implemented in the form of a computer program product.

[0106] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center through wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can store or a data storage device such as a server, data center, etc. integrated with one or more available media. The available media can be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid state disk (SSD)) and the like.

Claims

1. A method of quasi-isolation, characterized in that, The method is used for a service governance system, the service governance system comprises a plug-in system framework and a service governance plug-in, and the method comprises the following steps: Two jar packages are constructed for the plug-in system framework, which are a first jar package and a second jar package, wherein the first jar package corresponds to a general capability interface definition of the plug-in system framework, and the second jar package corresponds to a general capability interface implementation of the plug-in system framework, and the general capability interface definition is used for calling the general capability interface implementation; A third jar package is constructed for the service governance plug-in, the third jar package corresponds to bytecode enhancement logic in the service governance plug-in, and the bytecode enhancement logic is used for calling the general capability interface definition; The first jar package is loaded by an application class loader; The second jar package is loaded by a self-defined framework class loader, and the framework class loader is a subclass of the application class loader; A java program and the third jar package are loaded by a target class loader, and the target class loader is a class loader other than the framework class loader and its subclasses.

2. The method of claim 1, wherein, The target class loader is an application class loader or a subclass thereof.

3. The method of claim 1 or 2, wherein, The method further comprises the following steps: A fourth jar package and a fifth jar package are constructed for the service governance plug-in, wherein the fourth jar package corresponds to a service governance interface definition, and the fifth jar package corresponds to a service governance interface implementation in the service governance plug-in, the general capability interface definition is used for calling the general capability interface implementation, and the bytecode enhancement logic is further used for calling the general capability interface definition; The fourth jar package is loaded by the application class loader; The fifth jar package is loaded by a self-defined plug-in class loader, and the plug-in class loader is a subclass of the application class loader.

4. The method of claim 1 or 2, wherein, The method further comprises the following steps: A fourth jar package and a plurality of fifth jar packages are constructed for the service governance plug-in, wherein the fourth jar package corresponds to a service governance interface definition, the plurality of fifth jar packages correspond to a plurality of service governance interface implementations in the service governance plug-in in a one-to-one manner, the general capability interface definition is used for calling a plurality of general capability interface implementations, and the bytecode enhancement logic is further used for calling the general capability interface definition; The fourth jar package is loaded by the application class loader; The plurality of fifth jar packages are loaded by a self-defined plug-in class loader, and the plug-in class loader is a subclass of the application class loader.

5. The method according to any one of claims 1 to 4, characterized in that, The service governance system is a gray release function.

6. A programmable device, characterized by The method is used for a service governance system, the service governance system comprises a plug-in system framework and a service governance plug-in, and the programmable device comprises: A construction module is configured to construct two jar packages for the plug-in system framework, which are a first jar package and a second jar package, wherein the first jar package corresponds to a general capability interface definition of the plug-in system framework, and the second jar package corresponds to a general capability interface implementation of the plug-in system framework, and the general capability interface definition is used for calling the general capability interface implementation; The construction module is further configured to construct a third jar package for the service governance plug-in, the third jar package corresponding to bytecode enhancement logic in the service governance plug-in, the bytecode enhancement logic being configured to invoke the general capability interface definition; The loading module is configured to load the first jar package by an application class loader; The loading module is further configured to load the second jar package by a custom framework class loader, the framework class loader being a subclass of the application class loader; The loading module is further configured to load a java program and the third jar package by a target class loader, the target class loader being a class loader other than the framework class loader and subclasses thereof.

7. The programmable device of claim 6, wherein, The target class loader is an application class loader or a subclass thereof.

8. The programmable device of claim 6 or 7, wherein, Further comprising: The construction module is further configured to construct a fourth jar package and a fifth jar package for the service governance plug-in, the fourth jar package corresponding to a service governance interface definition, the fifth jar package corresponding to service governance interface implementation in the service governance plug-in, the general capability interface definition being configured to invoke the general capability interface implementation, and the bytecode enhancement logic being further configured to invoke the general capability interface definition; The loading module is further configured to load the fourth jar package by the application class loader; The loading module is further configured to load the fifth jar package by a custom plug-in class loader, the plug-in class loader being a subclass of the application class loader.

9. The programmable device of claim 6 or 7, wherein, Further comprising: The construction module is further configured to construct a fourth jar package and a plurality of fifth jar packages for the service governance plug-in, the fourth jar package corresponding to a service governance interface definition, the plurality of fifth jar packages one-to-one corresponding to a plurality of service governance interface implementations in the service governance plug-in, the general capability interface definition being configured to invoke a plurality of general capability interface implementations, and the bytecode enhancement logic being further configured to invoke the general capability interface definition; The loading module is further configured to load the fourth jar package by the application class loader; The loading module is further configured to load the plurality of fifth jar packages by a custom plug-in class loader, the plug-in class loader being a subclass of the application class loader.

10. The programmable device according to any of claims 6-9, wherein, The service governance system is a gray release function.

11. A computer readable storage medium, characterized in that, The computer readable storage medium stores a program, and the program causes a computer device to execute the method in any one of claims 1-5.

12. A computer program product, characterised in that, The computer program product includes computer execution instructions stored in a computer readable storage medium; at least one processor of a device reads the computer execution instructions from the computer readable storage medium, and the at least one processor executes the computer execution instructions to cause the device to execute the method in any one of claims 1-5.

13. A communications device, characterized by The communication device includes at least one processor, a memory, and a communication interface; The at least one processor is coupled with the memory and the communication interface; The memory is configured to store instructions, the processor is configured to execute the instructions, and the communication interface is configured to communicate with other communication devices under control of the at least one processor. The instructions, when executed by the at least one processor, cause the at least one processor to perform the method of any one of claims 1-5.

14. A chip system, characterized by The chip system comprises a processor and a memory, the memory and the processor are interconnected by a line, the memory stores instructions, and the processor is configured to execute the method of any one of claims 1-5.

Citation Information

Patent Citations

  • Automatic index generation method and system based on byte codes

    CN113254317A

  • System function expansion method and device, equipment and medium

    CN114661376A