Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cactus.integration.ant.deployment.webapp
Class WebXml

    java.lang.Object
      org.apache.cactus.integration.ant.deployment.webapp.WebXml

public class WebXml
extends java.lang.Object

Encapsulates the DOM representation of a web deployment descriptor `web.xml` to provide convenience methods for easy access and manipulation.

Since:
  Cactus 1.5
Version:
  $Id: WebXml.java 239137 2005-02-10 19:51:34Z vmassol $

Constructor Summary
`WebXml(org.w3c.dom.Document theDocument)` Constructor.

Method Summary
`void` | `addContextParam(org.w3c.dom.Element theContextParam)` Adds a new context-param element to the descriptor.
`void` | `addElement(WebXmlTag theTag, org.w3c.dom.Element theElement)` Adds an element of the specified tag to the descriptor.
`void` | `addFilter(org.w3c.dom.Element theFilter)` Adds a new servlet filter to the descriptor.
`void` | `addFilter(java.lang.String theFilterName, java.lang.String theFilterClass)` Adds a new servlet filter to the descriptor.
`void` | `addFilterInitParam(java.lang.String theFilterName, java.lang.String theParamName, java.lang.String theParamValue)` Adds an initialization parameter to the specified filter.
`void` | `addFilterMapping(java.lang.String theFilterName, java.lang.String theUrlPattern)` Adds a filter mapping to the descriptor.
`void` | `addJspFile(java.lang.String theServletName, java.lang.String theJspFile)` Adds a mapped JSP file to the descriptor.
`void` | `addSecurityConstraint(java.lang.String theWebResourceName, java.lang.String theUrlPattern, java.util.List theRoles)` Creates and adds a security-constraint to the descriptor.
`void` | `addSecurityRole(java.lang.String theRoleName)` Adds a new security role to the descriptor.
`void` | `addServlet(org.w3c.dom.Element theServlet)` Adds a new servlet to the descriptor.
`void` | `addServlet(java.lang.String theServletName, java.lang.String theServletClass)` Adds a new servlet to the descriptor.
`void` | `addServletInitParam(java.lang.String theServletName, java.lang.String theParamName, java.lang.String theParamValue)` Adds an initialization parameter to the specified servlet.
`void` | `addServletMapping(java.lang.String theServletName, java.lang.String theUrlPattern)` Adds a servlet mapping to the descriptor.
`void` | `addServletRunAsRoleName(java.lang.String theServletName, java.lang.String theRoleName)` Adds a run-as declaration to the specified servlet.
`org.w3c.dom.Element` | `getContextParam(java.lang.String theParamName)` Returns the element that contains the definition of a specific context param, or `null` if a context param of the specified name is not defined in the descriptor.
`java.lang.String` | `getContextParamName(org.w3c.dom.Element theContextParam)`
`org.w3c.dom.Document` | `getDocument()` Returns the DOM document representing the deployment descriptor.
`java.util.Iterator` | `getElements(WebXmlTag theTag)` Returns an iterator over the elements that match the specified tag.
`org.w3c.dom.Element` | `getFilter(java.lang.String theFilterName)` Returns the element that contains the definition of a specific servlet filter, or `null` if a filter of the specified name is not defined in the descriptor.
`java.lang.String` | `getFilterInitParam(java.lang.String theFilterName, java.lang.String theParamName)` Returns the value of an initialization parameter of the specified filter.
`java.util.Iterator` | `getFilterInitParamNames(java.lang.String theFilterName)` Returns the names of the initialization parameters of the specified servlet filter.
`java.util.Iterator` | `getFilterMappings(java.lang.String theFilterName)` Returns the URL-patterns that the specified filter is mapped to in an ordered list.
`java.util.Iterator` | `getFilterNames()` Returns the names of all filters defined in the deployment descriptor.
`java.util.Iterator` | `getFilterNamesForClass(java.lang.String theClassName)` Returns a list of names of filters that are mapped to the specified class.
`org.w3c.dom.Element` | `getLoginConfig()` Returns whether the descriptor has a login configuration.
`java.lang.String` | `getLoginConfigAuthMethod()` Returns the authorization method defined by the login configuration.
`org.w3c.dom.Element` | `getSecurityConstraint(java.lang.String theUrlPattern)` Returns the element that contains the security constraint defined for the specified URL pattern.
`org.w3c.dom.Element` | `getSecurityRole(java.lang.String theRoleName)` Returns the element that contains the specified security role, or `null` if the role is not defined in the descriptor.
`java.util.Iterator` | `getSecurityRoleNames()` Returns a list of the security role names defined in the deployment descriptor
`org.w3c.dom.Element` | `getServlet(java.lang.String theServletName)` Returns the element that contains the definition of a specific servlet, or `null` if a servlet of the specified name is not defined in the descriptor.
`java.lang.String` | `getServletInitParam(java.lang.String theServletName, java.lang.String theParamName)` Returns the value of an initialization parameter of the specified servlet.
`java.util.Iterator` | `getServletInitParamNames(java.lang.String theServletName)` Returns the names of the initialization parameters of the specified servlet.
`java.util.Iterator` | `getServletMappings(java.lang.String theServletName)` Returns the URL-patterns that the specified servlet is mapped to in an ordered list.
`java.util.Iterator` | `getServletNames()` Returns the names of all servlets defined in the deployment descriptor.
`java.util.Iterator` | `getServletNamesForClass(java.lang.String theClassName)` Returns a list of names of servlets that are mapped to the specified class.
`java.util.Iterator` | `getServletNamesForJspFile(java.lang.String theJspFile)` Returns a list of names of servlets that are mapped to the specified JSP file.
`java.lang.String` | `getServletRunAsRoleName(java.lang.String theServletName)` Returns the role name that the servlet is running as.
`WebXmlVersion` | `getVersion()` Returns the servlet API version.
`boolean` | `hasContextParam(java.lang.String theParamName)` Returns whether a context param by the specified name is defined in the deployment descriptor.
`boolean` | `hasFilter(java.lang.String theFilterName)` Returns whether a servlet filter by the specified name is defined in the deployment descriptor.
`boolean` | `hasLoginConfig()` Returns whether the descriptor has a login configuration.
`boolean` | `hasSecurityConstraint(java.lang.String theUrlPattern)` Returns whether a security constraint has been mapped to the specified URL pattern.
`boolean` | `hasSecurityRole(java.lang.String theRoleName)` Returns whether a specific security role has been defined.
`boolean` | `hasServlet(java.lang.String theServletName)` Returns whether a servlet by the specified name is defined in the deployment descriptor.
`void` | `replaceElement(WebXmlTag theTag, org.w3c.dom.Element theElement)` Replaces all elements of the specified tag with the provided element.
`void` | `setLoginConfig(java.lang.String theAuthMethod, java.lang.String theRealmName)` Sets the login configuration.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### WebXml

    public WebXml(org.w3c.dom.Document theDocument)

  Constructor.

