difference between WAB and WAR
Asked Answered
R

1

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

Renatarenate answered 5/7, 2012 at 5:17 Comment(2)
There's a 4th option: having your OSGi services provide a servlet service <provide interface="javax.servlet.Servlet"/> will register them in the HTTP service of your OSGi container. This is plain OSGi and does not require WAR/WAB artifacts.Selfdriven
@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.Rheo
R
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.

Rheo answered 5/7, 2012 at 13:47 Comment(1)
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.Thevenot

© 2022 - 2024 — McMap. All rights reserved.