更进一步
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
条目。 相反,我将使用 dm Server OSGi 配置文件 再次运行 Bundlor。 此配置文件从系统捆绑包导出每个这些软件包。 此运行返回时没有警告,并以 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 上开设一个问题或投票支持现有问题。