Parameters:
  `theDocument` - The DOM document representing the parsed deployment descriptor

Method Detail

### getDocument

    public final org.w3c.dom.Document getDocument()

  Returns the DOM document representing the deployment descriptor. The document will contain any modifications made through this instance.

  Returns:
    The document representing the deploy descriptor

### getVersion

    public final WebXmlVersion getVersion()

  Returns the servlet API version.

  Returns:
    The version

### addFilter

    public final void addFilter(java.lang.String theFilterName,
                                java.lang.String theFilterClass)

  Adds a new servlet filter to the descriptor.

  Parameters:
    `theFilterName` - The name of the filter to add
    `theFilterClass` - The name of the class implementing the filter

### addContextParam

    public final void addContextParam(org.w3c.dom.Element theContextParam)

  Adds a new context-param element to the descriptor.

  Parameters:
    `theContextParam` - The element representing the context-param definition

### addFilter

    public final void addFilter(org.w3c.dom.Element theFilter)

  Adds a new servlet filter to the descriptor.

  Parameters:
    `theFilter` - The element representing the filter definition

### addFilterInitParam

    public final void addFilterInitParam(java.lang.String theFilterName,
                                         java.lang.String theParamName,
                                         java.lang.String theParamValue)

  Adds an initialization parameter to the specified filter.

  Parameters:
    `theFilterName` - The name of the filter
    `theParamName` - The name of the parameter
    `theParamValue` - The parameter value

