org.springframework.shell.support.util
Class WebXmlUtils

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

public final class WebXmlUtils
extends Object

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

Since:
1.1

Nested Class Summary
static class WebXmlUtils.Dispatcher
          Enum to define dispatcher
static class WebXmlUtils.FilterPosition
          Enum to define filter position
static class WebXmlUtils.WebResourceCollection
          Convenience class for passing a web-resource-collection element's details
static class WebXmlUtils.WebXmlParam
          Value object that holds init-param style information
 
Method Summary
static void addContextParam(WebXmlUtils.WebXmlParam contextParam, Document document, String comment)
          Add a context param to the web.xml document
static void addErrorCode(Integer errorCode, String location, Document document, String comment)
          Add error code to web.xml document
static void addExceptionType(String exceptionType, String location, Document document, String comment)
          Add exception type to web.xml document
static void addFilter(String filterName, String filterClass, String urlPattern, Document document, 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 document, String comment, List<WebXmlUtils.WebXmlParam> initParams, List<WebXmlUtils.Dispatcher> dispatchers)
          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 document, String comment, WebXmlUtils.WebXmlParam... initParams)
          Add a new filter definition to web.xml document.
static void addListener(String className, Document document, String comment)
          Add listener element to web.xml document
static void addSecurityConstraint(String displayName, List<WebXmlUtils.WebResourceCollection> webResourceCollections, List<String> roleNames, String transportGuarantee, Document document, String comment)
          Add a security constraint to a web.xml document
static void addServlet(String servletName, String className, String urlPattern, Integer loadOnStartup, Document document, String comment, WebXmlUtils.WebXmlParam... initParams)
          Add servlet element to the web.xml document
static void addWelcomeFile(String path, Document document, String comment)
          Add a welcome file definition to web.xml document
static void setDescription(String description, Document document, String comment)
          Set the description element in the web.xml document.
static void setDisplayName(String displayName, Document document, String comment)
          Set the display-name element in the web.xml document.
static void setSessionTimeout(int timeout, Document document, 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
 

Method Detail

setDisplayName

public static void setDisplayName(String displayName,
                                  Document document,
                                  String comment)
Set the display-name element in the web.xml document.

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

setDescription

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

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

addContextParam

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

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

addFilter

public static void addFilter(String filterName,
                             String filterClass,
                             String urlPattern,
                             Document document,
                             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:
filterName - (required)
filterClass - the fully qualified name of the filter type (required)
urlPattern - (required)
document - the web.xml document (required)
comment - (optional)
initParams - a vararg of initial parameters (optional)

addFilterAtPosition

public static void addFilterAtPosition(WebXmlUtils.FilterPosition filterPosition,
                                       String afterFilterName,
                                       String beforeFilterName,
                                       String filterName,
                                       String filterClass,
                                       String urlPattern,
                                       Document document,
                                       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)
document - 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 document,
                                       String comment,
                                       List<WebXmlUtils.WebXmlParam> initParams,
                                       List<WebXmlUtils.Dispatcher> dispatchers)
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)
document - the web.xml document (required)
comment - (optional)
initParams - (optional)
dispatchers - (optional)

addListener

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

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

addServlet

public static void addServlet(String servletName,
                              String className,
                              String urlPattern,
                              Integer loadOnStartup,
                              Document document,
                              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)
document - (required)
comment - (optional)
initParams - (optional)

setSessionTimeout

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

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

addWelcomeFile

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

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

addExceptionType

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

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

addErrorCode

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

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

addSecurityConstraint

public static void addSecurityConstraint(String displayName,
                                         List<WebXmlUtils.WebResourceCollection> webResourceCollections,
                                         List<String> roleNames,
                                         String transportGuarantee,
                                         Document document,
                                         String comment)
Add a security constraint to a web.xml document

Parameters:
displayName - (optional)
webResourceCollections - (required)
roleNames - (optional)
transportGuarantee - (optional)
document - (required)
comment - (optional)