velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nbu...@apache.org
Subject svn commit: r676935 - /velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/VelocityView.java
Date Tue, 15 Jul 2008 15:36:54 GMT
Author: nbubna
Date: Tue Jul 15 08:36:53 2008
New Revision: 676935

URL: http://svn.apache.org/viewvc?rev=676935&view=rev
Log:
make it easier to prepareToolboxes for non-http servlet requests

Modified:
    velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/VelocityView.java

Modified: velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/VelocityView.java
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/VelocityView.java?rev=676935&r1=676934&r2=676935&view=diff
==============================================================================
--- velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/VelocityView.java (original)
+++ velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/VelocityView.java Tue
Jul 15 08:36:53 2008
@@ -28,6 +28,7 @@
 import javax.servlet.FilterConfig;
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
+import javax.servlet.ServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
@@ -850,21 +851,16 @@
     }
 
 
+    /**
+     * Prepares the request scope toolbox, if one is configured for
+     * the toolbox factory, and then prepares the session toolbox
+     * if one is configured for the factory and has not yet been created
+     * for the current session.
+     */
     public void prepareToolboxes(HttpServletRequest request)
     {
-        // only set a new toolbox if we need one
-        if (toolboxFactory.hasTools(Scope.REQUEST)
-            && request.getAttribute(this.toolboxKey) == null)
-        {
-            // add request toolbox, if any
-            Toolbox reqTools = toolboxFactory.createToolbox(Scope.REQUEST);
-            if (reqTools != null)
-            {
-                request.setAttribute(this.toolboxKey, reqTools);
-            }
-        }
+        prepareToolbox(request);
 
-        //TODO: move this string constant somewhere static
         if (toolboxFactory.hasTools(Scope.SESSION))
         {
             //FIXME? does this honor createSession props set on the session Toolbox?
@@ -885,6 +881,30 @@
         }
     }
 
+    /**
+     * Prepares the request scope toolbox, if one is configured for
+     * the toolbox factory.
+     */
+    public void prepareToolboxes(ServletRequest request)
+    {
+        prepareToolbox(request);
+    }
+
+    private void prepareToolbox(ServletRequest request)
+    {
+        // only set a new toolbox if we need one
+        if (toolboxFactory.hasTools(Scope.REQUEST)
+            && request.getAttribute(this.toolboxKey) == null)
+        {
+            // add request toolbox, if any
+            Toolbox reqTools = toolboxFactory.createToolbox(Scope.REQUEST);
+            if (reqTools != null)
+            {
+                request.setAttribute(this.toolboxKey, reqTools);
+            }
+        }
+    }
+
 
     /**
      * Returns a mutex (lock object) unique to the specified session



Mime
View raw message