Doubt w.r.t @Reference Annotation usage | Community
Skip to main content
New Participant
February 10, 2016
Solved

Doubt w.r.t @Reference Annotation usage

  • February 10, 2016
  • 2 replies
  • 647 views

Hi All,

Doubt as below :

I have an interface where couple of methods are defined. In my component Java class[which is not a service class], if I have to refer any of the method present in the interface, it is not possible.

- Is my Understanding correct?

- Any way we can access methods declared in the interface, via my Component java class?

Any thoughts/pointers on this will be helpful.

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 Jitendra_S_Toma

Yes. Your understanding is correct. 

POJO class can't refer to methods which are in service. There are multiple ways to pass service to your component class. Sling models do provide a way to inject services directly to the component class. You can try that.

https://helpx.adobe.com/experience-manager/using/sling_models.html

Let me know if you are not willing to use SlingModesl. There are other ways as well.

--

Jitendra

2 replies

askdctmAuthor
New Participant
February 10, 2016

Hi Jitendra,

Thank you for your reply. Used getSlingscriptheler.getservice() and it worked.

Jitendra_S_Toma
Jitendra_S_TomaAccepted solution
New Participant
February 10, 2016

Yes. Your understanding is correct. 

POJO class can't refer to methods which are in service. There are multiple ways to pass service to your component class. Sling models do provide a way to inject services directly to the component class. You can try that.

https://helpx.adobe.com/experience-manager/using/sling_models.html

Let me know if you are not willing to use SlingModesl. There are other ways as well.

--

Jitendra