The SpringSource Application Platform support three kinds of application architectures: regular WAR, WAR with shared libraries, and OSGi-based applications. Each of these styles improves upon the prior one and offers increasing number of advantages. In this section, we take a closer look at all these styles and discuss their suitability for a target application.
In this application style, you create a regular web application packaged as a WAR file. The SpringSource Application Platform can deploy it in a normal fashion. In this kind of deployment, the platform approximates the behavior to match that of Tomcat as well as enabling the following features:
The main benefit of this application style is familiarity--everyone knows how to create a WAR file! You can take advantages of the platform's capability without modifying the application. The application can also be deployed on other web- or application-servers.
You may choose this application style if the application is fairly simple and small. You may also prefer this style even for large and complex applications as a starting point and migrate to the other styles over time as discussed in Chapter 7, Migrating to OSGi.
In this application style, you create the web application as a WAR file. However, unlike the regular WAR file, you do not include dependent JARs. Instead, you specify the required packages and the platform will make the associated jars available to the application.
Compared to regular WAR application, this style offers reduced package size, since the WAR file no longer contains the required jars. However, the main benefit of this application style is to serve as a step in migrating a regular WAR application to the OSGi-styled application as we see next.
This application style takes full advantage of the application platform's capabilities. This style differs from the previous one in a few significant ways. Firstly, the application is composed of various OSGi bundles instead of one monolithic distribution. Secondly, each bundle exposes a set of types and services that other bundles may use, thus controlling the public interface to that bundle.
Most of the benefits of this style are due to the underlying OSGi infrastructure. The main benefits include:
![]() | OSGi != multiple JARs |
|---|---|
|
Note that while physically separated modules discussed earlier can, in theory,
be implemented simply using multiple jars with each
representing a module, complex versioning requirements often makes this impractical.
For example, consider a situation shown in the figure below,
where version 1.0.0 of bundle A depends on version 1.0.0 of bundle B and version 2.0.0 of
bundle C, while bundle B depends on 1.0.0 version of bundle C.
Suppose that version 1.0.0 and 2.0.0 of C are not
backward or forward compatible. Regular monolithic applications
cannot handle such situations: either bundle A or bundle B would need reworking
which undermines truly independent development.
OSGi's versioning scheme enables this scenario to be implemented in a
robust manner. If it is desirable to rework the application to share a single version of C,
then this can be planned in and is not forced.
|