*
The moose likes Other Application Frameworks and the fly likes Modular Java: servlet container Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Modular Java: servlet container" Watch "Modular Java: servlet container" New topic
Author

Modular Java: servlet container

Tomasz Prus
Ranch Hand

Joined: May 20, 2008
Posts: 73
Can OSGi be replacement for servlet containers or this is rather misunderstanding?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41587
    
  54
While OSGi can be used to architect a web server or servlet container, there's nothing in it that handles HTTP, so, no, it's not a replacement for that.


Ping & DNS - my free Android networking tools app
Craig Walls
author
Ranch Hand

Joined: Sep 19, 2003
Posts: 301
Ulf Dittmer wrote:While OSGi can be used to architect a web server or servlet container, there's nothing in it that handles HTTP, so, no, it's not a replacement for that.


Not exactly true. The core OSGi spec doesn't call for any HTTP handling, but the compendium to the spec does describe an HTTP service that can handle basic servlet requests (not much more than that, though). And you have to programmatically register servlets with the HTTP service (eg, no web.xml).

Building on top of the HTTP service is a project called Pax Web. It provides an implementation of OSGi's HTTP service that also supports JSP, servlet filters, listeners...pretty much everything you'd need. And, it includes an extender that makes it possible to deploy near-standard WAR files (with a tiny bit of extra goodness in the manifest) to OSGi.

Spring-DM also supports servlet-based web development, but in a different way. They lean heavily on either Tomcat or Jetty to do what they do best, but let you install WAR files as bundles in the OSGi framework. This is my current preferred approach, but I may change my mind as the OSGi R4.2 spec starts taking shape with web bundle support.


Spring in Action - Unleash POJO power in your applications!
Modular Java - Discover the secret weapon to modularity on the Java platform!
XDoclet in Action - Your complete guide to code generation with XDoclet.
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
What about EJB support?
Is OpenEJB similar to Pax Web in a sense that OpenEJB supports OSGi?


SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
Craig Walls
author
Ranch Hand

Joined: Sep 19, 2003
Posts: 301
Kengkaj Sathianpantarit wrote:What about EJB support?
Is OpenEJB similar to Pax Web in a sense that OpenEJB supports OSGi?


I'm not clear on what level of OSGi support OpenEJB offers. But, if it comes as one or more OSGi bundles that once installed in an OSGi runtime, it will install and serve .EAR files, then yes...OSGi supports EJB. But, again, I don't know enough about OpenEJB to know if that's anywhere near the truth.

The current implementations of the various web extenders (Spring-DM and Pax Web) demonstrate that it's possible to create OSGi bundles that can deploy traditional web artifacts to a web container embedded in the OSGi framework. If that's true, then I have a hard time believing that you couldn't do the same thing for EJB. Why not have an "ear extender" (sounds funny when you say it out loud) that watches for OSGi bundles that look a little like EAR files and, if it finds them, deploys them to an embedded EJB container. Sounds plausible. Is this what OpenEJB does? I don't know...but now you have me curious, so I'm going to find out.
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
From OSGi & OpenEJB, OpenEJB can be run as a bundle, and we can create EJB bundles.
I'm still not sure about EAR (WAR + EJB), but I guess it should work if we combine power of OpenEJB and a web extender like Pax Web together.
Craig Walls
author
Ranch Hand

Joined: Sep 19, 2003
Posts: 301
Kengkaj Sathianpantarit wrote:From OSGi & OpenEJB, OpenEJB can be run as a bundle, and we can create EJB bundles.
I'm still not sure about EAR (WAR + EJB), but I guess it should work if we combine power of OpenEJB and a web extender like Pax Web together.


I took a quick look at this and yes...it looks like OpenEJB will do the trick, allowing you to deploy EJBs in OSGi.

I think that their approach could be improved upon by employing an extender (so that the EJB bundle author doesn't have to provide a BundleActivator). But it's a good start.

FYI, the extender pattern is a common OSGi design pattern. Basically an extender is a bundle that watches for other bundles to be started and if those bundles are the kinds of bundles that the extender is interested in, then the extender can apply certain extra behavior to those bundles.

The common example is a web extender that watches for web bundles to be started and then installs them in an embedded web container. For OpenEJB, they could benefit from an EJB extender that watches for EJB bundles to be started and then installs them in an embedded OpenEJB container.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Modular Java: servlet container