[Httpunit-commit] CVS: httpunit/src/com/meterware/servletunit WebApplication.java,1.1,1.2
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2002-01-01 19:29:11
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit
In directory usw-pr-cvs1:/tmp/cvs-serv5993/src/com/meterware/servletunit
Modified Files:
WebApplication.java
Log Message:
More refactoring
Index: WebApplication.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/WebApplication.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- WebApplication.java 2001/11/26 14:20:12 1.1
+++ WebApplication.java 2002/01/01 19:29:08 1.2
@@ -65,7 +65,6 @@
*/
WebApplication( Document document ) throws MalformedURLException,SAXException {
registerServlets( document );
- registerServlet( "/j_security_check", SecurityCheckServlet.class.getName() );
NodeList nl = document.getElementsByTagName( "security-constraint" );
for (int i = 0; i < nl.getLength(); i++) {
_securityConstraints.add( new SecurityConstraintImpl( (Element) nl.item(i) ) );
@@ -91,7 +90,7 @@
Servlet getServlet( URL url ) throws ServletException {
- final ServletConfiguration configuration = (ServletConfiguration) _servlets.get( getServletName( getURLPath( url ) ) );
+ final ServletConfiguration configuration = getServletConfiguration( url );
if (configuration == null) throw new HttpNotFoundException( url );
try {
@@ -111,6 +110,16 @@
}
+ private ServletConfiguration getServletConfiguration(URL url) {
+ String servletName = getServletName( getURLPath( url ) );
+ if (servletName.endsWith( "j_security_check" )) {
+ return SECURITY_CHECK_CONFIGURATION;
+ } else {
+ return (ServletConfiguration) _servlets.get( servletName );
+ }
+ }
+
+
private String getURLPath( URL url ) {
return url.getFile();
}
@@ -175,6 +184,8 @@
//------------------------------------------------ private members ---------------------------------------------
+ private final static ServletConfiguration SECURITY_CHECK_CONFIGURATION = new ServletConfiguration( SecurityCheckServlet.class.getName() );
+
/** A mapping of resource names to servlet class names. **/
private Hashtable _servlets = new Hashtable();
@@ -235,12 +246,12 @@
}
- private String getChildNodeValue( Element root, String childNodeName ) throws SAXException {
+ private static String getChildNodeValue( Element root, String childNodeName ) throws SAXException {
return getChildNodeValue( root, childNodeName, null );
}
- private String getChildNodeValue( Element root, String childNodeName, String defaultValue ) throws SAXException {
+ private static String getChildNodeValue( Element root, String childNodeName, String defaultValue ) throws SAXException {
NodeList nl = root.getElementsByTagName( childNodeName );
if (nl.getLength() == 1) {
return getTextValue( nl.item(0) );
@@ -307,7 +318,7 @@
//============================================= ServletConfiguration class =============================================
- class ServletConfiguration {
+ static class ServletConfiguration {
public ServletConfiguration( String className ) {
_className = className;
|