[16.0.0.3 以及更新版本]

配置應用程式端點

WAB 配置檔用來配置「Web 應用程式軟體組 (WAB)」。 如果要配置 WAB,必須將一個 WABConfiguration 登錄為一項 OSGI 服務。 WABConfiguration 是一個沒有方法的標記介面。 WAB 的配置由 WABConfiguration OSGi 服務登錄利用 contextNamecontextPath 服務內容來指定。

關於這項作業

WAB 利用 OSGi 軟體組資訊清單標頭 Web-ContextPath 來指定環境定義路徑。 如果要指定 WAB 有可配置的環境定義路徑,Web-ContextPath 標頭值的開頭必須是 @ 字元,起始 @ 字元之後的其餘內容用來作為 contextName。 下列範例說明含有可配置環境定義路徑的 WAB:
Web-ContextPath: @myWABContextPath

程序

  1. 利用 contextNamemyWABContextPath 來配置環境定義路徑,以登錄一項 WABConfiguration 服務。 您可以使用宣告式服務元件。
    @Component(
     configurationPid = "my.wab.configuration",
     configurationPolicy = ConfigurationPolicy.REQUIRE)
     public class MyWABConfiguration implements WABConfiguration {
     	 // Only used to set "contextPath" and "contextName" service
    	 // properties from configuration admin using the pid
    	 // my.wab.configuration
     }
  2. metatype.xml 檔所包含的下列 XML 定義服務元件的配置選項。
    <metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.1.0"
                       xmlns:ibm="http://www.ibm.com/xmlns/appservers/osgi/metatype/v1.0.0"
                       localization="OSGI-INF/l10n/metatype">
     
        <OCD description="My WAB Configuration" name="My WAB Configuration"
             id="my.wab.configuration" ibm:alias="myWAB">
     
            <AD name="Context Path" description="The Context Path"
                id="contextPath" required="true" type="String" default="/default/path" />
            <AD name="internal" description="internal"
                id="contextName" ibm:final="true" type="String" default="myWABContextPath" />
        </OCD>
        
        <Designate pid="my.wab.configuration">
            <Object ocdref="my.wab.configuration"/>
        </Designate>
     </metatype:MetaData>
    這個 meta 類型指定 contextNamecontextPath 內容兩者的預設值。 如果未指定任何其他配置,會利用預設值來配置 WAB 環境定義路徑。
    註: ID 為 contextName<AD> 元素,名稱為 internal,且含有 ibm:final。 如此便能夠指定服務元件的預設值,但不讓您置換 server.xml 配置中的預設值。 之後,可以利用下列 server.xml 配置元素來配置 WAB 環境定義路徑:
    <usr_myWAB contextPath="/myWab/path"/>

    如果將含有 WABCconfiguration 元件的軟體組安裝為一項 usr 特性,usr_ 字首是必要的。 如果軟體組是與產品延伸一起安裝,字首便是產品名稱,後面接著 _ 字元。 如需產品延伸的相關資訊,請參閱產品延伸


指示主題類型的圖示 作業主題

檔名:twlp_config_app_endpoint.html