OSGI creating modular web application?

The OSGi spec details the WAB (Web Archive Bundle) format.

The OSGi spec details the WAB (Web Archive Bundle) format. And Pax Web offers great support for WAB/WAR webapps (PAX Web runs fine on Equinox, Felix, etc) Using pax web you get the BundleContext via the ServletContext, eg: BundleContext bundleContext = (BundleContext) getServletContext(). GetAttribute("osgi-bundlecontext"); For the user driven pluggability you mention, I'd suggested you provide some service interfaces for the plugin bundles to implement and in your webapp use a ServiceTracker to listen for their registration (unless you're using Declarative Services).

You also easily be able to install bundles from an upload servlet. I'm guessing users uploading plugins would have to be logged in and authorized, so security issues will have been met at this point. EDIT: replying to comment here as not enough space in comment field Apologies, think I misinterpreted you question - you have an existing webapp container(s) and you want to deploy a WAR with OSGi functionality?

If that's the case then either use the ServletBridge as others have mentioned or embed an OSGi framework into your WAR (this is relatively easy, see this for example). You could even make this optional by attempting to get the BundleContext from the ServletContext and if this returns null then launch your own embedded framework. That way it'll run in a native OSGi container (e.g. Glassfish) or in a JEE app server.

Otherwise, PaxWeb is an implementation of the HttpService and WebApp OSGi specs, but with lots of extensions to make life easier - but you deploy this to an OSGi container.

Your reply is interesting I know about WABs , thats what I mentioned in my question "i cant rely on my web container to provide osgi support and deploy web application as an osgi bundle itself". But I was not aware of the pax web, the official link you gave suggests its a extenstion for jetty to deploy wars as wabs? Can you explain further?

– ChingPing Sep 1 at 17:03 thanks, I will evalute the method you suggested in the link. – ChingPing Sep 2 at 4:15.

ServletBridge is for embedding an OSGI contianer within a web container. The other option is to embed a web container (as a bundle) in an OSGI container. The following article has some details on how to achieve this.

java.dzone.com/articles/osgi-and-embedde....

Thanks I am aware of that but I do not want to be restricted to any particular web container and afaik embedding most of the servers is not an option. – ChingPing Sep 1 at 16:59.

You might want to look into Apache Sling. It is a web framework that has an embedded OSGi container. The OSGi container is called Apache Felix and is pretty good.

This looks nice but I don't want to be restricted by what the framework supports, for instance I would like to use JSF for my web application. Perhaps I should have mentioned that in my question. – ChingPing Sep 1 at 10:14.

You may want to try ChonCMS - choncms.com Its architecture is based exactly on what you are asking, it comes with few plugins to enable base CMS functionality, it is modular platform with minor web app container using felix and plugins can be added/removed at run time as well. Disadvantage might be that it has lack of documentation, but you may ask, it is open source, I'm sure they will be happy to answer questions, and even better you can contribute - it is still in incubation phase.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions