[prev in list] [next in list] [prev in thread] [next in thread] 

List:       struts-dev
Subject:    [PATCH] Allow Multiple Config Files (1.1)
From:       James Holmes <jholmes612 () yahoo ! com>
Date:       2001-10-22 13:45:01
[Download RAW message or body]

Attached is the patch for multiple config file support
for Struts 1.1.  Any consensus/decision on whether or
not we should log "duplicates"?

James Holmes
jholmes612@yahoo.com
http://www.ejcenter.com/struts/


__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com
["ActionServlet.java.patch-1.1" (text/plain)]

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.76
diff -u -r1.76 ActionServlet.java
--- jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java	2001/10/07 04:48:08	1.76
+++ jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java	2001/10/22 13:24:47
@@ -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>
@@ -1257,30 +1258,40 @@
 	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 = initDigester(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();
+	// 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 = initDigester(detail);
+
+	    // 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);
 
     }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic