cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1186857 - /cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
Date Thu, 20 Oct 2011 15:38:05 GMT
Author: sergeyb
Date: Thu Oct 20 15:38:05 2011
New Revision: 1186857

URL: http://svn.apache.org/viewvc?rev=1186857&view=rev
Log:
[CXF-3869] Minor improvements to RequestDispatcherProvider

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java?rev=1186857&r1=1186856&r2=1186857&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
Thu Oct 20 15:38:05 2011
@@ -75,6 +75,7 @@ public class RequestDispatcherProvider e
     private String beanName;
     private String dispatcherName;
     private String servletPath;
+    private boolean saveParametersAsAttributes;
     
     @Context
     private MessageContext mc; 
@@ -111,7 +112,8 @@ public class RequestDispatcherProvider e
             
             String theServletPath = servletPath == null ? "/" : servletPath;
             HttpServletRequestFilter servletRequest = 
-                new HttpServletRequestFilter(mc.getHttpServletRequest(), path, theServletPath);
+                new HttpServletRequestFilter(mc.getHttpServletRequest(), path, 
+                                             theServletPath, saveParametersAsAttributes);
             if (REQUEST_SCOPE.equals(scope)) {
                 servletRequest.setAttribute(getBeanName(o), o);
             } else if (SESSION_SCOPE.equals(scope)) {
@@ -248,17 +250,30 @@ public class RequestDispatcherProvider e
     public void setResourcePaths(Map<String, String> resourcePaths) {
         this.resourcePaths = resourcePaths;
     }
+    
+    public void setClassResources(Map<String, String> resources) {
+        this.classResources = resources;
+    }
+
+    public void setSaveParametersAsAttributes(boolean saveParametersAsAttributes) {
+        this.saveParametersAsAttributes = saveParametersAsAttributes;
+    }
 
     protected static class HttpServletRequestFilter extends HttpServletRequestWrapper {
         
         private Map<String, String[]> params;
         private String path;
         private String servletPath;
+        private boolean saveParamsAsAttributes;
         
-        public HttpServletRequestFilter(HttpServletRequest request, String path, String servletPath)
{
+        public HttpServletRequestFilter(HttpServletRequest request, 
+                                        String path, 
+                                        String servletPath,
+                                        boolean saveParamsAsAttributes) {
             super(request);
             this.path = path;
             this.servletPath = servletPath;
+            this.saveParamsAsAttributes = saveParamsAsAttributes;
             params = new HashMap<String, String[]>(request.getParameterMap());
         }
         
@@ -278,11 +293,22 @@ public class RequestDispatcherProvider e
         }
         
         public void setParameter(String name, String value) {
-            params.put(name, new String[]{value});
+            doSetParameters(name, new String[]{value});
         }
         
         public void setParameters(String name, List<String> values) {
-            params.put(name, values.toArray(new String[]{}));
+            doSetParameters(name, values.toArray(new String[]{}));
+        }
+        
+        private void doSetParameters(String name, String[] values) {
+            if (saveParamsAsAttributes) {
+                if (values.length == 1) {
+                    super.setAttribute(name, values[0]);
+                }
+                super.setAttribute(name + "Array", values);
+            } else {
+                params.put(name, values);
+            }
         }
         
         @Override



Mime
View raw message