領先一步
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 上提出問題或投票支援現有問題。