OSGI捆绑包ServiceMix中的依赖关系管理 [英] Dependency management in OSGI bundle ServiceMix

查看:84
本文介绍了OSGI捆绑包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时,那些libs(camel,spring)已经存在于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捆绑包ServiceMix中的依赖关系管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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