0

我们正在开发一个带有 OSGi 包(Adobe CQ/Apache Sling/Felix 和 Maven)的网站。有 2 个捆绑包:1)Webapp 2)Common。
Common bundle 包含 Webapp 开发常用的模块,如加密、分页、排序等。
这些 bundle 部署在 CQ/OSGi 容器中,如下所示:

OSGi parent class loader ---|--- Webapp
                            |--- Commmon

Common bundle 包含一些维护配置(类似于PropertyConfiguratorlog4j)、连接池等作为静态数据的功能。
现在另一个网站出现了,我们想要 1) 重用 Commmon bundle 2) 在同一个 CQ 容器中部署新的 Web 应用程序。
新的部署布局可以是:

OSGi parent class loader ---|--- Webapp
                            |--- New web app
                            |--- Commmon

如果我们使用上述部署策略,Common bundle 中的静态数据在 2 个 Web 应用程序之间共享并产生重叠(因为 Common bundle 加载在 1 个类加载器中,该类加载器与 2 个 Web 应用程序的类加载器共享)。
什么是重用 Common bundle 的好架构?它是否应该嵌入到 Webapp 和新的 Web 应用程序中(这样每个 Web 应用程序都会在其类加载器中加载自己的 Common bundle 副本)?如果是,哪个 Maven 插件适合这个(我使用带有“wrap”目标的“maven-bundle-plugin”;但是构建日志有一条警告消息,不鼓励使用它)?

4

1 回答 1

0

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.

于 2013-10-05T22:28:51.320 回答