craigmcc 2002/12/07 18:43:09 Modified: src/share/org/apache/struts/action ActionServlet.java Log: Consistent with the way that validator and tiles initialization is done, enhance the "config" and "config/${prefix}" servlet initialization parameters to accept comma-delimited lists of resource paths to struts-config.xml files. This allows you to divide up the configuration of a single module into multiple files, if this is more convenient for your purposes. PR: Bugzilla #13810 Submitted by: Ted Husted <husted at apache.org> Revision Changes Path 1.134 +44 -24 jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java Index: ActionServlet.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v retrieving revision 1.133 retrieving revision 1.134 diff -u -r1.133 -r1.134 --- ActionServlet.java 29 Nov 2002 19:49:50 -0000 1.133 +++ ActionServlet.java 8 Dec 2002 02:43:08 -0000 1.134 @@ -177,10 +177,12 @@ * deprecated between the 1.0 and 1.1 releases. The deprecated parameters * are listed after the nominal parameters.</p> * <ul> - * <li><strong>config</strong> - Context-relative path to the XML resource - * containing the configuration information for the default module. + * <li><strong>config</strong> - Comma-separated list of context-relative + * path(s) to the XML resource(s) containing the configuration information + * for the default module. (Multiple files support since Struts 1.1) * [/WEB-INF/struts-config.xml].</li> - * <li><strong>config/${module}</strong> - Context-relative path to the XML resource + * <li><strong>config/${module}</strong> - Comma-separated list of + * Context-relative path(s) to the XML resource(s) * containing the configuration information for the module that * will use the specified prefix (/${module}). This can be repeated as many * times as required for multiple modules. (Since Struts 1.1)</li> @@ -310,8 +312,8 @@ /** - * The context-relative path to our configuration resource for the - * default module. + * Comma-separated list of context-relative path(s) to our configuration + * resource(s) for the default module. */ protected String config = "/WEB-INF/struts-config.xml"; @@ -858,18 +860,18 @@ * specified module.</p> * * @param prefix Module prefix for this module - * @param path Context-relative resource path for this application's - * configuration resource + * @param paths Comma-separated list of context-relative resource path(s) + * for this application's configuration resource(s) * * @exception ServletException if initialization cannot be performed * @since Struts 1.1 */ protected ModuleConfig initModuleConfig - (String prefix, String path) throws ServletException { + (String prefix, String paths) throws ServletException { if (log.isDebugEnabled()) { log.debug("Initializing module path '" + prefix + - "' configuration from '" + path + "'"); + "' configuration from '" + paths + "'"); } // Parse the application configuration for this module @@ -886,20 +888,38 @@ config.setActionMappingClass(mapping); } + // Configure the Digester instance we will use Digester digester = initConfigDigester(); - digester.push(config); - URL url = getServletContext().getResource(path); - InputSource is = new InputSource(url.toExternalForm()); - input = getServletContext().getResourceAsStream(path); - is.setByteStream(input); - digester.parse(is); - getServletContext().setAttribute - (Globals.MODULE_KEY + prefix, config); - + + // Process each specified resource path + while (paths.length() > 0) { + digester.push(config); + String path = null; + int comma = paths.indexOf(','); + if (comma >= 0) { + path = paths.substring(0, comma).trim(); + paths = paths.substring(comma + 1); + } else { + path = paths.trim(); + paths = ""; + } + if (path.length() < 1) { + break; + } + URL url = getServletContext().getResource(path); + InputSource is = new InputSource(url.toExternalForm()); + input = getServletContext().getResourceAsStream(path); + is.setByteStream(input); + digester.parse(is); + getServletContext().setAttribute + (Globals.MODULE_KEY + prefix, config); + input.close(); + } + } catch (Throwable t) { - log.error(internal.getMessage("configParse", path), t); + log.error(internal.getMessage("configParse", paths), t); throw new UnavailableException - (internal.getMessage("configParse", path)); + (internal.getMessage("configParse", paths)); } finally { if (input != null) { try {
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>