7

I am a newbie to this and read about WABs , but wish to clear the basic difference - I mean using osgi embedded in tomcat and making a WAR vs making a WAB ?

When should one consider each option ?

1) OSGI embedded in tomcat

2) tomcat in OSGI

3) using a WAB

Rndm
  • 6,710
  • 7
  • 39
  • 58
  • There's a 4th option: having your OSGi services provide a servlet service `` will register them in the HTTP service of your OSGi container. This is plain OSGi and does not require WAR/WAB artifacts. – maasg Jul 05 '12 at 15:04
  • @maasg, the "whiteboard" pattern does not work on all OSGi HttpService implementations. It's only supported by a few and not standard. But it's a nice pattern, though. – Gunnar Jul 07 '12 at 09:18

1 Answers1

8

OSGi embedded in a container (not only Tomcat!) is likely the only option when you are forced to a traditional JavaEE WAR deployment model, i.e. an IT department operates the container and you can only deloy WAR files to it. This bootstraps a whole OSGi framework within the web application and allows modular development within the web application. The web application is then composed as a set of OSGi bundles. It can also be used to migrate/transfer an existing legacy web application into OSGi modules. However, this will be challenging.

I'd like to call the second approach (Tomcat in OSGi) as a pure OSGi approach. Tomcat or any other Servlet container (eg., Jetty) can be deployed as a bundle (or a set of bundles) in an OSGi framework. The OSGi framework is the container. You don't have the full separation of a web application anymore. The can intersect. Some bundles/modules may implement web functionality and others may not. Core functionality (core bundles) can be reused by other web bundles.

The third option is a result of new spec work in OSGi. Basically, it's a web application with an OSGi bundle manifest. Thus, the whole web application can be deployed as a single OSGi bundle on any framework with WAB support. Technically, the bundle may be deployed as a web application to a Servlet container. But it gets access to a BundleContext. This allows the web application to inter-operate with other bundles or web applications running in the same framework.

Gunnar
  • 2,264
  • 17
  • 31
  • 2
    Good answer. Note that an artifact can be both a WAR *and* a WAB, and therefore be deployed to both OSGi and to a traditional container. This could help with migration. – Neil Bartlett Jul 05 '12 at 14:18