CN106354533A - Dynamic module loading method and device - Google Patents
Dynamic module loading method and device Download PDFInfo
- Publication number
- CN106354533A CN106354533A CN201610757151.0A CN201610757151A CN106354533A CN 106354533 A CN106354533 A CN 106354533A CN 201610757151 A CN201610757151 A CN 201610757151A CN 106354533 A CN106354533 A CN 106354533A
- Authority
- CN
- China
- Prior art keywords
- service object
- servlet
- servlet service
- module
- request
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44521—Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Transfer Between Computers (AREA)
Abstract
The invention discloses a dynamic module loading method and device. The method comprises the following steps: when requiring to dynamically load an application module, establishing a new servlet service object; when receiving a servlet request, forwarding the received servlet request to a new servlet service object by using the original servlet service object to dynamically load the application module by the new servlet service object; and after the new service object is established, destroying the servlet service object established during last dynamic module loading. By the method disclosed by the invention, a project framework does not need to be established again, when the application module is loaded dynamically every time, only the new servlet service object needs to be established, therefore, dynamic loading to modules can still be realized under the condition that the project framework is not changed, the dynamic module loading method is easy to realized, moreover, learning cost is low, and consumed labor and time are less.
Description
Technical field
The present invention relates to module loading technical field, in particular, it is related to a kind of module dynamic loading method and device.
Background technology
In java web application, it is usually present a lot of needs long lasting for the b/s application running, these applications sometimes
May require that interpolation or delete some application modules, be at this moment accomplished by using module Dynamic loading technique, to realize not stopping answering
With in the case of, dynamic add or delete application module.
At present, conventional module Dynamic loading technique is osgi technology, and osgi technology is java mobilism modular system
A series of specifications and based on this specification technology realize, be the module Dynamic loading technique in a kind of more fine granularity.Although
Osgi technology can realize the dynamic load of application modules, but does not adopt osgi technology when a project is in framework,
And when increased module dynamic load demand (the dynamic load demand for example to mvc module) in project development process, may
It is accomplished by rebuilding project framework.Because osgi technology has higher complexity, therefore rebuild project framework inevitable
Learning cost can be led to increase, and also more manpower and time can be expended.
To sum up, a kind of module dynamic loading method and system how are provided, to realize keeping the constant feelings of project framework
Still can achieve under condition that the dynamic load to module is those skilled in the art's technical problem urgently to be resolved hurrily.
Content of the invention
In view of this, the present invention discloses a kind of module dynamic loading method and device, to realize keeping project framework not
The dynamic load to module is still can achieve in the case of change.
A kind of module dynamic loading method, comprising:
When needing dynamic load application module, build a new servlet service object;
When receiving servlet request, described servlet request is sent to original servlet service object;
Using described original servlet service object, described servlet request is transmitted to described new servlet clothes
Business object is processed, to realize the dynamic load to described application module by described new servlet service object;
After the completion of described new servlet service object builds, build during the last module dynamic load of destruction
Servlet service object.
Preferably, described when needing dynamic load application module, build a new servlet service object include:
When needing dynamic load application module, obtain all resources that described application module needs to load;
Construct predefined Classloader classloader using described all resources;
Call the initial method of spring Request dispatcher, the resource in described classloader is carried out building
To described new servlet service object;
The address of described new servlet service object is preserved to described original servlet service object.
Preferably, described construct predefined Classloader classloader using described all resources and include:
Described all resources are divided into fixed class resource and change class resource;
Using URL loader urlclassloader, construction is carried out to described fixed class resource and obtain father
Loader;
Using described father's loader as parent, using described urlclassloader, described change class resource is constructed
Obtain sub- loader, wherein, described father's loader and described sub- loader constitute described classloader.
Preferably, described using described original servlet service object, described servlet request is transmitted to described new
Servlet service object processed, to realize described application module is moved by described new servlet service object
State loads and includes:
Judge to whether there is in described servlet request and belong to same kind but adhere to the request of different classloader separately;
If there is described request, the described attribute asked in corresponding first request entity being replicated, obtains institute
State the duplication attribute of the first request entity;
According to the described resource replicating in attribute and predefined classloader, obtain the second request entity, wherein
Described resource is all resources that described application module needs to load;
Using described original servlet service object, described second request entity is transmitted to described new servlet
Service object is processed, to realize the dynamic load to described application module by described new servlet service object.
Preferably, described after the completion of described new servlet service object builds, destroy last module dynamic load
When the process of servlet service object that builds include:
After the completion of described new servlet service object builds, build when destroying described last time module dynamic load
Servlet service object in resource in network application container, and described network application container is set to sky;
Destroy the resource in the servlet service object's neutron loader building during described last time module dynamic load,
And described sub- loader is set to sky;
Destroy the servlet service object building during described last time module dynamic load.
Preferably, after destroying the servlet service object building during once module dynamic load on described, also wrap
Include:
Right to destroying the servlet service building during described last time module dynamic load using system rubbish recovering method
As during generate rubbish reclaimed.
A kind of module dynamic loading device, comprising:
Construction unit, for when needing dynamic load application module, building a new servlet service object;
Transmitting element, for when receiving servlet request, described servlet request being sent to original
Servlet service object;
Retransmission unit, described for being transmitted to described servlet request using described original servlet service object
New servlet service object is processed, to be realized to described application module by described new servlet service object
Dynamic load;
Destroy unit, after the completion of building as described new servlet service object, destroy last module and dynamically add
The servlet service object building during load.
Preferably, described construction unit includes:
Obtain subelement, for when needing dynamic load application module, obtaining the institute that described application module needs to load
There is resource;
Construction subelement, for constructing predefined Classloader classloader using described all resources;
Instantiation subelement, for calling the initial method of spring Request dispatcher, in described classloader
Resource carry out building and obtain described new servlet service object;
Preserve subelement, for preserving the address of described new servlet service object to described original servlet
In service object.
Preferably, described construction subelement includes:
Resource category divides subelement, for described all resources are divided into fixed class resource and change class resource;
Father's loader construct subelement, for using URL loader urlclassloader to described solid
Determine class resource and carry out construction to obtain father's loader;
Sub- loader constructs subelement, for using described father's loader as parent, using described urlclassloader
Construction is carried out to described change class resource and obtains sub- loader, wherein, described father's loader and described sub- loader composition are described
classloader.
Preferably, described retransmission unit includes:
Judgment sub-unit, belongs to same kind but adheres to difference separately for judging to whether there is in described servlet request
The request of classloader;
Replicate subelement, in the case of being judged as YES in described judgment sub-unit, then to described request corresponding the
Attribute in one request entity is replicated, and obtains the duplication attribute of described first request entity;
Second request entity obtains subelement, for according in described duplication attribute and predefined classloader
Resource, obtain the second request entity, wherein said resource is all resources that described application module needs to load;
Forward subelement, for being transmitted to described second request entity using described original servlet service object
Described new servlet service object is processed, to be realized to described application mould by described new servlet service object
The dynamic load of block.
Preferably, described destruction unit includes:
First destruction subelement, after the completion of building as described new servlet service object, destroys the described last time
Resource in network application container in the servlet service object building during module dynamic load, and described network application is held
Device is set to sky;
Second destruction subelement, for destroying the servlet service object building during described last time module dynamic load
Resource in neutron loader, and described sub- loader is set to sky;
3rd destruction subelement, for destroying the servlet service object building during described last time module dynamic load.
Preferably, also include:
Garbage reclamation subelement, the servlet service for building during once module dynamic load on destruction is described is right
As afterwards, right to destroying the servlet service building during described last time module dynamic load using system rubbish recovering method
As during generate rubbish reclaimed.
Knowable to above-mentioned technical scheme, the invention discloses a kind of module dynamic loading method and device, dynamic when needing
When state loads application module, build a new servlet service object, when receiving servlet request, using original
The servlet receiving request is transmitted to new servlet service object by servlet service object, with by new
Servlet service object realizes the dynamic load of application modules, and after the completion of new service object builds, destroys last
The servlet service object building during module dynamic load.It follows that need not be rebuild using method disclosed by the invention
Project framework, in each dynamic load application module, only need to build new servlet service object, therefore, the present invention
Achieve the dynamic load that still can achieve in the case of keeping project framework constant to module, be not only easy to realize, and learn
Low cost, the manpower of consuming and time are less.
Brief description
In order to be illustrated more clearly that the embodiment of the present invention or technical scheme of the prior art, below will be to embodiment or existing
Have technology description in required use accompanying drawing be briefly described it should be apparent that, drawings in the following description be only this
Inventive embodiment, for those of ordinary skill in the art, on the premise of not paying creative work, can also basis
Disclosed accompanying drawing obtains other accompanying drawings.
Fig. 1 is a kind of method flow diagram of module dynamic loading method disclosed in the embodiment of the present invention;
Fig. 2 is a kind of method flow diagram building new servlet service object disclosed in the embodiment of the present invention;
Fig. 3 is a kind of method flow diagram destroying original servlet service object disclosed in the embodiment of the present invention;
Fig. 4 is a kind of structural representation of module dynamic loading device disclosed in the embodiment of the present invention;
Fig. 5 is a kind of structural representation of construction unit disclosed in the embodiment of the present invention;
Fig. 6 is a kind of structural representation of construction unit disclosed in the embodiment of the present invention.
Specific embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out clear, complete
Site preparation description is it is clear that described embodiment is only a part of embodiment of the present invention, rather than whole embodiments.It is based on
Embodiment in the present invention, it is every other that those of ordinary skill in the art are obtained under the premise of not making creative work
Embodiment, broadly falls into the scope of protection of the invention.
The embodiment of the invention discloses a kind of module dynamic loading method and device, to realize keeping project framework constant
In the case of still can achieve dynamic load to module.
Referring to Fig. 1, a kind of method flow diagram of module dynamic loading method disclosed in the embodiment of the present invention, the method includes
Step:
Step s101, when needing dynamic load application module, build a new servlet service object;
Wherein it is desired to the application module of dynamic load can be mvc module.
The full name of servlet is java servlet, is the server write with java.
Step s102, when receiving servlet request, servlet request is sent to original servlet service right
As;
It should be noted that due to new servlet service object and original servlet service object adhere to separately different
Classloader (Classloader), new servlet service object is sightless for server, therefore for client
The servlet request sending, server still can send it to original servlet service object.
Step s103, using described original servlet service object, described servlet request is transmitted to described new
Servlet service object is processed, dynamic to described application module to be realized by described new servlet service object
Load;
Wherein, for making new servlet service object come into force, server need to pass through original servlet service object will
Servlet request is transmitted to new servlet service object, to realize application modules by new servlet service object
Dynamic load.
Step s104, after the completion of new servlet service object builds, destroy and build during last module dynamic load
Servlet service object.
It should be noted that original servlet service object is to be built by server (for example, tomcat), own
Original servlet service object all can be sent to by the request of server to be processed, the present invention is former by being sent to
The servlet request of the servlet service object begun is transmitted to new servlet service object and is processed, and realizing will
Servlet request is forwarded to new servlet service object from original servlet service object, to realize application modules
Dynamic load.Therefore, actually there are two servlet service objects in server in the present invention: an original servlet
Service object and a new servlet service object, the address of new servlet service object is saved in original
In servlet service object, original servlet service object exists all the time, will not be destroyed.In servlet new every time
After the completion of service object creates, new servlet service object will replace building during last module dynamic load
Servlet service object, based on server performance consider build during last module dynamic load in addition it is also necessary to destroy
Servlet service object.
Wherein, the present invention does not modify to original servlet service object but to build new servlet service right
As the reason be: original servlet service object is to be built by server (for example, tomcat), all by server
Request all can be sent to original servlet service object and processed.If desired the request that client sends is handed to
Other servlet service object, is necessary for changing the servlet build mechanism of server or request transmission mechanism, thus
Can go deep into the details of server, specific server be produced and relies on, ultimately cause the height coupling of project server.Cause
This, the present invention does not have the technological means of the servlet service object original using directly modification, but new using building
Servlet request is transmitted to new servlet service by original servlet service object right by servlet service object
As realizing the dynamic load of application modules, wherein, this application module can be new application module.
In summary, the present invention, in each dynamic load application module, can build a new servlet service right
As then servlet request being transmitted to new servlet service object using original servlet service object, by new
Servlet service object realize the dynamic load of application modules.For comparing existing scheme, the present invention need not rebuild
Project framework, in each dynamic load application module, only need to build new servlet service object, it is achieved that
Still can achieve the dynamic load to module in the case of keeping project framework constant, be not only easy to realize, and learning cost
Low, the manpower of consuming and the time less.
In addition, compared to existing technologies, implementation of the present invention is simple it is not necessary to developer should to dynamic load
Carry out excessive concern with the details of module, facilitate developer to use, and easy to maintain.
It should be noted that the present invention is the springmvc framework realization based on lightweight.
For optimizing above-described embodiment further, referring to Fig. 2, the invention also discloses building new servlet service object
Detailed process, including step:
Step s201, when needing dynamic load application module, obtain application module need load all resources;
Wherein, application module needs all resources loading to include: class file, jar bag, configuration file etc..
Step s202, construct predefined classloader using all resources;
Wherein, classloader (Chinese is: Classloader) is a kind of for loading java class to java virtual machine
One of loader.
Because new servlet service object and original servlet service object adhere to different classloader separately,
Therefore, a classloader need to be pre-defined for new servlet service object.
Step s203, call the initial method of spring Request dispatcher, the resource in described classloader is entered
Row builds and obtains new servlet service object;
Specifically, using the reflex mechanism of java, call the initial method of spring Request dispatcher, to described
Resource in classloader carries out building and obtains new servlet service object.
Step s204, the address of new servlet service object is preserved to original servlet service object.
Wherein, the address of new servlet service object is preserved the purpose to original servlet service object
It is: make original servlet service object after receiving servlet request, new servlet can be found by this address
Service object, servlet request is forwarded to new servlet service object.
Wherein, in the present embodiment, step s202 specifically may include that
First application module is needed all resources loading to be divided into fixed class resource and change class resource;Secondly utilize
Urlclassloader (Chinese: URL loader) carries out construction to described fixed class resource and obtains father adding
Carry device;Again using father's loader as parent, using urlclassloader, construction is carried out to change class resource and obtain sub- loading
Device, wherein, father's loader and sub- loader constitute the classloader in step s202.
It should be noted that when needing dynamic load application module every time, being required for reconfiguring sub- loader, same with this
When, father's loader can be always maintained at constant.
Wherein, in above-described embodiment, step s103 utilizes original servlet service object to ask to forward by servlet
Processed to new servlet service object, to realize described application module is moved by new servlet service object
The process that state loads specifically includes:
First, it is determined that servlet request in the presence or absence of belong to same kind but adhere to separately different classloader please
Ask, if there is this request, the attribute in the first request entity corresponding to this request replicates, and obtains the first request entity
Duplication attribute;Then (namely pre- in step s202 according to the resource replicating in attribute and predefined classloader
Resource in the classloader first defining, this resource also needs all resources loading for application module), obtaining second please
Realistic body;Finally using original servlet service object, the second request entity is transmitted to described new servlet service right
As being processed, to realize the dynamic load of application modules by new servlet service object.
It should be noted that the process of the network asynchronous request tool-class of the present embodiment namely modification extension spring.
For optimizing above-described embodiment further, referring to Fig. 3, the invention also discloses it is right to destroy original servlet service
The detailed process of elephant, including step:
Step s301, after the completion of new servlet service object builds, destroy and build during last module dynamic load
Servlet service object in resource in network application container (webapplicationcontext), and should by described network
It is set to sky with container;
In the servlet service object's neutron loader building when step s302, the last module dynamic load of destruction
Resource, and this sub- loader is set to sky;
The servlet service object building when step s303, the last module dynamic load of destruction.
It is understood that during the servlet service object building during once module dynamic load on destroying,
A lot of system rubbish will necessarily be produced, system rubbish not only occupies Installed System Memory, also can affect the speed of service of system, therefore,
The present invention on having destroyed once module dynamic load when the servlet that builds after, also whole Destruction can be generated
Rubbish is purged.
Therefore, for optimizing above-described embodiment further, after step s303, can also include:
Step s304, using system rubbish recovering method to destroying the servlet building during last module dynamic load
The rubbish generating during service object is reclaimed.
Wherein, system rubbish recovering method can select system.gc ().
Corresponding with said method embodiment, the invention also discloses a kind of module dynamic loading device.
Referring to Fig. 4, a kind of structural representation of module dynamic loading device disclosed in the embodiment of the present invention, this device bag
Include:
Construction unit 401, for when needing dynamic load application module, building a new servlet service object;
It should be noted that due to new servlet service object and original servlet service object adhere to separately different
Classloader (Classloader), new servlet service object is sightless for server, therefore for client
The servlet request sending, server still can send it to original servlet service object.
Transmitting element 402, for when receiving servlet request, described servlet request being sent to original
Servlet service object;
Retransmission unit 403, for being transmitted to described servlet request using described original servlet service object
Described new servlet service object is processed, to be realized to described application mould by described new servlet service object
The dynamic load of block;
Wherein, for making new servlet service object come into force, server need to pass through original servlet service object will
Servlet request is transmitted to new servlet service object, to realize application modules by new servlet service object
Dynamic load.
Destroy unit 404, after the completion of building as new servlet service object, destroy last module and dynamically add
The servlet service object building during load.
It should be noted that original servlet service object is to be built by server (for example, tomcat), own
Original servlet service object all can be sent to by the request of server to be processed, the present invention is former by being sent to
The servlet request of the servlet service object begun is transmitted to new servlet service object and is processed, and realizing will
Servlet request is forwarded to new servlet service object from original servlet service object, to realize application modules
Dynamic load.Therefore, actually there are two servlet service objects in server in the present invention: an original servlet
Service object and a new servlet service object, the address of new servlet service object is saved in original
In servlet service object, original servlet service object exists all the time, will not be destroyed.In servlet new every time
After the completion of service object creates, new servlet service object will replace building during last module dynamic load
Servlet service object, based on server performance consider build during last module dynamic load in addition it is also necessary to destroy
Servlet service object.
In summary, the present invention, in each dynamic load application module, can build a new servlet service right
As then servlet request being transmitted to new servlet service object using original servlet service object, by new
Servlet service object realize the dynamic load of application modules.For comparing existing scheme, the present invention need not rebuild
Project framework, in each dynamic load application module, only need to build new servlet service object, it is achieved that
Still can achieve the dynamic load to module in the case of keeping project framework constant, be not only easy to realize, and learning cost
Low, the manpower of consuming and the time less.
In addition, compared to existing technologies, implementation of the present invention is simple it is not necessary to developer should to dynamic load
Carry out excessive concern with the details of module, facilitate developer to use, and easy to maintain.
It should be noted that the present invention is the springmvc framework realization based on lightweight.
For optimizing above-described embodiment further, referring to Fig. 5, a kind of structure of construction unit disclosed in the embodiment of the present invention is shown
It is intended to, comprising:
Obtain subelement 501, need loading for when needing dynamic load application module, obtaining described application module
All resources;
Wherein, application module needs all resources loading to include: class file, jar bag, configuration file etc..
Construction subelement 502, for constructing predefined Classloader classloader using described all resources;
Instantiation subelement 503, for calling the initial method of spring Request dispatcher, to described
Resource in classloader carries out building and obtains described new servlet service object;
Preserve subelement 504, for preserving the address of described new servlet service object to described original
In servlet service object.
Wherein, the address of new servlet service object is preserved the purpose to original servlet service object
It is: make original servlet service object after receiving servlet request, new servlet can be found by this address
Service object, servlet request is forwarded to new servlet service object.
Wherein, in the present embodiment, construction subelement 502 specifically may include that
Resource category divides subelement, for described all resources are divided into fixed class resource and change class resource;
Father's loader construct subelement, for using URL loader urlclassloader to described solid
Determine class resource and carry out construction to obtain father's loader;
Sub- loader constructs subelement, for using described father's loader as parent, using described urlclassloader
Construction is carried out to described change class resource and obtains sub- loader, wherein, described father's loader and described sub- loader composition are described
classloader.
It should be noted that when needing dynamic load application module every time, being required for reconfiguring sub- loader, same with this
When, father's loader can be always maintained at constant.
Wherein, for optimizing above-described embodiment further, retransmission unit 403 specifically may include that
Judgment sub-unit, belongs to same kind but adheres to difference separately for judging to whether there is in described servlet request
The request of classloader;
Replicate subelement, in the case of being judged as YES in described judgment sub-unit, then to described request corresponding the
Attribute in one request entity is replicated, and obtains the duplication attribute of described first request entity;
Second request entity obtains subelement, for according in described duplication attribute and predefined classloader
Resource, obtain the second request entity, wherein said resource is all resources that described application module needs to load;
Forward subelement, for being transmitted to described second request entity using described original servlet service object
Described new servlet service object is processed, to be realized to described application mould by described new servlet service object
The dynamic load of block.
It should be noted that the process of the network asynchronous request tool-class of the present embodiment namely modification extension spring.
For optimizing above-described embodiment further, participate in Fig. 6, disclosed in the embodiment of the present invention, a kind of structure destroying unit is shown
It is intended to, destroy unit and include:
First destruction subelement 601, after the completion of building as new servlet service object, destroys last module
Resource in network application container (webapplicationcontext) in the servlet service object building during dynamic load,
And described network application container is set to sky;
Second destruction subelement 602, the servlet service object's neutron building during for last module dynamic load adds
Carry the resource in device, and this sub- loader is set to sky;
3rd destruction subelement 603, for destroying the servlet service object building during last module dynamic load.
It is understood that during the servlet service object building during once module dynamic load on destroying,
A lot of system rubbish will necessarily be produced, system rubbish not only occupies Installed System Memory, also can affect the speed of service of system, therefore,
The present invention on having destroyed once module dynamic load when the servlet that builds after, the rubbish that also whole Destruction can be generated
Rubbish is purged.
Therefore, for optimizing above-described embodiment further, can also include:
Garbage reclamation subelement 604, builds for destroying when once module dynamic load destroyed by subelement 603 the 3rd
Servlet after, using system rubbish recovering method to destroying the servlet service building during last module dynamic load
The rubbish generating during object is reclaimed.
Wherein, system rubbish recovering method can select system.gc ().
It should be noted that the concrete operating principle of each ingredient refers to embodiment of the method correspondence in device embodiment
Part, here is omitted.
Last in addition it is also necessary to explanation, herein, such as first and second or the like relational terms be used merely to by
One entity or operation are made a distinction with another entity or operation, and not necessarily require or imply these entities or operation
Between there is any this actual relation or order.And, term " inclusion ", "comprising" or its any other variant meaning
Covering comprising of nonexcludability, so that including a series of process of key elements, method, article or equipment not only include that
A little key elements, but also include other key elements being not expressly set out, or also include for this process, method, article or
The intrinsic key element of equipment.In the absence of more restrictions, the key element being limited by sentence "including a ...", does not arrange
Remove and also there is other identical element in the process including described key element, method, article or equipment.
In this specification, each embodiment is described by the way of going forward one by one, and what each embodiment stressed is and other
The difference of embodiment, between each embodiment identical similar portion mutually referring to.
Described above to the disclosed embodiments, makes professional and technical personnel in the field be capable of or uses the present invention.
Multiple modifications to these embodiments will be apparent from for those skilled in the art, as defined herein
General Principle can be realized without departing from the spirit or scope of the present invention in other embodiments.Therefore, the present invention
It is not intended to be limited to the embodiments shown herein, and be to fit to and principles disclosed herein and features of novelty phase one
The scope the widest causing.
Claims (12)
1. a kind of module dynamic loading method is it is characterised in that include:
When needing dynamic load application module, build a new servlet service object;
When receiving servlet request, described servlet request is sent to original servlet service object;
Using described original servlet service object, described servlet request is transmitted to described new servlet service right
As being processed, to realize the dynamic load to described application module by described new servlet service object;
After the completion of described new servlet service object builds, destroy the servlet building during last module dynamic load
Service object.
2. module dynamic loading method according to claim 1 is it is characterised in that described ought need dynamic load application mould
During block, build a new servlet service object and include:
When needing dynamic load application module, obtain all resources that described application module needs to load;
Construct predefined Classloader classloader using described all resources;
Call the initial method of spring Request dispatcher, structure is carried out to the resource in described classloader and obtains institute
State new servlet service object;
The address of described new servlet service object is preserved to described original servlet service object.
3. module dynamic loading method according to claim 2 is it is characterised in that described constructed using described all resources
Predefined Classloader classloader includes:
Described all resources are divided into fixed class resource and change class resource;
Using URL loader urlclassloader, described fixed class resource is carried out with construction and obtain father's loading
Device;
Using described father's loader as parent, using described urlclassloader, construction is carried out to described change class resource and obtain
Sub- loader, wherein, described father's loader and described sub- loader constitute described classloader.
4. module dynamic loading method according to claim 1 it is characterised in that described using described original
Described servlet request is transmitted to described new servlet service object and is processed by servlet service object, to pass through
Described new servlet service object realizes the dynamic load of described application module is included:
Judge to whether there is in described servlet request and belong to same kind but adhere to the request of different classloader separately;
If there is described request, the described attribute asked in corresponding first request entity being replicated, obtains described the
The duplication attribute of one request entity;
According to the described resource replicating in attribute and predefined classloader, obtain the second request entity, wherein said
Resource is all resources that described application module needs to load;
Using described original servlet service object, described second request entity is transmitted to described new servlet service
Object is processed, to realize the dynamic load to described application module by described new servlet service object.
5. module dynamic loading method according to claim 1 it is characterised in that described when described new servlet clothes
After the completion of business object builds, the process destroying the servlet service object building during last module dynamic load includes:
After the completion of described new servlet service object builds, build during destruction described last time module dynamic load
Resource in network application container in servlet service object, and described network application container is set to sky;
Destroy the resource in the servlet service object's neutron loader building during described last time module dynamic load, and will
Described sub- loader is set to sky;
Destroy the servlet service object building during described last time module dynamic load.
6. module dynamic loading method according to claim 5 is it is characterised in that once module is dynamic on destruction is described
After the servlet service object building during loading, also include:
The servlet service object's building during using system rubbish recovering method last time described to destruction module dynamic load
During generate rubbish reclaimed.
7. a kind of module dynamic loading device is it is characterised in that include:
Construction unit, for when needing dynamic load application module, building a new servlet service object;
Transmitting element, for when receiving servlet request, described servlet request being sent to original servlet clothes
Business object;
Retransmission unit is described new for being transmitted to described servlet request using described original servlet service object
Servlet service object is processed, dynamic to described application module to be realized by described new servlet service object
Load;
Destroy unit, after the completion of building as described new servlet service object, when destroying last module dynamic load
The servlet service object building.
8. module dynamic loading device according to claim 7 is it is characterised in that described construction unit includes:
Obtain subelement, for when needing dynamic load application module, obtaining all moneys that described application module needs to load
Source;
Construction subelement, for constructing predefined Classloader classloader using described all resources;
Instantiation subelement, for calling the initial method of spring Request dispatcher, to the money in described classloader
Source carries out building and obtains described new servlet service object;
Preserve subelement, for preserving the address of described new servlet service object to described original servlet service
In object.
9. module dynamic loading device according to claim 8 is it is characterised in that described construction subelement includes:
Resource category divides subelement, for described all resources are divided into fixed class resource and change class resource;
Father's loader construct subelement, for using URL loader urlclassloader to described fixed class
Resource carries out construction and obtains father's loader;
Sub- loader constructs subelement, for using described father's loader as parent, using described urlclassloader to institute
State change class resource to carry out construction and obtain sub- loader, wherein, described father's loader and described sub- loader constitute described
classloader.
10. module dynamic loading device according to claim 7 is it is characterised in that described retransmission unit includes:
Judgment sub-unit, belongs to same kind but adheres to difference separately for judging to whether there is in described servlet request
The request of classloader;
Replicate subelement, in the case of being judged as YES in described judgment sub-unit, then please to described request corresponding first
Attribute in realistic body is replicated, and obtains the duplication attribute of described first request entity;Second request entity obtains subelement,
For according to the described resource replicating in attribute and predefined classloader, obtaining the second request entity, wherein said
Resource is all resources that described application module needs to load;
Forward subelement, described for being transmitted to described second request entity using described original servlet service object
New servlet service object is processed, to be realized to described application module by described new servlet service object
Dynamic load.
11. module dynamic loading devices according to claim 7 are it is characterised in that described destruction unit includes:
First destruction subelement, after the completion of building as described new servlet service object, destroys described last time module
Resource in network application container in the servlet service object building during dynamic load, and described network application container is put
For sky;
Second destruction subelement, for destroying the servlet service object's neutron building during described last time module dynamic load
Resource in loader, and described sub- loader is set to sky;
3rd destruction subelement, for destroying the servlet service object building during described last time module dynamic load.
12. module dynamic loading devices according to claim 7 are it is characterised in that also include:
Garbage reclamation subelement, for the servlet service object that builds when destroying once module dynamic load on described it
The servlet service object's building when afterwards, using system rubbish recovering method last time described to destruction module dynamic load
During generate rubbish reclaimed.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610757151.0A CN106354533B (en) | 2016-08-29 | 2016-08-29 | A kind of module dynamic loading method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610757151.0A CN106354533B (en) | 2016-08-29 | 2016-08-29 | A kind of module dynamic loading method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106354533A true CN106354533A (en) | 2017-01-25 |
CN106354533B CN106354533B (en) | 2019-09-20 |
Family
ID=57857646
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610757151.0A Active CN106354533B (en) | 2016-08-29 | 2016-08-29 | A kind of module dynamic loading method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106354533B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109033436A (en) * | 2018-08-14 | 2018-12-18 | 武汉达梦数据库有限公司 | A kind of multiple version JDBC driving coexistence methods of same database and system |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20040177352A1 (en) * | 2003-03-03 | 2004-09-09 | Narayanaswamy Sreedhara Srinivasulu | Universal deployment tool |
CN104360846A (en) * | 2014-10-27 | 2015-02-18 | 江西博微新技术有限公司 | OSGi-based adaptive design method for authority management of Web application development platform based on OSGi |
CN105512324A (en) * | 2015-12-21 | 2016-04-20 | 用友网络科技股份有限公司 | Front end module loader for partial renewal of package file |
-
2016
- 2016-08-29 CN CN201610757151.0A patent/CN106354533B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20040177352A1 (en) * | 2003-03-03 | 2004-09-09 | Narayanaswamy Sreedhara Srinivasulu | Universal deployment tool |
CN104360846A (en) * | 2014-10-27 | 2015-02-18 | 江西博微新技术有限公司 | OSGi-based adaptive design method for authority management of Web application development platform based on OSGi |
CN105512324A (en) * | 2015-12-21 | 2016-04-20 | 用友网络科技股份有限公司 | Front end module loader for partial renewal of package file |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109033436A (en) * | 2018-08-14 | 2018-12-18 | 武汉达梦数据库有限公司 | A kind of multiple version JDBC driving coexistence methods of same database and system |
Also Published As
Publication number | Publication date |
---|---|
CN106354533B (en) | 2019-09-20 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN102185901B (en) | Client message conversion method | |
CN108270818B (en) | Micro-service architecture system and access method thereof | |
CN110297620A (en) | A method of dynamic rules maintenance and generation based on Drools | |
CN101763269A (en) | Method for making software installation package | |
CN111290753A (en) | Method, device, equipment and storage medium for building front-end development environment | |
CN101477463A (en) | Software platform and software development platform used for digital television set-top box | |
CN102413185A (en) | Cloud platform automatic updating system based on BT technology | |
CN101968745A (en) | Development system and development method for application programs of mobile terminal | |
CN106201466B (en) | A kind of Template Manager method based on heat | |
CN105959302A (en) | Terminal management framework and method | |
CN102479355A (en) | Method and device for loading business documents and mobile terminal | |
CN103677983A (en) | Scheduling method and device of application | |
CN115248692A (en) | Device and method for supporting cloud deployment of multiple deep learning framework models | |
CN105955790B (en) | Data processing method and device | |
CN106354533A (en) | Dynamic module loading method and device | |
CN103197951A (en) | Method and device for constructing application operation environment | |
CN109683875B (en) | Application framework system of MVC (model view controller) pattern in distributed environment and method thereof | |
CN113626128B (en) | Audio-visual media micro-service third-party module access method, system and electronic equipment | |
CN105607928A (en) | Supporting method for browser kernel and webpage display method and apparatus | |
CN105446732A (en) | Operation realization method, device and system of 64-bit program | |
CN113795001A (en) | Method and device for sending system short message based on SPI | |
CN100364270C (en) | Dynamically constructed network management method | |
CN102255872A (en) | Method and device for accessing non-remote object | |
CN104363273A (en) | Flex server-free external program invoking method and system | |
CN102469118B (en) | A kind of method and device realizing information exploitation |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |