Sling Annotations | 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.
lukasz-m
lukasz-mAccepted solution
New Participant
Mar 13, 2023 1:51 PM UTC

Hi @madhur-madan,

On OSGi service level you should use Reference annotation. So this will be option you should use in case you want to get reference of other OSGi service inside another.

import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; @Component public class YourService { @Reference private OtherService otherService; }

 

OSGiService annotation is dedicated for Sling Model it will not work inside OSGi service/component. You can use it, in case you would like to inject OSGi Service into your Sling Model.

See also below links:

1 reply

lukasz-m
lukasz-mAccepted solution
New Participant
Mar 13, 2023 1:51 PM UTC

Hi @madhur-madan,

On OSGi service level you should use Reference annotation. So this will be option you should use in case you want to get reference of other OSGi service inside another.

import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; @Component public class YourService { @Reference private OtherService otherService; }

 

OSGiService annotation is dedicated for Sling Model it will not work inside OSGi service/component. You can use it, in case you would like to inject OSGi Service into your Sling Model.

See also below links:

Translate