public class WebXml extends AbstractDescriptor implements J2eeDescriptor
web.xml
to
provide convenience methods for easy access and manipulation.Modifier and Type | Method and Description |
---|---|
void |
addContextParam(Element contextParam)
Adds a new context-param element to the descriptor.
|
void |
addEjbRef(EjbRef ref)
Adds an ejb-ref.
|
void |
addFilter(Element filter)
Adds a new servlet filter to the descriptor.
|
void |
addFilter(String filterName,
String filterClass)
Adds a new servlet filter to the descriptor.
|
void |
addFilterInitParam(String filterName,
String paramName,
String paramValue)
Adds an initialization parameter to the specified filter.
|
void |
addFilterMapping(String filterName,
String urlPattern)
Adds a filter mapping to the descriptor.
|
void |
addJspFile(String theServletName,
String theJspFile)
Adds a mapped JSP file to the descriptor.
|
void |
addRootElement(DescriptorTag tag,
Element element)
Adds an element of the specified tag to root of the descriptor.
|
void |
addSecurityConstraint(String theWebResourceName,
String theUrlPattern,
List theRoles)
Creates and adds a security-constraint to the descriptor.
|
void |
addSecurityRole(String theRoleName)
Adds a new security role to the descriptor.
|
void |
addServlet(Element theServlet)
Adds a new servlet to the descriptor.
|
void |
addServlet(String theServletName,
String theServletClass)
Adds a new servlet to the descriptor.
|
void |
addServletInitParam(String theServletName,
String theParamName,
String theParamValue)
Adds an initialization parameter to the specified servlet.
|
void |
addServletMapping(String theServletName,
String theUrlPattern)
Adds a servlet mapping to the descriptor.
|
void |
addServletRunAsRoleName(String theServletName,
String theRoleName)
Adds a run-as declaration to the specified servlet.
|
void |
addVendorDescriptor(VendorWebAppDescriptor descr)
Associates a vendor specific descriptor with this web.xml.
|
Element |
getContextParam(String paramName)
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. |
String |
getContextParamName(Element contextParam) |
AbstractNodeList |
getContextParams()
Get the context parameters.
|
String |
getFileName()
Returns the file name of this descriptor.
|
Element |
getFilter(String filterName)
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. |
String |
getFilterInitParam(String filterName,
String paramName)
Returns the value of an initialization parameter of the specified filter.
|
Iterator |
getFilterInitParamNames(String theFilterName)
Returns the names of the initialization parameters of the specified servlet filter.
|
Iterator |
getFilterMappings(String theFilterName)
Returns the URL-patterns that the specified filter is mapped to in an ordered list.
|
Iterator |
getFilterNames()
Returns the names of all filters defined in the deployment descriptor.
|
Iterator |
getFilterNamesForClass(String className)
Returns a list of names of filters that are mapped to the specified class.
|
AbstractNodeList |
getListeners()
Returns a list of nodes that are of web listeners.
|
Element |
getLoginConfig()
Returns whether the descriptor has a login configuration.
|
String |
getLoginConfigAuthMethod()
Returns the authorization method defined by the login configuration.
|
Element |
getSecurityConstraint(String theUrlPattern)
Returns the element that contains the security constraint defined for the specified URL
pattern.
|
Element |
getSecurityRole(String theRoleName)
Returns the element that contains the specified security role, or
null if the
role is not defined in the descriptor. |
Iterator |
getSecurityRoleNames()
Returns a list of the security role names defined in the deployment descriptor.
|
Element |
getServlet(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. |
String |
getServletInitParam(String theServletName,
String theParamName)
Returns the value of an initialization parameter of the specified servlet.
|
Iterator |
getServletInitParamNames(String theServletName)
Returns the names of the initialization parameters of the specified servlet.
|
Iterator |
getServletMappings(String theServletName)
Returns the URL-patterns that the specified servlet is mapped to in an ordered list.
|
Iterator |
getServletNames()
Returns the names of all servlets defined in the deployment descriptor.
|
Iterator |
getServletNamesForClass(String theClassName)
Returns a list of names of servlets that are mapped to the specified class.
|
Iterator |
getServletNamesForJspFile(String theJspFile)
Returns a list of names of servlets that are mapped to the specified JSP file.
|
String |
getServletRunAsRoleName(String theServletName)
Returns the role name that the servlet is running as.
|
Iterator |
getVendorDescriptors()
Returns all vendor descriptors associated with this web.xml.
|
WebXmlVersion |
getVersion()
Returns the servlet API version.
|
boolean |
hasContextParam(String theParamName)
Returns whether a context param by the specified name is defined in the deployment
descriptor.
|
boolean |
hasFilter(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(String theUrlPattern)
Returns whether a security constraint has been mapped to the specified URL pattern.
|
boolean |
hasSecurityRole(String theRoleName)
Returns whether a specific security role has been defined.
|
boolean |
hasServlet(String theServletName)
Returns whether a servlet by the specified name is defined in the deployment descriptor.
|
void |
replaceRootElement(DescriptorTag tag,
Element element)
Replaces all elements of the specified tag with the provided element.
|
void |
setLoginConfig(String theAuthMethod,
String theRealmName)
Sets the login configuration.
|
addElement, checkElement, createNestedText, getChildText, getDocument, getElements, getImmediateChild, getInsertionPointFor, getNestedElements, getNestedText, getRootElement, getText, replaceElement
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDocument
public WebXml(Document document)
document
- The DOM document representing the parsed deployment descriptorpublic String getFileName()
getFileName
in interface Descriptor
Descriptor.getFileName()
public AbstractNodeList getContextParams()
public void addVendorDescriptor(VendorWebAppDescriptor descr)
descr
- the vendor specific dexcriptor to associatepublic Iterator getVendorDescriptors()
getVendorDescriptors
in interface J2eeDescriptor
public final WebXmlVersion getVersion()
public final void addFilter(String filterName, String filterClass)
filterName
- The name of the filter to addfilterClass
- The name of the class implementing the filterpublic final void addContextParam(Element contextParam)
contextParam
- The element representing the context-param definitionpublic final void addFilter(Element filter)
filter
- The element representing the filter definitionpublic final void addFilterInitParam(String filterName, String paramName, String paramValue)
filterName
- The name of the filterparamName
- The name of the parameterparamValue
- The parameter valuepublic final void addFilterMapping(String filterName, String urlPattern)
filterName
- The name of the filterurlPattern
- The URL pattern the filter should be mapped topublic final Element getFilter(String filterName)
null
if a filter of the specified name is not defined in the descriptor.filterName
- The name of the servlet filterpublic final Element getContextParam(String paramName)
null
if a context param of the specified name is not defined in the descriptor.paramName
- The context param namepublic final String getContextParamName(Element contextParam)
contextParam
- the context param element from which to extractthe namepublic final Iterator getFilterNamesForClass(String className)
className
- The fully qualified name of the filter classpublic final String getFilterInitParam(String filterName, String paramName)
filterName
- The name of the servlet filterparamName
- The name of the initialization parameterpublic final Iterator getFilterInitParamNames(String theFilterName)
theFilterName
- The name of the servlet filter of which the parameter names should be
retrievedpublic final Iterator getFilterMappings(String theFilterName)
theFilterName
- The name of the servlet filter of which the mappings should be
retrievedpublic final Iterator getFilterNames()
public final boolean hasContextParam(String theParamName)
theParamName
- The name of the context paramtrue
if the context param is defined, false
otherwisepublic final boolean hasFilter(String theFilterName)
theFilterName
- The name of the filtertrue
if the filter is defined, false
otherwisepublic final void addJspFile(String theServletName, String theJspFile)
theServletName
- The name of the servlet to addtheJspFile
- The path to the JSP file relative to the root of the web applicationpublic final void addServlet(String theServletName, String theServletClass)
theServletName
- The name of the servlet to addtheServletClass
- The name of the class implementing the servletpublic final void addServlet(Element theServlet)
theServlet
- The element representing the servlet definitionpublic final void addServletInitParam(String theServletName, String theParamName, String theParamValue)
theServletName
- The name of the filtertheParamName
- The name of the parametertheParamValue
- The parameter valuepublic final void addServletRunAsRoleName(String theServletName, String theRoleName)
theServletName
- the name of the servlet to manipulatetheRoleName
- the role name that the servlet should be running aspublic final void addServletMapping(String theServletName, String theUrlPattern)
theServletName
- The name of the servlettheUrlPattern
- The URL pattern the servlet should be mapped topublic final Element getServlet(String theServletName)
null
if a servlet of the specified name is not defined in the descriptor.theServletName
- The name of the servletpublic final String getServletInitParam(String theServletName, String theParamName)
theServletName
- The name of the servlettheParamName
- The name of the initialization parameterpublic final Iterator getServletInitParamNames(String theServletName)
theServletName
- The name of the servlet of which the parameter names should be
retrievedpublic final String getServletRunAsRoleName(String theServletName)
theServletName
- The name of the servlet of which the role name should be retrievedpublic final Iterator getServletMappings(String theServletName)
theServletName
- The name of the servlet of which the mappings should be retrievedpublic final Iterator getServletNames()
public final Iterator getServletNamesForClass(String theClassName)
theClassName
- The fully qualified name of the servlet classpublic final Iterator getServletNamesForJspFile(String theJspFile)
theJspFile
- The path to the JSP file, relative to the root of the web-applicationpublic final boolean hasServlet(String theServletName)
theServletName
- The name of the servlettrue
if the servlet is defined, false
otherwisepublic final void addSecurityConstraint(String theWebResourceName, String theUrlPattern, List theRoles)
theWebResourceName
- The name of the web resource collection to protecttheUrlPattern
- The URL pattern to apply the constraint totheRoles
- The list of authorized rolespublic final Element getSecurityConstraint(String theUrlPattern)
theUrlPattern
- The URL patternpublic final boolean hasSecurityConstraint(String theUrlPattern)
theUrlPattern
- The URL pattermtrue
if a security constraint is defined, false
otherwisepublic final boolean hasLoginConfig()
true
if a login config is defined, false
otherwisepublic final Element getLoginConfig()
true
if a login config is defined, false
otherwisepublic final String getLoginConfigAuthMethod()
public final void setLoginConfig(String theAuthMethod, String theRealmName)
theAuthMethod
- The authentication method (for example, BASIC)theRealmName
- The name of the realmpublic final void addSecurityRole(String theRoleName)
theRoleName
- The name of the role to addpublic final Element getSecurityRole(String theRoleName)
null
if the
role is not defined in the descriptor.theRoleName
- The name of the rolepublic final Iterator getSecurityRoleNames()
public final boolean hasSecurityRole(String theRoleName)
theRoleName
- The name of the roletrue
if the security role is defined, false
otherwisepublic final void addRootElement(DescriptorTag tag, Element element)
tag
- The descriptor tagelement
- The element to addpublic final void replaceRootElement(DescriptorTag tag, Element element)
tag
- The descriptor tagelement
- The element to replace the current elements withpublic void addEjbRef(EjbRef ref)
ref
- the ejb-refpublic AbstractNodeList getListeners()
Copyright © 2004-2013 Codehaus. All Rights Reserved.