velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nbu...@apache.org
Subject svn commit: r535073 - in /velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools: ToolboxFactory.java view/VelocityView.java
Date Fri, 04 May 2007 03:30:55 GMT
Author: nbubna
Date: Thu May  3 20:30:55 2007
New Revision: 535073

URL: http://svn.apache.org/viewvc?view=rev&rev=535073
Log:
s/hasToolbox/hasTools && s/getToolbox/createToolbox

Modified:
    velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/ToolboxFactory.java
    velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/VelocityView.java

Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/ToolboxFactory.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/ToolboxFactory.java?view=diff&rev=535073&r1=535072&r2=535073
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/ToolboxFactory.java
(original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/ToolboxFactory.java
Thu May  3 20:30:55 2007
@@ -186,13 +186,21 @@
         return data;
     }
 
-    public boolean hasToolbox(String scope)
+    public boolean hasTools(String scope)
     {
         Map<String,ToolInfo> tools = scopedToolInfo.get(scope);
-        return (tools != null && !tools.isEmpty());
+        if (tools != null && !tools.isEmpty())
+        {
+            return true;
+        }
+        else if (data != null && APPLICATION_SCOPE.equals(scope))
+        {
+            return true;
+        }
+        return false;
     }
 
-    public Toolbox getToolbox(String scope)
+    public Toolbox createToolbox(String scope)
     {
         Map<String,ToolInfo> tools = scopedToolInfo.get(scope);
         Map properties = scopedProperties.get(scope);

Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/VelocityView.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/VelocityView.java?view=diff&rev=535073&r1=535072&r2=535073
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/VelocityView.java
(original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/VelocityView.java
Thu May  3 20:30:55 2007
@@ -365,7 +365,7 @@
 
         // add any application toolbox to the application attributes
         Toolbox appTools =
-            toolboxFactory.getToolbox(ToolboxFactory.APPLICATION_SCOPE);
+            toolboxFactory.createToolbox(ToolboxFactory.APPLICATION_SCOPE);
         if (appTools != null &&
             this.servletContext.getAttribute(this.toolboxKey) == null)
         {
@@ -746,11 +746,12 @@
     protected void prepareToolboxes(HttpServletRequest request)
     {
         // only set a new toolbox if we need one
-        if (toolboxFactory.hasToolbox(ToolboxFactory.DEFAULT_SCOPE)
+        if (toolboxFactory.hasTools(ToolboxFactory.DEFAULT_SCOPE)
             && request.getAttribute(this.toolboxKey) == null)
         {
             // add request toolbox, if any
-            Toolbox reqTools = toolboxFactory.getToolbox(ToolboxFactory.DEFAULT_SCOPE);
+            Toolbox reqTools =
+                toolboxFactory.createToolbox(ToolboxFactory.DEFAULT_SCOPE);
             if (reqTools != null)
             {
                 request.setAttribute(this.toolboxKey, reqTools);
@@ -758,7 +759,7 @@
         }
 
         //TODO: move this string constant somewhere static
-        if (toolboxFactory.hasToolbox("session"))
+        if (toolboxFactory.hasTools("session"))
         {
             //FIXME? does this honor createSession props set on the session Toolbox?
             HttpSession session = request.getSession(this.createSession);
@@ -769,8 +770,9 @@
                 {
                     if (session.getAttribute(this.toolboxKey) == null)
                     {
-                       Toolbox sessTools = toolboxFactory.getToolbox("session");
-                       session.setAttribute(this.toolboxKey, sessTools);
+                        Toolbox sessTools =
+                            toolboxFactory.createToolbox("session");
+                        session.setAttribute(this.toolboxKey, sessTools);
                     }
                 }
             }



Mime
View raw message