> Hi all,
> Don't know if this is the right group for my question - please point
> me elsewhere if it isnt.
> I'm porting a legacy Java framework to an OSGI-based framework. My new
> application consists of a number of plugins:
> - the eclipse and osgi core plugins
> - a plugin that contains the old framework
> - new application plugins
> This new framework is booted the Eclipse way using an IPlatformRunnable.
> Now I want to use some of the new application plugins inside the old
> framework. This is still started as an ordinary Java application.
> Insided this application I boot osgi, and by setting
> parentClassloader=app I can use the old framework
I do not understand your scenario completely. Are you launching the
"old" framework from within a bundle in the Equinox/OSGi Framework or
are you launching the Equinox/OSGi Framework from within your "old"
> Off course, in this case the old framework is not available as a
> plugin. So my question is: how do I configure my application plugins
> so that their dependencies are correctly resolved in both settings. If
> I do an import-package where this package is provided by the app
> classloader, will this be correctly wired ? Would it be possible to
> create a dummy plugin whose classes are loaded from the app
> classloader ?
This question leads me to believe that you are launching the Equinox/OSGi
framework from within your "old" framework because you are talking
about providing "old" framework packages from the app classloader which
I assume you used to load your "old" framework to begin with. To
do this you would have to do the following:
1) launch the Equinox/OSGi framework from within the "old" framework.
Use the system property osgi.parentClassloader=app. This will allow
the framework to use the app classloader as the parent classloader.
By default it uses the boot classloader.
2) install a framework fragment that exports the extra packages from
the "old" framework. A framework fragment is like a normal fragment
except it uses the header "Fragment-Host: system.bundle" to specify
the framework system.bundle as its host. This fragment can specify
the "old" framework packages that should be exported from the app
classloader (using the Export-Package header).
3) bundles installed in the Equinox/OSGi framework should use
Import-Package to access the packages from the "old" framework.
A limitation to this setup is the code in the "old" framework will
not have access to code from bundles installed in the Equinox/OSGi
Framework. This is because its classloader (the app classloader)
is not controlled by the Equinox/OSGi Framework therefore OSGi
cannot provide the delegation model to allow access to packages
exported by other OSGi bundles.
To support this kind of scenario you need to have the
Equinox/OSGi framework sit at the bottom and launch your "old"
framework from within a bundle installed in the OSGi framework.
This "old" framework bundle would have to use Import-Package or
Require-Bundle to access any packages exported by other bundles
for all the code running within the "old" framework. Other "new"
bundles would still use Import-Package to wire to the packages
exported by your "old" framework bundle.
equinox-dev mailing list