Specific implementation mode
Since current many virtual machines (such as JVM) are not provided with the mechanism of differentiation version, compare if used
Complicated Classloader architecture is easy for version punching occur when there are multiple versions of some data packet or class
It is prominent.For example, a Java, which is applied, depends on plug-in unit A and plug-in unit B, and plug-in unit A depends on the version 1 of plug-in unit C, plug-in unit B to depend on
The version 2 of plug-in unit C, then if using the Classloader system with branch, when the lookup of parent loader and subclass loader
When all there is plug-in unit C in range, parent loader will be prevented preferentially to load the version 1 of plug-in unit C and cause plug-in unit B from normally adding
It carries, and then Java applications is caused to be not normally functioning.
The core concept of this specification is:So that intended application is no longer directly run on virtual machine, and is operate in container
On, by container in such a way that mutually independent different Classloader loads different plug-in units or application, load target is answered
With the plug-in unit and/or other application relied on, to achieve the purpose that class is isolated, to ensure the normal operation of application.
In order to make those skilled in the art more fully understand the technical solution in this specification one or more embodiment,
Below in conjunction with the attached drawing in this specification one or more embodiment, to the technology in this specification one or more embodiment
Scheme is clearly and completely described, it is clear that and described embodiment is only this specification a part of the embodiment, rather than
Whole embodiments.The embodiment of base in this manual, those of ordinary skill in the art are not before making creative work
The every other embodiment obtained is put, the range of this specification protection should be all belonged to.
Fig. 1 is the process schematic for the operation application that this specification provides, and specifically includes following steps:
S100:Start container.
In the present specification, the container is used for operational objective application, provides and is relied on for loading the intended application
Plug-in unit and/or other application Classloader, and manage these Classloaders, plug-in unit and other application.The container
It runs on virtual machine.
Below only by intended application be Java for illustrate, it will be understood by those skilled in the art that it is following only with
Java illustratively illustrated, does not constitute the limitation to the application, it is any with realize identical of other computer languages or
Similar functions, within the protection domain of the application.
Java is run on using (intended application) on JVM, is starting Java in application, need to first start described in this specification
Container.Specifically, the corresponding code of container can be written in Java applications, that is, being wrapped in the corresponding data packet of intended application
Containing the corresponding code of container, then the Java is being run in application, the container corresponding generation for including in the data packet can directly be run
Code, has been turned on the container.
Further, since virtual machine is starting one in application, the data packet for first having to find the application is corresponding
Entry method therefore, can be corresponding by the data packet of the intended application when by the corresponding code write-in intended application of container
Entry method is revised as:The corresponding entry method of the container.When then starting the intended application, the target that virtual machine is found is answered
The corresponding entry method of container of the data packet is actually written in the corresponding entry method of data packet, and then can be according to this
Entry method, the corresponding code of container for including in operation data packet.
S102:The corresponding data packet of container analysis intended application, to determine plug-in unit and/or other that intended application is relied on
Using.
S104:Container by several mutually independent Classloaders, with different Classloaders load different plug-in units or
The mode of application, the plug-in unit and/or other application that load intended application is relied on.
In this specification embodiment, the corresponding data packet of intended application may include two kinds.
The first, data packet also includes the intended application sheet other than it can include the above-mentioned corresponding code of container
The mark for the plug-in unit and/or other application that the corresponding service code of body and the intended application are relied on.Then container is in parsing mesh
It, can be according to the plug-in unit and/or other application that the intended application for including in the data packet is relied on when the mark corresponding data packet of application
Mark, determine the plug-in unit and/or other application that intended application is relied on, by Classloader load intended application relied on
Plug-in unit and/or when other application, can according to the mark of plug-in unit and/or other application that intended application is relied on, download or
It is local to search the plug-in unit and/or other application that intended application is relied on, and load.
Second, data packet also includes the intended application sheet other than it can include the above-mentioned corresponding code of container
The corresponding data packet of plug-in unit and/or the corresponding number of other application that the corresponding service code of body and the intended application are relied on
According to packet.When intended application be Java in application, second of data packet is Fat Jar packets.
When the corresponding data packet of intended application is above-mentioned second of data packet, after the container analysis data packet, you can straight
Connected Classloader, the corresponding data of plug-in unit relied on comprising the intended application in the corresponding data packet of load intended application
Packet, and/or, the corresponding data of other application relied on comprising the intended application in the corresponding data packet of load intended application
Packet.Obviously, second of data packet is more convenient the deployment of application developer compared to the first data packet.
It should be noted that intended application depends on plug-in unit and/or other application, it is inherently that intended application depends on
Class derived from class and/or other application derived from plug-in unit.For add-in developer, only one or several may have been write out
The code of a class, these codes can not constitute an application, and therefore, specified tool can be used in add-in developer, by these
Class is packaged into the format that container can be parsed and be loaded, and also just becomes plug-in unit, in other words, the plug-in unit of class.That is, this
Apply for that the plug-in unit refers to:By specified tool, several classes are packaged into the lattice that the container can be parsed and be loaded
The data packet of formula.
Similar, for application developer, several classes write out may be constructed an application, but this is applied
Class needs derived from institute are relied on by intended application, and therefore, specified tool can also be used in application developer, which is packaged
The format that can be parsed and load at container, and since the application needs to be relied on by intended application, which does not need
Run on an individual container, and need to operate on the same container with intended application, therefore, be packaged should in application,
This, which is applied, does not include the corresponding code of container in corresponding data packet.That is, intended application described herein is relied on
Other application refer to:By specified tool, the other application is packaged into the lattice that the container can be parsed and be loaded
The data packet of formula, and do not include the corresponding code of the container in the corresponding data packet of the other application.
Certainly, for the developer of intended application, also specified tool is used to be packaged into the intended application
The format that the container can be parsed and be loaded, the other application relied on the intended application difference lies in since answer by target
With not relied on by other application, intended application needs independent operating on container, and therefore, the tool is in addition to by the intended application sheet
The plug-in unit and/or other application that the service code of body, the intended application are relied on are packed into other than the data packet of the intended application,
The corresponding code of container is still packed into the data packet of the intended application, to the side described in S100 through the above steps
Method starts container.
The plug-in unit and/or container relied on by intended application is no longer directly loaded by the Classloader of virtual machine itself,
But loaded by the Classloader that container provides, therefore, container can jump out the limitation that virtual machine itself does not differentiate between version, using not
Same Classloader loads different plug-in units or other application, and rank (father is not present between each Classloader that container is provided
Sub- rank, upper and lower rank etc.) on differentiation, and be independent from each other Classloader, that is to say, that as long as be different plug-in unit or
Using just using different and mutually independent Classloader load.Different plug-in units described herein or application refer to:
Any two identifies different plug-in units or application.
In addition, container can preferentially load intended application when loading the plug-in unit and/or other application that intended application is relied on
The plug-in unit relied on reloads the other application that intended application is relied on, and when loading plug-in unit, can be relied on according to intended application
Each plug-in unit priority, load each plug-in unit successively, when loading other application, can also be relied on according to intended application it is each its
The priority that he applies, loads each other application successively.The priority of each plug-in unit and other application can be set as needed
It is fixed.
S106:Plug-in unit and/or other application of the container based on load, run the intended application pair for including in the data packet
The service code answered.
It is run on virtual machine just because of container, container itself has jumped out virtual machine and do not provide the mechanism for distinguishing version
And mutually independent Classloader is provided, therefore, different plug-in unit that the intended application run on container is relied on and/or
Other application can be loaded by mutually independent different Classloader, version conflict would not also occur, it is ensured that target
The normal operation of application.
In this specification embodiment, container can manage the plug-in unit and application that it is loaded by class derived table, specifically,
After the plug-in unit that is relied on of load intended application, derived class is (that is, the plug-in unit institute energy by the mark of plug-in unit and after loading the plug-in unit
Derived class) class identification record in class derived table;After the other application that load intended application is relied on, by other application
The class identification record for identifying and loading derived class (that is, class derived from the other application institute energy) after the other application is led in class
Go out in table.
Since container is when loading the plug-in unit and/or other application that intended application is relied on, the plug-in unit and/or other application
Other plug-in units or application can may be also relied on, therefore, container can be determined when loading plug-in unit according to the configuration file of plug-in unit
The class that the plug-in unit is relied on is loaded, and searches such determining other plug-in units of export, last base in the class derived table of record
In other plug-in units found, the plug-in unit is loaded.The configuration file of the plug-in unit may include in the corresponding data packet of the plug-in unit.Class
As, in load in application, can determine the class for loading the application and being relied on, and searches export in the class derived table of record and determine
Such other plug-in units or application, be finally based on other plug-in units found or application, load the application.
After being loaded with the plug-in unit and/or other application that intended application is relied on, container can determine operational objective application pair
The class that the service code answered is relied on, and judge whether the class that operational objective applies corresponding service code to be relied on is to refer in advance
Fixed class, if so, searching such in the corresponding service code of intended application and loading, with the class operational objective based on load
Using corresponding service code, otherwise, is searched in class derived table and export such plug-in unit or other application, and be based on having loaded
The plug-in unit found or other application, operational objective apply corresponding service code.
Wherein, above-mentioned specified class refers to:The developer of development goal application is not desired to preferentially load plug-in unit or other application
Derived class, and think preferentially to load the self-contained class of the intended application.
It is and upper it should be noted that container loads the method for other application that intended application is relied on by Classloader
The method for stating the application of container operational objective is identical, is just no longer repeated one by one here.
Certainly, container is when loading the plug-in unit that is relied on of intended application and/or other application, these plug-in units and/or other
Using derived from class be also likely to be virtual machine itself or container itself foundation class, therefore, container is in load intended application institute
When the plug-in unit of dependence, class derived from the plug-in unit can be first searched in the foundation class of virtual machine and (if finding, is loaded directly into virtual
The foundation class of machine), then search class derived from the plug-in unit in the foundation class of container and (if finding, be loaded directly into the base of container
Plinth class), the plug-in unit is finally searched in the data packet of intended application and is loaded.Similar, container is applied or is added in operational objective
When carrying the other application that intended application is relied on, container can first search the derived class of application (if looking into the foundation class of virtual machine
Find, be then loaded directly into the foundation class of virtual machine), then in the foundation class of container search application derived class (if finding,
It is loaded directly into the foundation class of container), then judge whether such is specified class (if so, directly in the corresponding code of application
Search and load), it finally searches and loads in the data packet of application, as shown in Figure 2.
As it can be seen that if ignoring above-mentioned class derived table, it is described herein compared to the Classloader that JVM itself is provided
The Classloader that container is provided is completely non-interference independently of each other, and the Classloader that JVM is provided is that there are father and son passes
System, it is not independent, therefore the Classloader that container described herein provides can provide class isolation mech isolation test, to ensure that target is answered
Do not conflicted between the class relied on.Further, in conjunction with above-mentioned class derived table, the class that container described herein provides adds
Carrying device can be interdepended again by class derived table, and this original mutually independent Classloader is realized by class derived table
Dependence be a kind of netted relationship, the set membership (being equivalent to relationship between superior and subordinate) between the Classloader of JVM
It is entirely different.Therefore, Classloader provided herein can also interdepend while providing class isolation mech isolation test, ensure
Intended application is based on normally relying on and normal operation.
It is the method for running application that one or more embodiments of this specification provide above, is based on same thinking,
This specification additionally provides the device of corresponding operation application, as shown in Figure 3.
Parsing module 301, the corresponding data packet of parsing intended application, the plug-in unit relied on the determination intended application
And/or other application;
Load-on module 302 loads different plug-in units with different Classloaders by several mutually independent Classloaders
Or the mode of application, load the plug-in unit and/or other application that the intended application is relied on;
Module 303, the plug-in unit based on load and/or other application are run, the institute for including in the data packet is run
State the corresponding service code of intended application.
The corresponding data packet of plug-in unit relied on comprising the intended application in the corresponding data packet of the intended application;
And/or
The corresponding data of other application relied on comprising the intended application in the corresponding data packet of the intended application
Packet does not include the corresponding code of described device in the corresponding data packet of the other application;
The load-on module 302 is loaded in the corresponding data packet of the intended application and is relied on comprising the intended application
The corresponding data packet of plug-in unit;And/or it loads in the corresponding data packet of the intended application and is relied on comprising the intended application
The corresponding data packet of other application.
The load-on module 302 determines according to the configuration file of the plug-in unit and loads the class that the plug-in unit is relied on;
Other plug-in units of the determining class of export are searched in the class derived table of record;Based on other plug-in units found, described in load
Plug-in unit.
Described device further includes:
Management module 304 will be described after the plug-in unit that the load-on module 302 loads that the intended application is relied on
The class identification record of derived class is in class derived table after the mark and the load plug-in unit of plug-in unit;In the load-on module
After the other application that the 302 load intended applications are relied on, by the mark of the other application and load it is described other
The class identification record of derived class is in class derived table after.
The operation module 303 determines and runs the class that the corresponding service code of the intended application is relied on;Judge operation
Whether the class that the corresponding service code of the intended application is relied on is preassigned class;If so, in the intended application
The class is searched in corresponding service code and is loaded, and the corresponding business of the intended application is run with the class based on load
Code;Otherwise, the plug-in unit or other application for exporting the class are searched in the class derived table, and are found based on what is loaded
Plug-in unit or other application, run the corresponding service code of the intended application.
This specification also correspondence provides a kind of equipment for information recommendation, as shown in Figure 4.The equipment include one or
Multiple memories and processor, the memory stores program, and is configured to be held by one or more of processors
Row following steps:
Start container;
The corresponding data packet of the container analysis intended application, the plug-in unit relied on the determination intended application and/or
Other application;
The container is loaded different plug-in units with different Classloaders or is answered by several mutually independent Classloaders
Mode loads plug-in unit and/or other application that the intended application is relied on;
The plug-in unit and/or other application of the container based on load, run in the data packet mesh for including
Mark applies corresponding service code.
In addition, this specification additionally provides a kind of container run on virtual machine, as shown in Figure 5.
Fig. 5 is the structural schematic diagram for the container that this specification provides.
Starting module is mainly responsible for the initialization of container, starts for container and prepares resource and service.
Parsing module (parsing module being equivalent in Fig. 3) is responsible for the plug-in unit that parsing intended application relies on and/or other are answered
With.
Plug-in unit load-on module, the plug-in unit that according to priority load intended application relies on successively.
Using load-on module, the other application that according to priority load intended application relies on successively (plug-in unit load-on module and is answered
The load-on module being equivalent to load-on module in Fig. 3).
Management module, including Classloader management module, plug-in management module, plug-in services management module, application management
Module, application service management module.Classloader management module is used to manage the mutually independent class load that container can be provided
Device.The mark of plug-in unit is recorded after plug-in unit of the plug-in management module for managing container load, including load plug-in unit in class derived table
Know and the class of derived class identifies.Plug-in services management module is equivalent to for externally providing class derived from the plug-in unit institute of load
The service for the plug-in unit that container is loaded externally is provided.Application management module is used to manage application (the intended application institute of container load
The other application of dependence), including the mark of record application and the class of derived class identify in class derived table after load plug-in unit.It answers
With service management module for externally providing class derived from the application institute of load, it is equivalent to and the application that container is loaded externally is provided
Service.
Foundation class management module, the foundation class for managing virtual machine and/or container itself.
In the 1990s, the improvement of a technology can be distinguished clearly be on hardware improvement (for example,
Improvement to circuit structures such as diode, transistor, switches) or software on improvement (improvement for method flow).So
And with the development of technology, the improvement of current many method flows can be considered as directly improving for hardware circuit.
Designer nearly all obtains corresponding hardware circuit by the way that improved method flow to be programmed into hardware circuit.Cause
This, it cannot be said that the improvement of a method flow cannot be realized with hardware entities module.For example, programmable logic device
(Programmable Logic Device, PLD) (such as field programmable gate array (Field Programmable Gate
Array, FPGA)) it is exactly such a integrated circuit, logic function determines device programming by user.By designer
Voluntarily programming comes a digital display circuit " integrated " on a piece of PLD, designs and makes without asking chip maker
Dedicated IC chip.Moreover, nowadays, substitution manually makes IC chip, this programming is also used instead mostly " patrols
Volume compiler (logic compiler) " software realizes that software compiler used is similar when it writes with program development,
And the source code before compiling also write by handy specific programming language, this is referred to as hardware description language
(Hardware Description Language, HDL), and HDL is also not only a kind of, but there are many kind, such as ABEL
(Advanced Boolean Expression Language)、AHDL(Altera Hardware Description
Language)、Confluence、CUPL(Cornell University Programming Language)、HDCal、JHDL
(Java Hardware Description Language)、Lava、Lola、MyHDL、PALASM、RHDL(Ruby
Hardware Description Language) etc., VHDL (Very-High-Speed are most generally used at present
Integrated Circuit Hardware Description Language) and Verilog.Those skilled in the art also answer
This understands, it is only necessary to method flow slightly programming in logic and is programmed into integrated circuit with above-mentioned several hardware description languages,
The hardware circuit for realizing the logical method flow can be readily available.
Controller can be implemented in any suitable manner, for example, controller can take such as microprocessor or processing
The computer for the computer readable program code (such as software or firmware) that device and storage can be executed by (micro-) processor can
Read medium, logic gate, switch, application-specific integrated circuit (Application Specific Integrated Circuit,
ASIC), the form of programmable logic controller (PLC) and embedded microcontroller, the example of controller includes but not limited to following microcontroller
Device:ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20 and Silicone Labs C8051F320, are deposited
Memory controller is also implemented as a part for the control logic of memory.It is also known in the art that in addition to
Pure computer readable program code mode is realized other than controller, can be made completely by the way that method and step is carried out programming in logic
Controller is obtained in the form of logic gate, switch, application-specific integrated circuit, programmable logic controller (PLC) and embedded microcontroller etc. to come in fact
Existing identical function.Therefore this controller is considered a kind of hardware component, and to including for realizing various in it
The device of function can also be considered as the structure in hardware component.Or even, it can will be regarded for realizing the device of various functions
For either the software module of implementation method can be the structure in hardware component again.
System, device, module or the unit that above-described embodiment illustrates can specifically realize by computer chip or entity,
Or it is realized by the product with certain function.It is a kind of typically to realize that equipment is computer.Specifically, computer for example may be used
Think personal computer, laptop computer, cellular phone, camera phone, smart phone, personal digital assistant, media play
It is any in device, navigation equipment, electronic mail equipment, game console, tablet computer, wearable device or these equipment
The combination of equipment.
For convenience of description, it is divided into various units when description apparatus above with function to describe respectively.Certainly, implementing this
The function of each unit is realized can in the same or multiple software and or hardware when specification.
It should be understood by those skilled in the art that, the embodiment of this specification can be provided as method, system or computer journey
Sequence product.Therefore, in terms of this specification can be used complete hardware embodiment, complete software embodiment or combine software and hardware
Embodiment form.Moreover, it wherein includes computer usable program code that this specification, which can be used in one or more,
The computer implemented in computer-usable storage medium (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.)
The form of program product.
This specification is with reference to the method, equipment (system) and computer according to this specification one or more embodiment
The flowchart and/or the block diagram of program product describes.It should be understood that flow chart and/or side can be realized by computer program instructions
The combination of the flow and/or box in each flow and/or block and flowchart and/or the block diagram in block diagram.It can provide
These computer program instructions are set to the processing of all-purpose computer, special purpose computer, Embedded Processor or other programmable datas
Standby processor is to generate a machine so that is executed by computer or the processor of other programmable data processing devices
Instruction generates specifies for realizing in one flow of flow chart or multiple flows and/or one box of block diagram or multiple boxes
Function device.
These computer program instructions, which may also be stored in, can guide computer or other programmable data processing devices with spy
Determine in the computer-readable memory that mode works so that instruction generation stored in the computer readable memory includes referring to
Enable the manufacture of device, the command device realize in one flow of flow chart or multiple flows and/or one box of block diagram or
The function of being specified in multiple boxes.
These computer program instructions also can be loaded onto a computer or other programmable data processing device so that count
Series of operation steps are executed on calculation machine or other programmable devices to generate computer implemented processing, in computer or
The instruction executed on other programmable devices is provided for realizing in one flow of flow chart or multiple flows and/or block diagram one
The step of function of being specified in a box or multiple boxes.
In a typical configuration, computing device includes one or more processors (CPU), input/output interface, net
Network interface and memory.
Memory may include computer-readable medium in volatile memory, random access memory (RAM) and/or
The forms such as Nonvolatile memory, such as read-only memory (ROM) or flash memory (flash RAM).Memory is computer-readable medium
Example.
Computer-readable medium includes permanent and non-permanent, removable and non-removable media can be by any method
Or technology realizes information storage.Information can be computer-readable instruction, data structure, the module of program or other data.
The example of the storage medium of computer includes, but are not limited to phase transition internal memory (PRAM), static RAM (SRAM), moves
State random access memory (DRAM), other kinds of random access memory (RAM), read-only memory (ROM), electric erasable
Programmable read only memory (EEPROM), fast flash memory bank or other memory techniques, read-only disc read only memory (CD-ROM) (CD-ROM),
Digital versatile disc (DVD) or other optical storages, magnetic tape cassette, tape magnetic disk storage or other magnetic storage apparatus
Or any other non-transmission medium, it can be used for storage and can be accessed by a computing device information.As defined in this article, it calculates
Machine readable medium does not include temporary computer readable media (transitory media), such as data-signal and carrier wave of modulation.
It should also be noted that, the terms "include", "comprise" or its any other variant are intended to nonexcludability
Including so that process, method, commodity or equipment including a series of elements include not only those elements, but also wrap
Include other elements that are not explicitly listed, or further include for this process, method, commodity or equipment intrinsic want
Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that wanted including described
There is also other identical elements in the process of element, method, commodity or equipment.
This specification can describe in the general context of computer-executable instructions executed by a computer, such as journey
Sequence module.Usually, program module include routines performing specific tasks or implementing specific abstract data types, program, object,
Component, data structure etc..One or more embodiments that this specification can also be put into practice in a distributed computing environment, at this
In a little distributed computing environment, by executing task by the connected remote processing devices of communication network.It is counted in distribution
It calculates in environment, program module can be located in the local and remote computer storage media including storage device.
Each embodiment in this specification is described in a progressive manner, identical similar portion between each embodiment
Point just to refer each other, and each embodiment focuses on the differences from other embodiments.Especially for system reality
For applying example, since it is substantially similar to the method embodiment, so description is fairly simple, related place is referring to embodiment of the method
Part explanation.
It is above-mentioned that this specification specific embodiment is described.Other embodiments are in the scope of the appended claims
It is interior.In some cases, the action recorded in detail in the claims or step can be come according to different from the sequence in embodiment
It executes and desired result still may be implemented.In addition, the process described in the accompanying drawings not necessarily require show it is specific suitable
Sequence or consecutive order could realize desired result.In some embodiments, multitasking and parallel processing be also can
With or it may be advantageous.
The foregoing is merely one or more embodiments of this specification, are not limited to this specification.For
For those skilled in the art, one or more embodiments of this specification can have various modifications and variations.It is all in this explanation
Any modification, equivalent replacement, improvement and so within the spirit and principle of one or more embodiments of book, should be included in
Within the right of this specification.