首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何让绑定器为OSGi蓝图依赖项生成导入包

如何让绑定器为OSGi蓝图依赖项生成导入包
EN

Stack Overflow用户
提问于 2012-02-03 15:36:49
回答 1查看 1.1K关注 0票数 2

我在一个打包为OSGi包的服务实现中使用了Spring和Spring Integration。该服务由Blueprint发布,更具体地说是由Gemini Blueprint http://www.springframework.org/schema/osgi发布

代码语言:javascript
复制
<bean id="myService" class="org.example.mti.MyServiceImplementation"/>
<osgi:service ref="myService" interface="org.example.mti.api.MyService"/>

上下文文件在META-INF/spring/applicationContext*.xml

这对于一些存根服务来说工作得很好,比如内存支持的DAO,它们的实现不依赖于库。服务已注册,并可由另一个捆绑包执行。

对于更复杂的服务,我使用的是Spring Integration,服务实现显然需要访问Spring类,这些类是由普通的Spring库包导出的。

我正在使用Bundlor来管理MANIFEST.MF文件。我已经尝试过Spring Bundlet1.0.0.RELEASE和Eclipse Virgo Bundlet1.1.0.M3。

我的理解是Bundlor应该能够扫描Blueprint上下文文件来确定所需的类,但我没有看到任何非常有用的东西添加到Import-Package清单文件头中。

代码语言:javascript
复制
Import-Package:
 org.example.dao,
 org.example.domain,
 org.example.mti.api,
 javax.inject,
 org.springframework.integration,
 org.springframework.integration.annotation,
 org.springframework.integration.support

在尝试使用Pax Exam运行包时,在Felix下,我看到了ClassNotFoundException

代码语言:javascript
复制
java.lang.ClassNotFoundException:
    org.springframework.integration.gateway.GatewayProxyFactoryBean

我尝试在manifest.mf中设置Bundle-BlueprintSpring-Context清单标头,它们被复制到MANIFEST.MF,但没有添加新的Import-Package值。

例如,将<int:gateway .../>添加到蓝图上下文中会允许Bundlor正确地确定运行时依赖项,例如上面的GatewayProxyFactoryBean吗?

如果Bundlor无法确定正确的Import-Package值,那么您如何管理这些“内部”包需求?我认为,必须在某个第三方库中列出所有可能的包是不合理的。有没有类似于我模糊地回忆起Spring DM中的Import-Library

参考文献:

http://static.springsource.org/s2-bundlor/1.0.x/user-guide/htmlsingle/user-guide.html http://blog.springsource.org/2009/09/26/bundlor-adds-support-for-the-blueprint-service/

EN

回答 1

Stack Overflow用户

发布于 2012-02-03 18:11:18

用一个潜在的解决方案来回答我自己的问题。

代码语言:javascript
复制
DynamicImport-Package: org.springframework.*

虽然这是a bit of a hack,但它确实可以工作

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9125215

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档