The model is simply a sling model class, not an osgi service at all. 

The model is being looked up via slightly, thus it has to be fully populated 
when that happen which require that the model invoke a service to obtain data 
from. 

Sling model documentation says that you can inject osgi services into sling 
models but that is not seem to be working. 

Sent from my iPhone

> On 19 Nov 2014, at 09:09, Sarwar Bhuiyan <[email protected]> wrote:
> 
> The model is not an OSGi service/component right?
> 
> I'm not sure of why you need a reference to an osgi service in the model
> but you can probably use a setter by yourself but I still think you can
> just have another service which does the action on the model instead of the
> model calling the service.
> 
> On Wednesday, November 19, 2014, Hass Joseph Khafaji <[email protected]>
> wrote:
> 
>> Hello,
>> 
>> I am trying to inject OSGI service defined using scr annotation into a
>> sling model class using the @inject annotation.
>> 
>> What we seem to be getting is that the ModelAdapterFactory is unable to
>> inject the service into the corresponding field as if it was an
>> incompatible type. We not doing anything fancy here, it's just a simple
>> service injection.
>> 
>> Did anyone faced a similar issue in the past? Do we have to use custom
>> injectors for this?
>> 
>> Note: tried to use the @inject @source with an osgi-service but getting
>> the same result.
>> 
>> Cheers.

Reply via email to