Skip to main content

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

I answer to myself as I have understood how to work around the problem.
I realize that the way I'm developing my application is not the good way using osgi, I might soon repackage it into a bundle. So by changing the system property osgi.parentClassloader, I can set the system to use the same class loader so the cast I'm doing to get the service implementation is ok.

Fabien Autrel a écrit :
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!
_______________________________________________
equinox-dev mailing list
equinox-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/equinox-dev




Back to the top