views:

197

answers:

4

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.

A: 

Maybe ServiceLoader is a solution, but what class loader can I use? Something that will load jar and dependencies easily

IttayD
A: 

Have you tried googling for each library + osgi? A quick glance shows some others experiences and (it would seem) successes.

Sorry for the "just google it answer" but since I don't actively use these libraries in my OSGi app I can only suggest how I've handled this for some of my libraries ... which was google.

This is not really a good answer, but I don't want this buried in comments.

basszero
A: 

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

There are other service frameworks, but to get dynamic loading and several versions of the same class there is nothing else by OSGi that I know of.

Also, now that OSGi seems to finally gain some traction, the pressure on libraries to "play nice" is rising. SpringSource for example maintains a growing collection of OSGified libraries. The package you need may already be there.

Thilo
A: 

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.

Carl