Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » How are classes loaded when using BundleLoader.addDynamicImportPackage() ?
How are classes loaded when using BundleLoader.addDynamicImportPackage() ? [message #101767] Wed, 21 November 2007 09:59 Go to next message
Eclipse UserFriend
Originally posted by: richard256.gmx.de

I am using BundleLoader.addDynamicImportPackage for on-the-fly
instrumentation of classes. I observed, that it is sufficient to give the
packages of classes directly being refered of the instrumented classes in
the target bundle. Classes refered by the classes in the dynamically
imported package are found themselves.

Since I am not familiar enough with the OSGi specification (is it specified
behaviour at all?), I would like to know how the inported package is linked
into the target bundle? Will the classes be loaded anew by the class loader
of the target bundle? From the behaviour in my prototype I would assume that
the answer is no, and the classloader of the imported package is queried for
class definitions. Is that the desired behaviour? Or just by chance? And
;-), most important, can I rely on that behaviour?

Thanks
Richard
Re: How are classes loaded when using BundleLoader.addDynamicImportPackage() ? [message #103722 is a reply to message #101767] Fri, 11 January 2008 19:54 Go to previous messageGo to next message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 503
Registered: July 2009
Senior Member
Hi Richard,

The BundleLoader.addDynamicImportPackage is not specified by OSGi. That
is an internal method specific to org.eclipse.osgi implementation of the
OSGi Framework specification. It was added for a similar situation that
the AspectJ team had in the Equinox incubator. They needed to
dynamically bind additional packages for class dependencies which they
wove into classes included in a bundle.

The package is linked (or wired) from the importing (target) bundle to
the exporter at the time the class is loaded at runtime. This is the
specified behavior of the packages declared on the DynamicImport-Package
header. The target bundle will delegate the load to the exporting
bundles classloader, so it is not the target bundle's classloader which
does the loading/defining of the class.

You can rely on the behavior of dynamically imported packages because
this behavior is specified by the OSGi specification. But you should
recognize that you are using an internal method to add the imports.
Being an internal method, this could change with later releases. But
since the team knows quite a few clients of the internal method we will
not go changing it on a whim.

HTH.

Tom.
Re: How are classes loaded when using BundleLoader.addDynamicImportPackage() ? [message #103804 is a reply to message #103722] Mon, 14 January 2008 07:27 Go to previous message
Eclipse UserFriend
Originally posted by: richard256.gmx.de

Hi Tom,

many thanks for the clarification.

Kindest Regards
Richard
Previous Topic:Equinox JSP example - how to run it?
Next Topic:How to shutdown an Equinox program ?
Goto Forum:
  


Current Time: Tue Apr 23 13:23:50 GMT 2024

Powered by FUDForum. Page generated in 0.03462 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top