Class based on OSGI loads shielding system and method
Technical field
The present invention relates to network and field of computer technology, particularly a kind of class based on OSGI loads shielding system and method.
Background technology
Along with the develop rapidly of computer networking technology, for application server, how design class loading structure meet class in application server time and isolate, time and shared problem is day by day lofty.
The Classloader of tradition application server realizing is all chain structure, and the last-of-chain of Classloader chain is all responsible for the privately owned class under load application usually, and the closer to the front end of chain, the class being responsible for loading gets over system-level common class.Therefore the practice of traditional application server is exactly to need the class shared to be placed on the position that Classloader chain front end can be loaded into, such as system lib catalogue, or under general class common catalogue, then the class configuring application loads and adopts parents' way of bailment, that is, the class in web application is preferentially loaded by parent loader.When needs are isolated, the class just will isolated is placed on the privately owned class position that Classloader last-of-chain is responsible for loading, such as, under the WEB-INF/lib catalogue of web application, the class load mechanism then configuring web application is that son is preferential, and the class namely in web application is preferentially loaded by the Classloader applied.Relatively more typical, just can make to control isolation to each other or sharing in this way as the multiple web application in EAR (EnterpriseArchiveFile) application.
But this implementation underaction, and granularity is too thick.The class that such as cannot realize in independent web application A is isolation to independent web application B, but the class in application A is shared independent web application C.And the isolation that jar wraps this rank can only be controlled to, if wrap for certain jar, the class of some package is wanted to be shared, and the class of some package is wanted to be isolated, and so also cannot accomplish.In addition, the control of traditional isolation just determines in deployment, cannot implement to change during operation.
Along with OSGi(OpenServiceGatewayInitiative) technology growing, new version has all done based on OSGi framework in a lot of application server manufacturer.Utilize the netted class loading structure of the two-stage of OSGi framework uniqueness, the class isolation design being different from traditional application server completely can be made.Wherein typical design be exactly for each application distribute an independent OSGi run a time, when the OSGi at each like this application place runs, there is natural isolation, also just ensure that application class isolation to each other.But this design also exists an open defect, that is applied exactly and can not remove isolation.
Summary of the invention
(1) technical matters solved
The technical matters that the present invention solves proposes a kind of class based on OSGI to load shielding system and method, and to solve, the dirigibility of current class loading shielding system is low, the problem of coarseness.
(2) technical scheme
The present invention proposes a kind of class based on OSGI and load shielding system, it is characterized in that, described system comprises:
Converter, for being converted to standard wab by web application;
Processor, for creating virtual component set for described web application;
Filtrator, for arranging isolated relation for described virtual component set.
Preferably, described web is applied as bundle form or war form.
Preferably, described virtual component set operates in when same OSGI runs interior.
Preferably, described virtual component set is made up of application component bundles and filtrator.
Preferably, described filtrator comprises: bundle visibility list, package visibility list or service visibility list.
The invention allows for a kind of class based on OSGI and load partition method, it is characterized in that, described method comprises:
S1: convert web application to standard wab, and be that described web applies the set of establishment virtual component;
S2: for described virtual component set creates filtrator;
S3: according to the observability list in described filtrator, for described virtual component set arranges isolated relation.
Preferably, described web is applied as bundle form or war form.
Preferably, described virtual component set operates in when same OSGI runs interior.
Preferably, also comprise upon step s 2: the observability list that described filtrator is set.
Preferably, also comprise after step S3: described web application is arranged in described virtual component set, and start described web and apply.
(3) beneficial effect
The present invention loads shielding system and method by proposing a kind of class based on OSGI, and be towards the web application under JavaEE platform, according to the fine-grained isolation controlling class isolation and service between application of real needs, and configuration is more flexible.
Accompanying drawing explanation
Fig. 1 is the system construction drawing that the present invention proposes;
Fig. 2 is the virtual component collecting structure figure that the present invention proposes;
Fig. 3 is the filtration device structure figure that the present invention proposes;
Fig. 4 is the method flow diagram that the present invention proposes;
Fig. 5 is the method flow schematic diagram that the present invention proposes.
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 clearly and completely described.
The present invention proposes a kind of class based on OSGI and load shielding system, as shown in Figure 1, described system comprises:
Converter, for being converted to standard wab by web application;
Processor, for creating virtual component set for described web application;
Filtrator, for arranging isolated relation for described virtual component set.
Described system also comprises web application class loader, and wherein, the class isolation between web application is by the filtrator Collaborative Control between web application class loader and virtual component set.
Described web is applied as bundle form or war form.Wab converter converts the web application of traditional war form or bundle Informal development to standard wab, and creates virtual component set for this web applies.
Described virtual component set operates in when same OSGI runs interior, and described virtual component set not only can control class isolation to each other, and the OSGI that can also control to each other serves isolation.
Be illustrated in figure 2 the virtual component collecting structure figure of the class load server of the JavaEE application server based on OSGI, described virtual component set is made up of application component bundles and filtrator.Application component bundles is the concrete element of composition web application, and application component bundle is exactly a module in web application.Described filtrator is for arranging the isolated relation between virtual component set.
Be illustrated in figure 3 the filtration device structure figure of the class load server of the JavaEE application server based on OSGI, described filtrator comprises: bundle visibility list, package visibility list or service visibility list.Which bundle that bundle visibility list controls in this virtual component set is visible to destination virtual assembly set; Which bag that package visibility list controls in this virtual component set is visible to destination virtual assembly set; Which OSGiservice that service visibility list controls to expose in this virtual component set is visible to destination virtual assembly set.
Because the observability between virtual component set is two-way, therefore need to be respectively it according to the actual requirements and filtrator is set.If do not arrange filtrator between two virtual component set, so these two virtual component set are by completely isolated, i.e. bundle, class, and service is sightless each other.Between the application that this acquiescence effect is just applicable to JavaEE application server, class loads isolation requirement, if want to remove isolation, or past release isolation, so only need add corresponding filtrator.
And for the class of JavaEE application server system level and service, usually all need the virtual component set of application layer visible, to complete application deployment and request processing flow smoothly.On the contrary, class in the set of application layer virtual component to the operation of JavaEE application server without any effect, but the service in the set of application layer virtual component needs the set of JavaEE application server system level virtual component visible, to complete the function of some distribution subscription models.
For realizing above-mentioned general requirment, need the set of add-on system level virtual component to the filtrator of application layer virtual component set and the set of application layer virtual component to the filtrator of system-level virtual component set.In the filtrator of wherein system-level virtual component set end, need system-level core classes place bundle, package belonging to core classes, the OSGiservice of core exposure adds in the bundle visibility list of isolated relation filtrator, package visibility list and service visibility list respectively; In the isolated relation filtrator of application layer virtual component set, the OSGiservice by application exposes only is needed to add in the service visibility list of isolated relation filtrator.
The invention allows for a kind of class based on OSGI and load partition method, as shown in Figure 4, described method comprises:
S1: convert web application to standard wab, and be that described web applies the set of establishment virtual component;
S2: for described virtual component set creates filtrator;
S3: according to the observability list in described filtrator, for described virtual component set arranges isolated relation.
Described web is applied as bundle form or war form.
Described virtual component set operates in when same OSGI runs interior.
Also comprise upon step s 2: the observability list that described filtrator is set.
Also comprise after step S3: described web application is arranged in described virtual component set, and start described web and apply.
As shown in Figure 5, the class that the present invention is based on the JavaEE application server of OSGi loads partition method and is: first use converter that traditional war is converted to standard wab, virtual component geometric processor is that traditional war creates an empty virtual component set, then be that this virtual component set creates filtrator, according to the actual requirements, if needing to arrange has different isolations to other different virtual assembly sets, so just need the filtrator creating multiple correspondence, again due to the amphicheirality of isolation, also need to be that other virtual component set create corresponding filtrator from direction on the contrary, the observability list of each filtrator is set afterwards, preliminary work is substantially ready herein, related virtual component set isolated relation filtrator couples together by the api that then starting to call virtual component collection manager provides, again web application component is installed in this virtual component set, such web application component to the observability of other virtual component set just and its place virtual component set to the same visi-bility of other virtual component set.Finally start web application component, so far isolation arranges and all completes.
Above embodiment is only for illustration of the present invention; and be not limitation of the present invention; the those of ordinary skill of relevant technical field; without departing from the spirit and scope of the present invention; can also make a variety of changes and modification; therefore all equivalent technical schemes also belong to category of the present invention, and scope of patent protection of the present invention should be defined by the claims.