### addFilterMapping

    public final void addFilterMapping(java.lang.String theFilterName,
                                       java.lang.String theUrlPattern)

  Adds a filter mapping to the descriptor.

  Parameters:
    `theFilterName` - The name of the filter
    `theUrlPattern` - The URL pattern the filter should be mapped to

### getFilter

    public final org.w3c.dom.Element getFilter(java.lang.String theFilterName)

  Returns the element that contains the definition of a specific servlet filter, or `null` if a filter of the specified name is not defined in the descriptor.

  Parameters:
    `theFilterName` - The name of the servlet filter
  Returns:
    The DOM element representing the filter definition

### getContextParam

    public final org.w3c.dom.Element getContextParam(java.lang.String theParamName)

  Returns the element that contains the definition of a specific context param, or `null` if a context param of the specified name is not defined in the descriptor.

  Parameters:
    `theParamName` - The context param name
  Returns:
    The DOM element representing the context param definition

### getContextParamName

    public final java.lang.String getContextParamName(org.w3c.dom.Element theContextParam)

  Parameters:
    `theContextParam` - the context param element from which to extract the name
  Returns:
    the name of the passed context param element

### getFilterNamesForClass

    public final java.util.Iterator getFilterNamesForClass(java.lang.String theClassName)

  Returns a list of names of filters that are mapped to the specified class.

  Parameters:
    `theClassName` - The fully qualified name of the filter class
  Returns:
    An iterator over the names of the filters mapped to the class

### getFilterInitParam

    public final java.lang.String getFilterInitParam(java.lang.String theFilterName,
                                                     java.lang.String theParamName)

  Returns the value of an initialization parameter of the specified filter.

  Parameters:
    `theFilterName` - The name of the servlet filter
    `theParamName` - The name of the initialization parameter
  Returns:
    The parameter value

### getFilterInitParamNames

    public final java.util.Iterator getFilterInitParamNames(java.lang.String theFilterName)

  Returns the names of the initialization parameters of the specified servlet filter.

  Parameters:
    `theFilterName` - The name of the servlet filter of which the parameter names should be retrieved
  Returns:
    An iterator over the ordered list of parameter names

### getFilterMappings

    public final java.util.Iterator getFilterMappings(java.lang.String theFilterName)

  Returns the URL-patterns that the specified filter is mapped to in an ordered list. If there are no mappings for the specified filter, an iterator over an empty list is returned.

  Parameters:
    `theFilterName` - The name of the servlet filter of which the mappings should be retrieved
  Returns:
    An iterator over the ordered list of URL-patterns

### getFilterNames

    public final java.util.Iterator getFilterNames()

  Returns the names of all filters defined in the deployment descriptor. The names are returned as an iterator over an ordered list.

  Returns:
    The filter names

### hasContextParam

    public final boolean hasContextParam(java.lang.String theParamName)

  Returns whether a context param by the specified name is defined in the deployment descriptor.

  Parameters:
    `theParamName` - The name of the context param
  Returns:
    `true` if the context param is defined, `false` otherwise

### hasFilter

    public final boolean hasFilter(java.lang.String theFilterName)

  Returns whether a servlet filter by the specified name is defined in the deployment descriptor.

  Parameters:
    `theFilterName` - The name of the filter
  Returns:
    `true` if the filter is defined, `false` otherwise

### addJspFile

    public final void addJspFile(java.lang.String theServletName,
                                 java.lang.String theJspFile)

  Adds a mapped JSP file to the descriptor.

  Parameters:
    `theServletName` - The name of the servlet to add
    `theJspFile` - The path to the JSP file relative to the root of the web application

