Expand my Community achievements bar.

SOLVED

Doubt w.r.t @Reference Annotation usage

Avatar

Level 9

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.

1 Accepted Solution

Avatar

Correct answer by
Level 9

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

View solution in original post

2 Replies

Avatar

Correct answer by
Level 9

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

Avatar

Level 9

Hi Jitendra,

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