Author: mrdon Date: Thu Nov 18 22:58:36 2004 New Revision: 105785 Modified: struts/core/trunk/src/share/org/apache/struts/action/ActionServlet.java struts/core/trunk/src/share/org/apache/struts/tiles/xmlDefinition/I18nFactorySet.java struts/core/trunk/src/share/org/apache/struts/validator/ValidatorPlugIn.java Log: Added ability to load struts, validator, and tiles config files from classloader if not found in the servlet context
Modified: struts/core/trunk/src/share/org/apache/struts/action/ActionServlet.java ============================================================================== --- struts/core/trunk/src/share/org/apache/struts/action/ActionServlet.java (original) +++ struts/core/trunk/src/share/org/apache/struts/action/ActionServlet.java Thu Nov 18 22:58:36 2004 @@ -701,14 +701,20 @@ try { URL url = getServletContext().getResource(path); - if (url == null) { - String msg = internal.getMessage("configMissing", path); - log.error(msg); - throw new UnavailableException(msg); - } + // 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 (url == null) { + url = getClass().getResource(path); + } + + if (url == null) { + String msg = internal.getMessage("configMissing", path); + log.error(msg); + throw new UnavailableException(msg); + } InputSource is = new InputSource(url.toExternalForm()); - input = getServletContext().getResourceAsStream(path); + input = url.openStream(); is.setByteStream(input); digester.parse(is); Modified: struts/core/trunk/src/share/org/apache/struts/tiles/xmlDefinition/I18nFactorySet.java ============================================================================== --- struts/core/trunk/src/share/org/apache/struts/tiles/xmlDefinition/I18nFactorySet.java (original) +++ struts/core/trunk/src/share/org/apache/struts/tiles/xmlDefinition/I18nFactorySet.java Thu Nov 18 22:58:36 2004 @@ -499,6 +499,12 @@ } catch (Exception e) { } } + + // 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(filename); + } // If still nothing found, this mean no config file is associated if (input == null) { Modified: struts/core/trunk/src/share/org/apache/struts/validator/ValidatorPlugIn.java ============================================================================== --- struts/core/trunk/src/share/org/apache/struts/validator/ValidatorPlugIn.java (original) +++ struts/core/trunk/src/share/org/apache/struts/validator/ValidatorPlugIn.java Thu Nov 18 22:58:36 2004 @@ -212,6 +212,12 @@ } InputStream input = servlet.getServletContext().getResourceAsStream(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); + } if (input != null) { BufferedInputStream bis = new BufferedInputStream(input); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]