I've planning to develop a web application using Java and based on some MVC framework. This application should support plugins.
So, I planning to create plugin using OSGI container(apache felix) and expose plugin as a service (using service registry feature of OSGI).
Both(web application and OSGI service) will be running in same JVM.
So, I need help on how can I use the OSGI service(plugin) outside OSGI container ?
I basically want to invoke exposed OSGI service outside OSGI, in this case in my web application.
Thanks in advance !
To make this work you need to have the api package of the service in the classpath where you start the OSGi framework. You then need to export this package as a system package export. This is the only way how the bundle implementing the service and the non OSGi code can see the same service interface class.
You then use the FrameworkFactory to create a Framework instance which you can start. From the framework you can obtain the BundleContext and use it to obtain the service instance(s).
See embedding felix for some more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With