Configuring an application endpoint

A WAB Configuration file is used to configure a Web Application Bundle (WAB). To configure a WAB, a WABConfiguration must be registered as an OSGi service. The WABConfiguration is a marker interface that has no methods. Configuration for a WAB is specified by the WABConfiguration OSGi service registration by using the contextName and contextPath service properties.

About this task

A WAB specifies the context path by using the OSGi bundle manifest header Web-ContextPath. To specify that a WAB has a configurable context path, the Web-ContextPath header value must begin with the @ character and the remaining content after the initial @ character is used as the contextName. The following example illustrates a WAB with a configurable context path:
Web-ContextPath: @myWABContextPath

Procedure

  1. Register a WABConfiguration service by using the contextName value of myWABContextPath to configure the context path. You can use the declarative service component.
    @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. The following XML contained within the metatype.xml file defines the configuration options for the service component.
    <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>
    This metatype specifies the default values for both the contextName and contextPath properties. If you specify no additional configuration, then the default values are used to configure the WAB context path.
    Note: The <AD> element with the ID contextName has internal as the name and includes ibm:final. This allows the default to be specified for the service component but does not allow you to override the default in the server.xml configuration. The WAB context path can then be configured by using the following server.xml configuration element:
    <usr_myWAB contextPath="/myWab/path"/>

    The usr_ prefix is necessary if the bundle with the WABCconfiguration component is installed as a usr feature. If the bundle is installed with a product extension, the prefix is the product name followed by the _ character. For more information about product extensions, see Liberty:Product extension


Icon that indicates the type of topic Task topic



Timestamp icon Last updated: Monday, 5 December 2016
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=twlp_config_app_endpoint
File name: twlp_config_app_endpoint.html