CN102158490B - Service switching method based on OSGi and device thereof - Google Patents

Service switching method based on OSGi and device thereof Download PDF

Info

Publication number
CN102158490B
CN102158490B CN 201110086817 CN201110086817A CN102158490B CN 102158490 B CN102158490 B CN 102158490B CN 201110086817 CN201110086817 CN 201110086817 CN 201110086817 A CN201110086817 A CN 201110086817A CN 102158490 B CN102158490 B CN 102158490B
Authority
CN
China
Prior art keywords
metadata
state
component
host
service
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.)
Active
Application number
CN 201110086817
Other languages
Chinese (zh)
Other versions
CN102158490A (en
Inventor
刘鹏
刘春�
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
CVIC Software Engineering Co Ltd
Original Assignee
CVIC Software Engineering Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by CVIC Software Engineering Co Ltd filed Critical CVIC Software Engineering Co Ltd
Priority to CN 201110086817 priority Critical patent/CN102158490B/en
Publication of CN102158490A publication Critical patent/CN102158490A/en
Application granted granted Critical
Publication of CN102158490B publication Critical patent/CN102158490B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention discloses a service switching method based on OSGi and a device thereof. The method comprises the following steps of: performing coding, adding metadata contents based on DService frame and weaving in a component implementation class; when the OSGi platform is started, configuring the metadata of a component embodiment and declaring the aspect component of an assembly component embodiment; reading the metadata of a host embodiment to the aspect embodiment and host embodiment configuration information; initializing an aspect component factory and an aspect embodiment, and obtaining the aspect embodiment of a certain state; when the state of the component embodiment is switched, notifying the aspect embodiment in the component embodiment to change the state; while interacting the instantiated object of the component implementation class, noting a value for the field of the host embodiment by the aspect embodiment of the certain state. The process not only reduces the starttime of system but also reduces the memory utilization of the system by loading a service component when necessary; and the OSGi service is issued, searched and bound in a declaration manner so that the operation process of registration and processing service is simplified.

Description

Service conversion method and device based on OSGi
Technical field
The present invention relates to network and field of computer technology, in particular, relate to a kind of service conversion method and device based on OSGi.
Background technology
OSGi (Open Service Gateway Initiative, public service platform) is a kind of service based on Java language (business) platform standard.This service platform is the application program of all types of network equipments under a kind of indoor, vehicles, portable terminal and other environment and service is transmitted and the open platform of telemanagement.The core of this standard is a framework, has wherein defined life cycle pattern and the service registry of application program.And OSGi emphasizes modularization and serviceization, and the technical staff can be in the situation that use handed over service based on OSGi, the purpose that realization dynamically updates.The OSGi framework also comprise one the cover programmatic method service unit, it can provide service issue, search and bindings.This model can also make related application carry out communication and cooperation by method of service with outside Bundle.The application of existing OSGi service platform comprises: gateway, automobile, mobile phone, industrial automation, building automation, PDA grid computing, amusement and IDE etc. need long-play, dynamically update and the system as far as possible little on the impact of running environment.
In the prior art, adopt the micronucleus structure of OSGi can the process of Assurance component exploitation in, assembly and expansion are independent and controlled, and can solve the problem of the dependence tracking, version tracking and the service binding that are applied in the small-sized system in the process of Components Development.
But, when the service platform of OSGi is applied to large-scale system and large-scale the deployment, its existing programmatic method service unit that adopts can cause the problem of performance and compatible aspect: one, start-up time is longer, programmatic method service unit among the OSGi needs on one's own initiative registration service and obtain service of Bundle, these services of registration all need to be carried out when starting, and need Bundle to carry out initialization in its activator appliance.When being applied to large-scale system, the time that system is started is elongated, makes toggle speed slack-off; Its two, internal memory is occupied, ISP's resource of taking of service of can't distributing according to need, when a service is registered to the OSGi framework, realize that the associated class of service all is instantiated, be loaded in the internal memory, if should service never use, always committed memory; Its three, comparatively complicated when the non-functional requirements such as issue, releasing, discovery and follow-up service of management service, this complexity can play passive impact to the application of exploitation framework, can not guarantee that all dynamic process all are in correct status.
Summary of the invention
In view of this, the invention provides a kind of service conversion method and device based on OSGi, because the defective of the service unit among the OSGi, when the service platform of OSGi is applied to large scale system or disposes on a large scale, easily cause performance and compatible problem to overcome in the prior art.
For achieving the above object, the invention provides following technical scheme:
A kind of service conversion method based on OSGi comprises:
Encode, based on the project management module maven increase content metadata of DService framework, and inweave member realization class;
When the OSGi platform starts, in the DService framework, the metadata of member example is configured, in the Bundle of OSGi the statement component members example aspect member;
Read host's example to metadata and host's instance configuration information of described aspect example;
Initialization aspect member factory and aspect example start the aspect example in the member example, obtain the aspect example of arbitrary state in valid or the invalid two states;
When the member example state was switched, traversal was notified the aspect example change that has in described member example state;
The object POJO that realizes the class instantiation with member carries out alternately, directly obtains the type information of host's member by metadata, is the field notes value of host's example by the aspect example of determining state.
Preferably, the aspect member of described statement component instance comprises: be unique XML NameSpace and the title of described aspect member statement.
Preferably, comprising: the aspect member of a plurality of component instances of statement among described Bundle;
The statement services component is used the party's surface member when the aspect of a plurality of component instances of statement among described Bundle member.
The process of preferably, initialization aspect member factory comprises:
Bundle starts, described Bundle disposes the DService metadata when the DService framework detects, and in the described metadata there be when determining unique aspect member by DService root node title and XML NameSpace statement, the aspect member that the DService framework is searched among the Bundle is realized class, is created by factory to be used for calling the corresponding interim aspect of initializeComponentFactory method component object;
The aspect component metadata of stating in the input link example.
Preferably, after initialization aspect member factory finished, the process of carrying out initialization aspect example comprised:
The DService framework creates the aspect example that configures for each member example;
Call the configure method of aspect example, the metadata of input link definition is finished the initialization of aspect example.
Preferably, start the aspect example in the member example, the process of obtaining the aspect example of arbitrary state in Valid and the Invalid two states comprises:
Call before the start method the sub-aspect example that all statements in the startup aspect example need;
Call after the start method, the current state of context of detection example, all sub-aspect example state of using in described aspect example are Valid, then the state of described aspect example is Valid;
All sub-aspect example state of using in described aspect example have one to be invalid, and then the state of described aspect example is Invalid.
Preferably, when the aspect example state was switched, traversal notified the process of the aspect example change state that has in the described member example to comprise:
When the state of member example became Valid from Invalid, it was Valid that traversal is notified the aspect example change state that has in the described member example;
When the state of member example became Invalid from Valid, it was Invalid that traversal is notified the aspect example change state that has in the described member example.
Preferably, also comprise:
When the member example stopped, all aspect members of described member example called the stop method, enter halted state.
Preferably, realizing that with member the object POJO of class instantiation carries out also comprising in the mutual process:
Before or after public method in the POJO of host's example object is called, when mistake occurring, tackled all public methods of described host's example by the aspect example.
A kind of service conversion equipment based on OSGi comprises:
The configuration statement module is used in the services component metadata member example being configured when the OSGi platform starts, the aspect member of statement member example;
Read module is used for reading host's example to metadata and host's instance configuration information of described aspect example;
Initial module is used for initialization aspect member factory and aspect example, starts the aspect example in the member example;
Acquisition module is for the aspect example that obtains Valid and Invalid two states;
Handover module is used for when the aspect example of described Valid and Invalid two states switches, and traversal is notified the aspect example change that has in all member examples state;
Notes value module is used for carrying out alternately with Java object POJO, directly obtains the type information of host's member by metadata, is the field notes value of host's example by the aspect example of determining state.
Via above-mentioned technical scheme as can be known, compared with prior art, the invention discloses a kind of service conversion method and device based on OSGi.By making up new service unit, thereby avoid the start-up time of registration service minimizing system in activator appliance, and when need to loading, services component just loads detecting, to reduce the occupancy in the Installed System Memory, and the method that adopts the statement formula is searched, is obtained, the service of issue and binding O SGi, thereby the simplification system is in registration service, the service of obtaining with step and its power consumption that produces when processing service.
Description of drawings
In order to be illustrated more clearly in the embodiment of the invention or technical scheme of the prior art, the below will do to introduce simply to the accompanying drawing of required use in embodiment or the description of the Prior Art, apparently, accompanying drawing in the following describes only is embodiments of the invention, for those of ordinary skills, under the prerequisite of not paying creative work, can also obtain according to the accompanying drawing that provides other accompanying drawing.
Fig. 1 is the flow chart of the disclosed a kind of service conversion method based on OSGi of the embodiment of the invention;
Fig. 2 is the class figure of the disclosed metadata object of the embodiment of the invention;
Fig. 3 is the execution sequence of the disclosed aspect of embodiment of the invention example life cycle and the flow chart that obtains the aspect example of different conditions;
Fig. 4 is the structural representation of the disclosed a kind of service conversion equipment based on OSGi of the embodiment of the invention.
Embodiment
For quote and know for the purpose of, the explanation of the technical term that hereinafter uses, write a Chinese character in simplified form or abridge and be summarized as follows:
OSGi:Open Service Gateway Initiative, public service platform;
POJO:Plain Old Java Objects, member is realized the object after the class instantiation, can be described by the class name by the member element in the metadata.xml meta data file, is managed by the member example during operation;
DService framework: Declarative Services, be one based on the service-oriented component model of OSGi framework, adopt the mode of the delay loading of serviced component and component lifecycle management to control for the taking and start fast of internal memory, it describes member with XML;
The modular unit of Bundle:OSGi service framework definition is referred to as a Bundle.Bundle is comprised of class and other resources of java, can provide function for the terminal use.The descriptor of Bundle leaves in the manifest file, under the META-INF catalogue of this file including in jar file, called after MANIFEST.MF, the designation by Bundle and version number are can be in framework only determines a Bundle;
Metadata: the metadata of statement services component, it is included in an XML document among the Bundle;
Member: be also referred to as services component, comprise service object (POJO) class, aspect member etc.;
Member example: the instantiation of the services component that services component creates when operation, the structure attribute that defines in can heavily loaded services component in the member example, realize many examples of member, while member example or the manager of real POJO and aspect member, it realizes management to follow-up service is issued, quoted and member example life cycle is controlled etc. by the different aspect member, and the example of management POJO object, the member example has the member context, can carry out alternately with the OSGi framework;
Structure attribute: the configuration attribute of services component, can arrange by meta data file, can also receive configuration admin service to the renewal operation of configuration attribute by configuration attribute aspect member;
The member context: services component example context running environment, inherit from the ComponentContext of standard interface, realized simultaneously BundleContext and ServiceContext context, be used for carrying out alternately with the OSGi framework;
Member example state: the state of describing services component, the whole life cycle of services component comprises altogether four kinds of states such as Valid, Invalid, Stopped, Disposed, and ordinary circumstance lower member example only has these 2 kinds of Valid and Invalid to the visible state in outside;
Aspect member: abbreviation aspect, it is special services component, it is the expansion to the generic services member, be configured at the metadata.xml meta data file equally, each aspect member is for the treatment of member demand in a certain respect, and the aspect members such as wherein issuing service, the service of quoting, the control of member example life cycle, attribute configuration, structure introspection, method interception are the built-in aspect member of statement formula service framework;
Aspect member example: the instantiation of aspect member when operation, aspect member example is the manager of concrete aspect object (Aspect), aspect member example is as the special services component of a class simultaneously, can process in the our surface member in a certain respect demand with other aspect member equally, namely realize the nested of different aspect;
The member container: the container of services component, deposit all services component examples that created and aspect member example, and its corresponding configuration information, lifetime are managed;
Service: service comprises member example externally two kinds of the service of issue and the services of quoting by the OSGi framework, and the mode of Dservice container by service realizes the mutual and cooperation between the member example;
Host's example: for aspect member example, when services component A states use member B in metadata, be host's example of example B at runtime example A, example B is the sub-member example of example A, and example A depends on example B.
Below in conjunction with the accompanying drawing in the embodiment of the invention, the technical scheme in the embodiment of the invention is clearly and completely described, obviously, described embodiment only is the present invention's part embodiment, rather than whole embodiment.Based on the embodiment among the present invention, those of ordinary skills belong to the scope of protection of the invention not making the every other embodiment that obtains under the creative work prerequisite.
By background technology as can be known, when the service unit of OSGi is applied to large-scale system and large-scale the deployment in the prior art, because the restriction of its structure can cause the problem of some performances and compatible aspect.Therefore the invention discloses a kind of new service conversion method and device based on OSGi, by this service-oriented component model of statement formula service DService framework, adopt the mode of statement aspect member, set up mutual between POJO, member container, OSGi framework and other external entities of host's example take the aspect member as bridge.Detailed process is elaborated by following examples.
Embodiment one
This embodiment of the invention discloses a kind of service conversion method based on OSGi, and its flow chart mainly may further comprise the steps as shown in Figure 1:
Step S101 encodes, and based on the project management module maven increase content metadata of DService framework, and inweaves member realization class.
When step S102, OSGi platform start, in the DService framework, the metadata of member example is configured, in the Bundle of OSGi the statement component members example aspect member.
Wherein, metadata is when using the service of statement formula to develop, to the member self attributes, and the each side that member comprises is configured dynamically, adopts this kind method to offer convenience for the new service of exploitation under the environment of OSGi in meta data file.
For convenient in the process of service conversion the member container can identification aspect member, it must be stated in metadata.In the DService framework, can state the many aspects member among the Bundle, and must be unique XML NameSpace and title of member statement aspect each in metadata.Explanation to metadata will describe follow-up.
Need to prove, in a Bundle statement aspect member, can also state services component use the party surface member.When statement is used aspect this in the services component metadata, will bind the NameSpace of the party's surface member first, and the binding mode that adopts is the same with the mode that the XML NameSpace of standard defines.
Step S102 reads host's example to metadata and host's instance configuration information of described aspect example.
Serving aspect the conversion before the example, read first host's example to metadata information and host's instance configuration information of this aspect example, so that facilitate when carrying out this aspect example initial work.
Host's example can utilize initializeComponentFactory method and configure method to read and revise to the metadata information of this aspect example, the metadata of the XML form that obtains is metadata object by the member container analysis in advance, and utilizing org.trustie.loong.dservice.metadata.Element interface and org.trustie.loong.dservice.metadata.Attribute to operate, these two interfaces are arranged in loong-dservice-metadata Bundle.Wherein, an Element object represents an XML element, and each attribute of this element uses an Attribute object encoding.
Need to prove, when member container analysis metadata, all expansion aspect members are resolved to: org.trustie.loong.dservice.metadata.ExtendElement.And with all metadata that can be identified by the member container, resolve to corresponding metadata object.Wherein, the metadata that can identify of member container comprises the content that defines among the schema of XML metadata of DService.The class figure of metadata object as shown in Figure 2, the following all classes of DService class are all inherited the Elementlmpl in figure all for descriptive metadata among the figure, and most operation of encapsulation in such.
Step S103, initialization aspect member factory and aspect example start the aspect example in the member example, obtain the aspect example of arbitrary state in Valid or the Invalid two states.
Aspect have four life cycles and two states in the member, these four life cycles comprise: aspect member factory initialization, aspect example initialization, aspect member start and the aspect member stops.Aspect member can exist with Valid and Invalid two states after starting, and in the stateChanged method, switch.
Step S104, when the member example state was switched, traversal was notified the aspect example change that has in described member example state.
In the process of execution in step S103 and step S104, wherein, for the execution sequence of four life cycles in the aspect member and obtain different conditions the aspect example process as shown in Figure 3:
Step S201, aspect member factory initialization.
Step S202, aspect example initialization.
Step S203, startup aspect example.
Step S204, the state that detects current aspect example changes, and notifies the aspect example in all member examples to change state, as not changing execution in step S206.
Step S205, the state of all the aspect examples in the change member example.
Step S206 stops the startup of aspect example.
For the process of above-mentioned concrete four life cycles of execution, the below is described in detail:
The process of initialization aspect member factory mainly comprises:
Bundle starts and Bundle disposes the DService metadata when the DService framework detects, and in this metadata there be when determining unique aspect member by DService root node title and NameSpace statement, the aspect member that the DService framework is searched among the Bundle is realized class, is created by aspect member factory to be used for calling the corresponding interim aspect of initializeComponentFactory method component object.
The aspect component metadata of stating in the input link example, finish the input after auto-destruct former aspect component metadata.
Call the initializeComponentFactory method corresponding interim aspect during component object, the correctness of checking metadata, when having incorrect metadata in the aspect member, revise or the described aspect of completion member in metadata.
After member factory finished aspect the initialization, the process of carrying out initialization aspect example mainly comprised:
The DService framework creates the example of the aspect that configures for each member example, and calls the configure method of aspect example, and the metadata of input link definition is finished the initialization of aspect example.
Need to prove, the configure method of calling is for detection of the distinctive attribute of each member example, and the correctness of member instance configuration information, so that improve the descriptor of this aspect example.
After the example, the member container can call the start method of this aspect example aspect carrying out initialization.The method is used for defining the service logic that need to finish.
Calling before the start method finishes, start first the sub-aspect example that needs in all these aspect examples statements.
Calling after the start method finishes, the state of aspect example generally is defaulted as Valid.But, still call the real state that AspectManager detects this aspect example, the concrete state of all sub-aspect examples that namely use in this aspect example.
The concrete process that detects is: when the state of all sub-aspect examples that use when this aspect example was Valid, the state of this aspect example was Valid; All sub-aspect example state of using in this aspect example have one to be Invalid, and then the state of described aspect example is Invalid.The state of the member example of same this aspect example of use also is Invalid, i.e. the state consistency of member example and aspect example.
Aspect example start finish after, before stopping, from the above, the aspect example has two states.When the member example state changes, traversal is notified all aspect example state changes that this member example uses, and call the stateChangedFromInstance method of each sub-aspect example, changed according to own demand completion status by the various aspects example.
The definition of state Valid in system is set to generally speaking: int VALID=2 is defined in the org.trustie.loong.dservice.spi.ComponentInstance interface.When the state of member example became Valid, traversal was notified all aspect examples that this member example uses, and notify status is changed into Valid.
The definition of state I nvalid in system is set to generally speaking: int Invalid=1 is defined in the org.trustie.loong.dservice.spi.ComponentInstance interface.When the state of member example became Invalid, traversal was notified all aspect examples that this member example uses, and notify status is changed into Invalid.
In the end, when the member example stopped, all these member examples were quoted or the aspect example that uses calls the stop method, enter halted state.So that guarantee to discharge the resource that all are quoted in the example aspect current, reduce Installed System Memory occupied.
Need to prove, do not destroyed after the member example stops and reclaiming, can also restart the member example by the start method again after the member example stops.Accordingly, the aspect example of counterpart member example can enter starting state in re invocation start method after the stop method equally, and after the stop method call, the aspect example enters the state that the aspect initialization is finished.
Step S105 realizes that with member the object POJO of class instantiation carries out alternately, directly obtains the type information of host's member by metadata, is the field notes value of host's example by the aspect example of determining state.
When execution in step S105, realize that with member the object POJO of class instantiation carries out alternately, the aspect example directly obtains the type information of host's member by metadata, and the type information comprises: the interface of parent, expansion, field, public method etc.And during the above-mentioned all types of information of obtaining host's member, component metadata obtains by the getPojoMetadata method of org.trustie.loong.dservice.metadata.Component, is specially:
GetSuperClass: return the parent that member is realized class;
GetInterfaces: return the total interface that member realizes that class realizes;
GetFieldMetadatas: return all fields that member is realized class;
GetMethodMetadata: return all public methods that member is realized class.
When execution in step S105, after obtaining the type information of host's member, aspect example by definite state is the field notes value of host's example, namely aspect example during to host's member value of notes, value by the field of realization class concrete management of each org.trustie.loong.dservice.spi.FieldValueProvider interface, after the value of field provides the device instantiation, be registered in the manager of host's member example, register so that call getInstanceManager () .register (FieldValueProvider) method.
The manner of execution that this interface is corresponding comprises:
GetFieldName: the field name of specifying host's field that this realization class manages;
GetType: the field type of specifying host's field that this realization class manages;
IsDynamic: whether dynamic the field of this realization class management is, if the dynamic then variation of every sub-value all can be injected in host's example;
GetValueFromProvider: from current realization class, obtain up-to-date field value.Can obtain last look by the method after monitor is notified, and be injected among the POJO of host's example;
GetUpdateTime: the time of from current realization class, obtaining last renewal;
SetValueFromOtherProvider: the variation of this field value of host's example all can be delivered in this realization class by the method, thereby this realization class can be taken this field by other local amended last looks.
Need to prove, in setValueFromOtherProvider, each field might not only corresponding value provide device.
SetFieldChangedListener: import the monitor that this field value changes into by the member container, the implementor needs the value of this field of proactive notification monitor to change after the field value of managing in this realization class changes, and initiatively records current time millisecond value as the return value of getUpdateTime method.
Need to prove, carry out in the mutual process at execution in step S105 and Java object POJO, also comprise: before or after the public method in the POJO of host's example object is called, when mistake occurring, tackled all public methods of described host's example by the aspect example.Wrong corresponding method appears in above-mentioned trip:
OnEntry: carry out before entering host's public method;
OnExit: carry out after executing host's public method;
OnError: behind host's public method throw exception, carry out;
OnFinally: no matter host's public method is normally to withdraw from or unusually withdraw from, all can in the end carry out.
After the method blocker instantiation that is used for interception host example, by calling getInstanceManager () .register (methodMetadata, methodInterceptor) method it is registered in host's member instance management device.
In the disclosed method of the embodiment of the invention, during execution in step S101, the setting of in meta data file, carrying out member that wherein relates to.Generally speaking, to the member self attributes, and the each side that member comprises is configured dynamically in meta data file metadata.xml file.
Below be illustrated with a meta data file metadata.xml:
Figure BDA0000054244490000111
Figure BDA0000054244490000121
For the above-mentioned content related as an example of the metadata.xml file example:
Wherein, the DService node is the root element of metadata.An XML meta data file only has a DService root node.
Be configured to Component, its corresponding java class.Attribute in the structure is as shown in table 1 below.
Table 1:
Figure BDA0000054244490000122
For the downstream site service of component, be used for the service that this member of statement provides.Acquiescence is with all services of issuing into of interface of all realizations.Provide concrete service at the service node downstream site provide that given a definition.And can define a plurality of provide nodes under the service node.
Under the provide node, also can define a plurality of downstream site property, represent the Service Properties that member in this respect provides.
Wherein, the provide nodal information is described in detail as follows shown in the table 2.
Table 2:
Figure BDA0000054244490000123
Being described in detail as follows shown in the table 3 of property element information.
Table 3:
Figure BDA0000054244490000131
In above-mentioned tabulation 3, first is illustrated as: when not stating the field attribute, when still having stated the party method attribute, framework calls corresponding method value of notes, when only having stated the field attribute, then injects value by the member container.And can not carry out simultaneously about the above-mentioned statement of the attribute of field.
Second is illustrated as: when having stated field, do not need to state this attribute, acquiescence is used the type type of field corresponding field; When not stating field, this attribute needs statement.
For the downstream site Properites of component, be used for the attribute of this member of statement.Can define a plurality of attribute node property in this node, these attributes of definition can be quoted in a plurality of places, comprise the aspects such as service and instance.When service aspect use attribute, then in this member issuing service, these attribute issues are become Service Properties; When instance aspect use attribute, then make these attributes cover service aspect or the defined attribute in properties aspect.
For being described in detail as follows shown in the table 4 of properties nodal information.
Table 4:
Figure BDA0000054244490000141
For being described in detail as follows shown in the table 5 of property element.
Table 5:
Figure BDA0000054244490000142
In above-mentioned tabulation 5, first is illustrated as: when not stating the field attribute, when still having stated the party method attribute, framework calls corresponding method value of notes, when only having stated the field attribute, is then injected by container.These two attributes can not be stated simultaneously.
Second is illustrated as: when having stated field, do not need to state this attribute, acquiescence is used the type type of field corresponding field.When not stating field, this attribute needs statement.
For the downstream site reference of component, it is used for the service that this member of statement is quoted.The detailed description of reference element is as shown in table 6.
Table 6:
Figure BDA0000054244490000151
In above-mentioned tabulation 6, the 5th is illustrated as: the active obtaining strategy is used in obtaining of service object when defining field, definition bind and unbind method then use case drive strategy, and then the event-driven strategy is preferential when the two defines simultaneously.
For the downstream site lifecyle of component, be used for describing the method for adjusting back when this member state changes, control the start and stop state of this member.
Using lifecycle element declaration member lifetime control method, is the downstream site of component, describes the method for adjusting back when this member state changes.
Wherein, the lifecycle element is described in detail as follows shown in the table 7.
Table 7:
Figure BDA0000054244490000161
Downstream site advisor for component, the statement notifying device, under this node, can define a plurality of cutting point pointcut and a plurality of notice advice, and notifying all right defined attribute node property under the advice node, in the situation that this attribute of realization ConfigurableAdvice interface can assignment be given notice advice.
Wherein, the pointcut nodal information is described in detail as follows shown in the table 8.
Table 8:
Wherein, the advice nodal information is described in detail as follows shown in the table 9.
Table 9:
Figure BDA0000054244490000163
In above-mentioned tabulation 9, the 6th is illustrated as: two attributes of pointcut and pointcutref must have and only have one in same advice node.
Wherein, the property nodal information is described in detail as follows shown in the table 10.
Table 10:
Attribute-name Whether necessary Default value Explanation
name yes Attribute-name
value yes Property value
For the downstream site aspect of DService node, be used for certain concrete aspect of definition, such as aspects such as top defined service, properties, reference, lifecycle and advisor.And the aspects such as service, properties, reference, lifecycle and advisor of definition were as its sub-aspect member before the aspect member can also use.
Wherein, the aspect nodal information is described in detail as follows shown in the table 11.
Table 11:
Figure BDA0000054244490000171
For the downstream site instance of DService node, be used for defining the member example.It can realize that the fully qualified name of class claim to mate corresponding member by member name or member, and same member can corresponding a plurality of member examples, and prerequisite is that the title of these member examples can not be identical; Can define its attribute node property of subordinate under the instance node, the Property Name that defines among the Property Name that defines among the title of this attribute node and the aspect node service or the attribute node properties is identical.
Wherein, the instance nodal information is described in detail as follows shown in the table 12.
Table 12:
Figure BDA0000054244490000172
The property element is described in detail as follows shown in the table 13.
Table 13:
Figure BDA0000054244490000181
By the disclosed method of the invention described above embodiment, by making up new service unit, thereby can avoid the start-up time of registration service minimizing system in activator appliance, adopt member to postpone instantiation, when the member example needs, just be created, can avoid like this starting and take too many time and space, namely just load when services component need to load detecting, reducing the occupancy in the Installed System Memory, and adopt the mode of statement formula to issue, search the service with binding O SGi.So that the course of work of simplification registration service and processing service, and the course of work of simplification system when registration service, the service of obtaining and processing service.
In addition, because the support of member example examines oneself, the service object's who therefore can also dynamic queries member example state quotes with him state.Equally also can come the inquiry component example state by order line.
Describe a kind of service conversion method based on OSGi among the disclosed embodiment of the invention described above in detail, can adopt the device of various ways to realize for method of the present invention, therefore the invention also discloses a kind of service conversion equipment based on OSGi, the below provides specific embodiment and is elaborated.
As shown in Figure 4, structural representation for the disclosed a kind of service conversion equipment based on OSGi of the embodiment of the invention mainly comprises: coding inweaves module 101, configuration statement module 102, read module 103, initial module 104, acquisition module 105, handover module 106 and notes value module 107.
Coding inweaves module 101, is used for encoding, and based on the project management module maven increase content metadata of DService framework, and inweaves member realization class.
Configuration statement module 102 is used in the services component metadata member example being configured when the OSGi platform starts, and statement forms the aspect member of member example.
Read module 103 is used for reading host's example to metadata and host's instance configuration information of described aspect example.
Initial module 104 is used for initialization aspect member factory and aspect example, starts the aspect example in the member example.
Acquisition module 105 is for the aspect example that obtains Valid and Invalid two states.
Handover module 106 is used for when the aspect example of described Valid and Invalid two states switches, and traversal is notified the aspect example change that has in all member examples state.
Notes value module 107 is used for realizing that with member the object POJO of class instantiation carries out alternately, directly obtains the type information of host's member by metadata, is the field notes value of host's example by the aspect example of determining state.
The concrete execution function of disclosed each module of the invention described above is corresponding one by one with the disclosed method of the invention described above embodiment, therefore, repeats no more here.
Each embodiment adopts the mode of going forward one by one to describe in this specification, and what each embodiment stressed is and the difference of other embodiment that identical similar part is mutually referring to getting final product between each embodiment.For the disclosed device of embodiment, because it is corresponding with the disclosed method of embodiment, so description is fairly simple, relevant part partly illustrates referring to method and gets final product.
The method of describing in conjunction with embodiment disclosed herein or the step of algorithm can directly use the software module of hardware, processor execution, and perhaps the combination of the two is implemented.Software module can place the storage medium of any other form known in random asccess memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable ROM, register, hard disk, moveable magnetic disc, CD-ROM or the technical field.
To the above-mentioned explanation of the disclosed embodiments, make this area professional and technical personnel can realize or use the present invention.Multiple modification to these embodiment will be apparent concerning those skilled in the art, and General Principle as defined herein can be in the situation that do not break away from the spirit or scope of the present invention, in other embodiments realization.Therefore, the present invention will can not be restricted to these embodiment shown in this article, but will meet the widest scope consistent with principle disclosed herein and features of novelty.

Claims (10)

1. the service conversion method based on OSGi is characterized in that, comprising:
Encode, based on the project management module maven increase content metadata of DService framework, and inweave member realization class;
When the OSGi platform starts, in the DService framework, the metadata of member example is configured, in the Bundle of OSGi statement form the member example aspect member, wherein, described DService frame representation: Declarative Services framework, be one based on the service-oriented component model of OSGi framework, adopt the mode of the delay loading of serviced component and component lifecycle management to control for the taking and start fast of internal memory, it describes member with expandable mark language XML;
Read host's example to metadata and host's instance configuration information of aspect example;
Initialization aspect member factory and aspect example start the aspect example in the member example, obtain the aspect example of arbitrary state in Valid or the Invalid two states;
When the member example state was switched, traversal was notified the aspect example change that has in described member example state;
The object POJO that realizes the class instantiation with member carries out alternately, directly obtain the type information of host's member by metadata, aspect example by definite state is the field notes value of host's example, described member realizes that the object POJO of class instantiation represents: Plain Old Java Objects, member is realized the object after the class instantiation, can in the metadata.xml meta data file, be described by the class name by the member element, be managed by the member example during operation.
2. method according to claim 1 is characterized in that, the aspect member that described statement forms the member example comprises: be unique XML NameSpace and the title of described aspect member statement.
3. method according to claim 1 is characterized in that, comprising: the aspect member of a plurality of component instances of statement among described Bundle;
The statement services component is used the party's surface member when the aspect of a plurality of component instances of statement among described Bundle member.
4. method according to claim 1 is characterized in that, the process of initialization aspect member factory comprises:
When detecting Bundle, the DService framework starts, described Bundle disposes the DService metadata, and in the described metadata there be when determining unique aspect member by DService root node title and XML NameSpace statement, the aspect member that the DService framework is searched among the Bundle is realized class, created for calling the corresponding interim aspect of initializeComponentFactory method component object by factory, wherein said DService represents: Declarative Services, be one based on the service-oriented component model of OSGi framework, described metadata represents: the metadata of statement services component, it is included in an expandable mark language XML document among the Bundle, described initializeComponentFactory when call corresponding interim aspect during component object, the correctness that is used for the checking metadata, when having incorrect metadata in the aspect member, the metadata in correction or the described aspect of the completion member;
The aspect component metadata of stating in the input link example.
5. method according to claim 1 is characterized in that, after initialization aspect member factory finished, the process of carrying out initialization aspect example comprised:
The DService framework creates the aspect example that configures for each member example;
Call the configure method of aspect example, the metadata of input link definition is finished the initialization of aspect example, and described configure method is for detection of the distinctive attribute of each member example, and the correctness of member instance configuration information, improve the descriptor of this aspect example.
6. method according to claim 1 is characterized in that, starts the aspect example in the member example, and the process of obtaining the aspect example of arbitrary state in Valid and the Invalid two states comprises:
Call before the start method, the sub-aspect example that all statements in the startup aspect example need, described start method is used for defining the service logic that need to finish;
Call after the start method, the current state of context of detection example, all sub-aspect example state of using in described aspect example are Valid, then the state of described aspect example is Valid;
All sub-aspect example state of using in described aspect example have one to be Invalid, and then the state of described aspect example is Invalid.
7. method according to claim 1 is characterized in that, when the aspect example state was switched, traversal notified the process of the aspect example change state that has in the described member example to comprise:
When the state of member example became Valid from Invalid, it was Valid that traversal is notified the aspect example change state that has in the described member example;
When the state of member example became Invalid from Valid, it was Invalid that traversal is notified the aspect example change state that has in the described member example.
8. method according to claim 1 is characterized in that, also comprises:
When the member example stopped, all aspect members of described member example called the stop method, enter halted state.
9. method according to claim 1 is characterized in that, is realizing that with member the object POJO of class instantiation carries out also comprising in the mutual process:
Before or after public method in the POJO of host's example object is called, when mistake occurring, tackled all public methods of described host's example by the aspect example, wherein, described host's example when services component A states use member B in metadata, is the host example of example B at runtime example A for aspect member example, example B is the sub-member example of example A, and example A depends on example B; Described POJO object encoding: Plain Old Java Objects, member is realized the object after the class instantiation, can be described by the class name by the member element in the metadata.xml meta data file, is managed by the member example during operation.
10. the service conversion equipment based on OSGi is characterized in that, comprising:
Coding inweaves module, be used for encoding, project management module maven based on the DService framework increases content metadata, and inweave member and realize class, wherein, described DService frame representation: Declarative Services framework, be one based on the service-oriented component model of OSGi framework, adopt the mode of the delay loading of serviced component and component lifecycle management to control for the taking and start fast of internal memory, it describes member with expandable mark language XML;
The configuration statement module is used in the services component metadata member example being configured when the OSGi platform starts, and statement forms the aspect member of member example;
Read module is used for reading host's example to metadata and host's instance configuration information of aspect example;
Initial module is used for initialization aspect member factory and aspect example, starts the aspect example in the member example;
Acquisition module is for the aspect example that obtains Valid and Invalid two states;
Handover module is used for when the aspect example of described Valid and Invalid two states switches, and traversal is notified the aspect example change that has in all member examples state;
Notes value module, be used for realizing that with member the object POJO of class instantiation carries out alternately, directly obtain the type information of host's member by metadata, aspect example by definite state is the field notes value of host's example, described member realizes that the object POJO of class instantiation represents: Plain Old Java Objects, member is realized the object after the class instantiation, can be described by the class name by the member element in the metadata.xml meta data file, is managed by the member example during operation.
CN 201110086817 2011-04-07 2011-04-07 Service switching method based on OSGi and device thereof Active CN102158490B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 201110086817 CN102158490B (en) 2011-04-07 2011-04-07 Service switching method based on OSGi and device thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 201110086817 CN102158490B (en) 2011-04-07 2011-04-07 Service switching method based on OSGi and device thereof

Publications (2)

Publication Number Publication Date
CN102158490A CN102158490A (en) 2011-08-17
CN102158490B true CN102158490B (en) 2013-10-23

Family

ID=44439672

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 201110086817 Active CN102158490B (en) 2011-04-07 2011-04-07 Service switching method based on OSGi and device thereof

Country Status (1)

Country Link
CN (1) CN102158490B (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102325180B (en) * 2011-09-07 2015-01-07 山东中创软件工程股份有限公司 Component management method and system
CN102868747B (en) * 2012-09-19 2016-07-06 深圳中兴网信科技有限公司 Resource information management method and resource information management device
CN103095491B (en) * 2012-12-30 2016-08-24 山东中创软件商用中间件股份有限公司 A kind of log services processing method and processing device
CN105630540A (en) * 2015-12-21 2016-06-01 山东中创软件工程股份有限公司 Application class loading method and device as well as web application class loader
CN107870845B (en) * 2017-10-19 2020-10-27 北京工业大数据创新中心有限公司 Management method and system for micro-service architecture application
CN109656528A (en) * 2018-10-29 2019-04-19 中国航空无线电电子研究所 Measured modularization software development methodology
US11086605B1 (en) * 2020-03-26 2021-08-10 Red Hat, Inc. Processing portable extensions at build time

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101634946A (en) * 2009-08-20 2010-01-27 华南理工大学 Generation method of RFID member
CN101964797A (en) * 2010-09-29 2011-02-02 山东中创软件工程股份有限公司 Service interaction method and system

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101226569A (en) * 2007-01-19 2008-07-23 国际商业机器公司 Method and device for checking code module in virtual machine

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101634946A (en) * 2009-08-20 2010-01-27 华南理工大学 Generation method of RFID member
CN101964797A (en) * 2010-09-29 2011-02-02 山东中创软件工程股份有限公司 Service interaction method and system

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
《OSGi框架分析和应用研究》;吴波;《中国硕士学位论文全文数据库》;20100230;I138-165页 *
OSGI.《osgi service platform core specification.release 4,version-4.2.0》.《OSGI》.2009, *
吴波.《OSGi框架分析和应用研究》.《中国硕士学位论文全文数据库》.2010,I138-165.

Also Published As

Publication number Publication date
CN102158490A (en) 2011-08-17

Similar Documents

Publication Publication Date Title
CN102158490B (en) Service switching method based on OSGi and device thereof
CN101266542B (en) Method and device for loading component in container
KR100959173B1 (en) Component architecture
US20120304174A1 (en) Virtual solution composition and deployment system and method
Hsieh et al. A self-adaptation scheme for workflow management in multi-agent systems
CN103955364A (en) Front end assembly method suitable for mobile phone
CN101276271A (en) Method and interceptor system facing to tangent plane programming
CN101246424A (en) Menu automatic generation system and method for based on file
CN101174217A (en) Method for implementing dynamic update of Java program
CN103473696A (en) Method and system for collecting, analyzing and distributing internet business information
CN102073525A (en) Method and device for dynamically upgrading Web service system based on Java platform
CN103645908A (en) Full life circle development achievement system of intemetware
US9122559B2 (en) Extensible dependency management framework and method
Zhang et al. A modeling framework for service-oriented architecture
WO2012115665A1 (en) Dynamic reprovisioning of resources to software offerings
CN102375894B (en) Method for managing different types of file systems
CN110134428A (en) A kind of safety protecting method and device
CN104615489A (en) Multi-node data interaction achieving method
EP2842044A1 (en) Platform runtime abstraction
CN103701935A (en) Construction method and system of cloud computing service platform
CN103685572A (en) Method and system for building data center management platform based on SOA (service-oriented architecture)
CN105404530B (en) It is a kind of to realize easy deployment and the system and method using private clound
EP2777215B1 (en) Method, apparatus and system for simultaneously transmitting or receiving multiple managed objects
Rouvoy et al. Towards context-aware transaction services
Rouvoy et al. Music: an autonomous platform supporting self-adaptive mobile applications

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant