[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[equinox-dev] plugin host problem

Dear all,

I am new to the osgi framework and I have a question.
I have developped an application in which I want to add plugins. I have chosen the osgi framework to implement that but I am now facing a problem: my application manages the bundles through an instance of BundleContext obtained via a call to EclipseStarter.startup();
I have defined an interface which the plugins must implement, I have developped a plugin implementing the interface, the bundle is loaded and started without any problem but a ClassCastException is raised when I try to obtain the service implementation in my application though this piece of code:
IPolicyProcessorService service = (IPolicyProcessorService) context.getService(serviceRefs[i]);
where serviceRefs[i] is the ServiceReference object corresponding to the plugin.

If my understanding of classloaders is correct, this exception is raised because the IPolicyProcessorService class file has been loaded by two different class loaders in the application and in the bundle so even though the loaded data on the disk is the same, I cannot make the cast.
So I understand that I could encapsulate my application in a bundle, my plugin in a bundle and import the plugin interface class from another bundle but it would be quite a big amount of work to modify my application.

So my final question is, is there a way of using the services exposed by bundles from a "host" application running equinox like I'm trying to do?

Thank you!