You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by mr...@apache.org on 2005/08/30 06:22:30 UTC
svn commit: r264700 -
/struts/core/trunk/src/share/org/apache/struts/validator/ValidatorPlugIn.java
Author: mrdon
Date: Mon Aug 29 21:22:27 2005
New Revision: 264700
URL: http://svn.apache.org/viewcvs?rev=264700&view=rev
Log:
Changing loading of validator XML files to pass uri's rather than
InputStreams. This enables entity imports correctly because the
Digester will have something to create a path from
Modified:
struts/core/trunk/src/share/org/apache/struts/validator/ValidatorPlugIn.java
Modified: struts/core/trunk/src/share/org/apache/struts/validator/ValidatorPlugIn.java
URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/validator/ValidatorPlugIn.java?rev=264700&r1=264699&r2=264700&view=diff
==============================================================================
--- struts/core/trunk/src/share/org/apache/struts/validator/ValidatorPlugIn.java (original)
+++ struts/core/trunk/src/share/org/apache/struts/validator/ValidatorPlugIn.java Mon Aug 29 21:22:27 2005
@@ -27,6 +27,7 @@
import java.io.BufferedInputStream;
import java.io.InputStream;
import java.io.IOException;
+import java.net.URL;
import javax.servlet.ServletException;
import javax.servlet.UnavailableException;
@@ -203,7 +204,7 @@
}
StringTokenizer st = new StringTokenizer(pathnames, RESOURCE_DELIM);
- List streamList = new ArrayList();
+ List urlList = new ArrayList();
try {
while (st.hasMoreTokens()) {
String validatorRules = st.nextToken().trim();
@@ -211,41 +212,33 @@
log.info("Loading validation rules file from '" + validatorRules + "'");
}
- InputStream input = servlet.getServletContext().getResourceAsStream(validatorRules);
+ URL input = servlet.getServletContext().getResource(validatorRules);
// If the config isn't in the servlet context, try the class loader
// which allows the config files to be stored in a jar
if (input == null) {
- input = getClass().getResourceAsStream(validatorRules);
+ input = getClass().getResource(validatorRules);
}
if (input != null) {
- BufferedInputStream bis = new BufferedInputStream(input);
- streamList.add(bis);
+ urlList.add(input);
} else {
throw new ServletException("Skipping validation rules file from '"
- + validatorRules + "'. No stream could be opened.");
+ + validatorRules + "'. No url could be located.");
}
}
- int streamSize = streamList.size();
- InputStream[] streamArray = new InputStream[streamSize];
- for (int streamIndex = 0;streamIndex < streamSize;streamIndex++) {
- InputStream is = (InputStream) streamList.get(streamIndex);
- streamArray[streamIndex] = is;
+ int urlSize = urlList.size();
+ String[] urlArray = new String[urlSize];
+ for (int urlIndex = 0;urlIndex < urlSize;urlIndex++) {
+ URL url = (URL) urlList.get(urlIndex);
+ urlArray[urlIndex] = url.toExternalForm();
}
- this.resources = new ValidatorResources(streamArray);
+ this.resources = new ValidatorResources(urlArray);
} catch (SAXException sex) {
log.error("Skipping all validation",sex);
throw new ServletException(sex);
- } finally {
- Iterator streamIterator = streamList.iterator();
- while (streamIterator.hasNext()) {
- InputStream is = (InputStream) streamIterator.next();
- is.close();
- }
- }
-
+ }
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org