The only way you could do this is by
having the host co-operate with the fragment. For example, the host
would have to stash the BundleContext away in some class in a private package
(e.g. one that is not exported). Then the fragment could access that
bundle context using this class once it is attached to the host and the
host is started. This is one way you could do this. But I have
to ask why you want to do this instead of just having your own bundle.
I think Peter Kriens is asking the same thing in another post.
David Kemper <djk@xxxxxxxxx> Sent by: equinox-dev-bounces@xxxxxxxxxxx
02/13/2007 11:26 AM
Please respond to
Equinox development mailing list <equinox-dev@xxxxxxxxxxx>
[equinox-dev] Re: Adding to the framework
I've been wondering how to register services from
As far as I know, a fragment *cannot* have a bundle activator.
Without a bundle activator, how does a fragment get access to its
bundle context through which it can register services?
What am I missing?
> Message: 4
> Date: Mon, 12 Feb 2007 07:44:35 +0100
> From: Gunnar Wagenknecht <gunnar@xxxxxxxxxxxxxxx>
> Subject: [equinox-dev] Re: Adding to the framework exported libraries?
> To: equinox-dev@xxxxxxxxxxx
> Message-ID: <eqp2ci$9e1$1@xxxxxxxxxxxxx>
> Content-Type: text/plain; charset=ISO-8859-1
> Kabe wrote:
> > Hi Tom, thanks for the suggestion. Only reason i don't think
> > work (and maybe i'm wrong?) is that i need my host application
> > instances (services) to the bundles, so for example my host
> > creates in instance of FooService, and then registers it with
> > BundleContext of the Equinox framework. However, unless i somehow
> > Equinox that the package is available from the host (parent
> > it won't let any bundle load that depends on this package. So
> > not seeing how Fragment Bundles can solve this problem, because
> > seem like they need to be full bundles and not just passed in,
> but there
> > could be some API or technique i'm not familiar with?
> The system bundle is "org.eclipse.osgi". It exports the
> Fragments contribute to the classpath of their bundle host. Thus,
> if you
> create a fragment to "org.eclipse.osgi" you can add the
> your application to the set of exported packages of the system bundle,
> which makes them available to all bundles.
> For registering your services from the host application I suggest
> creating a bundle that is started when the framework is started. This
> bundle can register any OSGi services, etc. It could be also the
> fragment you created above.
> Cu, Gunnar
equinox-dev mailing list