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.
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.
OSGi evolved the concept of services, so that bundles could reduce their coupling with other bundles - ie. achieve loose coupling. The 'loosest' coupling comes from using dynamic services, where bundles that produce services are started dynamically as consumers register to consume those services. The dynamic services model went through several evolutions with OSGi, through service registration and event listening, Service Tracker, and finally Declarative Services.
With all but the last (Declarative Services), the service registration code is put in the bundle's Activator. With Declarative Services, the bundle that exposes a service is called a component and it's declared in a component.xml file that the framework understands - no need for activators. In the Eclipse IDE, you can use Declarative Services by right-clicking on a bundle and adding a 'Component Definition'. There's a really good book on the subject that takes you through the technology with tutorials:
OSGi and Equinox