velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nbu...@apache.org
Subject svn commit: r546679 - /velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/ViewToolContext.java
Date Wed, 13 Jun 2007 00:07:00 GMT
Author: nbubna
Date: Tue Jun 12 17:06:58 2007
New Revision: 546679

URL: http://svn.apache.org/viewvc?view=rev&rev=546679
Log:
break up get() to make it easier for subclasses to override

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

Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/ViewToolContext.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/ViewToolContext.java?view=diff&rev=546679&r1=546678&r2=546679
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/ViewToolContext.java
(original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/ViewToolContext.java
Tue Jun 12 17:06:58 2007
@@ -164,14 +164,38 @@
      */
     public Object get(String key)
     {
-        /* search for a tool first */
+        /* search for a tool first, keeping them read-only */
         Object o = findTool(key);
         if (o != null)
         {
             return o;
         }
 
-        /* make the four scopes of the Apocalypse Read only */
+        /* put servlet API access here to keep it read-only */
+        o = getServletApi(key);
+        if (o != null)
+        {
+            return o;
+        }
+
+        /* try the local context */
+        o = internalGet(key);
+        if (o != null)
+        {
+            return o;
+        }
+
+        /* if not found, wander down the scopes... */
+        return getAttribute(key);
+    }
+
+    /**
+     * Returns the current matching servlet request, response, session, 
+     * or servlet context instance, or null if the key matches none of those
+     * keys.
+     */
+    protected Object getServletApi(String key)
+    {
         if (key.equals(REQUEST))
         {
             return request;
@@ -188,16 +212,7 @@
         {
             return application;
         }
-
-        /* try the local context */
-        o = internalGet(key);
-        if (o != null)
-        {
-            return o;
-        }
-
-        /* if not found, wander down the scopes... */
-        return getAttribute(key);
+        return null;
     }
 
 



Mime
View raw message