org.springframework.roo.support.util
Class WebXmlUtils

java.lang.Object
  extended by org.springframework.roo.support.util.WebXmlUtils

public abstract class WebXmlUtils
extends Object

Helper util class to allow more convenient handling of web.xml file in Web projects.

Since:
1.1
Author:
Stefan Schmidt

Nested Class Summary
static class WebXmlUtils.FilterPosition
          Enum to define filter position
static class WebXmlUtils.WebXmlParam
          Value object used to hold init-param style information
 
Constructor Summary
WebXmlUtils()
           
 
Method Summary
static void addContextParam(WebXmlUtils.WebXmlParam contextParam, Document webXml, String comment)
          Add a context param to the web.xml document
static void addErrorCode(Integer errorCode, String location, Document webXml, String comment)
          Add error code to web.xml document
static void addExceptionType(String exceptionType, String location, Document webXml, String comment)
          Add exception type to web.xml document
static void addFilter(String filterName, String filterClass, String urlPattern, Document webXml, String comment, WebXmlUtils.WebXmlParam... initParams)
          Add a new filter definition to web.xml document.
static void addFilterAtPosition(WebXmlUtils.FilterPosition filterPosition, String afterFilterName, String beforeFilterName, String filterName, String filterClass, String urlPattern, Document webXml, String comment, WebXmlUtils.WebXmlParam... initParams)
          Add a new filter definition to web.xml document.
static void addListener(String className, Document webXml, String comment)
          Add listener element to web.xml document
static void addServlet(String servletName, String className, String urlPattern, Integer loadOnStartup, Document webXml, String comment, WebXmlUtils.WebXmlParam... initParams)
          Add servlet element to the web.xml document
static void addWelcomeFile(String path, Document webXml, String comment)
          Add a welcome file definition to web.xml document
static void setDescription(String description, Document webXml, String comment)
          Set the description element in the web.xml document.
static void setDisplayName(String displayName, Document webXml, String comment)
          Set the displayname element in the web.xml document.
static void setSessionTimeout(Integer timeout, Document webXml, String comment)
          Set session timeout in web.xml document
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebXmlUtils

public WebXmlUtils()
Method Detail

setDisplayName

public static void setDisplayName(String displayName,
                                  Document webXml,
                                  String comment)
Set the displayname element in the web.xml document.

Parameters:
displayName - (required)
webXml - the web.xml document (required)
comment - (optional)

setDescription

public static void setDescription(String description,
                                  Document webXml,
                                  String comment)
Set the description element in the web.xml document.

Parameters:
description - (required)
webXml - the web.xml document (required)
comment - (optional)

addContextParam

public static void addContextParam(WebXmlUtils.WebXmlParam contextParam,
                                   Document webXml,
                                   String comment)
Add a context param to the web.xml document

Parameters:
contextParam - (required)
webXml - the web.xml document (required)
comment - (optional)

addFilter

public static void addFilter(String filterName,
                             String filterClass,
                             String urlPattern,
                             Document webXml,
                             String comment,
                             WebXmlUtils.WebXmlParam... initParams)
Add a new filter definition to web.xml document. The filter will be added AFTER (FilterPosition.LAST) all existing filters.

Parameters:
filterPosition - Filter position (required)
filterPositionFilterName - (optional for filter position FIRST and LAST, required for BEFORE and AFTER)
filterName - (required)
filterClass - the fully qualified name of the filter type (required)
urlPattern - (required)
webXml - the web.xml document (required)
comment - (optional)
initParams - (optional)

addFilterAtPosition

public static void addFilterAtPosition(WebXmlUtils.FilterPosition filterPosition,
                                       String afterFilterName,
                                       String beforeFilterName,
                                       String filterName,
                                       String filterClass,
                                       String urlPattern,
                                       Document webXml,
                                       String comment,
                                       WebXmlUtils.WebXmlParam... initParams)
Add a new filter definition to web.xml document. The filter will be added at the FilterPosition specified.

Parameters:
filterPosition - Filter position (required)
beforeFilterName - (optional for filter position FIRST and LAST, required for BEFORE and AFTER)
filterName - (required)
filterClass - the fully qualified name of the filter type (required)
urlPattern - (required)
webXml - the web.xml document (required)
comment - (optional)
initParams - (optional)

addListener

public static void addListener(String className,
                               Document webXml,
                               String comment)
Add listener element to web.xml document

Parameters:
className - the fully qualified name of the listener type (required)
webXml - (required)
comment - (optional)

addServlet

public static void addServlet(String servletName,
                              String className,
                              String urlPattern,
                              Integer loadOnStartup,
                              Document webXml,
                              String comment,
                              WebXmlUtils.WebXmlParam... initParams)
Add servlet element to the web.xml document

Parameters:
servletName - (required)
className - the fully qualified name of the servlet type (required)
urlPattern - this can be set to null in which case the servletName will be used for mapping (optional)
loadOnStartup - (optional)
webXml - (required)
comment - (optional)
initParams - (optional)

setSessionTimeout

public static void setSessionTimeout(Integer timeout,
                                     Document webXml,
                                     String comment)
Set session timeout in web.xml document

Parameters:
timeout - (required)
webXml - (required)
comment - (optional)

addWelcomeFile

public static void addWelcomeFile(String path,
                                  Document webXml,
                                  String comment)
Add a welcome file definition to web.xml document

Parameters:
path - (required)
webXml - (required)
comment - (optional)

addExceptionType

public static void addExceptionType(String exceptionType,
                                    String location,
                                    Document webXml,
                                    String comment)
Add exception type to web.xml document

Parameters:
exceptionType - fully qualified exception type name (required)
location - (required)
webXml - (required)
comment - (optional)

addErrorCode

public static void addErrorCode(Integer errorCode,
                                String location,
                                Document webXml,
                                String comment)
Add error code to web.xml document

Parameters:
errorCode - (required)
location - (required)
webXml - (required)
comment - (optional)


Copyright © 2009-2010 VMware, Inc. All Rights Reserved.