Author: wesw
Date: Tue Jun  9 14:12:23 2009
New Revision: 783008

URL: http://svn.apache.org/viewvc?rev=783008&view=rev
Log:
Updating core to support pluggable upload capabilities WW-3100

Modified:
    
struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java
    
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
    struts/struts2/trunk/core/src/main/resources/struts-default.xml

Modified: 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java?rev=783008&r1=783007&r2=783008&view=diff
==============================================================================
--- 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java 
(original)
+++ 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java 
Tue Jun  9 14:12:23 2009
@@ -116,6 +116,11 @@
     public static final String STRUTS_MULTIPART_SAVEDIR = 
"struts.multipart.saveDir";
 
     /**
+     * The name of the bean that will handle multipart requests
+     */
+    public static final String STRUTS_MULTIPART_HANDLER = 
"struts.multipart.handler";
+
+    /**
      * The org.apache.struts2.dispatcher.multipart.MultiPartRequest parser 
implementation
      * for a multipart request (file upload)
      */

Modified: 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java?rev=783008&r1=783007&r2=783008&view=diff
==============================================================================
--- 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
 (original)
+++ 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
 Tue Jun  9 14:12:23 2009
@@ -59,6 +59,7 @@
 import com.opensymphony.xwork2.ActionProxyFactory;
 import com.opensymphony.xwork2.ObjectFactory;
 import com.opensymphony.xwork2.Result;
+import com.opensymphony.xwork2.UnknownHandler;
 import com.opensymphony.xwork2.config.Configuration;
 import com.opensymphony.xwork2.config.ConfigurationException;
 import com.opensymphony.xwork2.config.ConfigurationManager;
@@ -135,6 +136,11 @@
     private String multipartSaveDir;
 
     /**
+     * Stores the value of StrutsConstants.STRUTS_MULTIPART_HANDLER setting
+     */
+    private String multipartHandlerName;
+
+    /**
      * Provide list of default configuration files.
      */
     private static final String DEFAULT_CONFIGURATION_PATHS = 
"struts-default.xml,struts-plugin.xml,struts.xml";
@@ -237,6 +243,11 @@
         multipartSaveDir = val;
     }
 
+    @Inject(StrutsConstants.STRUTS_MULTIPART_HANDLER)
+    public void setMultipartHandler(String val) {
+        multipartHandlerName = val;
+    }
+
     @Inject
     public void setValueStackFactory(ValueStackFactory valueStackFactory) {
         this.valueStackFactory = valueStackFactory;
@@ -682,8 +693,20 @@
 
         String content_type = request.getContentType();
         if (content_type != null && 
content_type.indexOf("multipart/form-data") != -1) {
-            MultiPartRequest multi = 
getContainer().getInstance(MultiPartRequest.class);
-            request = new MultiPartRequestWrapper(multi, request, 
getSaveDir(servletContext));
+            MultiPartRequest mpr = null;
+            //add all available UnknownHandlers
+            Set<String> multiNames = 
getContainer().getInstanceNames(MultiPartRequest.class);
+            if (multiNames != null) {
+                for (String multiName : multiNames) {
+                    if (multiName.equals(multipartHandlerName)) {
+                        mpr = 
getContainer().getInstance(MultiPartRequest.class, multiName);
+                    }
+                }
+            }
+            if (mpr == null ) {
+                mpr = getContainer().getInstance(MultiPartRequest.class);
+            }
+            request = new MultiPartRequestWrapper(mpr, request, 
getSaveDir(servletContext));
         } else {
             request = new StrutsRequestWrapper(request);
         }

Modified: struts/struts2/trunk/core/src/main/resources/struts-default.xml
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/struts-default.xml?rev=783008&r1=783007&r2=783008&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/struts-default.xml (original)
+++ struts/struts2/trunk/core/src/main/resources/struts-default.xml Tue Jun  9 
14:12:23 2009
@@ -46,6 +46,7 @@
 
     <bean type="org.apache.struts2.dispatcher.multipart.MultiPartRequest" 
name="struts" 
class="org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest" 
scope="default"/>
     <bean type="org.apache.struts2.dispatcher.multipart.MultiPartRequest" 
name="jakarta" 
class="org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest" 
scope="default" />
+    <constant name="struts.multipart.handler" value="jakarta" />
 
     <bean type="org.apache.struts2.views.TagLibrary" name="s" 
class="org.apache.struts2.views.DefaultTagLibrary" />
 


Reply via email to