javaosgiequinoxosgi-bundleknopflerfish

Service and Component in OSGI


I have some little silly doubts in an OSGI concepts but they need to be clarified to have better understanding of concepts. Can anybody tell me what is the difference between OSGI Service and Component. What i know is that Service is like an interface file in java that can be used either by a different service or by a component. While component is like a particular implementation of the service.

Please let me know if i am wrong or suggest some link from where i can get the things nicely.


Solution

  • The OSGi Core specification defines the service model which is a key part of the OSGi concept. A service is an object (instance) which implements a declared type (normally an interface). The OSGi framework provides the service layer which is a broker between service providers and service consumers.

    DS introduced the concept of Service Components which are classes in a bundle which that are managed by the DS runtime (SCR). The components are described by XML in the bundle which is read by SCR. These components, once instantiated and if declared to be services, can be registered as services by SCR.

    So components can be services (but they do not have to be) and they can use services.