plugin.xml 檔
外掛程式在稱為 plugin.xml的 XML 資訊清單檔中說明,這是外掛程式部署檔的一部分。 資訊清單檔會告知入口網站應用程式的執行時期登錄及啟動外掛程式所需的資訊。 基本上,資訊清單檔是作為外掛元件與入口網站應用程式執行時期之間的合約。 雖然 WebSphere® Application Server plugin.xml 緊跟著提供給 Eclipse 工作台的 WebSphere ® Application Server ,但它在數個位置中確實偏離 Eclipse 工作台。
位置
Theplugin.xml檔案必須位於 Web 應用程式存在之目錄階層的環境定義下的 WEB-INF 目錄中,或包含在 Web 應用程式保存檔中時。 Theplugin.xml檔案必須位於根目錄中plugin.xml檔案放置在 Enterprise JavaBeans Java™ 保存檔 (JAR) 或共用程式庫 JAR 檔中。 延伸登錄服務包括plugin.xml檔案,因為已在應用程式伺服器上載入並啟動參與元件。
使用注意事項
- 這個檔案是唯讀的嗎?
否
- 這個檔案是由產品元件來更新嗎?
???
- 若是如此,更新由什麼來觸發?
Rational Application Developer 會更新web.xml當您將 Web 元件組合到 Web 模組時,或當您修改 Web 元件或 Web 模組的內容時。
- 如何及何時使用這個檔案的內容?
在 Web 應用程式開發的配置和部署階段期間, WebSphere Application Server 功能會使用這個檔案中的資訊。
- 資訊清單標記定義會使用各種命名記號和 ID。 為了消除語義不明確,下列是這些命名慣例的正式作業規則。 一般而言,所有 ID 都區分大小寫。
SimpleToken := sequence of characters from ('a-z','A-Z','0-9') ComposedToken := SimpleToken | (SimpleToken '.' ComposedToken) PlugInId := ComposedToken PlugInPrereq := PlugInId ExtensionId := SimpleToken ExtensionPointId := SimpleToken ExtensionPointReference := ExtensionPointId | (PlugInId '.' ExtensionPointId)
範例檔項目
整個外掛程式 Manifest DTD 如下。 XML 綱目不是用來定義資訊清單,因為外掛程式的現行 Eclipse 工具需要 DTD。 XML DTD 建構規則元素 * 表示元素; 元素? 表示元素的零或一次出現; 而 element + 表示元素的一或多次出現。
<?xml encoding="US-ASCII"?>
<!ELEMENT plugin (requires?, extension-point*, extension*)>
<!ATTLIST plugin
name CDATA #IMPLIED
id CDATA #REQUIRED
version CDATA #REQUIRED
provider-name CDATA #IMPLIED
>
<!ELEMENT requires (import+)>
<!ELEMENT import EMPTY>
<!ATTLIST import
plugin CDATA #REQUIRED
version CDATA #IMPLIED
match (exact | compatible | greaterOrEqual) #IMPLIED
>
<!ELEMENT extension-point EMPTY>
<!ATTLIST extension-point
name CDATA #IMPLIED
id CDATA #REQUIRED
schema CDATA #IMPLIED
>
<!ELEMENT extension ANY>
<!ATTLIST extension
point CDATA #REQUIRED
id CDATA #IMPLIED
name CDATA #IMPLIED
>
WebSphere Application Server 差異
- Theplugin元素 (element)
- 此資訊清單中提供的外掛程式元素不包含類別屬性。 class 屬性是不必要的,因為外掛程式機制不需要外掛程式開發人員依照 Eclipse 工作台的要求來延伸或使用任何特定的類別。 此外,外掛程式元素不包含執行時期元素,因為 J2EE 之類的標準已定義應用程式執行時期程式庫的位置。
- Theimport元素 (element)
- requires 元素不包含匯出屬性,因為建議 J2EE 模組自行包含,以改善可管理性。 除了刪除匯出屬性之外,比對屬性還具有大於或等於的選項,以符合版本 (greaterOrEqual)。
- Theextension-point元素 (element)
- 延伸點元素的 name 屬性是選用的,因為它在這個 J2EE 實作中沒有實際用途。
您可以在 Eclipse 說明文件中,在 Platform Plug-In Developer Guide> 其他參照資訊> 外掛程式資訊清單下找到外掛程式資訊清單的相關詳細資料。
<?xml version="1.0"?>
<!--the plugin id is derived from the vendor domain name -->
<plugin
id="com.ibm.ws.console.core"
version="1.0.0"
provider-name="IBM WebSphere">
<!--declaration of prerequisite plugins-->
<requires>
<import plugin="com.ibm.data" version="2.0.1" match="compatible"/>
<import plugin="com.ibm.resources" version="3.0" match="exact"/>
</requires>
<!--declaration of link extension point -->
<extension-point
id="linkExtensionPoint"
schema="/schemas/linkSchema.xsd"/>
<!--declaration of an extension to the link extension point -->
<extension
point="com.ibm.ws.console.core.linkExtensionPoint"
id="linkExtension">
<link
label="Example.displayName"
actionView="com.ibm.ws.console.servermanagement.forwardCmd.do?
forwardName=example.config.view&
lastPage=ApplicationServer.config.view">
</link>
</extension>
</plugin>