If you use the new framework launching API (in 4.2 spec draft and implemented in the recent Equinox and Felix builds), you will have a Bundle and BundleContext for the framework (system bundle) you created. You can then register/use services to communicate with bundles installed in the framework. This is a far better idea than trying to directly interact with implementation classes in bundles.

Thank you so much for the info. Framework launching API seems to be just what I need.

You can either
(a) have your code register a service which bundles can use(call) to get information from the C code.

I am working on this and it seems promising. At first I couldn't figure out how to make a non-bundle interface available to a bundle, but I found a property called "org.osgi.framework.system.packages.extra" which seems to add packages to framework namespace.

(b) have bundles register services which the C code can get and call with information

Actually I tried this first, but could not get it working.

I have a Java code that launches OSGi using the launching API. It then installs a bundle that registers a service. It then tries to get that service instance from the framework's BundleContext. I get the service instance when I call context.getService(ref), but I can't call a method on it because I cannot cast it to the service interface. The service interface that the service object implements comes from a bundle class loader, so it's not accessible to my non-OSGi launcher code.

Is there a way to get around this?

You can even do a combination of both.
--
BJ Hargrave

Thanks again for the tips.  Really appreciate it.

- Jae


_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to