Skip to content

Webapp Configuration

Ryan Heaton edited this page Sep 17, 2015 · 2 revisions

Note: The following is only applicable to Enunciate 1.x. Enunciate 2 no longer deals with deployment descriptors or building a war.

Webapp Configuration

This webapp configuration element is used to customize the way the application is compiled, built, and assembled. It provides hooks for customizing the web.xml file, for customizing the classes and resources that get included into the web application, and for adding additional files and resources to the application.

The webapp configuration element supports the following attributes:

attribute description
disabled The disabled attribute can be used to disable the Enunciate application assembly. The default value is false
dir The dir attribute specifies the directory into which to build the web application. The default value is a temporary directory.
war The war attribute specifies the war file that will be created. The default value is a temporary file.
doCompile The doCompile attribute specifies whether Enunciate should take on the responsibility of compiling the server-side classes. This may not be desired if Enunciate is being used only for generating the war structure and configuration files. The default is true except for Maven users, for whom the default is false.
doLibCopy The doLibCopy attribute specifies Whether Enunciate should take on the responsibility of copying libraries to WEB-INF/lib. This may not be desired if the Enunciate is being used only for generating the war structure and configuration files. The default is true except for Maven users, for whom the default is false.
doPackage The doPackage attribute specifies whether Enunciate should take on the responsibility of packaging (zipping) up the war. This may not be desired if Enunicate is being used only for generating the war structure and configuration files. The default is true except for Maven users, for whom the default is false.
webXMLTransform The webXMLTransform attribute specifies the XSLT tranform file that the web.xml file will pass through before being copied to the WEB-INF directory. No tranformation will be applied if none is specified.
webXMLTransformURL The webXMLTransformURL attribute specifies the URL to an XSLT tranform that the web.xml file will pass through before being copied to the WEB-INF directory. No tranformation will be applied if none is specified.
mergeWebXML The mergeWebXML attribute specifies the web.xml file that is to be merged into the Enunciate-generated web.xml file. No file will be merged if none is specified.
mergeWebXMLURL The mergeWebXMLURL attribute specifies the URL to a web.xml file that is to be merged into the Enunciate-generated web.xml file. No file will be merged if none is specified.
preBase The preBase attribute specifies a directory (could be gzipped) that supplies a base for the war. The directory contents will be copied to the building war directory before it is provided with any Enunciate-specific files and directories.
postBase The postBase attribute specifies a directory (could be gzipped) that supplies a base for the war. The directory contents will be copied to the building war directory after it is provided with any Enunciate-specific files and directories.
includeClasspathLibs The includeClasspathLibs attribute specifies whether Enunciate will use the libraries from the classpath for applying the include/exclude filters. If false only the libs explicitly included by file (see below) will be filtered.
excludeDefaultLibs The excludeDefaultLibs attribute specifies whether Enunciate should perform its default filtering of known compile-time-only jars.

Including/Excluding Jars from the War

Note: the following doesn't really apply for Maven users, since the war is put together using the standard Maven WAR plugin.

By default, the war is constructed by copying jars that are on the Enunciate classpath to its "lib" directory (the contents of directories on the classpath will be copied to the "classes" directory). You add a specific file to this list with the "file" attribute of the "includeLibs" element of the "war" element.

Once the initial list of jars to be potentially copied is created, it is passed through an "include" filter that you may specify with nested "includeLibs" elements. For each of these elements, you can specify a set of files to include with the "pattern" attribute. This is an ant-style pattern matcher against the absolute path of the file (or directory). By default, all files are included.

Once the initial list is passed through the "include" filter, it will be passed through an "exclude" filter. There is a set of known jars that by default will not be copied to the "lib" directory. These include the jars that ship by default with the JDK and the jars that are known to be build-time-only jars for Enunciate. You can disable the default filter with the "excludeDefaultLibs" attribute of the "war" element. You can also specify additional jars that are to be excluded with an arbitrary number of "excludeLibs" child elements under the "war" element in the configuration file. The "excludeLibs" element supports either a "pattern" attribute or a "file" attribute. The "pattern" attribute is an ant-style pattern matcher against the absolute path of the file (or directory) on the classpath that should not be copied to the destination war. The "file" attribute refers to a specific file on the filesystem (relative paths are resolved relative to the configuration file). Furthermore, the "excludeLibs" element supports a "includeInManifest" attribute specifying whether the exclude should be listed in the "Class-Path" attribute of the manifest, even though they are excluded in the war. The is useful if, for example, you're assembling an "ear" with multiple war files. By default, excluded jars are not included in the manifest.

You can customize the manifest for the war by the "manifest" element of the "war" element. Underneath the "manifest" element can be an arbitrary number of "attribute" elements that can be used to specify the manifest attributes. Each "attribute" element supports a "name" attribute, a "value" attribute, and a "section" attribute. If no section is specified, the default section is assumed. If there is no "Class-Path" attribute in the main section, one will be provided listing the jars on the classpath.

Webapp Configuration Elements

globalServletFilter

The "globalServletFilter" element is used to specify a servlet filter that will be applied to all web service requests. It requires a "name" attribute and a "classname" attribute and supports an arbitrary number of "init-param" child elements, each supporting a "name" attribute and a "value" attribute.

resources

The "resources" element is used to specify a pattern of resources to copy to the compile directory. It supports the following attributes:

attribute description
dir The dir attribute specifies the base directory of the resources to copy.
pattern The pattern attribute specifies an Ant-style pattern used to find the resources to copy.

Example Configuration

<enunciate ...>
  ...
  <webapp disabled="[true|false] dir="..." war="..."
    doCompile="..." doLibCopy="..." doPackage="..."
    webXMLTransform="..." webXMLTransformURL="..."
    mergeWebXML="..." mergeWebXMLURL="..."
    preBase="..." postBase="..."
    includeClasspathLibs="[true|false]" excludeDefaultLibs="[true|false]">

    <globalServletFilter name="..." classname="...">
      <init-param name="..." value="..."/>
    </globalServletFilter>
    <globalServletFilter name="..." classname="...">
      <init-param name="..." value="..."/>
    </globalServletFilter>
    ...

    <resources dir="..." pattern="..."/>
    <resources dir="..." pattern="..."/>
    ...

    <includeLibs pattern="..." file="..."/>
    <includeLibs pattern="..." file="..."/>
    ...

    <excludeLibs pattern="..." file="..."/>
    <excludeLibs pattern="..." file="..."/>
    ...

    <resource-env-ref name="..." type="..."/>
    <resource-env-ref name="..." type="..."/>
    ...

    <resource-ref name="..." type="..." auth="..."/>
    <resource-ref name="..." type="..." auth="..."/>
    ...

    <env name="..." type="..." value="..."/>
    <env name="..." type="..." value="..."/>
    ...

    <manifest>
      <attribute name="..." value="..."/>
      <attribute section="..." name="..." value="..."/>
      ...
    </manifest>
  </webapp>
  ...
</enunciate>
Clone this wiki locally