> > (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? >
Well, you can either simply use reflection to call the service and avoid the need to cast. The alternate would be for your launching code to provide the service interface (add that package to the extras property) and have the bundles import that package. Then you both use the same interface class objects (since the come from the launcher's class loader).
_______________________________________________ OSGi Developer Mail List [email protected] https://mail.osgi.org/mailman/listinfo/osgi-dev