### addServlet

    public final void addServlet(java.lang.String theServletName,
                                 java.lang.String theServletClass)

  Adds a new servlet to the descriptor.

  Parameters:
    `theServletName` - The name of the servlet to add
    `theServletClass` - The name of the class implementing the servlet

### addServlet

    public final void addServlet(org.w3c.dom.Element theServlet)

  Adds a new servlet to the descriptor.

  Parameters:
    `theServlet` - The element representing the servlet definition

### addServletInitParam

    public final void addServletInitParam(java.lang.String theServletName,
                                          java.lang.String theParamName,
                                          java.lang.String theParamValue)

  Adds an initialization parameter to the specified servlet.

  Parameters:
    `theServletName` - The name of the filter
    `theParamName` - The name of the parameter
    `theParamValue` - The parameter value

### addServletRunAsRoleName

    public final void addServletRunAsRoleName(java.lang.String theServletName,
                                              java.lang.String theRoleName)

  Adds a run-as declaration to the specified servlet.

  Parameters:
    `theServletName` - the name of the servlet to manipulate
    `theRoleName` - the role name that the servlet should be running as

### addServletMapping

    public final void addServletMapping(java.lang.String theServletName,
                                        java.lang.String theUrlPattern)

  Adds a servlet mapping to the descriptor.

  Parameters:
    `theServletName` - The name of the servlet
    `theUrlPattern` - The URL pattern the servlet should be mapped to

### getServlet

    public final org.w3c.dom.Element getServlet(java.lang.String theServletName)

  Returns the element that contains the definition of a specific servlet, or `null` if a servlet of the specified name is not defined in the descriptor.

  Parameters:
    `theServletName` - The name of the servlet
  Returns:
    The DOM element representing the servlet definition

### getServletInitParam

    public final java.lang.String getServletInitParam(java.lang.String theServletName,
                                                      java.lang.String theParamName)

  Returns the value of an initialization parameter of the specified servlet.

  Parameters:
    `theServletName` - The name of the servlet
    `theParamName` - The name of the initialization parameter
  Returns:
    The parameter value

### getServletInitParamNames

    public final java.util.Iterator getServletInitParamNames(java.lang.String theServletName)

  Returns the names of the initialization parameters of the specified servlet.

  Parameters:
    `theServletName` - The name of the servlet of which the parameter names should be retrieved
  Returns:
    An iterator over the ordered list of parameter names

### getServletRunAsRoleName

    public final java.lang.String getServletRunAsRoleName(java.lang.String theServletName)

  Returns the role name that the servlet is running as.

  Parameters:
    `theServletName` - The name of the servlet of which the role name should be retrieved
  Returns:
    the roleName or null if non is specified

### getServletMappings

    public final java.util.Iterator getServletMappings(java.lang.String theServletName)

  Returns the URL-patterns that the specified servlet is mapped to in an ordered list. If there are no mappings for the specified servlet, an iterator over an empty list is returned.

  Parameters:
    `theServletName` - The name of the servlet of which the mappings should be retrieved
  Returns:
    An iterator over the ordered list of URL-patterns

### getServletNames

    public final java.util.Iterator getServletNames()

  Returns the names of all servlets defined in the deployment descriptor. The names are returned as an iterator over an ordered list.

  Returns:
    The servlet names

### getServletNamesForClass

    public final java.util.Iterator getServletNamesForClass(java.lang.String theClassName)

  Returns a list of names of servlets that are mapped to the specified class.

  Parameters:
    `theClassName` - The fully qualified name of the servlet class
  Returns:
    An iterator over the names of the servlets mapped to the class

### getServletNamesForJspFile

    public final java.util.Iterator getServletNamesForJspFile(java.lang.String theJspFile)

  Returns a list of names of servlets that are mapped to the specified JSP file.

  Parameters:
    `theJspFile` - The path to the JSP file, relative to the root of the web-application
  Returns:
    An iterator over the names of the servlets mapped to the JSP file

