【问题标题】:How do I get Bundlor to generate Import-Package for OSGi Blueprint dependencies如何让 Bundler 为 OSGi 蓝图依赖项生成 Import-Package
【发布时间】:2012-02-25 20:50:04
【问题描述】:

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

<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 Bundlor 1.0.0.RELEASE 和 Eclipse Virgo Bundlor 1.1.0.M3。

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

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

java.lang.ClassNotFoundException:
    org.springframework.integration.gateway.GatewayProxyFactoryBean

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

是否期望将&lt;int:gateway .../&gt; 添加到蓝图上下文中将允许 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/

【问题讨论】:

    标签: spring maven osgi bundlor


    【解决方案1】:

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

    DynamicImport-Package: org.springframework.*
    

    虽然这是a bit of a hack,但它确实有效

    【讨论】:

      猜你喜欢
      • 2017-06-30
      • 2013-06-22
      • 1970-01-01
      • 2014-04-14
      • 2018-06-28
      • 2014-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多