When migrating an existing application to the PAR packaging and deployment format, you consider modularity as the prime objective. Following the ideas discussed in Section 4.3, “A guide to forming bundles”, you refactor the application into multiple bundles. You may start conservatively with a small number of bundles and then further refactor those bundles.
If the original code is crafted following good software practices such as separation of concerns and use of well-defined interfaces, migration may involve modifying only configuration and packaging. In other words, your Java sources will remain unchanged. Even configuration is likely to change only slightly.
For example, the following diagram depicts a typical web application that has been refactored and
packaged as a PAR. The blue elements within the Application box constitute
the bundles of the application. Each of these bundles imports types from other bundles within
the PAR using Import-Package
. The green elements in the left column represent
libraries installed on the dm Server. The PAR's bundles reference these
libraries using Import-Library
. The purple element in the left column
represents a bundle within the dm Server's bundle repository which is imported by the DAO
bundle using Import-Bundle
. In contrast to a traditional, monolithic
WAR deployment, the PAR format provides both a logical and physical application boundary
and simultaneously allows the application to benefit from both the OSGi container and
the SpringSource dm Server.