OSGi Declarative Services (DS)

OSGi Declarative Services is way to share services between the components. OSGi Declarative Service (DS) is shortly we can call it as DS. We can say DS is framework, which provides implementation that makes components can share services each other.

According OSGi, application is composed of bundles and each bundles have set of components. Components consist of services and these services performs some tasks.

Most of the times one component is depends on other component or we can say one component uses the other component services.

 DS uses the concept Publish-Find-Bind. DS will use Service Component Runtime (SCR) to publish and bind the services.

Register / Publish

The component services are published/registered with SCR. Service Component Runtime will manage the registered services and it makes available to other components.

Listen / Find

Once the component services published then it will available to other components. Other components will find the published services with help of SCR. Sometime services may be unregistered then components will be notified or listen the services unregistered information.

Get / Bind

Once the Services found then it will bind to the consumer bundles and it will use the services implementation.

All this concept work through Service Component Runtime (SCR)implementation. OSGi implantation provides the SCR implementation. SCR is part of OSGi environment.
The following is Picture of Publish-Find-Bind concept.



Bundle Aregistered the service implantation with Service Run Time (SCR) and consumer Bundle B will get the Service Implementation will use it. SCR it is responsible to manage the component services registration and reference to other components.

Technically, when we implements the components using Declarative Services we can find the following bundles.

Service API Bundle
Service Provider Bundle
Service Consumer Bundle

Service API Bundle

Service API Bundle we will define the set of interfaces and its methods. We will export bundle in OSGi way so that it will be available to other bundles.

Service Provider Bundle

Service Provider Bundle provides the service implementation for Service API. Here actual implementation developed as Java classes. We will register this service implementation as components using Declarative Services framework.

Component is java class, which provide the implementation for the services, which we declared in the Service API bundles.

DS framework will provide xml configuration file or some Annotations such a way we can make implementation class as Service Component.

Service Component is simple java class have services implementation and we make service component by configuring the information in the xml file that followed by the Declarative Service Framework. We can say its service provider or publisher as per the concept.


Service Consumer Bundle

Service Consumer Bundle will consume the services, which registered in the Service Component Run time. As per the DS concept bundle will find the component services and bind to the consumer bundle such a way it will use the implementation provided by the publisher bundle.

OSGi in Liferay

Liferay have used Declarative Services in the portlet development. Liferay applications development based on OSGi. Most of the Liferay Application Development have used DS framework.

Author
Share on Google Plus

About Meera Prince

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment