public final class WebXmlUtils extends Object
Modifier and Type | Method and Description |
---|---|
static void |
addContextParam(WebXml webXml,
String name,
String value)
Adds a new context-param element to the descriptor.
|
static void |
addEjbRef(WebXml webXml,
EjbRef ref)
Add an EJB Reference.
|
static void |
addFilter(WebXml webXml,
Filter filter) |
static void |
addFilter(WebXml webXml,
String filterName,
String filterClass)
Add a filter to the descriptor.
|
static void |
addFilterInitParam(WebXml webXml,
String name,
String paramName,
String paramValue)
Add an init param to a filter.
|
static void |
addFilterMapping(WebXml webXml,
FilterMapping rhs) |
static void |
addJspFile(WebXml webXml,
String theServletName,
String theJspFile)
Add a JSP file.
|
static void |
addSecurityConstraint(WebXml webXml,
String theWebResourceName,
String theUrlPattern,
List theRoles)
Add a security constraint.
|
static void |
addSecurityRole(WebXml webXml,
String theRoleName) |
static void |
addServlet(WebXml webXml,
Servlet element)
Add a servlet to the web xml.
|
static void |
addServlet(WebXml webXml,
String servletName,
String servletClass)
Add a servlet to the descriptor.
|
static void |
addServletInitParam(WebXml webXml,
String theServletName,
String name,
String value)
Add an init param to a servlet.
|
static void |
addServletMapping(WebXml webXml,
String theServletName,
String theUrlPattern) |
static void |
addServletRunAsRoleName(WebXml webXml,
String theServletName,
String theRoleName) |
static void |
addTagInitParam(WebXmlElement itemElement,
String name,
String value)
Add an init-param to the web xml.
|
static org.jdom.Element |
getContextParam(WebXml webXml,
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. |
static Filter |
getFilter(WebXml theWebXml,
String filterName) |
static String |
getFilterInitParam(WebXml theWebXml,
String filterName,
String paramName) |
static Iterator |
getFilterInitParamNames(WebXml webXml,
String name)
Get the init parameter names for a filter.
|
static Iterator |
getFilterMappingElements(WebXml webXml,
String theFilterName)
Returns the filter mappings that the specified filter is mapped to in an ordered list.
|
static Iterator |
getFilterMappings(WebXml webXml,
String theFilterName)
Returns the URL-patterns that the specified filter is mapped to in an ordered list.
|
static Iterator |
getFilterNames(WebXml webXml) |
static Iterator |
getFilterNamesForClass(WebXml webXml,
String className)
Returns a list of names of filters that are mapped to the specified class.
|
static String |
getLoginConfigAuthMethod(WebXml webXml)
Get the login config authorization method.
|
static SecurityConstraint |
getSecurityConstraint(WebXml webXml,
String theUrlPattern)
Get a security constraint by URL.
|
static org.jdom.Element |
getSecurityRole(WebXml webXml,
String theRoleName)
Get the security role by name.
|
static Iterator |
getSecurityRoleNames(WebXml webXml)
Get the security role names.
|
static Servlet |
getServlet(WebXml theWebXml,
String servletName) |
static String |
getServletInitParam(WebXml theWebXml,
String servletName,
String paramName) |
static Iterator |
getServletInitParamNames(WebXml webXml,
String theServletName)
Get the names of all the servlet init parameters.
|
static Iterator |
getServletMappings(WebXml webXml,
String theServletName)
Get the servlet mappings to the named servlet.
|
static Iterator |
getServletNames(WebXml webXml)
Get an iterator of the servlet names in the web xml.
|
static Iterator |
getServletNamesForClass(WebXml webXml,
String className)
Get the names that this servlet uses.
|
static Iterator |
getServletNamesForJspFile(WebXml webXml,
String theJspFile)
Returns a list of names of servlets that are mapped to the specified JSP file.
|
static String |
getServletRunAsRoleName(WebXml webXml,
String theServletName)
For a named servlet, return the run-as role name.
|
static boolean |
hasContextParam(WebXml webXml,
String theParamName)
Returns whether a context param by the specified name is defined in the deployment
descriptor.
|
static boolean |
hasFilter(WebXml webXml,
String theFilterName)
Returns whether a servlet filter by the specified name is defined in the deployment
descriptor.
|
static boolean |
hasLoginConfig(WebXml webXml)
Does the descriptor have a login config?
|
static boolean |
hasSecurityConstraint(WebXml webXml,
String theUrlPattern)
Does the descriptor have a security constraint for a URL?
|
static boolean |
hasSecurityRole(WebXml webXml,
String theRoleName)
Does the role have a security definition?
|
static boolean |
hasServlet(WebXml webXml,
String servletName)
Does the web xml have a named servlet.
|
static void |
setLoginConfig(WebXml webXml,
String theAuthMethod,
String theRealmName)
Set the login config.
|
public static Iterator getFilterNamesForClass(WebXml webXml, String className)
webXml
- The webXml file to useclassName
- The fully qualified name of the filter classpublic static Iterator getFilterMappings(WebXml webXml, String theFilterName)
webXml
- The webXml file to usetheFilterName
- The name of the servlet filter of which the mappings should be retrievedpublic static Iterator getFilterMappingElements(WebXml webXml, String theFilterName)
webXml
- The webXml file to usetheFilterName
- The name of the servlet filter of which the mappings should be retrievedpublic static boolean hasContextParam(WebXml webXml, String theParamName)
webXml
- The webXml file to usetheParamName
- The name of the context paramtrue
if the context param is defined, false
otherwisepublic static org.jdom.Element getContextParam(WebXml webXml, String paramName)
null
if a context param of the specified name is not defined in the
descriptor.webXml
- The webXml file to useparamName
- The context param namepublic static boolean hasFilter(WebXml webXml, String theFilterName)
webXml
- The webXml file to usetheFilterName
- The name of the filtertrue
if the filter is defined, false
otherwisepublic static String getServletRunAsRoleName(WebXml webXml, String theServletName)
webXml
- The webXml file to usetheServletName
- the name of the servletpublic static void addTagInitParam(WebXmlElement itemElement, String name, String value)
itemElement
- The the parent element to add toname
- The name of the paramvalue
- The value for the parampublic static Iterator getFilterInitParamNames(WebXml webXml, String name)
webXml
- The webXml file to usename
- The name of the filter to usepublic static void addFilterInitParam(WebXml webXml, String name, String paramName, String paramValue)
webXml
- The webXml file to usename
- The name of the filterparamName
- The name of the parameterparamValue
- The value of the parameterpublic static boolean hasServlet(WebXml webXml, String servletName)
webXml
- The webXml file to useservletName
- The name of the servlettrue
if it does, false
if not.public static void addServlet(WebXml webXml, String servletName, String servletClass)
webXml
- The webXml file to useservletName
- The servlet nameservletClass
- The servlet class namepublic static Iterator getServletNamesForClass(WebXml webXml, String className)
webXml
- The webXml file to useclassName
- the name of the classpublic static Iterator getServletNamesForJspFile(WebXml webXml, String theJspFile)
webXml
- The webXml file to usetheJspFile
- The path to the JSP file, relative to the root of the web-applicationpublic static Iterator getServletNames(WebXml webXml)
webXml
- The webXml file to usepublic static Iterator getServletMappings(WebXml webXml, String theServletName)
webXml
- The webXml file to usetheServletName
- The name of the servletpublic static void addServlet(WebXml webXml, Servlet element)
webXml
- The webXml file to useelement
- The servlet elementpublic static void addServletInitParam(WebXml webXml, String theServletName, String name, String value)
webXml
- The webXml file to usetheServletName
- The name of the servletname
- The name of the init paramvalue
- The value for the init parampublic static Iterator getServletInitParamNames(WebXml webXml, String theServletName)
webXml
- The webXml file to usetheServletName
- The name of the servletpublic static void addSecurityConstraint(WebXml webXml, String theWebResourceName, String theUrlPattern, List theRoles)
webXml
- The webXml file to usetheWebResourceName
- The name of the web resourcetheUrlPattern
- The URL PatterntheRoles
- the Roles to AllowInvocationTargetException
IllegalAccessException
InstantiationException
NoSuchMethodException
IllegalArgumentException
SecurityException
public static void addJspFile(WebXml webXml, String theServletName, String theJspFile)
webXml
- The webXml file to usetheServletName
- The name of the servlettheJspFile
- The name of the JSP fileInvocationTargetException
IllegalAccessException
InstantiationException
NoSuchMethodException
IllegalArgumentException
SecurityException
public static boolean hasSecurityConstraint(WebXml webXml, String theUrlPattern)
webXml
- The webXml file to usetheUrlPattern
- The URL pattern to querypublic static boolean hasLoginConfig(WebXml webXml)
webXml
- The webXml file to usepublic static void setLoginConfig(WebXml webXml, String theAuthMethod, String theRealmName)
webXml
- The webXml file to usetheAuthMethod
- The authorization methodtheRealmName
- The realm namepublic static String getLoginConfigAuthMethod(WebXml webXml)
webXml
- The webXml file to usepublic static SecurityConstraint getSecurityConstraint(WebXml webXml, String theUrlPattern)
webXml
- The webXml file to usetheUrlPattern
- The URL Patternpublic static boolean hasSecurityRole(WebXml webXml, String theRoleName)
webXml
- The webXml file to usetheRoleName
- The name of the rolepublic static Iterator getSecurityRoleNames(WebXml webXml)
webXml
- The webXml file to usepublic static org.jdom.Element getSecurityRole(WebXml webXml, String theRoleName)
webXml
- The webXml file to usetheRoleName
- The name of the rolepublic static void addEjbRef(WebXml webXml, EjbRef ref)
webXml
- The webXml file to useref
- the EJB Reference element to addpublic static void addSecurityRole(WebXml webXml, String theRoleName)
webXml
- The webXml file to usetheRoleName
- The role name to usepublic static Servlet getServlet(WebXml theWebXml, String servletName)
theWebXml
- The webXml file to useservletName
- The name of the servlet to getpublic static Iterator getFilterNames(WebXml webXml)
webXml
- The webXml file to usepublic static Filter getFilter(WebXml theWebXml, String filterName)
theWebXml
- The webXml file to usefilterName
- The name of the filterpublic static void addFilterMapping(WebXml webXml, FilterMapping rhs)
webXml
- The webXml file to userhs
- The mapping to addpublic static String getServletInitParam(WebXml theWebXml, String servletName, String paramName)
theWebXml
- The webXml file to useservletName
- The servlet nameparamName
- The parameter Namepublic static void addServletRunAsRoleName(WebXml webXml, String theServletName, String theRoleName)
webXml
- The webXml file to usetheServletName
- The name of the servlettheRoleName
- The role name to addpublic static void addServletMapping(WebXml webXml, String theServletName, String theUrlPattern)
webXml
- The webXml file to usetheServletName
- The name of the servlettheUrlPattern
- the URL PAttern to addpublic static String getFilterInitParam(WebXml theWebXml, String filterName, String paramName)
theWebXml
- The webXml file to usefilterName
- The name of the filterparamName
- The name of the parameterpublic static void addFilter(WebXml webXml, Filter filter)
webXml
- The webXml file to usefilter
- The filter to addpublic static void addFilter(WebXml webXml, String filterName, String filterClass)
webXml
- The webXml file to usefilterName
- The servlet namefilterClass
- The servlet class nameCopyright © 2004-2013 Codehaus. All Rights Reserved.