Dependency management in OSGI bundle ServiceMix

倖福魔咒の 提交于 2019-12-06 16:03:12

Looks like you're using the maven-bundle-plugin to generate your own bundle. In that case just make sure your dependencies for camel, etc. are of provided-scope instead of compile-scope

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-core</artifactId>
    <scope>provided</scope>
</dependency>

This will make sure your bundle only contains the dependencies it needs.

It all depends on how your manifest looks like:

  • You don't import the package (either with Import-Package, Require-Bundle or Dynamic-Import-Package): all classes are only loaded from your bundles classpath
  • You import the package with the optional flag: If the package is available it will be taken from the OSGi framework otherwise it will search your bundle classpath
  • You import the package with Dynamic-Import-Package: The framework will search your bundle and then other bundles exporting the package

So normally you choose to import package all dependencies but you can also embedd them into your jar, it all depends on your use-case.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!