serachley
serachley

Reputation: 7

OSGi bundle shared jar dependency

I have a legacy swing application that I need to extend with JavaFX functionality. I have been looking at using OSGi to do this (currently looking at Equinox).

The existing legacy application is dependent on a jar file, main.jar. This jar holds the interfaces required for any bundles I create to extend functionality, e.g. add new panels, menu's, etc.

The legacy application initiates the OSGi framework once it has completed it's swing tasks, registers services that implement the interfaces in main.jar, and install any bundles.

I have attempted to put this jar in the bundle, and compilation is fine, but I get a ClassCastException when retrieving the service from the OSGi registry.

What I'm not sure of is how do I configure the framework/bundles so that both the legacy application and the osgi bundles can use main.jar?

Upvotes: 0

Views: 256

Answers (1)

Neil Bartlett
Neil Bartlett

Reputation: 23948

You need to expose the packages that need to be shared using the OSGi framework's system bundle exports. You do this by passing the property org.osgi.framework.system.packages.extra.

I wrote a blog post some time ago about embedding OSGi, it covers aspects such as sharing packages and services between the inner OSGi bundles and the outer Java application.

Upvotes: 0

Related Questions