Search code examples
javapluginsosgiclassloader

osgi-like framework without the import/export restrictions?


I like OSGi, but the import/export restrictions and the lack of context class loader creates havoc when trying to use 3rd party libraries (e.g., some libraries try to find file.xml in META-INF, expecting for all such files in all jars to be returned, other libraries use ServiceLoader).

I want OSGi's dynamic loading, ability for handling several versions of the same library, and service framework.

So what are my alternatives? I know of JPF, looking for something less xmlish.


Solution

  • I had this problem with having a java mail bundle separate from my java activation bundle. You have the following options to get 1 bundle to see files (ie. not java resources but things like xml files) in META-INF of other bundles.

    1) Merge the bundles together. This is often icky to deal with or just not impossible for the project.

    2) Have the bundles that need to share resources be bundle fragments of the bundle that needs to read up the resources. Bundle fragments are defined by the OSGi spec and allow separate bundles to share resources as though they were merged together.