### hasServlet

    public final boolean hasServlet(java.lang.String theServletName)

  Returns whether a servlet by the specified name is defined in the deployment descriptor.

  Parameters:
    `theServletName` - The name of the servlet
  Returns:
    `true` if the servlet is defined, `false` otherwise

### addSecurityConstraint

    public final void addSecurityConstraint(java.lang.String theWebResourceName,
                                            java.lang.String theUrlPattern,
                                            java.util.List theRoles)

  Creates and adds a security-constraint to the descriptor.

  Parameters:
    `theWebResourceName` - The name of the web resource collection to protect
    `theUrlPattern` - The URL pattern to apply the constraint to
    `theRoles` - The list of authorized roles

### getSecurityConstraint

    public final org.w3c.dom.Element getSecurityConstraint(java.lang.String theUrlPattern)

  Returns the element that contains the security constraint defined for the specified URL pattern.

  Parameters:
    `theUrlPattern` - The URL pattern
  Returns:
    The DOM element representing the security constraint

### hasSecurityConstraint

    public final boolean hasSecurityConstraint(java.lang.String theUrlPattern)

  Returns whether a security constraint has been mapped to the specified URL pattern.

  Parameters:
    `theUrlPattern` - The URL patterm
  Returns:
    `true` if a security constraint is defined, `false` otherwise

### hasLoginConfig

    public final boolean hasLoginConfig()

  Returns whether the descriptor has a login configuration.

  Returns:
    `true` if a login config is defined, `false` otherwise

### getLoginConfig

    public final org.w3c.dom.Element getLoginConfig()

  Returns whether the descriptor has a login configuration.

  Returns:
    `true` if a login config is defined, `false` otherwise

### getLoginConfigAuthMethod

    public final java.lang.String getLoginConfigAuthMethod()

  Returns the authorization method defined by the login configuration.

  Returns:
    The authorization method

### setLoginConfig

    public final void setLoginConfig(java.lang.String theAuthMethod,
                                     java.lang.String theRealmName)

  Sets the login configuration.

  Parameters:
    `theAuthMethod` - The authentication method (for example, BASIC)
    `theRealmName` - The name of the realm

### addSecurityRole

    public final void addSecurityRole(java.lang.String theRoleName)

  Adds a new security role to the descriptor.

  Parameters:
    `theRoleName` - The name of the role to add

### getSecurityRole

    public final org.w3c.dom.Element getSecurityRole(java.lang.String theRoleName)

  Returns the element that contains the specified security role, or `null` if the role is not defined in the descriptor.

  Parameters:
    `theRoleName` - The name of the role
  Returns:
    The DOM element representing the security role

### getSecurityRoleNames

    public final java.util.Iterator getSecurityRoleNames()

  Returns a list of the security role names defined in the deployment descriptor

  Returns:
    An iterator over the list of security role names, or an empty iterator if no security roles are defined in the descriptor

### hasSecurityRole

    public final boolean hasSecurityRole(java.lang.String theRoleName)

  Returns whether a specific security role has been defined.

  Parameters:
    `theRoleName` - The name of the role
  Returns:
    `true` if the security role is defined, `false` otherwise

### getElements

    public final java.util.Iterator getElements(WebXmlTag theTag)

  Returns an iterator over the elements that match the specified tag.

  Parameters:
    `theTag` - The descriptor tag of which the elements should be returned
  Returns:
    An iterator over the elements matching the tag, in the order they occur in the descriptor

### addElement

    public final void addElement(WebXmlTag theTag,
                                 org.w3c.dom.Element theElement)

  Adds an element of the specified tag to the descriptor.

  Parameters:
    `theTag` - The descriptor tag
    `theElement` - The element to add

### replaceElement

    public final void replaceElement(WebXmlTag theTag,
                                     org.w3c.dom.Element theElement)

  Replaces all elements of the specified tag with the provided element.

  Parameters:
    `theTag` - The descriptor tag
    `theElement` - The element to replace the current elements with

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2004 Apache Software Foundation. All Rights Reserved.