File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Application Frameworks and the fly likes Plug in architecture using OSGi(Equinox) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Plug in architecture using OSGi(Equinox)" Watch "Plug in architecture using OSGi(Equinox)" New topic

Plug in architecture using OSGi(Equinox)

Deependra Tewari

Joined: Apr 12, 2006
Posts: 13
I need to develop a system for a requirement where there needs to be a module or plug-in like system with a web front end. Each module/plug-in will be doing a specific job and may have associated views in the form of JSP pages for IO. The web front must be available at all times and the modules need to be loaded/unloaded at run time dynamically via user intervention.

I figured OSGi would give me the constant uptime and the dynamic loading/unloading of the modules. I am currently trying a proof of concept using Springsource DM Server and Springsource Tool Suite.

I have fairly limited knowledge of Spring itself and as such prefer to use programmatic approach rather that declarative approach.
So the architecture I have thought of is something as follows:

OSGi'fied Webapp running in DM Server, the webapp has a reference to a OSGi service that is given by another bundle. Now this bundle tries to get a list of all the bundles using bundleContext.getBundles() and then tries to look for the registeredService of each bundle. The idea is that if I can make a list of all the bundles and their exported services, then I can give this list to the webapp and it can then show what plug-ins are loaded and also forward requests to such plug-ins.

The problems:

[1] Each plug-in can have a different interface and if I don't have the interface handle in the webapp source code, I can't call their methods!

[2] Also, is their a way to get access to all services exported by various bundles without declaring them in applicationContext.xml of the webapp? This way new bundles can be probed timely or maybe using the ServiceListener interface!

[3] I might provide a common interface with a set of methods that plug-ins must implement. However, if many bundles export their service for a common interface, I understand that the last one to be loaded is what all others will get. Is their a way of getting all the services without using ranks? I may distinguish them then using some property they must expose via one of the interface methods.

I wan't to use the least of Spring or declarative model. This way I can just provide a bundle or jar and let others create new plug-ins.

I understand that I may be looking at the architecture from a wrong perspective. Insights on this would also be highly appreciated!

I'm still going through the OSGi specs so will be ignorant of a lot of things. Please do point me in the right direction if so.

I agree. Here's the link:
subject: Plug in architecture using OSGi(Equinox)
It's not a secret anymore!