tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r886814 - in /tomcat/trunk/java/org/apache/catalina: Wrapper.java connector/Request.java core/StandardWrapper.java startup/WebXml.java
Date Thu, 03 Dec 2009 15:25:55 GMT
Author: markt
Date: Thu Dec  3 15:25:54 2009
New Revision: 886814

URL: http://svn.apache.org/viewvc?rev=886814&view=rev
Log:
Add support for the MultipartConfig annotation

Modified:
    tomcat/trunk/java/org/apache/catalina/Wrapper.java
    tomcat/trunk/java/org/apache/catalina/connector/Request.java
    tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java
    tomcat/trunk/java/org/apache/catalina/startup/WebXml.java

Modified: tomcat/trunk/java/org/apache/catalina/Wrapper.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/Wrapper.java?rev=886814&r1=886813&r2=886814&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/Wrapper.java (original)
+++ tomcat/trunk/java/org/apache/catalina/Wrapper.java Thu Dec  3 15:25:54 2009
@@ -340,12 +340,12 @@
      * multi-part configuration has been defined, then <code>null</code> will
be
      * returned.
      */
-    public MultipartConfigElement getMultipartConfig();
+    public MultipartConfigElement getMultipartConfigElement();
     
     
     /**
      * Set the multi-part configuration for the associated servlet. To clear the
      * multi-part configuration specify <code>null</code> as the new value.
      */
-    public void setMultipartConfig(MultipartConfigElement multipartConfig);
+    public void setMultipartConfigElement(MultipartConfigElement multipartConfig);
 }

Modified: tomcat/trunk/java/org/apache/catalina/connector/Request.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/Request.java?rev=886814&r1=886813&r2=886814&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/Request.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/Request.java Thu Dec  3 15:25:54 2009
@@ -2393,12 +2393,19 @@
     public Collection<Part> getParts() throws IOException, IllegalStateException,
             ServletException {
         
-        MultipartConfigElement mce = getWrapper().getMultipartConfig();
+        MultipartConfigElement mce = getWrapper().getMultipartConfigElement();
         if (mce == null) {
             return Collections.emptyList();
         }
         
-        File location = new File(mce.getLocation());
+        File location;
+        String locationStr = mce.getLocation();
+        if (locationStr == null || locationStr.length() == 0) {
+            location = ((File) context.getServletContext().getAttribute(
+                    ServletContext.TEMPDIR));
+        } else {
+            location = new File(locationStr);
+        }
         
         if (!location.isAbsolute() || !location.isDirectory()) {
             throw new IOException(

Modified: tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java?rev=886814&r1=886813&r2=886814&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java Thu Dec  3 15:25:54 2009
@@ -44,6 +44,7 @@
 import javax.servlet.ServletResponse;
 import javax.servlet.SingleThreadModel;
 import javax.servlet.UnavailableException;
+import javax.servlet.annotation.MultipartConfig;
 
 import org.apache.catalina.Container;
 import org.apache.catalina.ContainerServlet;
@@ -258,7 +259,7 @@
     /**
      * Multipart config
      */
-    protected MultipartConfigElement multipartConfig = null;
+    protected MultipartConfigElement multipartConfigElement = null;
 
     /**
      * Static class array used when the SecurityManager is turned on and 
@@ -1052,6 +1053,15 @@
                     (sm.getString("standardWrapper.instantiate", actualClass), e);
             }
 
+            if (multipartConfigElement == null) {
+                MultipartConfig annotation =
+                        servlet.getClass().getAnnotation(MultipartConfig.class);
+                if (annotation != null) {
+                    multipartConfigElement =
+                            new MultipartConfigElement(annotation);
+                }
+            }
+
             // Special handling for ContainerServlet instances
             if ((servlet instanceof ContainerServlet) &&
                   (isContainerProvidedServlet(actualClass) ||
@@ -1483,12 +1493,13 @@
         return classLoadTime;
     }
 
-    public MultipartConfigElement getMultipartConfig() {
-        return multipartConfig;
+    public MultipartConfigElement getMultipartConfigElement() {
+        return multipartConfigElement;
     }
 
-    public void setMultipartConfig(MultipartConfigElement multipartConfig) {
-        this.multipartConfig = multipartConfig;
+    public void setMultipartConfigElement(
+            MultipartConfigElement multipartConfigElement) {
+        this.multipartConfigElement = multipartConfigElement;
     }
 
     // -------------------------------------------------------- Package Methods

Modified: tomcat/trunk/java/org/apache/catalina/startup/WebXml.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/WebXml.java?rev=886814&r1=886813&r2=886814&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/WebXml.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/WebXml.java Thu Dec  3 15:25:54 2009
@@ -568,23 +568,18 @@
             wrapper.setServletClass(servlet.getServletClass());
             MultipartDef multipartdef = servlet.getMultipartDef();
             if (multipartdef != null) {
-                String location = multipartdef.getLocation();
-                if (location == null || location.length() == 0) {
-                    location = ((File) context.getServletContext().getAttribute(
-                            ServletContext.TEMPDIR)).getAbsolutePath();
-                }
                 if (multipartdef.getMaxFileSize() != null &&
                         multipartdef.getMaxRequestSize()!= null &&
                         multipartdef.getFileSizeThreshold() != null) {
-                    wrapper.setMultipartConfig(new MultipartConfigElement(
-                            location,
+                    wrapper.setMultipartConfigElement(new MultipartConfigElement(
+                            multipartdef.getLocation(),
                             Long.parseLong(multipartdef.getMaxFileSize()),
                             Long.parseLong(multipartdef.getMaxRequestSize()),
                             Integer.parseInt(
                                     multipartdef.getFileSizeThreshold())));
                 } else {
-                    wrapper.setMultipartConfig(new MultipartConfigElement(
-                            location));
+                    wrapper.setMultipartConfigElement(new MultipartConfigElement(
+                            multipartdef.getLocation()));
                 }
             }
             context.addChild(wrapper);



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message