Nice, that works. Thanks.
On Tue, Jun 12, 2012 at 4:23 PM, Felix Meschberger <[email protected]>wrote: > Hi, > > Am 12.06.2012 um 16:07 schrieb sam ”: > > > Hey, > > > > I am using maven-scr-plugin to create a Component. > > @Component > > public class MyComponent { > > //@Reference > > private ComponentContext context; > > private BundleContenxt bundleContext; > > } > > > > How can I initialize MyComponent.context ? > > You implement a method like this: > > @Activate > private void activate(ComponentContext context) { > this.context = context; > } > > The activate method is called by the DS runtime when the component is > activated. And there you get the ComponentContext. > > The ComponentContext is not a service and can thus not be provided as a > service @Reference > > > > > In project's pom.xml, I can specify Bundle-Activator: > > <plugin> > > <groupId>org.apache.felix</groupId> > > <artifactId>maven-bundle-plugin</artifactId> > > <version>2.3.6</version> > > <extensions>true</extensions> > > <configuration> > > <instructions> > > <Bundle-Activator> > > my.Activator > > </Bundle-Activator> > > .... > > > > In my.Activator, I have > > @Override > > public void start(BundleContext context) throws Exception { > > //would like to get reference of MyComponent so that I can pass > > context to it. > > } > > This does not work since your bundle activator does not have direct access > to the component and no access at all to any ComponentContext. > > Regards > Felix > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >

