New issue 53 by yungkce: PeaberryActivationModule should provide a
reference to OSGi BundleContext
http://code.google.com/p/peaberry/issues/detail?id=53
If the user uses the automatic bootstrapping of Peaberry bundles, there is
NO way to get the BundleContext object.
> --
> You received this message because you are subscribed to the Google Groups
> "Guice and OSGi" group.
> To post to this group, send email to guice...@googlegroups.com.
> To unsubscribe from this group, send email to
> guice-osgi+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/guice-osgi?hl=en.
>
>
As Todor mentioned on the mailing list, just @Inject BundleContext wherever
you need it.
But what if I would like to refer to the BundleContext in the
PeaberryActivationModule's configure() method? It is before Guice @Inject
the BundleContext object.
Can you elaborate on what you need to use the BundleContext for in the
module itself? Binding modules are usually small and side-effect free, so
I'm just wondering why you need the context when setting up bindings.
Since I would like to use the Manifest header of the bundle for setting the
attributes of the exported services inside the configure() method, the only
way to get those header is from the BundleContext.getBundle().getHeaders()
method unless I can export the services outside the configure() method.
It seems best to pass the BundleContext to the module constructor.
Currently we expect the module to have a default constructor. We could
support a constructor with a BundleContext as well. I am not sure how nice
this will be since now there are two ways to obtain the BundleContext and
the users cat try to bind it a second time.
Stuart what do you think?