Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Plug in architecture using OSGi(Equinox)

 
Deependra Tewari
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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.

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic