OSGI bundle ServiceMix 中的依赖管理 [英] Dependency management in OSGI bundle ServiceMix

查看:34
本文介绍了OSGI bundle ServiceMix 中的依赖管理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 ServiceMix 的新手,所以可能我在问同样的问题,但我无法弄清楚.

Hi I am new to ServiceMix, so probably I am asking same question which might be answered but I couldn't figure out.

我的疑问是在 ServiceMix OSGI 中使用包时如何管理编译时间与运行时依赖项.也就是说,如果我正在使用 maven 构建一个 .jar 可行(通过单元测试)工件,其中所有编译时依赖项说 example(camel,spring) 由 pom.xml 依赖项处理,并根据需要加载到 jar 中以成功构建的库.所以当我在 OSGI 中部署 jar 时,那些库(骆驼,弹簧)已经存在于 maven 生成的 jar 中.现在作为 OSGI 包,我在运行时从容器支持相同的包(骆驼,弹簧).

My doubt is how do I manage compile time vs runtime dependencies when using bundle in ServiceMix OSGI. That is if I am building a .jar workable(by unit tests aleast) artifact with maven where all compile time dependencies say example(camel,spring) are handled by pom.xml dependencies and are loaded into jar as needed libs for successful build. So when I am deploying the jar in OSGI those libs(camel,spring) are already existing in maven generated jar. Now as OSGI bundles I am supporting same bundles(camel,spring) here during runtime from container.

所以我很困惑我的代码如何或选择哪个副本来执行.它是 .jar 中的那个 由 OSGI 容器提供的那个.虽然我知道 MANIFEST 文件提供了一些选项,比如 Import Packages,它有助于从容器中的其他 OSGI 包中导入依赖项

So I am confused how or which copy of required dependency bundle my code picks for execution. Is it the one within .jar or the one provided by OSGI container. Though I am aware the MANIFEST file provides options, like Import Packages which help to import the dependencies from other OSGI bundles in container

可能是我在这里遗漏了使用 OSGI 的一些非常关键的点,所以如果我对任何假设有错误,请纠正我并提供一些指示/建议

May be I am missing some very key points of using OSGI here, so please correct me if I am wrong on any assumptions and provide some pointers/suggestions

谢谢

推荐答案

看起来您正在使用 maven-bundle-plugin 来生成您自己的包.在这种情况下,只需确保您对骆驼等的依赖是提供范围而不是编译范围

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.

这篇关于OSGI bundle ServiceMix 中的依赖管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