felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sam lee <skyn...@gmail.com>
Subject Re: how can I get a Component object?
Date Thu, 02 Jun 2011 22:16:29 GMT
Originally, I was using JCR RMI. And I'm slowly converting the code to be
OSGi bundle.

If I make Foo  a @Service, how can I get a reference to Foo object?
I know sling has SlingScriptHelper.getService(Class) .


If I use static member, I can actually use new Foo():

    @Reference(policy = ReferencePolicy.STATIC, bind =
"setResourceResolverFactory")
    protected static ResourceResolverFactory resourceResolverFactory;


then the static resourceResolverFactory is bound after new Foo().







On Thu, Jun 2, 2011 at 6:05 PM, Justin Edelson <justin@justinedelson.com>wrote:

> Is there a reason you don't want to make it a service?
>
> On Thu, Jun 2, 2011 at 3:02 PM, sam lee <skynare@gmail.com> wrote:
> > Hey,
> >
> > I am using maven-scr-plugin.
> >
> > I have:
> >
> > @Component(immediate=true)
> > public class Foo {
> >    @Reference
> >    private Bar bar;
> > }
> >
> >
> > Obviously, when I get  Foo instance by  calling constructor,  new Foo(),
> > bar isn't set.
> >
> > Is there a way to get Foo instance OSGi-way?
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message