Author: remy.maucherat(a)jboss.com
Date: 2009-09-10 08:19:50 -0400 (Thu, 10 Sep 2009)
New Revision: 1164
Modified:
trunk/java/org/apache/catalina/Wrapper.java
trunk/java/org/apache/catalina/connector/Request.java
trunk/java/org/apache/catalina/core/StandardWrapper.java
trunk/java/org/apache/catalina/deploy/Multipart.java
trunk/java/org/apache/catalina/startup/ContextConfig.java
trunk/java/org/apache/catalina/startup/WebAnnotationSet.java
Log:
- Add proper configuration for multipart.
Modified: trunk/java/org/apache/catalina/Wrapper.java
===================================================================
--- trunk/java/org/apache/catalina/Wrapper.java 2009-09-08 16:24:57 UTC (rev 1163)
+++ trunk/java/org/apache/catalina/Wrapper.java 2009-09-10 12:19:50 UTC (rev 1164)
@@ -23,8 +23,8 @@
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;
import javax.servlet.UnavailableException;
-import javax.servlet.annotation.MultipartConfig;
+import org.apache.catalina.deploy.Multipart;
import org.apache.catalina.util.InstanceSupport;
@@ -172,13 +172,13 @@
/**
* Multipart configuration for this Servlet.
*/
- public MultipartConfig getMultipartConfig();
+ public Multipart getMultipartConfig();
/**
* Set the multipart configuration for this Servlet.
*/
- public void setMultipartConfig(MultipartConfig multipartConfig);
+ public void setMultipartConfig(Multipart multipartConfig);
/**
Modified: trunk/java/org/apache/catalina/connector/Request.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Request.java 2009-09-08 16:24:57 UTC (rev
1163)
+++ trunk/java/org/apache/catalina/connector/Request.java 2009-09-10 12:19:50 UTC (rev
1164)
@@ -77,7 +77,6 @@
import javax.servlet.ServletRequestAttributeEvent;
import javax.servlet.ServletRequestAttributeListener;
import javax.servlet.ServletResponse;
-import javax.servlet.annotation.MultipartConfig;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -96,6 +95,7 @@
import org.apache.catalina.core.ApplicationFilterConfig;
import org.apache.catalina.core.ApplicationFilterFactory;
import org.apache.catalina.deploy.FilterDef;
+import org.apache.catalina.deploy.Multipart;
import org.apache.catalina.realm.GenericPrincipal;
import org.apache.catalina.util.Enumerator;
import org.apache.catalina.util.ParameterMap;
@@ -2758,7 +2758,7 @@
*/
protected void parseMultipart() {
- MultipartConfig config = wrapper.getMultipartConfig();
+ Multipart config = wrapper.getMultipartConfig();
if (config == null) {
return;
}
@@ -2782,14 +2782,17 @@
return;
DiskFileUpload fu = new DiskFileUpload();
- fu.setRepositoryPath(config.location());
- if (config.fileSizeThreshold() > 0) {
- fu.setSizeThreshold(config.fileSizeThreshold());
+ fu.setRepositoryPath(config.getLocation());
+ if (config.getFileSizeThreshold() > 0) {
+ fu.setSizeThreshold(config.getFileSizeThreshold());
}
- if (config.maxRequestSize() > 0) {
- fu.setSizeMax(config.maxRequestSize());
+ if (config.getMaxRequestSize() > 0) {
+ fu.setSizeMax(config.getMaxRequestSize());
}
- // FIXME: Unimplemented per file max size:
fu.setSizeFileMax(config.maxFileSize());
+ if (config.getMaxFileSize() > 0) {
+ // FIXME: Unimplemented per file max size
+ //fu.setSizeFileMax(config.getMaxFileSize());
+ }
parts = new HashMap<String, Part>();
try {
Modified: trunk/java/org/apache/catalina/core/StandardWrapper.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardWrapper.java 2009-09-08 16:24:57 UTC (rev
1163)
+++ trunk/java/org/apache/catalina/core/StandardWrapper.java 2009-09-10 12:19:50 UTC (rev
1164)
@@ -43,7 +43,6 @@
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;
@@ -53,6 +52,7 @@
import org.apache.catalina.InstanceListener;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.Wrapper;
+import org.apache.catalina.deploy.Multipart;
import org.apache.catalina.security.SecurityUtil;
import org.apache.catalina.util.Enumerator;
import org.apache.catalina.util.InstanceSupport;
@@ -190,7 +190,7 @@
/**
* The multipart config annotation configured on this servlet.
*/
- protected MultipartConfig multipartConfig = null;
+ protected Multipart multipartConfig = null;
/**
@@ -544,7 +544,7 @@
/**
* Multipart configuration for this Servlet.
*/
- public MultipartConfig getMultipartConfig() {
+ public Multipart getMultipartConfig() {
return multipartConfig;
}
@@ -552,7 +552,7 @@
/**
* Set the multipart configuration for this Servlet.
*/
- public void setMultipartConfig(MultipartConfig multipartConfig) {
+ public void setMultipartConfig(Multipart multipartConfig) {
this.multipartConfig = multipartConfig;
}
Modified: trunk/java/org/apache/catalina/deploy/Multipart.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/Multipart.java 2009-09-08 16:24:57 UTC (rev
1163)
+++ trunk/java/org/apache/catalina/deploy/Multipart.java 2009-09-10 12:19:50 UTC (rev
1164)
@@ -27,8 +27,8 @@
public class Multipart implements Serializable {
protected String location = null;
- protected long maxFileSize = 0;
- protected long maxRequestSize = 0;
+ protected long maxFileSize = -1;
+ protected long maxRequestSize = -1;
protected int fileSizeThreshold = 0;
public String getLocation() {
Modified: trunk/java/org/apache/catalina/startup/ContextConfig.java
===================================================================
--- trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-09-08 16:24:57 UTC (rev
1163)
+++ trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-09-10 12:19:50 UTC (rev
1164)
@@ -430,15 +430,6 @@
*/
protected void processConfigAnnotations(Class<?> clazz) {
- if (clazz.isAnnotationPresent(WebInitParam.class)) {
- WebInitParam annotation = clazz.getAnnotation(WebInitParam.class);
- // Add init param
- context.addParameter(annotation.name(), annotation.value());
- }
- if (clazz.isAnnotationPresent(MultipartConfig.class)) {
- MultipartConfig annotation = clazz.getAnnotation(MultipartConfig.class);
- // FIXME: Do something ....
- }
if (clazz.isAnnotationPresent(WebFilter.class)) {
WebFilter annotation = clazz.getAnnotation(WebFilter.class);
// Add servlet filter
@@ -493,7 +484,6 @@
}
}
if (clazz.isAnnotationPresent(WebListener.class)) {
- WebListener annotation = clazz.getAnnotation(WebListener.class);
// Add listener
context.addApplicationListener(clazz.getName());
}
Modified: trunk/java/org/apache/catalina/startup/WebAnnotationSet.java
===================================================================
--- trunk/java/org/apache/catalina/startup/WebAnnotationSet.java 2009-09-08 16:24:57 UTC
(rev 1163)
+++ trunk/java/org/apache/catalina/startup/WebAnnotationSet.java 2009-09-10 12:19:50 UTC
(rev 1164)
@@ -32,6 +32,8 @@
import javax.annotation.security.RolesAllowed;
import javax.annotation.security.RunAs;
import javax.annotation.security.TransportProtected;
+import javax.servlet.annotation.MultipartConfig;
+import javax.servlet.annotation.WebInitParam;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -46,6 +48,7 @@
import org.apache.catalina.deploy.ContextService;
import org.apache.catalina.deploy.FilterDef;
import org.apache.catalina.deploy.MessageDestinationRef;
+import org.apache.catalina.deploy.Multipart;
import org.apache.catalina.deploy.SecurityCollection;
import org.apache.catalina.deploy.SecurityConstraint;
@@ -95,7 +98,7 @@
protected static void loadApplicationFilterAnnotations(Context context) {
FilterDef[] filterDefs = context.findFilterDefs();
for (int i = 0; i < filterDefs.length; i++) {
- loadClassAnnotation(context, (filterDefs[i]).getFilterClass());
+ loadClassAnnotation(context, filterDefs[i].getFilterClass());
}
}
@@ -107,7 +110,7 @@
ClassLoader classLoader = context.getLoader().getClassLoader();
StandardWrapper wrapper = null;
- Class classClass = null;
+ Class<?> classClass = null;
Container[] children = context.findChildren();
for (int i = 0; i < children.length; i++) {
@@ -131,7 +134,19 @@
}
loadClassAnnotation(context, wrapper.getServletClass());
-
+
+ // Multipart configuration annotation
+ if (classClass.isAnnotationPresent(MultipartConfig.class)) {
+ MultipartConfig annotation =
+ (MultipartConfig)
classClass.getAnnotation(MultipartConfig.class);
+ Multipart multipartConfig = new Multipart();
+ multipartConfig.setLocation(annotation.location());
+ multipartConfig.setMaxRequestSize(annotation.maxFileSize());
+ multipartConfig.setMaxFileSize(annotation.maxFileSize());
+
multipartConfig.setFileSizeThreshold(annotation.fileSizeThreshold());
+ wrapper.setMultipartConfig(multipartConfig);
+ }
+
// Process JSR 250 access control annotations
// Process PermitAll, TransportProtected and RolesAllowed on the class
boolean classPA = false, classTP = false;
@@ -278,7 +293,7 @@
protected static void loadClassAnnotation(Context context, String fileString) {
ClassLoader classLoader = context.getLoader().getClassLoader();
- Class classClass = null;
+ Class<?> classClass = null;
try {
classClass = classLoader.loadClass(fileString);