领先一步
VMware 提供培训和认证,助您加速进步。
了解更多当管理和转换像 SpringSource 企业捆绑包仓库中包含的捆绑包那样多的捆绑包时,要记住哪些包是启动委托的,从系统捆绑包导出的,或从系统中其他捆绑包导出的会变得非常困难。这些信息很重要,因为你可能不想导入启动委托的包,你可能确实想以“0”版本导入系统捆绑包的包,并且你希望为所有其他包定义自定义导入。记住哪些包属于这些类别中的每一个最终会有点容易出错,并且为它们定义模板条目可能会很耗时。
随着 1.0.0.M4 的发布,Bundlor 获得了将 OSGi 配置文件作为输入,并自动为启动委托的包和系统捆绑包添加模板条目的能力。此输入以属性文件的形式获取,可与命令行、ANT 和 Maven 配合使用。
org.osgi.framework.system.packages 定义了从系统捆绑包导出的包,org.osgi.framework.bootdelegation 定义了启动委托的包。有关这些属性值语法的更多信息,请参阅 OSGi 规范 §3.8.3 和 §3.8.5。对于 Bundlor,这些属性在标准 .properties 文件中定义,如下所示。
org.osgi.framework.system.packages = \
javax.accessibility,\
javax.activation,\
javax.activation;version="1.1.0",\
javax.activity,\
javax.annotation,\
...
org.osgi.framework.bootdelegation = \
com_cenqua_clover,\
com.cenqua.*,\
com.yourkit.*,\
...
Bundle-SymbolicName: com.springsource.org.apache.log4j
Bundle-Name: Apache Log4J
Bundle-Vendor: SpringSource
Bundle-ManifestVersion: 2
Import-Template:
com.sun.jdmk.*;version="[5.1.0, 5.1.0]";resolution:=optional,
javax.jms.*;version="[1.1.0, 2.0.0)";resolution:=optional,
javax.mail.*;version="[1.4.0, 2.0.0)";resolution:=optional
在没有配置文件的情况下针对 Bundlor 运行时,我收到以下警告:
SB0001W: The import of package javax.management does not specify a version.
SB0001W: The import of package javax.naming does not specify a version.
SB0001W: The import of package javax.swing does not specify a version.
SB0001W: The import of package javax.swing.border does not specify a version.
SB0001W: The import of package javax.swing.event does not specify a version.
SB0001W: The import of package javax.swing.table does not specify a version.
SB0001W: The import of package javax.swing.text does not specify a version.
SB0001W: The import of package javax.swing.tree does not specify a version.
SB0001W: The import of package javax.xml.parsers does not specify a version.
SB0001W: The import of package org.w3c.dom does not specify a version.
SB0001W: The import of package org.xml.sax does not specify a version.
SB0001W: The import of package org.xml.sax.helpers does not specify a version.
为了消除这些警告,我可以添加一些 Import-Template 条目。相反,我将再次运行 Bundlor,并使用 dm Server OSGi 配置文件。此配置文件从系统捆绑包导出这些包中的每一个。这次运行没有警告,并以 version="0" 导入了这些包中的每一个。此捆绑包不依赖于任何启动委托的包,因此我们的清单中没有忽略导入。
osgiProfilePath 属性。<bundlor:bundlor
bundlePath="${basedir}/org.springframework.integration.jar"
outputPath="${basedir}/target/org.springframework.integration.jar"
bundleVersion="1.0.2.BUILD-${timestamp}"
osgiProfilePath="java6-server.profile"
manifestTemplatePath="${basedir}/template.mf"/>
osgiProfilePath 配置。<build>
<plugins>
<plugin>
<groupId>com.springsource.bundlor</groupId>
<artifactId>com.springsource.bundlor.maven</artifactId>
<version>1.0.0.M2</version>
<executions>
<execution>
<id>bundlor</id>
<goals>
<goal>transform</goal>
</goals>
<configuration>
<osgiProfilePath>java6-server.profile</osgiProfilePath>
</configuration>
</execution>
</executions>
</plugin>
...
</plugins>
...
</build>
manifest 和 transform 执行新增了一个可选的 -p, --profile 参数。bin/bundlor.sh transform
-b com.springsource.org.apache.log4j.jar
-m com.springsource.org.apache.log4j.mf
-p java6-server.profile
将 OSGi 配置文件作为输入读取的能力大大简化了清单模板的内容。如果您能想到更多可以改进的领域,请在 Bundlor JIRA 上提出问题或投票支持现有问题。