I've read several articles about the difference between @Service
and @Component
. Now I understand that @Component
is user to annotate an object as an OSGi component and its lifecycle will then be managed by OSGi.
However, what is the need to declare an object as service with @Service
is unknown. What happens if you write your business logic in a object that is declared as a component?
I also want to know what does the below statement means:
Components can refer/call (using container injection – @Reference) other services but not components. In other words, a component cannot be injected into another component / service. Only services can be injected into another component.