I don't know how other people feel, but personally, I see this as new 
functionality, rather than a bug fix. Hence I'd be happy to see this added 
for Struts 1.1, but I'd be reluctant to see it added for the Struts 1.0.1 
patch.

Incidentally, I assume this implementation is effectively "last one in 
wins". That is, if I have form beans (or action mappings, etc.) with the 
same name in multiple config files, the last one read is the one that will 
actually be used. If that's the case, it might be useful, for debugging 
purposes, to log a message when one entry is overwritten by a later one.

--
Martin Cooper


At 02:22 PM 10/19/01, James Holmes wrote:
>Attached is a patch for ActionServlet to allow
>multiple config files.  With this patch you can
>specify a comma separated list of config files like
>this:
>
><init-param>
>     <param-name>config</param-name>
>     <param-value>
>         /WEB-INF/struts-config.xml,
>         /WEB-INF/struts-config2.xml
>     </param-value>
></init-param>
>
>This is also backwards compatible so that existing
>config files still work.
>
>This is a patch for "STRUTS_1_0_BRANCH".  I will
>follow up with a 1.1 patch too.
>
>Thoughts?  I know there has been a reasonable amount
>of desire for this functionality on the user list.
>
>-james
>[EMAIL PROTECTED]
>http://www.ejcenter.com/struts/
>
>__________________________________________________
>Do You Yahoo!?
>Make a great connection at Yahoo! Personals.
>http://personals.yahoo.com
>
>Index: jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java
>===================================================================
>RCS file: 
>/home/cvspublic/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v
>retrieving revision 1.68.2.4
>diff -u -r1.68.2.4 ActionServlet.java
>--- 
>jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java 
 > 2001/10/07 04:49:15     1.68.2.4
>+++ 
>jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java 
 > 2001/10/19 21:07:37
>@@ -72,6 +72,7 @@
>  import java.util.Iterator;
>  import java.util.Locale;
>  import java.util.MissingResourceException;
>+import java.util.StringTokenizer;
>  import javax.servlet.RequestDispatcher;
>  import javax.servlet.ServletException;
>  import javax.servlet.UnavailableException;
>@@ -159,9 +160,9 @@
>   *     resources bundle base class.  [NONE]</li>
>   * <li><strong>bufferSize</strong> - The size of the input buffer used when
>   *     processing file uploads.  [4096]</li>
>- * <li><strong>config</strong> - Context-relative path to the XML resource
>- *     containing our configuration information.
>- *     [/WEB-INF/struts-config.xml]</li>
>+ * <li><strong>config</strong> - Comma seperated list of context-relative 
>paths
>+ *     to the XML resources containing our configuration information.
>+ *     [/WEB-INF/struts-config.xml,/WEB-INF/struts-config2.xml]</li>
>   * <li><strong>content</strong> - Default content type and character 
> encoding
>   *     to be set on each response; may be overridden by a forwarded-to
>   *     servlet or JSP page.  [text/html]</li>
>@@ -1311,34 +1312,44 @@
>         if (debug >= 1)
>             log(internal.getMessage("configInit", config));
>
>-       // Acquire an input stream to our configuration resource
>-       InputStream input = getServletContext().getResourceAsStream(config);
>-       if (input == null)
>-           throw new UnavailableException
>-               (internal.getMessage("configMissing", config));
>-
>-       // Build a digester to process our configuration resource
>-       Digester digester = null;
>-       if (validate)
>-           digester = initDigester(detail);
>-       else
>-           digester = initDigesterOld(detail);
>+       // don't use fast
>+       formBeans.setFast(false);
>+       forwards.setFast(false);
>+       mappings.setFast(false);
>+
>+       // Process each config file
>+       StringTokenizer st = new StringTokenizer(config, ",");
>+       while (st.hasMoreTokens()) {
>+           String configToken = st.nextToken().trim();
>+
>+           // Acquire an input stream to our configuration resource
>+           InputStream input = 
>getServletContext().getResourceAsStream(configToken);
>+           if (input == null)
>+               throw new UnavailableException
>+                  (internal.getMessage("configMissing", configToken));
>+
>+           // Build a digester to process our configuration resource
>+           Digester digester = null;
>+           if (validate)
>+               digester = initDigester(detail);
>+           else
>+               digester = initDigesterOld(detail);
>
>-       // Parse the input stream to configure our mappings
>-       try {
>-            formBeans.setFast(false);
>-            forwards.setFast(false);
>-            mappings.setFast(false);
>-           digester.parse(input);
>-            mappings.setFast(true);
>-            forwards.setFast(true);
>-            formBeans.setFast(true);
>-       } catch (SAXException e) {
>-           throw new ServletException
>-               (internal.getMessage("configParse", config), e);
>-        } finally {
>-           input.close();
>+           // Parse the input stream to configure our mappings
>+           try {
>+               digester.parse(input);
>+           } catch (SAXException e) {
>+               throw new ServletException
>+                   (internal.getMessage("configParse", configToken), e);
>+           } finally {
>+               input.close();
>+           }
>         }
>+
>+       // use fast
>+       mappings.setFast(true);
>+       forwards.setFast(true);
>+       formBeans.setFast(true);
>
>          // Transitional support for old format
>          if (!validate) {


Reply via email to