cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r884440 - /cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/RequestProcessor.java
Date Thu, 26 Nov 2009 07:51:06 GMT
Author: reinhard
Date: Thu Nov 26 07:51:06 2009
New Revision: 884440

URL: http://svn.apache.org/viewvc?rev=884440&view=rev
Log:
make the preparation of request parameters reusable (for the Wicket integration)

Modified:
    cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/RequestProcessor.java

Modified: cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/RequestProcessor.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/RequestProcessor.java?rev=884440&r1=884439&r2=884440&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/RequestProcessor.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/RequestProcessor.java
Thu Nov 26 07:51:06 2009
@@ -128,7 +128,7 @@
     }
 
     @SuppressWarnings("unchecked")
-    private Map<String, Object> getInvocationParameters(HttpServletRequest req) {
+    private static Map<String, Object> getInvocationParameters(HttpServletRequest req)
{
         Map<String, Object> invocationParameters = new HashMap<String, Object>();
 
         for (Enumeration<String> names = req.getParameterNames(); names.hasMoreElements();)
{
@@ -247,13 +247,28 @@
         }
     }
 
-    private Map<String, Object> prepareParameters(HttpServletRequest request, HttpServletResponse
response,
-            Settings settings) {
-        Map<String, Object> parameters = this.getInvocationParameters(request);
+    public static Map<String, Object> prepareParameters(HttpServletRequest request,
HttpServletResponse response,
+            Settings settings, ServletContext servletContext) {
+        if (request == null) {
+            throw new NullPointerException("Request mustn't be null.");
+        }
+        if (response == null) {
+            throw new NullPointerException("Response mustn't be null.");
+        }
+        if (servletContext == null) {
+            throw new NullPointerException("ServletContext mustn't be null.");
+        }
+
+        Map<String, Object> parameters = getInvocationParameters(request);
+
         HttpContextHelper.storeRequest(request, parameters);
         HttpContextHelper.storeResponse(response, parameters);
-        HttpContextHelper.storeServletContext(this.servletContext, parameters);
-        SettingsHelper.storeSettings(settings, parameters);
+        HttpContextHelper.storeServletContext(servletContext, parameters);
+
+        if (settings != null) {
+            SettingsHelper.storeSettings(settings, parameters);
+        }
+
         return parameters;
     }
 
@@ -262,7 +277,8 @@
 
         // invoke the sitemap engine
         ByteArrayOutputStream baos = new ByteArrayOutputStream(8192);
-        this.invoke(this.calcSitemapRequestURI(request), this.prepareParameters(request,
response, settings), baos);
+        this.invoke(this.calcSitemapRequestURI(request), prepareParameters(request, response,
settings,
+                this.servletContext), baos);
 
         // collect meta information from the previous run of the sitemap engine
         long lastModified = LastModifiedCollector.getLastModified();



Mime
View raw message