@Reference | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Ravi_Pampana

Hi,

   As per Apache Felix documentation Apache Felix - SCR Annotations @Reference annotation is defined as below

The @Reference annotation defines references to other services made available to the component by the Service Component Runtime.

@reference is used to refer any service registered in your osgi console. So until you declare your class as a service , if you try to refer it using @reference annotation it is going to return you null.

Let us know your use case then community can provide more details

2 replies

Ravi_Pampana
Community Advisor
Ravi_PampanaCommunity AdvisorAccepted solution
Community Advisor
May 3, 2019

Hi,

   As per Apache Felix documentation Apache Felix - SCR Annotations @Reference annotation is defined as below

The @Reference annotation defines references to other services made available to the component by the Service Component Runtime.

@reference is used to refer any service registered in your osgi console. So until you declare your class as a service , if you try to refer it using @reference annotation it is going to return you null.

Let us know your use case then community can provide more details

Prince_Shivhare
Community Advisor
Community Advisor
May 3, 2019

if your component is a service it means if you have declared as @compnent and @service, then yes you can make use of @reference annotation. and include it in another service or component.