領先一步
VMware 提供培訓和認證,以加速您的進展。
了解更多當管理和轉換大量包含在 SpringSource Enterprise Bundle Repository 中的 bundles 時,要記住哪些套件已啟動委派(boot delegated)、從系統 bundle 匯出,或從系統中的其他 bundles 匯出,會變得非常困難。此資訊很重要,因為您可能不想匯入已啟動委派的套件,您可能想要以 "0" 的版本匯入系統 bundle 套件,並且您想要為所有其他套件定義自訂匯入。記住哪些套件屬於這些類別最終容易出錯,並且為它們定義範本項目可能很耗時。
隨著 1.0.0.M4 的發布,Bundlor 獲得了將 OSGi 設定檔作為輸入,並自動為啟動委派的套件和系統 bundles 新增範本項目的能力。此輸入採用屬性檔案的形式,並且可以與命令列、ANT 和 Maven 一起使用。
org.osgi.framework.system.packages
定義了從系統 bundle 匯出的套件,而 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。此設定檔從系統 bundle 匯出每個這些套件。此執行在沒有警告的情況下返回,並以 version="0"
匯入每個這些套件。此 bundle 不依賴任何啟動委派的套件,因此我們的 manifest 中沒有忽略的匯入。
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 設定檔作為輸入的能力極大地簡化了 manifest 範本的內容。如果您能想到更多可以改進的地方,請在 Bundlor JIRA 上開啟一個 issue 或投票給現有的 issue。