我在一个打包为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 Bundlet1.0.0.RELEASE和Eclipse Virgo Bundlet1.1.0.M3。
我的理解是Bundlor应该能够扫描Blueprint上下文文件来确定所需的类,但我没有看到任何非常有用的东西添加到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-Blueprint和Spring-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/
发布于 2012-02-03 18:11:18
用一个潜在的解决方案来回答我自己的问题。
DynamicImport-Package: org.springframework.*虽然这是a bit of a hack,但它确实可以工作
https://stackoverflow.com/questions/9125215
复制相似问题