|Re: Separation of Java and Eclipse Worlds [message #513001 is a reply to message #512716]
||Mon, 08 February 2010 14:36
| Paul Webster
Registered: July 2009
There are a number of articles talking about OSGi classloading, and |
there are probably another set that deal specifically with Eclipse and
classloading (extension points, etc).
The fundamental statement for OSGi is "bundles can only see other
bundles". You either have to require another bundle (promoted mostly be
eclipse) or import the other bundles packages (which it exports,
favoured in the OSGi world).
How to manage them depends on your scenario: Are you developing the 3rd
party jar and the eclipse plugin together? Are you simply consuming a
3rd party jar (org.apache.commons.lang-2.4.0.jar)?
If you want to work on a java project that should also be consumed as an
OSGi bundle, that's easy to set up in eclipse (SWT is like that, and is
usable from within eclipse both for a java app and as a plugin library).
If you want to consume a generic java project that doesn't use
reflection, then you have 2 choices ... either turn the jar into a
bundle (by adding the appropriate OSGi MANIFEST.MF entries) or create a
bundle that includes the jar in question and exports it appropriately.
Option 1 changes the 3rd party jar (although not much) and option 2 you
aren't modifying the 3rd party jar.
If you want to consume a java library that uses reflection, that's
harder ... it depends on a flat classpath, but OSGi provides modularity
imposed on the classpath. Then you have to pick the appropriate
workaround for the type of java library that it is (and it really
depends on what the java library is trying to do).
Extension points allow contributors to extend a bundles basic
functionality (and handle the classloading for you). In the OSGi world
I would imagine you get the same effect from implementing a common
interface and having contributors register their contributions as a
service (the whiteboard pattern is the common example I can think of).
I know this is more of a rambling description rather than a clear answer
to your question, but it really does depend on which OSGi vs Java
library problem you are trying to solve.
Powered by FUDForum
. Page generated in 0.02326 seconds