Reputation: 4098
We are developing a web site with OSGi bundles (Adobe CQ/Apache Sling/Felix and Maven). There are 2 bundles: 1) Webapp 2) Commmon.
The Common bundle contains modules common to Webapp development like encryption, paging, sorting etc.
The bundles are deployed in CQ/OSGi container as follows:
OSGi parent class loader ---|--- Webapp
|--- Commmon
The Common bundle contains some functionalities which maintain configurations (similar to PropertyConfigurator
in log4j), connection pool etc as static data.
Now another web site has come up and we want to 1) Re-use Commmon bundle 2) Deploy new web app in same CQ container.
The new deployment layout can be:
OSGi parent class loader ---|--- Webapp
|--- New web app
|--- Commmon
If we use above deployment strategy, the static data in Common bundle is shared between the 2 web apps and creates overlaps (because Common bundle is loaded in 1 class loader which is shared with class loaders of the 2 web apps).
What will be good architecture to re-use Common bundle? Should it be embedded inside Webapp and New web app (so each web app will have its own copy of Common bundle loaded in its class loader)? If yes, which Maven plug-in is suitable for this (I used "maven-bundle-plugin" with "wrap" goal; but the build log has a WARNING message which discourages it's use)?
Upvotes: 0
Views: 199
Reputation: 19606
The best solution would be to remove the statics and continue to use the common lib as a bundle.
If this is not possible then you can use the maven bundle plugin with the webapp bundles. Simply define the common packages you want to embed as private in the maven bundle config of the webapp. These classes will then be embedded.
Upvotes: 1