On Thu, Jun 2, 2011 at 3:16 PM, sam lee <skyn...@gmail.com> wrote: > 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?
>From where? From another SCR component, you'd do @Reference private Foo foo; >From a generic OSGi-aware class, you'd use either the BundleContext or the ServiceTracker API. You could also use any other framework which works with OSGi services, e.g. Peaberry, iPojo, SpringDM, Blueprint. Justin > 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 > <jus...@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 <skyn...@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-unsubscr...@felix.apache.org >> For additional commands, e-mail: users-h...@felix.apache.org >> >> > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@felix.apache.org For additional commands, e-mail: users-h...@felix.apache.org