<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>commits@velocity.apache.org Archives</title>
<link rel="self" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/?format=atom"/>
<link href="http://mail-archives.apache.org/mod_mbox/velocity-commits/"/>
<id>http://mail-archives.apache.org/mod_mbox/velocity-commits/</id>
<updated>2009-12-06T14:30:05Z</updated>
<entry>
<title>svn commit: r832324 - /velocity/engine/trunk/src/java/org/apache/velocity/app/event/InvalidReferenceEventHandler.java</title>
<author><name>wglass@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200911.mbox/%3c20091103073304.3ED1F23888D8@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091103073304-3ED1F23888D8@eris-apache-org%3e</id>
<updated>2009-11-03T07:33:04Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: wglass
Date: Tue Nov  3 07:33:03 2009
New Revision: 832324

URL: http://svn.apache.org/viewvc?rev=832324&amp;view=rev
Log:
fix typo

Modified:
    velocity/engine/trunk/src/java/org/apache/velocity/app/event/InvalidReferenceEventHandler.java

Modified: velocity/engine/trunk/src/java/org/apache/velocity/app/event/InvalidReferenceEventHandler.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/app/event/InvalidReferenceEventHandler.java?rev=832324&amp;r1=832323&amp;r2=832324&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/app/event/InvalidReferenceEventHandler.java
(original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/app/event/InvalidReferenceEventHandler.java
Tue Nov  3 07:33:03 2009
@@ -77,7 +77,7 @@
      * the chain until the first non-null value is returned. 
      * 
      * @param context the context when the reference was found invalid
-     * @param reference string with complete invalid reference.  . If silent reference, will
start with $!
+     * @param reference string with complete invalid reference.  If silent reference, will
start with $!
      * @param object the object referred to, or null if not found
      * @param method the name of the (non-existent) method
      * @param info contains template, line, column details




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r832302 - in /velocity/engine/trunk/src: java/org/apache/velocity/app/event/InvalidReferenceEventHandler.java java/org/apache/velocity/runtime/parser/node/ASTReference.java test/org/apache/velocity/test/InvalidEventHandlerTestCase.java</title>
<author><name>wglass@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200911.mbox/%3c20091103053232.25E1D23888CE@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091103053232-25E1D23888CE@eris-apache-org%3e</id>
<updated>2009-11-03T05:32:32Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: wglass
Date: Tue Nov  3 05:32:31 2009
New Revision: 832302

URL: http://svn.apache.org/viewvc?rev=832302&amp;view=rev
Log:
include ! in reference name when calling InvalidReferenceEventHandler, e.g. $!foo instead
of $foo.   VELOCITY-740.

Modified:
    velocity/engine/trunk/src/java/org/apache/velocity/app/event/InvalidReferenceEventHandler.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
    velocity/engine/trunk/src/test/org/apache/velocity/test/InvalidEventHandlerTestCase.java

Modified: velocity/engine/trunk/src/java/org/apache/velocity/app/event/InvalidReferenceEventHandler.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/app/event/InvalidReferenceEventHandler.java?rev=832302&amp;r1=832301&amp;r2=832302&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/app/event/InvalidReferenceEventHandler.java
(original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/app/event/InvalidReferenceEventHandler.java
Tue Nov  3 05:32:31 2009
@@ -44,7 +44,7 @@
      * returned.
      * 
      * @param context the context when the reference was found invalid
-     * @param reference string with complete invalid reference
+     * @param reference string with complete invalid reference. If silent reference, will
start with $!
      * @param object the object referred to, or null if not found
      * @param property the property name from the reference
      * @param info contains template, line, column details
@@ -77,7 +77,7 @@
      * the chain until the first non-null value is returned. 
      * 
      * @param context the context when the reference was found invalid
-     * @param reference string with complete invalid reference
+     * @param reference string with complete invalid reference.  . If silent reference, will
start with $!
      * @param object the object referred to, or null if not found
      * @param method the name of the (non-existent) method
      * @param info contains template, line, column details

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java?rev=832302&amp;r1=832301&amp;r2=832302&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
(original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
Tue Nov  3 05:32:31 2009
@@ -242,7 +242,7 @@
         if (result == null &amp;&amp; !strictRef)
         {
             return EventHandlerUtil.invalidGetMethod(rsvc, context, 
-                    "$" + rootString, null, null, uberInfo);
+                    getDollarBang() + rootString, null, null, uberInfo);
         }
 
         /*
@@ -291,11 +291,11 @@
                 if (failedChild == -1)
                 {
                     result = EventHandlerUtil.invalidGetMethod(rsvc, context, 
-                            "$" + rootString, previousResult, null, uberInfo);          
         
+                            getDollarBang() + rootString, previousResult, null, uberInfo);
                   
                 }
                 else
                 {
-                    StringBuffer name = new StringBuffer("$").append(rootString);
+                    StringBuffer name = new StringBuffer(getDollarBang()).append(rootString);
                     for (int i = 0; i &lt;= failedChild; i++)
                     {
                         Node node = jjtGetChild(i);
@@ -1010,4 +1010,9 @@
         }
         return obj;        
     }
+
+    public String getDollarBang()
+    {
+        return (referenceType == QUIET_REFERENCE) ? "$!" : "$";
+    }
 }

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/InvalidEventHandlerTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/InvalidEventHandlerTestCase.java?rev=832302&amp;r1=832301&amp;r2=832302&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/InvalidEventHandlerTestCase.java
(original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/InvalidEventHandlerTestCase.java
Tue Nov  3 05:32:31 2009
@@ -187,8 +187,10 @@
     {
         VelocityContext context = new VelocityContext(vc);
         context.put("a1",new Integer(5));
+        context.put("b1",new Integer(5));
         context.put("a4",new Integer(5));
-        context.put("b1","abc");
+        context.put("b4",new Integer(5));
+        context.put("z1","abc");
         
         String s;
         Writer w;
@@ -201,6 +203,14 @@
             fail("Expected exception.");
         } catch (RuntimeException e) {}
         
+        // good object, bad method
+        s = "$!b1.afternoon()";
+        w = new StringWriter();
+        try {
+            ve.evaluate( context, w, "mystring", s );
+            fail("Expected exception.");
+        } catch (RuntimeException e) {}
+        
         // bad object, bad method -- fails on get
         s = "$zz.daylight()";
         w = new StringWriter();
@@ -210,7 +220,7 @@
         } catch (RuntimeException e) {}
 
         // change result
-        s = "$b1.baby()";
+        s = "$z1.baby()";
         w = new StringWriter();
         ve.evaluate( context, w, "mystring", s );
         assertEquals("www",w.toString());        
@@ -229,11 +239,13 @@
         
         VelocityContext context = new VelocityContext(vc);
         context.put("a1",new Integer(5));
+        context.put("b1",new Integer(5));
         context.put("a4",new Integer(5));
-        context.put("b1","abc");
+        context.put("b4",new Integer(5));
+        context.put("z1","abc");
         
         // normal - should be no calls to handler
-        String s = "$a1 $a1.intValue() $b1 $b1.length() #set($c1 = '5')";
+        String s = "$a1 $a1.intValue() $z1 $z1.length() #set($c1 = '5')";
         Writer w = new StringWriter();
         ve.evaluate( context, w, "mystring", s );
         
@@ -245,6 +257,14 @@
             fail("Expected exception.");
         } catch (RuntimeException e) {}
         
+        // good object, bad property / silent
+        s = "$!b1.foobar";
+        w = new StringWriter();
+        try {
+            ve.evaluate( context, w, "mystring", s );
+            fail("Expected exception.");
+        } catch (RuntimeException e) {}
+        
         // bad object, bad property            
         s = "$a2.foobar";
         w = new StringWriter();
@@ -253,6 +273,14 @@
             fail("Expected exception.");
         } catch (RuntimeException e) {}
         
+        // bad object, bad property / silent            
+        s = "$!b2.foobar";
+        w = new StringWriter();
+        try {
+            ve.evaluate( context, w, "mystring", s );
+            fail("Expected exception.");
+        } catch (RuntimeException e) {}
+        
         // bad object, no property            
         s = "$a3";
         w = new StringWriter();
@@ -261,13 +289,21 @@
             fail("Expected exception.");
         } catch (RuntimeException e) {}
         
+        // bad object, no property / silent            
+        s = "$!b3";
+        w = new StringWriter();
+        try {
+            ve.evaluate( context, w, "mystring", s );
+            fail("Expected exception.");
+        } catch (RuntimeException e) {}
+        
         // good object, bad property; change the value
         s = "$a4.foobar";
         w = new StringWriter();
         ve.evaluate( context, w, "mystring", s );
         result = w.toString();
         assertEquals("zzz", result);
-        
+
     }
     
     
@@ -314,6 +350,30 @@
                 throw new RuntimeException("expected exception");
             }
             
+            // good object, bad property
+            else if (reference.equals("$!b1.foobar"))
+            {
+                assertEquals(new Integer(5),object);
+                assertEquals("foobar",property);
+                throw new RuntimeException("expected exception");
+            }
+            
+            // good object, bad property
+            else if (reference.equals("$a1.foobar"))
+            {
+                assertEquals(new Integer(5),object);
+                assertEquals("foobar",property);
+                throw new RuntimeException("expected exception");
+            }
+            
+            // good object, bad property
+            else if (reference.equals("$!b1.foobar"))
+            {
+                assertEquals(new Integer(5),object);
+                assertEquals("foobar",property);
+                throw new RuntimeException("expected exception");
+            }
+            
             // bad object, bad property            
             else if (reference.equals("$a2"))
             {
@@ -321,7 +381,15 @@
                 assertNull(property);
                 throw new RuntimeException("expected exception");
             }
-            
+
+            // bad object, bad property            
+            else if (reference.equals("$!b2"))
+            {
+                assertNull(object);
+                assertNull(property);
+                throw new RuntimeException("expected exception");
+            }
+
             // bad object, no property            
             else if (reference.equals("$a3"))
             {
@@ -330,6 +398,14 @@
                 throw new RuntimeException("expected exception");
             }
             
+            // bad object, no property            
+            else if (reference.equals("$!b3"))
+            {
+                assertNull(object);
+                assertNull(property);
+                throw new RuntimeException("expected exception");
+            }
+            
             // good object, bad property; change the value
             else if (reference.equals("$a4.foobar"))
             {
@@ -389,11 +465,24 @@
             // good reference, bad method
             if (object.getClass().equals(Integer.class))
             {
-                assertEquals("$a1.afternoon()",reference);
-                assertEquals("afternoon",method);
-                throw new RuntimeException("expected exception");
+                if (reference.equals("$a1.afternoon()"))
+                {
+                    assertEquals("afternoon",method);
+                    throw new RuntimeException("expected exception");                   

+                }
+                else if (reference.equals("$!b1.afternoon()"))
+                {
+                    assertEquals("afternoon",method);
+                    throw new RuntimeException("expected exception");                   

+                }
+                else
+                {
+                    fail("Unexpected invalid method.  " + method);
+                    
+                }
             }
 
+
             else if (object.getClass().equals(String.class) &amp;&amp; "baby".equals(method))
             {
                 return "www";




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r832280 - /velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/ResourceLoader.java</title>
<author><name>wglass@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200911.mbox/%3c20091103024755.8DBAF23888DA@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091103024755-8DBAF23888DA@eris-apache-org%3e</id>
<updated>2009-11-03T02:47:55Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: wglass
Date: Tue Nov  3 02:47:55 2009
New Revision: 832280

URL: http://svn.apache.org/viewvc?rev=832280&amp;view=rev
Log:
it's overkill to show a stack trace when the resource can't be found.  VELOCITY-720.

Modified:
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/ResourceLoader.java

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/ResourceLoader.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/ResourceLoader.java?rev=832280&amp;r1=832279&amp;r2=832280&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/ResourceLoader.java
(original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/ResourceLoader.java
Tue Nov  3 02:47:55 2009
@@ -229,7 +229,7 @@
             {
                 log.debug("Could not load resource '" + resourceName 
                         + "' from ResourceLoader " + this.getClass().getName() 
-                        + ": ", e);
+                        + ": " + e.getMessage());
             }
         }
         finally




</pre>
</div>
</content>
</entry>
<entry>
<title>svn propchange: r832275 - svn:log</title>
<author><name>wglass@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200911.mbox/%3c20091103023559.ADEDA23888D8@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091103023559-ADEDA23888D8@eris-apache-org%3e</id>
<updated>2009-11-03T02:35:59Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: wglass
Revision: 832275
Modified property: svn:log

Modified: svn:log at Tue Nov  3 02:35:59 2009
------------------------------------------------------------------------------
--- svn:log (original)
+++ svn:log Tue Nov  3 02:35:59 2009
@@ -1 +1 @@
-upgraded build requirements to ant 1.7 to simplify situation with junit.  (no need to copy
to ant lib directory)
+upgraded build requirements to ant 1.7 to simplify situation with junit.  (no need to copy
to ant lib directory). VELOCITY-724.



</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r832275 - in /velocity/engine/trunk: README.txt build/build.xml xdocs/docs/build.xml xdocs/docs/getting-started.xml xdocs/docs/index.xml</title>
<author><name>wglass@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200911.mbox/%3c20091103023346.D8F5923888D8@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091103023346-D8F5923888D8@eris-apache-org%3e</id>
<updated>2009-11-03T02:33:46Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: wglass
Date: Tue Nov  3 02:33:45 2009
New Revision: 832275

URL: http://svn.apache.org/viewvc?rev=832275&amp;view=rev
Log:
upgraded build requirements to ant 1.7 to simplify situation with junit.  (no need to copy
to ant lib directory)

Modified:
    velocity/engine/trunk/README.txt
    velocity/engine/trunk/build/build.xml
    velocity/engine/trunk/xdocs/docs/build.xml
    velocity/engine/trunk/xdocs/docs/getting-started.xml
    velocity/engine/trunk/xdocs/docs/index.xml

Modified: velocity/engine/trunk/README.txt
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/README.txt?rev=832275&amp;r1=832274&amp;r2=832275&amp;view=diff
==============================================================================
--- velocity/engine/trunk/README.txt (original)
+++ velocity/engine/trunk/README.txt Tue Nov  3 02:33:45 2009
@@ -108,7 +108,7 @@
 
 http://velocity.apache.org/engine/devel/build.html
 
-Note that you must use Ant version 1.6 or later.
+Note that you must use Ant version 1.7 or later.
 
 *IMPORTANT* As the Apache Velocity build process wants to download a
  number of jars from the internet, you must be online when you are

Modified: velocity/engine/trunk/build/build.xml
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/build/build.xml?rev=832275&amp;r1=832274&amp;r2=832275&amp;view=diff
==============================================================================
--- velocity/engine/trunk/build/build.xml (original)
+++ velocity/engine/trunk/build/build.xml Tue Nov  3 02:33:45 2009
@@ -1179,6 +1179,25 @@
   &lt;target name="test-main" depends="build-prepare,compile-test"
           description="Run the Velocity testcases"&gt;
 
+    &lt;!-- Require ant 1.7+ for Junit compatibility --&gt;
+	&lt;fail message="You are currently using ${ant.version}"&gt;
+			&lt;condition&gt;
+				&lt;or&gt;
+				&lt;contains string="${ant.version}" substring="1.2"/&gt;
+				&lt;contains string="${ant.version}" substring="1.3"/&gt;
+				&lt;contains string="${ant.version}" substring="1.4"/&gt;
+				&lt;contains string="${ant.version}" substring="1.5"/&gt;
+				&lt;contains string="${ant.version}" substring="1.6"/&gt;
+			&lt;/or&gt;
+		&lt;/condition&gt;
+	      Could not run junit tests:
+	  ***********************************************************
+	  **
+	  ** Ant must be at least version 1.7
+	  **
+	  ***********************************************************
+  	&lt;/fail&gt;
+
     &lt;mkdir dir="${build.test.reports}"/&gt;
     &lt;junit dir="${velocity.dir}"
            fork="true"

Modified: velocity/engine/trunk/xdocs/docs/build.xml
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/xdocs/docs/build.xml?rev=832275&amp;r1=832274&amp;r2=832275&amp;view=diff
==============================================================================
--- velocity/engine/trunk/xdocs/docs/build.xml (original)
+++ velocity/engine/trunk/xdocs/docs/build.xml Tue Nov  3 02:33:45 2009
@@ -45,7 +45,7 @@
 
 
 &lt;p&gt;Ant is also an Apache project, and can be
-found &lt;a href="http://ant.apache.org/"&gt;here&lt;/a&gt;. To build Apache Velocity, you
need at least Version 1.6 of Apache Ant.
+found &lt;a href="http://ant.apache.org/"&gt;here&lt;/a&gt;. To build Apache Velocity, you
need at least Version 1.7 of Apache Ant.
 &lt;/p&gt;
 
 &lt;p&gt;
@@ -73,7 +73,7 @@
 
 &lt;p&gt;
 To make building Velocity easy and consistent, we require an Apache project
-called &lt;a href="http://ant.apache.org/"&gt;Ant&lt;/a&gt; version 1.6 or
+called &lt;a href="http://ant.apache.org/"&gt;Ant&lt;/a&gt; version 1.7 or
 higher to perform the build process. We assume that you have followed
 Ant's installation instructions and have it properly installed.
 &lt;/p&gt;
@@ -307,11 +307,6 @@
 well with your build of Velocity.
 &lt;/p&gt;
 
-&lt;p&gt;The tests are run with the ant task &amp;lt;junit&amp;gt;.  For ant 1.6, this task
requires that 
-&lt;code&gt;junit.jar&lt;/code&gt; be copied into the &lt;code&gt;lib&lt;/code&gt; subdirectory
of your 
-ant directory.  For ant 1.7 this is not required.
-&lt;/p&gt;
-
 &lt;p&gt;
 To run the test suite, simply use the build target
 &lt;b&gt;test&lt;/b&gt; when you build:

Modified: velocity/engine/trunk/xdocs/docs/getting-started.xml
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/xdocs/docs/getting-started.xml?rev=832275&amp;r1=832274&amp;r2=832275&amp;view=diff
==============================================================================
--- velocity/engine/trunk/xdocs/docs/getting-started.xml (original)
+++ velocity/engine/trunk/xdocs/docs/getting-started.xml Tue Nov  3 02:33:45 2009
@@ -107,7 +107,7 @@
 &lt;p&gt;
 &lt;b&gt;Note:&lt;/b&gt; Velocity uses the &lt;a href="http://ant.apache.org/"&gt;Apache
Ant&lt;/a&gt;
 build tool for all code and documentation generation, so you will need to have it
-installed. Velocity requires at least Apache Ant 1.6.
+installed. Velocity requires at least Apache Ant 1.7.
    &lt;/p&gt;
 
 &lt;/section&gt;

Modified: velocity/engine/trunk/xdocs/docs/index.xml
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/xdocs/docs/index.xml?rev=832275&amp;r1=832274&amp;r2=832275&amp;view=diff
==============================================================================
--- velocity/engine/trunk/xdocs/docs/index.xml (original)
+++ velocity/engine/trunk/xdocs/docs/index.xml Tue Nov  3 02:33:45 2009
@@ -55,7 +55,7 @@
 
     &lt;section name="Where do I get releases?" href="WheredoIgetreleases?"&gt;
 
-      &lt;p&gt; The current stable release version is version 1.6.1. &lt;/p&gt;
+      &lt;p&gt; The current stable release version is version 1.6.2. &lt;/p&gt;
 
       &lt;p&gt; The release distribution is available as a combined source/binary distribution
in
         &lt;code&gt;tar.gz&lt;/code&gt; and




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r832264 - in /velocity/engine/trunk/test/includeevent: compare/test7.cmp macros.vm test7.vm</title>
<author><name>wglass@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200911.mbox/%3c20091103020837.02FC323888D8@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091103020837-02FC323888D8@eris-apache-org%3e</id>
<updated>2009-11-03T02:08:36Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: wglass
Date: Tue Nov  3 02:08:36 2009
New Revision: 832264

URL: http://svn.apache.org/viewvc?rev=832264&amp;view=rev
Log:
test that macros are blocked from loading with null return from IncludeEventHandler

Added:
    velocity/engine/trunk/test/includeevent/compare/test7.cmp   (with props)
    velocity/engine/trunk/test/includeevent/macros.vm   (with props)
    velocity/engine/trunk/test/includeevent/test7.vm   (with props)

Added: velocity/engine/trunk/test/includeevent/compare/test7.cmp
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/test/includeevent/compare/test7.cmp?rev=832264&amp;view=auto
==============================================================================
--- velocity/engine/trunk/test/includeevent/compare/test7.cmp (added)
+++ velocity/engine/trunk/test/includeevent/compare/test7.cmp Tue Nov  3 02:08:36 2009
@@ -0,0 +1,3 @@
+Test File 7
+
+#sample("boo")
\ No newline at end of file

Propchange: velocity/engine/trunk/test/includeevent/compare/test7.cmp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: velocity/engine/trunk/test/includeevent/compare/test7.cmp
------------------------------------------------------------------------------
    svn:keywords = Id Author Date Revision

Added: velocity/engine/trunk/test/includeevent/macros.vm
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/test/includeevent/macros.vm?rev=832264&amp;view=auto
==============================================================================
--- velocity/engine/trunk/test/includeevent/macros.vm (added)
+++ velocity/engine/trunk/test/includeevent/macros.vm Tue Nov  3 02:08:36 2009
@@ -0,0 +1,3 @@
+#macro(sample $a)
+	do something with $a
+#end
\ No newline at end of file

Propchange: velocity/engine/trunk/test/includeevent/macros.vm
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: velocity/engine/trunk/test/includeevent/macros.vm
------------------------------------------------------------------------------
    svn:keywords = Id Author Date Revision

Added: velocity/engine/trunk/test/includeevent/test7.vm
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/test/includeevent/test7.vm?rev=832264&amp;view=auto
==============================================================================
--- velocity/engine/trunk/test/includeevent/test7.vm (added)
+++ velocity/engine/trunk/test/includeevent/test7.vm Tue Nov  3 02:08:36 2009
@@ -0,0 +1,4 @@
+Test File 7
+#parse("macros.vm")
+
+#sample("boo")
\ No newline at end of file

Propchange: velocity/engine/trunk/test/includeevent/test7.vm
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: velocity/engine/trunk/test/includeevent/test7.vm
------------------------------------------------------------------------------
    svn:keywords = Id Author Date Revision




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r832262 - /velocity/engine/trunk/src/test/org/apache/velocity/test/IncludeEventHandlingTestCase.java</title>
<author><name>wglass@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200911.mbox/%3c20091103020540.9F33823888D8@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091103020540-9F33823888D8@eris-apache-org%3e</id>
<updated>2009-11-03T02:05:40Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: wglass
Date: Tue Nov  3 02:05:39 2009
New Revision: 832262

URL: http://svn.apache.org/viewvc?rev=832262&amp;view=rev
Log:
test that macros are blocked from loading with null return from IncludeEventHandler

Modified:
    velocity/engine/trunk/src/test/org/apache/velocity/test/IncludeEventHandlingTestCase.java

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/IncludeEventHandlingTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/IncludeEventHandlingTestCase.java?rev=832262&amp;r1=832261&amp;r2=832262&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/IncludeEventHandlingTestCase.java
(original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/IncludeEventHandlingTestCase.java
Tue Nov  3 02:05:39 2009
@@ -23,6 +23,8 @@
 import java.io.FileOutputStream;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -215,6 +217,36 @@
                 RESULT_FILE_EXT, CMP_FILE_EXT));
     }
 
+    /**
+     * Check bug VELOCITY-717.
+     */
+    public void testIncludeEventHandlingBlockMacros()
+            throws Exception
+    {
+        Template template = engine.getTemplate(
+            getFileName(null, "test7", TMPL_FILE_EXT));
+
+        FileOutputStream fos =
+            new FileOutputStream (
+                getFileName(RESULTS_DIR, "test7", RESULT_FILE_EXT));
+
+        Writer writer = new BufferedWriter(new OutputStreamWriter(fos));
+
+        // set up handler
+        Context context = new VelocityContext();
+        EventCartridge ec = new EventCartridge();
+        ec.addEventHandler(this);
+        ec.attachToContext( context );
+        
+        EventHandlerBehavior = BLOCK;
+        template.merge(context, writer);
+        writer.flush();
+        writer.close();
+
+        assertTrue("Output incorrect.", isMatch(RESULTS_DIR, COMPARE_DIR, "test7",
+                RESULT_FILE_EXT, CMP_FILE_EXT));
+    }
+
 
     public void setRuntimeServices( RuntimeServices rs )
     {




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r832253 - /velocity/engine/trunk/src/test/org/apache/velocity/test/IncludeEventHandlingTestCase.java</title>
<author><name>wglass@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200911.mbox/%3c20091103014134.3379D23888E4@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091103014134-3379D23888E4@eris-apache-org%3e</id>
<updated>2009-11-03T01:41:34Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: wglass
Date: Tue Nov  3 01:41:33 2009
New Revision: 832253

URL: http://svn.apache.org/viewvc?rev=832253&amp;view=rev
Log:
refactor to separate out tests to different methods

Modified:
    velocity/engine/trunk/src/test/org/apache/velocity/test/IncludeEventHandlingTestCase.java

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/IncludeEventHandlingTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/IncludeEventHandlingTestCase.java?rev=832253&amp;r1=832252&amp;r2=832253&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/IncludeEventHandlingTestCase.java
(original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/IncludeEventHandlingTestCase.java
Tue Nov  3 01:41:33 2009
@@ -122,51 +122,24 @@
     /**
      * Runs the test.
      */
-    public void testIncludeEventHandling ()
+    public void testIncludeEventHandlingPassThrough ()
             throws Exception
     {
         Template template1 = engine.getTemplate(
             getFileName(null, "test1", TMPL_FILE_EXT));
 
-        Template template2 = engine.getTemplate(
-            getFileName(null, "subdir/test2", TMPL_FILE_EXT));
-
-        Template template3 = engine.getTemplate(
-            getFileName(null, "test3", TMPL_FILE_EXT));
-
         FileOutputStream fos1 =
             new FileOutputStream (
                 getFileName(RESULTS_DIR, "test1", RESULT_FILE_EXT));
 
-        FileOutputStream fos2 =
-            new FileOutputStream (
-                getFileName(RESULTS_DIR, "test2", RESULT_FILE_EXT));
-
-        FileOutputStream fos3 =
-            new FileOutputStream (
-                getFileName(RESULTS_DIR, "test3", RESULT_FILE_EXT));
-
         Writer writer1 = new BufferedWriter(new OutputStreamWriter(fos1));
-        Writer writer2 = new BufferedWriter(new OutputStreamWriter(fos2));
-        Writer writer3 = new BufferedWriter(new OutputStreamWriter(fos3));
-
-        /*
-         *  lets make a Context and add the event cartridge
-         */
 
+        // set up handler
         Context context = new VelocityContext();
-
-        /*
-         *  Now make an event cartridge, register the
-         *  input event handler and attach it to the
-         *  Context
-         */
-
         EventCartridge ec = new EventCartridge();
         ec.addEventHandler(this);
         ec.attachToContext( context );
 
-
         // BEHAVIOR A: pass through #input and #parse with no change
         EventHandlerBehavior = PASS_THROUGH;
 
@@ -174,6 +147,31 @@
         writer1.flush();
         writer1.close();
 
+        assertTrue("Output incorrect.", isMatch(RESULTS_DIR, COMPARE_DIR, "test1",
+                RESULT_FILE_EXT, CMP_FILE_EXT));
+    }
+
+    /**
+     * Runs the test.
+     */
+    public void testIncludeEventHandlingRelative()
+            throws Exception
+    {
+        Template template2 = engine.getTemplate(
+            getFileName(null, "subdir/test2", TMPL_FILE_EXT));
+
+        FileOutputStream fos2 =
+            new FileOutputStream (
+                getFileName(RESULTS_DIR, "test2", RESULT_FILE_EXT));
+
+        Writer writer2 = new BufferedWriter(new OutputStreamWriter(fos2));
+
+        // set up handler
+        Context context = new VelocityContext();
+        EventCartridge ec = new EventCartridge();
+        ec.addEventHandler(this);
+        ec.attachToContext( context );
+
         // BEHAVIOR B: pass through #input and #parse with using a relative path
         EventHandlerBehavior = RELATIVE_PATH;
 
@@ -181,6 +179,31 @@
         writer2.flush();
         writer2.close();
 
+        assertTrue("Output incorrect.", isMatch(RESULTS_DIR, COMPARE_DIR, "test2",
+                RESULT_FILE_EXT, CMP_FILE_EXT));
+    }
+
+    /**
+     * Runs the test.
+     */
+    public void testIncludeEventHandlingBlock()
+            throws Exception
+    {
+        Template template3 = engine.getTemplate(
+            getFileName(null, "test3", TMPL_FILE_EXT));
+
+        FileOutputStream fos3 =
+            new FileOutputStream (
+                getFileName(RESULTS_DIR, "test3", RESULT_FILE_EXT));
+
+        Writer writer3 = new BufferedWriter(new OutputStreamWriter(fos3));
+
+        // set up handler
+        Context context = new VelocityContext();
+        EventCartridge ec = new EventCartridge();
+        ec.addEventHandler(this);
+        ec.attachToContext( context );
+
         // BEHAVIOR C: refuse to pass through #input and #parse
         EventHandlerBehavior = BLOCK;
 
@@ -188,22 +211,14 @@
         writer3.flush();
         writer3.close();
 
-        if (!isMatch(RESULTS_DIR, COMPARE_DIR, "test1",
-                RESULT_FILE_EXT, CMP_FILE_EXT) ||
-            !isMatch(RESULTS_DIR, COMPARE_DIR, "test2",
-                RESULT_FILE_EXT, CMP_FILE_EXT) ||
-            !isMatch(RESULTS_DIR, COMPARE_DIR, "test3",
-                RESULT_FILE_EXT, CMP_FILE_EXT)
-                )
-        {
-            fail("Output incorrect.");
-        }
+        assertTrue("Output incorrect.", isMatch(RESULTS_DIR, COMPARE_DIR, "test3",
+                RESULT_FILE_EXT, CMP_FILE_EXT));
     }
 
 
     public void setRuntimeServices( RuntimeServices rs )
-     {
-     }
+    {
+    }
 
     /**
      * Sample handler with different behaviors for the different tests.




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r832247 - in /velocity/engine/trunk/src/test/org/apache/velocity/test: ./ issues/ sql/ util/introspection/</title>
<author><name>wglass@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200911.mbox/%3c20091103012932.4806923888E4@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091103012932-4806923888E4@eris-apache-org%3e</id>
<updated>2009-11-03T01:29:31Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: wglass
Date: Tue Nov  3 01:29:30 2009
New Revision: 832247

URL: http://svn.apache.org/viewvc?rev=832247&amp;view=rev
Log:
Changed test cases to use VelocityEngine instead of Velocity, so they will work in Eclipse.
 (within the same JVM).  There's a few that will still fail in eclipse which rely on special
classpath elements or require the singleton Velocity class.

Modified:
    velocity/engine/trunk/src/test/org/apache/velocity/test/AbsoluteFileResourceLoaderTestCase.java
    velocity/engine/trunk/src/test/org/apache/velocity/test/IncludeEventHandlingTestCase.java
    velocity/engine/trunk/src/test/org/apache/velocity/test/InlineScopeVMTestCase.java
    velocity/engine/trunk/src/test/org/apache/velocity/test/MacroForwardDefineTestCase.java
    velocity/engine/trunk/src/test/org/apache/velocity/test/MultiLoaderTestCase.java
    velocity/engine/trunk/src/test/org/apache/velocity/test/MultipleFileResourcePathTestCase.java
    velocity/engine/trunk/src/test/org/apache/velocity/test/StringResourceLoaderRepositoryTestCase.java
    velocity/engine/trunk/src/test/org/apache/velocity/test/StringResourceLoaderTestCase.java
    velocity/engine/trunk/src/test/org/apache/velocity/test/VelocimacroTestCase.java
    velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity580TestCase.java
    velocity/engine/trunk/src/test/org/apache/velocity/test/sql/DataSourceResourceLoaderTestCase.java
    velocity/engine/trunk/src/test/org/apache/velocity/test/util/introspection/ChainedUberspectorsTestCase.java

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/AbsoluteFileResourceLoaderTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/AbsoluteFileResourceLoaderTestCase.java?rev=832247&amp;r1=832246&amp;r2=832247&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/AbsoluteFileResourceLoaderTestCase.java
(original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/AbsoluteFileResourceLoaderTestCase.java
Tue Nov  3 01:29:30 2009
@@ -29,6 +29,8 @@
 import org.apache.velocity.Template;
 import org.apache.velocity.VelocityContext;
 import org.apache.velocity.app.Velocity;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
 import org.apache.velocity.runtime.RuntimeSingleton;
 import org.apache.velocity.test.misc.TestLogChute;
 
@@ -71,6 +73,8 @@
      */
     private static final String COMPARE_DIR = TEST_COMPARE_DIR + "/absolute/compare";
 
+    VelocityEngine engine;
+    
     /**
      * Default constructor.
      */
@@ -82,15 +86,16 @@
         {
             assureResultsDirectoryExists(RESULTS_DIR);
 
-
+            engine = new VelocityEngine();
+            
             // signify we want to use an absolute path
-            Velocity.addProperty(
-                Velocity.FILE_RESOURCE_LOADER_PATH, "");
+            engine.addProperty(
+                RuntimeConstants.FILE_RESOURCE_LOADER_PATH, "");
 
-            Velocity.setProperty(
-                    Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName());
+            engine.setProperty(
+                    RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName());
 
-            Velocity.init();
+            engine.init();
         }
         catch (Exception e)
         {
@@ -116,7 +121,7 @@
 
             System.out.println("Retrieving template at absolute path: " + f);
 
-            Template template1 = RuntimeSingleton.getTemplate(f);
+            Template template1 = engine.getTemplate(f);
 
             FileOutputStream fos1 =
                 new FileOutputStream (

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/IncludeEventHandlingTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/IncludeEventHandlingTestCase.java?rev=832247&amp;r1=832246&amp;r2=832247&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/IncludeEventHandlingTestCase.java
(original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/IncludeEventHandlingTestCase.java
Tue Nov  3 01:29:30 2009
@@ -29,12 +29,12 @@
 
 import org.apache.velocity.Template;
 import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.Velocity;
+import org.apache.velocity.app.VelocityEngine;
 import org.apache.velocity.app.event.EventCartridge;
 import org.apache.velocity.app.event.IncludeEventHandler;
 import org.apache.velocity.context.Context;
+import org.apache.velocity.runtime.RuntimeConstants;
 import org.apache.velocity.runtime.RuntimeServices;
-import org.apache.velocity.runtime.RuntimeSingleton;
 import org.apache.velocity.test.misc.TestLogChute;
 import org.apache.velocity.util.RuntimeServicesAware;
 
@@ -85,6 +85,8 @@
 
     private int EventHandlerBehavior = PASS_THROUGH;
 
+    VelocityEngine engine;
+    
     /**
      * Default constructor.
      */
@@ -98,13 +100,15 @@
     {
         assureResultsDirectoryExists(RESULTS_DIR);
 
-        Velocity.addProperty(
-            Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH);
+        engine = new VelocityEngine();
+        
+        engine.addProperty(
+                RuntimeConstants.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH);
 
-        Velocity.setProperty(
-                Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName());
+        engine.setProperty(
+                RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName());
 
-        Velocity.init();
+        engine.init();
 
 
     }
@@ -121,13 +125,13 @@
     public void testIncludeEventHandling ()
             throws Exception
     {
-        Template template1 = RuntimeSingleton.getTemplate(
+        Template template1 = engine.getTemplate(
             getFileName(null, "test1", TMPL_FILE_EXT));
 
-        Template template2 = RuntimeSingleton.getTemplate(
+        Template template2 = engine.getTemplate(
             getFileName(null, "subdir/test2", TMPL_FILE_EXT));
 
-        Template template3 = RuntimeSingleton.getTemplate(
+        Template template3 = engine.getTemplate(
             getFileName(null, "test3", TMPL_FILE_EXT));
 
         FileOutputStream fos1 =

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/InlineScopeVMTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/InlineScopeVMTestCase.java?rev=832247&amp;r1=832246&amp;r2=832247&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/InlineScopeVMTestCase.java (original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/InlineScopeVMTestCase.java Tue
Nov  3 01:29:30 2009
@@ -29,8 +29,8 @@
 
 import org.apache.velocity.Template;
 import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.Velocity;
-import org.apache.velocity.runtime.RuntimeSingleton;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
 import org.apache.velocity.test.misc.TestLogChute;
 
 /**
@@ -42,6 +42,7 @@
  */
 public class InlineScopeVMTestCase extends BaseTestCase implements TemplateTestBase
 {
+    VelocityEngine engine;
     public InlineScopeVMTestCase(String name)
     {
         super(name);
@@ -50,24 +51,21 @@
     public void setUp()
             throws Exception
     {
-        /*
-         *  do our properties locally, and just override the ones we want
-         *  changed
-         */
-
-        Velocity.setProperty(
-            Velocity.VM_PERM_ALLOW_INLINE_REPLACE_GLOBAL, "true");
+        engine = new VelocityEngine();
+        
+        engine.setProperty(
+                RuntimeConstants.VM_PERM_ALLOW_INLINE_REPLACE_GLOBAL, "true");
 
-        Velocity.setProperty(
-            Velocity.VM_PERM_INLINE_LOCAL, "true");
+        engine.setProperty(
+                RuntimeConstants.VM_PERM_INLINE_LOCAL, "true");
 
-        Velocity.setProperty(
-            Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH);
+        engine.setProperty(
+                RuntimeConstants.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH);
         
-        Velocity.setProperty(
-                Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName());
+        engine.setProperty(
+                RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName());
 
-        Velocity.init();
+        engine.init();
     }
 
     public static Test suite ()
@@ -88,10 +86,10 @@
          * vm_test2 uses a local VM and vm_test1 doesn't
          */
 
-        Template template2 = RuntimeSingleton.getTemplate(
+        Template template2 = engine.getTemplate(
             getFileName(null, "vm_test2", TMPL_FILE_EXT));
 
-        Template template1 = RuntimeSingleton.getTemplate(
+        Template template1 = engine.getTemplate(
             getFileName(null, "vm_test1", TMPL_FILE_EXT));
 
         FileOutputStream fos1 =

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/MacroForwardDefineTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/MacroForwardDefineTestCase.java?rev=832247&amp;r1=832246&amp;r2=832247&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/MacroForwardDefineTestCase.java
(original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/MacroForwardDefineTestCase.java
Tue Nov  3 01:29:30 2009
@@ -19,16 +19,16 @@
  * under the License.    
  */
 
+import java.io.StringWriter;
+
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
-import org.apache.velocity.app.Velocity;
-import org.apache.velocity.runtime.RuntimeConstants;
-import org.apache.velocity.test.misc.TestLogChute;
 import org.apache.velocity.Template;
 import org.apache.velocity.VelocityContext;
-
-import java.io.*;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.test.misc.TestLogChute;
 
 /**
  * Make sure that a forward referenced macro inside another macro definition does
@@ -62,6 +62,8 @@
      */
     private TestLogChute logger = new TestLogChute();
 
+    VelocityEngine engine;
+    
     /**
      * Default constructor.
      */
@@ -75,16 +77,18 @@
     {
         assureResultsDirectoryExists(RESULTS_DIR);
 
+        engine = new VelocityEngine();
+        
         // use Velocity.setProperty (instead of properties file) so that we can use actual
instance of log
-        Velocity.setProperty(RuntimeConstants.RESOURCE_LOADER,"file");
-        Velocity.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH
);
-        Velocity.setProperty(RuntimeConstants.RUNTIME_LOG_REFERENCE_LOG_INVALID,"true");
+        engine.setProperty(RuntimeConstants.RESOURCE_LOADER,"file");
+        engine.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH
);
+        engine.setProperty(RuntimeConstants.RUNTIME_LOG_REFERENCE_LOG_INVALID,"true");
 
         // actual instance of logger
         logger = new TestLogChute(true, false);
-        Velocity.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM,logger);
-        Velocity.setProperty(TestLogChute.TEST_LOGGER_LEVEL, "debug");
-        Velocity.init();
+        engine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM,logger);
+        engine.setProperty(TestLogChute.TEST_LOGGER_LEVEL, "debug");
+        engine.init();
     }
 
     public static Test suite()
@@ -96,7 +100,7 @@
         throws Exception
     {
         VelocityContext context = new VelocityContext();
-        Template template = Velocity.getTemplate("macros.vm");
+        Template template = engine.getTemplate("macros.vm");
 
         // try to get only messages during merge
         logger.startCapture();

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/MultiLoaderTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/MultiLoaderTestCase.java?rev=832247&amp;r1=832246&amp;r2=832247&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/MultiLoaderTestCase.java (original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/MultiLoaderTestCase.java Tue Nov
 3 01:29:30 2009
@@ -29,7 +29,8 @@
 
 import org.apache.velocity.Template;
 import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.Velocity;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
 import org.apache.velocity.test.misc.TestLogChute;
 
 /**
@@ -72,6 +73,8 @@
      */
     private static final String COMPARE_DIR = TEST_COMPARE_DIR + "/multiloader/compare";
 
+    VelocityEngine engine;
+    
     /**
      * Default constructor.
      */
@@ -83,52 +86,54 @@
     public void setUp()
             throws Exception
     {
+        engine = new VelocityEngine();
+        
         assureResultsDirectoryExists(RESULTS_DIR);
 
         /*
          * Set up the file loader.
          */
 
-        Velocity.setProperty(Velocity.RESOURCE_LOADER, "file");
+        engine.setProperty(RuntimeConstants.RESOURCE_LOADER, "file");
 
-        Velocity.setProperty(
-            Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH);
+        engine.setProperty(
+                RuntimeConstants.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH);
 
-        Velocity.addProperty(Velocity.RESOURCE_LOADER, "classpath");
+        engine.addProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
 
-        Velocity.addProperty(Velocity.RESOURCE_LOADER, "jar");
+        engine.addProperty(RuntimeConstants.RESOURCE_LOADER, "jar");
 
         /*
          *  Set up the classpath loader.
          */
 
-        Velocity.setProperty(
-            "classpath." + Velocity.RESOURCE_LOADER + ".class",
+        engine.setProperty(
+            "classpath." + RuntimeConstants.RESOURCE_LOADER + ".class",
                 "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
 
-        Velocity.setProperty(
-            "classpath." + Velocity.RESOURCE_LOADER + ".cache", "false");
+        engine.setProperty(
+            "classpath." + RuntimeConstants.RESOURCE_LOADER + ".cache", "false");
 
-        Velocity.setProperty(
-            "classpath." + Velocity.RESOURCE_LOADER + ".modificationCheckInterval",
+        engine.setProperty(
+            "classpath." + RuntimeConstants.RESOURCE_LOADER + ".modificationCheckInterval",
                 "2");
 
         /*
          *  setup the Jar loader
          */
 
-        Velocity.setProperty(
-                             "jar." + Velocity.RESOURCE_LOADER + ".class",
+        engine.setProperty(
+                             "jar." + RuntimeConstants.RESOURCE_LOADER + ".class",
                              "org.apache.velocity.runtime.resource.loader.JarResourceLoader");
 
-        Velocity.setProperty( "jar." + Velocity.RESOURCE_LOADER + ".path",
+        engine.setProperty( "jar." + RuntimeConstants.RESOURCE_LOADER + ".path",
                               "jar:file:" + FILE_RESOURCE_LOADER_PATH + "/test2.jar" );
 
 
-        Velocity.setProperty(
-                Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName());
+        engine.setProperty(
+                RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName());
 
-        Velocity.init();
+        engine.init();
     }
 
     public static Test suite ()
@@ -150,18 +155,18 @@
         /*
          * Template to find with the file loader.
          */
-        Template template1 = Velocity.getTemplate(
+        Template template1 = engine.getTemplate(
             getFileName(null, "path1", TMPL_FILE_EXT));
 
         /*
          * Template to find with the classpath loader.
          */
-        Template template2 = Velocity.getTemplate("template/test1." + TMPL_FILE_EXT);
+        Template template2 = engine.getTemplate("template/test1." + TMPL_FILE_EXT);
 
         /*
          * Template to find with the jar loader
          */
-        Template template3 = Velocity.getTemplate("template/test2." + TMPL_FILE_EXT);
+        Template template3 = engine.getTemplate("template/test2." + TMPL_FILE_EXT);
 
         /*
          * and the results files

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/MultipleFileResourcePathTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/MultipleFileResourcePathTestCase.java?rev=832247&amp;r1=832246&amp;r2=832247&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/MultipleFileResourcePathTestCase.java
(original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/MultipleFileResourcePathTestCase.java
Tue Nov  3 01:29:30 2009
@@ -29,8 +29,8 @@
 
 import org.apache.velocity.Template;
 import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.Velocity;
-import org.apache.velocity.runtime.RuntimeSingleton;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
 import org.apache.velocity.test.misc.TestLogChute;
 
 /**
@@ -64,6 +64,8 @@
      */
     private static final String COMPARE_DIR = TEST_COMPARE_DIR + "/multi/compare";
 
+    VelocityEngine engine;
+    
     /**
      * Default constructor.
      */
@@ -82,16 +84,18 @@
     {
         assureResultsDirectoryExists(RESULTS_DIR);
 
-        Velocity.addProperty(
-                Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH1);
+        engine = new VelocityEngine();
+        
+        engine.addProperty(
+                RuntimeConstants.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH1);
 
-        Velocity.addProperty(
-                Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH2);
+        engine.addProperty(
+                RuntimeConstants.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH2);
 
-        Velocity.setProperty(
-                Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName());
+        engine.setProperty(
+                RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName());
 
-        Velocity.init();
+        engine.init();
     }
 
     /**
@@ -100,10 +104,10 @@
     public void  testMultipleFileResources ()
             throws Exception
     {
-        Template template1 = RuntimeSingleton.getTemplate(
+        Template template1 = engine.getTemplate(
             getFileName(null, "path1", TMPL_FILE_EXT));
 
-        Template template2 = RuntimeSingleton.getTemplate(
+        Template template2 = engine.getTemplate(
             getFileName(null, "path2", TMPL_FILE_EXT));
 
         FileOutputStream fos1 =

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/StringResourceLoaderRepositoryTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/StringResourceLoaderRepositoryTestCase.java?rev=832247&amp;r1=832246&amp;r2=832247&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/StringResourceLoaderRepositoryTestCase.java
(original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/StringResourceLoaderRepositoryTestCase.java
Tue Nov  3 01:29:30 2009
@@ -57,8 +57,14 @@
         Velocity.init();
 
         StringResourceRepository repo = getRepo(null, null);
-        repo.putStringResource("foo", "This is $foo");
-        repo.putStringResource("bar", "This is $bar");
+
+        // this will fail when run as part of suite of tests in one process
+        // but it's only required for several tests
+        if (repo != null)
+        {
+            repo.putStringResource("foo", "This is $foo");
+            repo.putStringResource("bar", "This is $bar");
+        }
 
         context = new VelocityContext();
         context.put("foo", "wonderful!");

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/StringResourceLoaderTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/StringResourceLoaderTestCase.java?rev=832247&amp;r1=832246&amp;r2=832247&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/StringResourceLoaderTestCase.java
(original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/StringResourceLoaderTestCase.java
Tue Nov  3 01:29:30 2009
@@ -29,10 +29,10 @@
 
 import org.apache.velocity.Template;
 import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.Velocity;
-import org.apache.velocity.runtime.RuntimeSingleton;
-import org.apache.velocity.test.misc.TestLogChute;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
 import org.apache.velocity.runtime.resource.loader.StringResourceLoader;
+import org.apache.velocity.test.misc.TestLogChute;
 
 /**
  * Multiple paths in the file resource loader.
@@ -52,6 +52,8 @@
      */
     private static final String COMPARE_DIR = TEST_COMPARE_DIR + "/stringloader/compare";
 
+    VelocityEngine engine;
+    
     /**
      * Default constructor.
      */
@@ -70,14 +72,16 @@
     {
         assureResultsDirectoryExists(RESULTS_DIR);
 
-        Velocity.setProperty(Velocity.RESOURCE_LOADER, "string");
-        Velocity.addProperty("string.resource.loader.class", StringResourceLoader.class.getName());
-        Velocity.addProperty("string.resource.loader.modificationCheckInterval", "1");
+        engine = new VelocityEngine();
+        
+        engine.setProperty(RuntimeConstants.RESOURCE_LOADER, "string");
+        engine.addProperty("string.resource.loader.class", StringResourceLoader.class.getName());
+        engine.addProperty("string.resource.loader.modificationCheckInterval", "1");
 
         // Silence the logger.
-        Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName());
+        engine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName());
 
-        Velocity.init();
+        engine.init();
     }
 
     public void  testSimpleTemplate()
@@ -85,7 +89,7 @@
     {
         StringResourceLoader.getRepository().putStringResource("simpletemplate.vm", "This
is a test for ${foo}");
 
-        Template template = RuntimeSingleton.getTemplate(getFileName(null, "simpletemplate",
TMPL_FILE_EXT));
+        Template template = engine.getTemplate(getFileName(null, "simpletemplate", TMPL_FILE_EXT));
 
         FileOutputStream fos =
             new FileOutputStream (
@@ -113,7 +117,7 @@
         StringResourceLoader.getRepository().putStringResource("multi1.vm", "I am the $first
template.");
         StringResourceLoader.getRepository().putStringResource("multi2.vm", "I am the $second
template.");
 
-        Template template1 = RuntimeSingleton.getTemplate(getFileName(null, "multi1", TMPL_FILE_EXT));
+        Template template1 = engine.getTemplate(getFileName(null, "multi1", TMPL_FILE_EXT));
 
         FileOutputStream fos =
             new FileOutputStream (
@@ -129,7 +133,7 @@
         writer.flush();
         writer.close();
 
-        Template template2 = RuntimeSingleton.getTemplate(getFileName(null, "multi2", TMPL_FILE_EXT));
+        Template template2 = engine.getTemplate(getFileName(null, "multi2", TMPL_FILE_EXT));
 
         fos = new FileOutputStream (
                 getFileName(RESULTS_DIR, "multi2", RESULT_FILE_EXT));
@@ -160,7 +164,7 @@
     {
         StringResourceLoader.getRepository().putStringResource("change.vm", "I am the $first
template.");
 
-        Template template = RuntimeSingleton.getTemplate(getFileName(null, "change", TMPL_FILE_EXT));
+        Template template = engine.getTemplate(getFileName(null, "change", TMPL_FILE_EXT));
 
         FileOutputStream fos =
             new FileOutputStream (
@@ -178,7 +182,7 @@
 
         StringResourceLoader.getRepository().putStringResource("change.vm", "I am the $second
template.");
         Thread.sleep(2000L);
-        template = RuntimeSingleton.getTemplate(getFileName(null, "change", TMPL_FILE_EXT));
+        template = engine.getTemplate(getFileName(null, "change", TMPL_FILE_EXT));
 
         fos = new FileOutputStream (
                 getFileName(RESULTS_DIR, "change2", RESULT_FILE_EXT));

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/VelocimacroTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/VelocimacroTestCase.java?rev=832247&amp;r1=832246&amp;r2=832247&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/VelocimacroTestCase.java (original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/VelocimacroTestCase.java Tue Nov
 3 01:29:30 2009
@@ -26,8 +26,9 @@
 import junit.framework.TestSuite;
 
 import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
 import org.apache.velocity.exception.MacroOverflowException;
-import org.apache.velocity.app.Velocity;
+import org.apache.velocity.runtime.RuntimeConstants;
 import org.apache.velocity.test.misc.TestLogChute;
 
 /**
@@ -44,6 +45,8 @@
     private String template3 = "#macro(baz $a)#set($a = $a + 1)$a#inner($a)#end#macro(inner
$b)#baz($b)#end#baz(0)";
     private String template4 = "#macro(bad $a)#set($a = $a + 1)$a#inside($a)#end#macro(inside
$b)#loop($b)#end#macro(loop $c)#bad($c)#end#bad(0)";
 
+    VelocityEngine engine = new VelocityEngine();
+    
     public VelocimacroTestCase(String name)
     {
         super(name);
@@ -55,11 +58,11 @@
         /*
          *  setup local scope for templates
          */
-        Velocity.setProperty( Velocity.VM_PERM_INLINE_LOCAL, Boolean.TRUE);
-        Velocity.setProperty( Velocity.VM_MAX_DEPTH, new Integer(5));
-        Velocity.setProperty(
-                Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName());
-        Velocity.init();
+        engine.setProperty( RuntimeConstants.VM_PERM_INLINE_LOCAL, Boolean.TRUE);
+        engine.setProperty( RuntimeConstants.VM_MAX_DEPTH, new Integer(5));
+        engine.setProperty(
+                RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName());
+        engine.init();
     }
 
     public static Test suite()
@@ -76,7 +79,7 @@
         VelocityContext context = new VelocityContext();
 
         StringWriter writer = new StringWriter();
-        Velocity.evaluate(context, writer, "vm_chain1", template1);
+        engine.evaluate(context, writer, "vm_chain1", template1);
 
         String out = writer.toString();
 
@@ -97,7 +100,7 @@
 
         try
         {
-            Velocity.evaluate(context, writer, "vm_chain2", template2);
+            engine.evaluate(context, writer, "vm_chain2", template2);
             fail("Did not exceed max macro call depth as expected");
         }
         catch (MacroOverflowException e)
@@ -109,7 +112,7 @@
 
         try
         {
-            Velocity.evaluate(context, writer, "vm_chain3", template3);
+            engine.evaluate(context, writer, "vm_chain3", template3);
             fail("Did not exceed max macro call depth as expected");
         }
         catch (MacroOverflowException e)
@@ -121,7 +124,7 @@
 
         try
         {
-            Velocity.evaluate(context, writer, "vm_chain4", template4);
+            engine.evaluate(context, writer, "vm_chain4", template4);
             fail("Did not exceed max macro call depth as expected");
         }
         catch (MacroOverflowException e)

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity580TestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity580TestCase.java?rev=832247&amp;r1=832246&amp;r2=832247&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity580TestCase.java
(original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity580TestCase.java
Tue Nov  3 01:29:30 2009
@@ -21,10 +21,10 @@
 
 import org.apache.velocity.Template;
 import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.Velocity;
-import org.apache.velocity.runtime.RuntimeSingleton;
-import org.apache.velocity.test.misc.TestLogChute;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
 import org.apache.velocity.test.BaseTestCase;
+import org.apache.velocity.test.misc.TestLogChute;
 
 /**
  * Test Case for &lt;a href="https://issues.apache.org/jira/browse/VELOCITY-580"&gt;Velocity
Issue 580&lt;/a&gt;.
@@ -56,6 +56,8 @@
      */
     private static final String COMPARE_DIR     = TEST_COMPARE_DIR + "/issues/velocity-580/compare";
 
+    VelocityEngine engine;
+    
     public Velocity580TestCase(final String name) throws Exception
     {
         super(name);
@@ -71,11 +73,13 @@
 
         assureResultsDirectoryExists(RESULTS_DIR);
 
-        Velocity.addProperty(Velocity.FILE_RESOURCE_LOADER_PATH, TEMPLATE_DIR);
+        engine = new VelocityEngine();
+        
+        engine.addProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, TEMPLATE_DIR);
 
-        Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName());
+        engine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName());
 
-        Velocity.init();
+        engine.init();
     }
 
     public void testVelocity580() throws Exception
@@ -85,7 +89,7 @@
 
     protected Template executeTest(final String templateName) throws Exception
     {
-        Template template = RuntimeSingleton.getTemplate(templateName);
+        Template template = engine.getTemplate(templateName);
 
         FileOutputStream fos = new FileOutputStream(getFileName(RESULTS_DIR, templateName,
RESULT_FILE_EXT));
 

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/sql/DataSourceResourceLoaderTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/sql/DataSourceResourceLoaderTestCase.java?rev=832247&amp;r1=832246&amp;r2=832247&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/sql/DataSourceResourceLoaderTestCase.java
(original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/sql/DataSourceResourceLoaderTestCase.java
Tue Nov  3 01:29:30 2009
@@ -33,9 +33,11 @@
 import org.apache.velocity.Template;
 import org.apache.velocity.VelocityContext;
 import org.apache.velocity.app.Velocity;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
 import org.apache.velocity.runtime.RuntimeSingleton;
-import org.apache.velocity.test.misc.TestLogChute;
 import org.apache.velocity.runtime.resource.loader.DataSourceResourceLoader;
+import org.apache.velocity.test.misc.TestLogChute;
 
 
 public class DataSourceResourceLoaderTestCase
@@ -77,6 +79,8 @@
      */
     private String UNICODE_TEMPLATE_NAME = "testUnicode";
 
+    VelocityEngine engine;
+    
     public DataSourceResourceLoaderTestCase(final String name)
     	throws Exception
     {
@@ -100,19 +104,21 @@
         DataSourceResourceLoader rl = new DataSourceResourceLoader();
         rl.setDataSource(ds);
 
+        engine = new VelocityEngine();
+        
         // pass in an instance to Velocity
-        Velocity.addProperty( "resource.loader", "ds" );
-        Velocity.setProperty( "ds.resource.loader.instance", rl );
+        engine.addProperty( "resource.loader", "ds" );
+        engine.setProperty( "ds.resource.loader.instance", rl );
 
-        Velocity.setProperty( "ds.resource.loader.resource.table",           "velocity_template");
-        Velocity.setProperty( "ds.resource.loader.resource.keycolumn",       "id");
-        Velocity.setProperty( "ds.resource.loader.resource.templatecolumn",  "def");
-        Velocity.setProperty( "ds.resource.loader.resource.timestampcolumn", "timestamp");
+        engine.setProperty( "ds.resource.loader.resource.table",           "velocity_template");
+        engine.setProperty( "ds.resource.loader.resource.keycolumn",       "id");
+        engine.setProperty( "ds.resource.loader.resource.templatecolumn",  "def");
+        engine.setProperty( "ds.resource.loader.resource.timestampcolumn", "timestamp");
 
         Velocity.setProperty(
-                Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName());
+                RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName());
 
-        Velocity.init();
+        engine.init();
     }
     
     public void setUpUnicode()
@@ -137,7 +143,7 @@
     public void testUnicode()
     throws Exception
     {
-        Template template = RuntimeSingleton.getTemplate(UNICODE_TEMPLATE_NAME);
+        Template template = engine.getTemplate(UNICODE_TEMPLATE_NAME);
 
         Writer writer = new StringWriter();
         VelocityContext context = new VelocityContext();
@@ -188,7 +194,7 @@
     protected Template executeTest(final String templateName)
     	throws Exception
     {
-        Template template = RuntimeSingleton.getTemplate(templateName);
+        Template template = engine.getTemplate(templateName);
 
         FileOutputStream fos =
                 new FileOutputStream (

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/util/introspection/ChainedUberspectorsTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/util/introspection/ChainedUberspectorsTestCase.java?rev=832247&amp;r1=832246&amp;r2=832247&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/util/introspection/ChainedUberspectorsTestCase.java
(original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/util/introspection/ChainedUberspectorsTestCase.java
Tue Nov  3 01:29:30 2009
@@ -19,21 +19,30 @@
  * under the License.    
  */
 
+import java.io.StringWriter;
+
 import junit.framework.Test;
 import junit.framework.TestSuite;
-import org.apache.velocity.app.Velocity;
-import org.apache.velocity.test.misc.TestLogChute;
-import org.apache.velocity.util.introspection.*;
-import org.apache.velocity.test.BaseTestCase;
-import org.apache.velocity.VelocityContext;
 
-import java.io.StringWriter;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.test.BaseTestCase;
+import org.apache.velocity.test.misc.TestLogChute;
+import org.apache.velocity.util.introspection.AbstractChainableUberspector;
+import org.apache.velocity.util.introspection.Info;
+import org.apache.velocity.util.introspection.UberspectImpl;
+import org.apache.velocity.util.introspection.VelPropertyGet;
+import org.apache.velocity.util.introspection.VelPropertySet;
 
 /**
  * Tests uberspectors chaining
  */
-public class ChainedUberspectorsTestCase extends BaseTestCase {
+public class ChainedUberspectorsTestCase extends BaseTestCase 
+{
 
+    VelocityEngine engine;
+    
     public ChainedUberspectorsTestCase(String name)
     	throws Exception
     {
@@ -48,11 +57,13 @@
     public void setUp()
             throws Exception
     {
-        Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName());
-        Velocity.addProperty(Velocity.UBERSPECT_CLASSNAME,"org.apache.velocity.util.introspection.UberspectImpl");
-        Velocity.addProperty(Velocity.UBERSPECT_CLASSNAME,"org.apache.velocity.test.util.introspection.ChainedUberspectorsTestCase$ChainedUberspector");
-        Velocity.addProperty(Velocity.UBERSPECT_CLASSNAME,"org.apache.velocity.test.util.introspection.ChainedUberspectorsTestCase$LinkedUberspector");
-	    Velocity.init();
+        engine = new VelocityEngine();
+        
+        engine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName());
+        engine.addProperty(RuntimeConstants.UBERSPECT_CLASSNAME,"org.apache.velocity.util.introspection.UberspectImpl");
+        engine.addProperty(RuntimeConstants.UBERSPECT_CLASSNAME,"org.apache.velocity.test.util.introspection.ChainedUberspectorsTestCase$ChainedUberspector");
+        engine.addProperty(RuntimeConstants.UBERSPECT_CLASSNAME,"org.apache.velocity.test.util.introspection.ChainedUberspectorsTestCase$LinkedUberspector");
+	    engine.init();
     }
 
     public void tearDown()
@@ -66,17 +77,17 @@
         context.put("foo",new Foo());
         StringWriter writer = new StringWriter();
 
-        Velocity.evaluate(context,writer,"test","$foo.zeMethod()");
+        engine.evaluate(context,writer,"test","$foo.zeMethod()");
         assertEquals(writer.toString(),"ok");
 
-        Velocity.evaluate(context,writer,"test","#set($foo.foo = 'someValue')");
+        engine.evaluate(context,writer,"test","#set($foo.foo = 'someValue')");
 
         writer = new StringWriter();
-        Velocity.evaluate(context,writer,"test","$foo.bar");
+        engine.evaluate(context,writer,"test","$foo.bar");
         assertEquals(writer.toString(),"someValue");
 
         writer = new StringWriter();
-        Velocity.evaluate(context,writer,"test","$foo.foo");
+        engine.evaluate(context,writer,"test","$foo.foo");
         assertEquals(writer.toString(),"someValue");
     }
 




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r825302 - /velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/StringResourceLoader.java</title>
<author><name>nbubna@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200910.mbox/%3c20091014215139.9228C23888D0@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091014215139-9228C23888D0@eris-apache-org%3e</id>
<updated>2009-10-14T21:51:39Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: nbubna
Date: Wed Oct 14 21:51:39 2009
New Revision: 825302

URL: http://svn.apache.org/viewvc?rev=825302&amp;view=rev
Log:
VELOCITY-737 fix StringResourceRepositoryImpl path in javadoc (thanks to Marcus Warm)

Modified:
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/StringResourceLoader.java

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/StringResourceLoader.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/StringResourceLoader.java?rev=825302&amp;r1=825301&amp;r2=825302&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/StringResourceLoader.java
(original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/StringResourceLoader.java
Wed Oct 14 21:51:39 2009
@@ -47,7 +47,7 @@
  * resource.loader = string
  * string.resource.loader.description = Velocity StringResource loader
  * string.resource.loader.class = org.apache.velocity.runtime.resource.loader.StringResourceLoader
- * string.resource.loader.repository.class = org.apache.velocity.runtime.resource.loader.StringResourceRepositoryImpl
+ * string.resource.loader.repository.class = org.apache.velocity.runtime.resource.util.StringResourceRepositoryImpl
  * &lt;/pre&gt;
  * Resources can be added to the repository like this:
  * &lt;pre&gt;&lt;code&gt;




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r823236 - /velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/VelocityLayoutServlet.java</title>
<author><name>nbubna@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200910.mbox/%3c20091008172449.0AE9623888CF@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091008172449-0AE9623888CF@eris-apache-org%3e</id>
<updated>2009-10-08T17:24:48Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: nbubna
Date: Thu Oct  8 17:24:48 2009
New Revision: 823236

URL: http://svn.apache.org/viewvc?rev=823236&amp;view=rev
Log:
VELTOOLS-123 check request attributes for non-default layouts (thanks to Frederic Daoud)

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

Modified: velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/VelocityLayoutServlet.java
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/VelocityLayoutServlet.java?rev=823236&amp;r1=823235&amp;r2=823236&amp;view=diff
==============================================================================
--- velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/VelocityLayoutServlet.java
(original)
+++ velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/VelocityLayoutServlet.java
Thu Oct  8 17:24:48 2009
@@ -165,9 +165,7 @@
      */
     protected void fillContext(Context ctx, HttpServletRequest request)
     {
-        // check if an alternate layout has been specified
-        // by way of the request parameters
-        String layout = request.getParameter(KEY_LAYOUT);
+        String layout = findLayout(request);
         if (layout != null)
         {
             // let the template know what its new layout is
@@ -175,6 +173,22 @@
         }
     }
 
+    /**
+     * Searches for a non-default layout to be used for this request.
+     * This implementation checks the request parameters and attributes.
+     */
+    protected String findLayout(HttpServletRequest request)
+    {
+        // check if an alternate layout has been specified
+        // by way of the request parameters
+        String layout = request.getParameter(KEY_LAYOUT);
+        // also look in the request attributes 
+        if (layout == null) 
+        { 
+            layout = (String)request.getAttribute(KEY_LAYOUT); 
+        }
+        return layout;
+    }
 
     /**
      * Overrides VelocityViewServlet.mergeTemplate to do a two-pass




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r809822 - in /velocity/engine/branches/2.0_Exp/src: java/org/apache/velocity/app/event/implement/IncludeNotFound.java test/org/apache/velocity/test/BuiltInEventHandlerTestCase.java</title>
<author><name>nbubna@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200909.mbox/%3c20090901053056.9133D23888DC@eris.apache.org%3e"/>
<id>urn:uuid:%3c20090901053056-9133D23888DC@eris-apache-org%3e</id>
<updated>2009-09-01T05:30:56Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: nbubna
Date: Tue Sep  1 05:30:56 2009
New Revision: 809822

URL: http://svn.apache.org/viewvc?rev=809822&amp;view=rev
Log:
VELOCITY-734 merge feature addition and test to 2.x branch (thanks to chad davis)

Modified:
    velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/implement/IncludeNotFound.java
    velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/BuiltInEventHandlerTestCase.java

Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/implement/IncludeNotFound.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/implement/IncludeNotFound.java?rev=809822&amp;r1=809821&amp;r2=809822&amp;view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/implement/IncludeNotFound.java
(original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/implement/IncludeNotFound.java
Tue Sep  1 05:30:56 2009
@@ -20,7 +20,9 @@
  */
 
 import org.apache.velocity.app.event.IncludeEventHandler;
+import org.apache.velocity.context.Context;
 import org.apache.velocity.runtime.RuntimeServices;
+import org.apache.velocity.util.ContextAware;
 import org.apache.velocity.util.RuntimeServicesAware;
 import org.apache.velocity.util.StringUtils;
 
@@ -36,17 +38,24 @@
  * eventhandler.include.notfound = error.vm
  * &lt;/PRE&gt;
  * &lt;/code&gt;
+ * &lt;/p&gt;&lt;p&gt;
+ * The name of the missing resource is put into the Velocity context, under the 
+ * key "missingResource", so that the "notfound" template can report the missing 
+ * resource with a Velocity reference, like: 
+ * &lt;code&gt;$missingResource&lt;/code&gt;
+ * &lt;/p&gt;
  *
  * @author &lt;a href="mailto:wglass@forio.com"&gt;Will Glass-Husain&lt;/a&gt;
  * @version $Id$
  * @since 1.5
  */
-public class IncludeNotFound implements IncludeEventHandler,RuntimeServicesAware {
+public class IncludeNotFound implements IncludeEventHandler,RuntimeServicesAware,ContextAware
{
 
     private static final String DEFAULT_NOT_FOUND = "notfound.vm";
     private static final String PROPERTY_NOT_FOUND = "eventhandler.include.notfound";
     private RuntimeServices rs = null;
     String notfound;
+    Context context;
 
     /**
      * Chseck to see if included file exists, and display "not found" page if it
@@ -70,10 +79,10 @@
         boolean exists = (rs.getLoaderNameForResource(includeResourcePath) != null);
         if (!exists)
         {
+            context.put("missingResource", includeResourcePath);
             if (rs.getLoaderNameForResource(notfound) != null)
             {
                 return notfound;
-
             }
             else
             {
@@ -83,7 +92,6 @@
                 rs.getLog().error("Can't find include not found page: " + notfound);
                 return null;
             }
-
         }
         else
             return includeResourcePath;
@@ -97,6 +105,13 @@
     {
          this.rs = rs;
          notfound = StringUtils.nullTrim(rs.getString(PROPERTY_NOT_FOUND, DEFAULT_NOT_FOUND));
-     }
+    }
 
+    /** 
+     * @see org.apache.velocity.util.ContextAware#setContext(org.apache.velocity.context.Context)
+     */ 
+    public void setContext(Context context)
+    {
+        this.context = context;
+    }
 }

Modified: velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/BuiltInEventHandlerTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/BuiltInEventHandlerTestCase.java?rev=809822&amp;r1=809821&amp;r2=809822&amp;view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/BuiltInEventHandlerTestCase.java
(original)
+++ velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/BuiltInEventHandlerTestCase.java
Tue Sep  1 05:30:56 2009
@@ -93,9 +93,10 @@
         super(name);
     }
 
-    public void setUp()
+    public void setUp() throws Exception
     {
         assureResultsDirectoryExists(RESULTS_DIR);
+        super.setUp();
     }
 
     public static Test suite()
@@ -391,6 +392,14 @@
 
     }
 
+    public void testIncludeNotFoundMissingResourceName() throws Exception
+    {
+        // uses base test support
+        engine.setProperty(RuntimeConstants.EVENTHANDLER_INCLUDE, "org.apache.velocity.app.event.implement.IncludeNotFound");
+        addTemplate("notfound.vm", "$missingResource");
+        assertEvalEquals("foo", "#parse('foo')");
+    }
+
     public void testIncludeRelativePath() throws Exception
     {
         VelocityEngine ve = new VelocityEngine();




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r809816 - in /velocity/engine/trunk/src: java/org/apache/velocity/app/event/implement/IncludeNotFound.java test/org/apache/velocity/test/BuiltInEventHandlerTestCase.java</title>
<author><name>nbubna@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200909.mbox/%3c20090901051428.401E923888DC@eris.apache.org%3e"/>
<id>urn:uuid:%3c20090901051428-401E923888DC@eris-apache-org%3e</id>
<updated>2009-09-01T05:14:28Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: nbubna
Date: Tue Sep  1 05:14:27 2009
New Revision: 809816

URL: http://svn.apache.org/viewvc?rev=809816&amp;view=rev
Log:
VELOCITY-734 put $missingResource name in context on includenotfound event (thanks to Chad
davis)

Modified:
    velocity/engine/trunk/src/java/org/apache/velocity/app/event/implement/IncludeNotFound.java
    velocity/engine/trunk/src/test/org/apache/velocity/test/BuiltInEventHandlerTestCase.java

Modified: velocity/engine/trunk/src/java/org/apache/velocity/app/event/implement/IncludeNotFound.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/app/event/implement/IncludeNotFound.java?rev=809816&amp;r1=809815&amp;r2=809816&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/app/event/implement/IncludeNotFound.java
(original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/app/event/implement/IncludeNotFound.java
Tue Sep  1 05:14:27 2009
@@ -20,7 +20,9 @@
  */
 
 import org.apache.velocity.app.event.IncludeEventHandler;
+import org.apache.velocity.context.Context;
 import org.apache.velocity.runtime.RuntimeServices;
+import org.apache.velocity.util.ContextAware;
 import org.apache.velocity.util.RuntimeServicesAware;
 import org.apache.velocity.util.StringUtils;
 
@@ -36,17 +38,24 @@
  * eventhandler.include.notfound = error.vm
  * &lt;/PRE&gt;
  * &lt;/code&gt;
+ * &lt;/p&gt;&lt;p&gt;
+ * The name of the missing resource is put into the Velocity context, under the 
+ * key "missingResource", so that the "notfound" template can report the missing 
+ * resource with a Velocity reference, like: 
+ * &lt;code&gt;$missingResource&lt;/code&gt;
+ * &lt;/p&gt;
  *
  * @author &lt;a href="mailto:wglass@forio.com"&gt;Will Glass-Husain&lt;/a&gt;
  * @version $Id$
  * @since 1.5
  */
-public class IncludeNotFound implements IncludeEventHandler,RuntimeServicesAware {
+public class IncludeNotFound implements IncludeEventHandler,RuntimeServicesAware,ContextAware
{
 
     private static final String DEFAULT_NOT_FOUND = "notfound.vm";
     private static final String PROPERTY_NOT_FOUND = "eventhandler.include.notfound";
     private RuntimeServices rs = null;
     String notfound;
+    Context context;
 
     /**
      * Chseck to see if included file exists, and display "not found" page if it
@@ -70,10 +79,10 @@
         boolean exists = (rs.getLoaderNameForResource(includeResourcePath) != null);
         if (!exists)
         {
+            context.put("missingResource", includeResourcePath);
             if (rs.getLoaderNameForResource(notfound) != null)
             {
                 return notfound;
-
             }
             else
             {
@@ -83,7 +92,6 @@
                 rs.getLog().error("Can't find include not found page: " + notfound);
                 return null;
             }
-
         }
         else
             return includeResourcePath;
@@ -97,6 +105,13 @@
     {
          this.rs = rs;
          notfound = StringUtils.nullTrim(rs.getString(PROPERTY_NOT_FOUND, DEFAULT_NOT_FOUND));
-     }
+    }
 
+    /** 
+     * @see org.apache.velocity.util.ContextAware#setContext(org.apache.velocity.context.Context)
+     */ 
+    public void setContext(Context context)
+    {
+        this.context = context;
+    }
 }

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/BuiltInEventHandlerTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/BuiltInEventHandlerTestCase.java?rev=809816&amp;r1=809815&amp;r2=809816&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/BuiltInEventHandlerTestCase.java
(original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/BuiltInEventHandlerTestCase.java
Tue Sep  1 05:14:27 2009
@@ -93,9 +93,10 @@
         super(name);
     }
 
-    public void setUp()
+    public void setUp() throws Exception
     {
         assureResultsDirectoryExists(RESULTS_DIR);
+        super.setUp();
     }
 
     public static Test suite()
@@ -391,6 +392,14 @@
 
     }
 
+    public void testIncludeNotFoundMissingResourceName() throws Exception
+    {
+        // uses base test support
+        engine.setProperty(RuntimeConstants.EVENTHANDLER_INCLUDE, "org.apache.velocity.app.event.implement.IncludeNotFound");
+        addTemplate("notfound.vm", "$missingResource");
+        assertEvalEquals("foo", "#parse('foo')");
+    }
+
     public void testIncludeRelativePath() throws Exception
     {
         VelocityEngine ve = new VelocityEngine();




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r806626 - /velocity/tools/trunk/pom.xml</title>
<author><name>nbubna@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200908.mbox/%3c20090821162159.04B192388878@eris.apache.org%3e"/>
<id>urn:uuid:%3c20090821162159-04B192388878@eris-apache-org%3e</id>
<updated>2009-08-21T16:21:58Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: nbubna
Date: Fri Aug 21 16:21:58 2009
New Revision: 806626

URL: http://svn.apache.org/viewvc?rev=806626&amp;view=rev
Log:
VELTOOLS-121 adjust pom to run tests in maven build

Modified:
    velocity/tools/trunk/pom.xml

Modified: velocity/tools/trunk/pom.xml
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/pom.xml?rev=806626&amp;r1=806625&amp;r2=806626&amp;view=diff
==============================================================================
--- velocity/tools/trunk/pom.xml (original)
+++ velocity/tools/trunk/pom.xml Fri Aug 21 16:21:58 2009
@@ -72,6 +72,18 @@
             &lt;outputEncoding&gt;UTF-8&lt;/outputEncoding&gt;
           &lt;/configuration&gt;
         &lt;/plugin&gt;
+        &lt;plugin&gt;
+          &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
+          &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
+          &lt;configuration&gt;
+            &lt;includes&gt;
+              &lt;include&gt;**/Test*.java&lt;/include&gt;
+              &lt;include&gt;**/*Test.java&lt;/include&gt;
+              &lt;include&gt;**/*TestCase.java&lt;/include&gt;
+              &lt;include&gt;**/*Tests.java&lt;/include&gt;
+            &lt;/includes&gt;
+          &lt;/configuration&gt;
+        &lt;/plugin&gt;
       &lt;/plugins&gt;
       &lt;resources&gt;
         &lt;resource&gt;




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r806625 - /velocity/tools/trunk/src/main/java/META-INF/velocity-view.tld</title>
<author><name>nbubna@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200908.mbox/%3c20090821162110.3D3262388878@eris.apache.org%3e"/>
<id>urn:uuid:%3c20090821162110-3D3262388878@eris-apache-org%3e</id>
<updated>2009-08-21T16:21:10Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: nbubna
Date: Fri Aug 21 16:21:09 2009
New Revision: 806625

URL: http://svn.apache.org/viewvc?rev=806625&amp;view=rev
Log:
VELTOOLS-120 fix body-content tag in tld (thanks to Antonio Petrelli)

Modified:
    velocity/tools/trunk/src/main/java/META-INF/velocity-view.tld

Modified: velocity/tools/trunk/src/main/java/META-INF/velocity-view.tld
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/src/main/java/META-INF/velocity-view.tld?rev=806625&amp;r1=806624&amp;r2=806625&amp;view=diff
==============================================================================
--- velocity/tools/trunk/src/main/java/META-INF/velocity-view.tld (original)
+++ velocity/tools/trunk/src/main/java/META-INF/velocity-view.tld Fri Aug 21 16:21:09 2009
@@ -33,7 +33,7 @@
   &lt;tag&gt;
     &lt;name&gt;view&lt;/name&gt;
     &lt;tag-class&gt;org.apache.velocity.tools.view.jsp.VelocityViewTag&lt;/tag-class&gt;
-    &lt;bodycontent&gt;tagdependent&lt;/bodycontent&gt;
+    &lt;body-content&gt;tagdependent&lt;/body-content&gt;
     &lt;attribute&gt;
       &lt;name&gt;id&lt;/name&gt;
       &lt;required&gt;false&lt;/required&gt;




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r806601 - in /velocity/engine/trunk: src/java/org/apache/velocity/runtime/ src/java/org/apache/velocity/runtime/defaults/ src/java/org/apache/velocity/runtime/parser/node/ src/test/org/apache/velocity/test/ xdocs/docs/</title>
<author><name>nbubna@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200908.mbox/%3c20090821153039.1BB642388906@eris.apache.org%3e"/>
<id>urn:uuid:%3c20090821153039-1BB642388906@eris-apache-org%3e</id>
<updated>2009-08-21T15:30:38Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: nbubna
Date: Fri Aug 21 15:30:38 2009
New Revision: 806601

URL: http://svn.apache.org/viewvc?rev=806601&amp;view=rev
Log:
VELOCITY-731 add option to avoid toString() null-check (thanks to Jorgen Rydenius)

Modified:
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeConstants.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/defaults/velocity.properties
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
    velocity/engine/trunk/src/test/org/apache/velocity/test/IfNullTestCase.java
    velocity/engine/trunk/xdocs/docs/developer-guide.xml

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeConstants.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeConstants.java?rev=806601&amp;r1=806600&amp;r2=806601&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeConstants.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeConstants.java Fri Aug
21 15:30:38 2009
@@ -146,6 +146,16 @@
     String SET_NULL_ALLOWED = "directive.set.null.allowed";
 
     /**
+     * Indicates if toString() should be called during #if condition evaluation
+     * just to ensure it does not return null. Check is unnecessary if all
+     * toString() implementations are known to have non-null return values.
+     * Disabling the check (like Velocity 1.5 did) will can boost performance
+     * since toString() may be a complex operation on large objects.
+     * @since 1.6
+     */
+    String DIRECTIVE_IF_TOSTRING_NULLCHECK = "directive.if.tostring.nullcheck";
+
+    /**
      * Starting tag for error messages triggered by passing a parameter not allowed in the
#include directive. Only string literals,
      * and references are allowed.
      */

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/defaults/velocity.properties
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/defaults/velocity.properties?rev=806601&amp;r1=806600&amp;r2=806601&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/defaults/velocity.properties
(original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/defaults/velocity.properties
Fri Aug 21 15:30:38 2009
@@ -70,6 +70,16 @@
 directive.set.null.allowed = false
 
 # ----------------------------------------------------------------------------
+# I F  P R O P E R T I E S
+# ----------------------------------------------------------------------------
+# These properties control the behavior of #if
+# Default behavior is to check return value of toString() and treat an object
+# with toString() that returns null as null. If all objects have toString()
+# methods that never return null, this check is unnecessary and can be disabled
+# to gain performance. In Velocity 1.5, no such null check was performed.
+directive.if.tostring.nullcheck = true
+
+# ----------------------------------------------------------------------------
 # I N C L U D E  P R O P E R T I E S
 # ----------------------------------------------------------------------------
 # These are the properties that governed the way #include'd content

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java?rev=806601&amp;r1=806600&amp;r2=806601&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
(original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
Fri Aug 21 15:30:38 2009
@@ -90,6 +90,15 @@
      */
     public boolean strictEscape = false;
     
+    /**
+     * Indicates if toString() should be called during condition evaluation just
+     * to ensure it does not return null. Check is unnecessary if all toString()
+     * implementations are known to have non-null return values. Disabling the
+     * check will give a performance improval since toString() may be a complex
+     * operation on large objects.
+     */
+    public boolean toStringNullCheck = true;
+    
     private int numChildren = 0;
 
     protected Info uberInfo;
@@ -129,6 +138,7 @@
         
         strictEscape = rsvc.getBoolean(RuntimeConstants.RUNTIME_REFERENCES_STRICT_ESCAPE,
false);
         strictRef = rsvc.getBoolean(RuntimeConstants.RUNTIME_REFERENCES_STRICT, false);
+        toStringNullCheck = rsvc.getBoolean(RuntimeConstants.DIRECTIVE_IF_TOSTRING_NULLCHECK,
true); 
             
         /*
          *  the only thing we can do in init() is getRoot()
@@ -166,7 +176,7 @@
          */
         logOnNull =
             rsvc.getBoolean(RuntimeConstants.RUNTIME_LOG_REFERENCE_LOG_INVALID, true);
-         
+
         /**
          * In the case we are referencing a variable with #if($foo) or
          * #if( ! $foo) then we allow variables to be undefined and we 
@@ -530,7 +540,7 @@
             else
                 return false;
         }        
-        else
+        else if (toStringNullCheck)
         {
             try
             {
@@ -542,6 +552,10 @@
                     + Log.formatFileString(this), e);
             }
         }
+        else
+        {
+            return true;
+        }
     }
 
     /**

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/IfNullTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/IfNullTestCase.java?rev=806601&amp;r1=806600&amp;r2=806601&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/IfNullTestCase.java (original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/IfNullTestCase.java Fri Aug 21
15:30:38 2009
@@ -20,6 +20,7 @@
  */
 
 import org.apache.velocity.VelocityContext;
+import org.apache.velocity.runtime.RuntimeConstants;
 
 /**
  * Used to check that nulls are properly handled in #if statements
@@ -89,6 +90,13 @@
         assertEvalEquals("foo", "#if( $notnull || $nullToString )foo#{else}bar#end");
     }
 
+    public void testToStringNullCheckConfig()
+    {
+        engine.setProperty(RuntimeConstants.DIRECTIVE_IF_TOSTRING_NULLCHECK, Boolean.FALSE);
+        assertEvalEquals("bar", "#if( $null )foo#{else}bar#end");
+        assertEvalEquals("foo", "#if( $nullToString )foo#{else}bar#end");
+    }
+
     public static class NullToString
     {
         public String toString()

Modified: velocity/engine/trunk/xdocs/docs/developer-guide.xml
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/xdocs/docs/developer-guide.xml?rev=806601&amp;r1=806600&amp;r2=806601&amp;view=diff
==============================================================================
--- velocity/engine/trunk/xdocs/docs/developer-guide.xml (original)
+++ velocity/engine/trunk/xdocs/docs/developer-guide.xml Fri Aug 21 15:30:38 2009
@@ -1659,6 +1659,19 @@
 &lt;/p&gt;
 
 &lt;p&gt;
+&lt;strong&gt;#if() Directive&lt;/strong&gt;
+&lt;/p&gt;
+
+&lt;p&gt;
+&lt;code&gt;directive.if.tostring.nullcheck = true&lt;/code&gt;&lt;br/&gt;
+Default behavior is to check return value of toString() and treat an
+object with toString() that returns null as null. If all objects have
+toString() methods that never return null, this check is unnecessary
+and can be disabled to gain performance. In Velocity 1.5, no such null
+check was performed.
+&lt;/p&gt;
+
+&lt;p&gt;
 &lt;strong&gt;#set() Directive&lt;/strong&gt;
 &lt;/p&gt;
 




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r806597 - in /velocity/engine/branches/1.6.x: src/java/org/apache/velocity/runtime/ src/java/org/apache/velocity/runtime/defaults/ src/java/org/apache/velocity/runtime/parser/node/ src/test/org/apache/velocity/test/ xdocs/docs/</title>
<author><name>nbubna@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200908.mbox/%3c20090821152147.28E8D238882F@eris.apache.org%3e"/>
<id>urn:uuid:%3c20090821152147-28E8D238882F@eris-apache-org%3e</id>
<updated>2009-08-21T15:21:46Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: nbubna
Date: Fri Aug 21 15:21:44 2009
New Revision: 806597

URL: http://svn.apache.org/viewvc?rev=806597&amp;view=rev
Log:
VELOCITY-731 add option to avoid toString() null-check (thanks to Jorgen Rydenius)

Modified:
    velocity/engine/branches/1.6.x/src/java/org/apache/velocity/runtime/RuntimeConstants.java
    velocity/engine/branches/1.6.x/src/java/org/apache/velocity/runtime/defaults/velocity.properties
    velocity/engine/branches/1.6.x/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
    velocity/engine/branches/1.6.x/src/test/org/apache/velocity/test/IfNullTestCase.java
    velocity/engine/branches/1.6.x/xdocs/docs/developer-guide.xml

Modified: velocity/engine/branches/1.6.x/src/java/org/apache/velocity/runtime/RuntimeConstants.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/1.6.x/src/java/org/apache/velocity/runtime/RuntimeConstants.java?rev=806597&amp;r1=806596&amp;r2=806597&amp;view=diff
==============================================================================
--- velocity/engine/branches/1.6.x/src/java/org/apache/velocity/runtime/RuntimeConstants.java
(original)
+++ velocity/engine/branches/1.6.x/src/java/org/apache/velocity/runtime/RuntimeConstants.java
Fri Aug 21 15:21:44 2009
@@ -141,6 +141,16 @@
     String SET_NULL_ALLOWED = "directive.set.null.allowed";
 
     /**
+     * Indicates if toString() should be called during #if condition evaluation
+     * just to ensure it does not return null. Check is unnecessary if all
+     * toString() implementations are known to have non-null return values.
+     * Disabling the check (like Velocity 1.5 did) will can boost performance
+     * since toString() may be a complex operation on large objects.
+     * @since 1.6
+     */
+    String DIRECTIVE_IF_TOSTRING_NULLCHECK = "directive.if.tostring.nullcheck";
+
+    /**
      * Starting tag for error messages triggered by passing a parameter not allowed in the
#include directive. Only string literals,
      * and references are allowed.
      */

Modified: velocity/engine/branches/1.6.x/src/java/org/apache/velocity/runtime/defaults/velocity.properties
URL: http://svn.apache.org/viewvc/velocity/engine/branches/1.6.x/src/java/org/apache/velocity/runtime/defaults/velocity.properties?rev=806597&amp;r1=806596&amp;r2=806597&amp;view=diff
==============================================================================
--- velocity/engine/branches/1.6.x/src/java/org/apache/velocity/runtime/defaults/velocity.properties
(original)
+++ velocity/engine/branches/1.6.x/src/java/org/apache/velocity/runtime/defaults/velocity.properties
Fri Aug 21 15:21:44 2009
@@ -70,6 +70,16 @@
 directive.set.null.allowed = false
 
 # ----------------------------------------------------------------------------
+# I F  P R O P E R T I E S
+# ----------------------------------------------------------------------------
+# These properties control the behavior of #if
+# Default behavior is to check return value of toString() and treat an object
+# with toString() that returns null as null. If all objects have toString()
+# methods that never return null, this check is unnecessary and can be disabled
+# to gain performance. In Velocity 1.5, no such null check was performed.
+directive.if.tostring.nullcheck = true
+
+# ----------------------------------------------------------------------------
 # I N C L U D E  P R O P E R T I E S
 # ----------------------------------------------------------------------------
 # These are the properties that governed the way #include'd content

Modified: velocity/engine/branches/1.6.x/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/1.6.x/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java?rev=806597&amp;r1=806596&amp;r2=806597&amp;view=diff
==============================================================================
--- velocity/engine/branches/1.6.x/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
(original)
+++ velocity/engine/branches/1.6.x/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
Fri Aug 21 15:21:44 2009
@@ -75,6 +75,15 @@
      */
     public boolean strictRef = false;
     
+    /**
+     * Indicates if toString() should be called during condition evaluation just
+     * to ensure it does not return null. Check is unnecessary if all toString()
+     * implementations are known to have non-null return values. Disabling the
+     * check will give a performance improval since toString() may be a complex
+     * operation on large objects.
+     */
+    public boolean toStringNullCheck = true;
+    
     private int numChildren = 0;
 
     protected Info uberInfo;
@@ -148,7 +157,8 @@
             rsvc.getBoolean(RuntimeConstants.RUNTIME_LOG_REFERENCE_LOG_INVALID, true);
 
         strictRef = rsvc.getBoolean(RuntimeConstants.RUNTIME_REFERENCES_STRICT, false);
- 
+        toStringNullCheck = rsvc.getBoolean(RuntimeConstants.DIRECTIVE_IF_TOSTRING_NULLCHECK,
true); 
+
         /**
          * In the case we are referencing a variable with #if($foo) or
          * #if( ! $foo) then we allow variables to be undefined and we 
@@ -470,7 +480,7 @@
             else
                 return false;
         }        
-        else
+        else if (toStringNullCheck)
         {
             try
             {
@@ -482,6 +492,10 @@
                     + Log.formatFileString(this), e);
             }
         }
+        else
+        {
+            return true;
+        }
     }
 
     /**

Modified: velocity/engine/branches/1.6.x/src/test/org/apache/velocity/test/IfNullTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/1.6.x/src/test/org/apache/velocity/test/IfNullTestCase.java?rev=806597&amp;r1=806596&amp;r2=806597&amp;view=diff
==============================================================================
--- velocity/engine/branches/1.6.x/src/test/org/apache/velocity/test/IfNullTestCase.java (original)
+++ velocity/engine/branches/1.6.x/src/test/org/apache/velocity/test/IfNullTestCase.java Fri
Aug 21 15:21:44 2009
@@ -20,6 +20,7 @@
  */
 
 import org.apache.velocity.VelocityContext;
+import org.apache.velocity.runtime.RuntimeConstants;
 
 /**
  * Used to check that nulls are properly handled in #if statements
@@ -89,6 +90,13 @@
         assertEvalEquals("foo", "#if( $notnull || $nullToString )foo#{else}bar#end");
     }
 
+    public void testToStringNullCheckConfig()
+    {
+        engine.setProperty(RuntimeConstants.DIRECTIVE_IF_TOSTRING_NULLCHECK, Boolean.FALSE);
+        assertEvalEquals("bar", "#if( $null )foo#{else}bar#end");
+        assertEvalEquals("foo", "#if( $nullToString )foo#{else}bar#end");
+    }
+
     public static class NullToString
     {
         public String toString()

Modified: velocity/engine/branches/1.6.x/xdocs/docs/developer-guide.xml
URL: http://svn.apache.org/viewvc/velocity/engine/branches/1.6.x/xdocs/docs/developer-guide.xml?rev=806597&amp;r1=806596&amp;r2=806597&amp;view=diff
==============================================================================
--- velocity/engine/branches/1.6.x/xdocs/docs/developer-guide.xml (original)
+++ velocity/engine/branches/1.6.x/xdocs/docs/developer-guide.xml Fri Aug 21 15:21:44 2009
@@ -1654,6 +1654,19 @@
 &lt;/p&gt;
 
 &lt;p&gt;
+&lt;strong&gt;#if() Directive&lt;/strong&gt;
+&lt;/p&gt;
+
+&lt;p&gt;
+&lt;code&gt;directive.if.tostring.nullcheck = true&lt;/code&gt;&lt;br/&gt;
+Default behavior is to check return value of toString() and treat an
+object with toString() that returns null as null. If all objects have
+toString() methods that never return null, this check is unnecessary
+and can be disabled to gain performance. In Velocity 1.5, no such null
+check was performed.
+&lt;/p&gt;
+
+&lt;p&gt;
 &lt;strong&gt;#set() Directive&lt;/strong&gt;
 &lt;/p&gt;
 




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r806596 - /velocity/engine/branches/1.6.x/xdocs/docs/user-guide.xml</title>
<author><name>nbubna@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200908.mbox/%3c20090821152031.D652823888EC@eris.apache.org%3e"/>
<id>urn:uuid:%3c20090821152031-D652823888EC@eris-apache-org%3e</id>
<updated>2009-08-21T15:20:31Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: nbubna
Date: Fri Aug 21 15:20:31 2009
New Revision: 806596

URL: http://svn.apache.org/viewvc?rev=806596&amp;view=rev
Log:
properly escape special html chars

Modified:
    velocity/engine/branches/1.6.x/xdocs/docs/user-guide.xml

Modified: velocity/engine/branches/1.6.x/xdocs/docs/user-guide.xml
URL: http://svn.apache.org/viewvc/velocity/engine/branches/1.6.x/xdocs/docs/user-guide.xml?rev=806596&amp;r1=806595&amp;r2=806596&amp;view=diff
==============================================================================
--- velocity/engine/branches/1.6.x/xdocs/docs/user-guide.xml (original)
+++ velocity/engine/branches/1.6.x/xdocs/docs/user-guide.xml Fri Aug 21 15:20:31 2009
@@ -757,7 +757,7 @@
 #if ($foo &amp;&amp; $foo == "bar")#end ## False and $foo == "bar" wil not be evaluated
 #if ($foo1 || $foo2)#end        ## False $foo1 and $foo2 are not defined]]&gt;&lt;/source&gt;
   &lt;p&gt;
-    Strict mode requires that comparisons of &gt;, &lt;, &gt;= or &lt;= within an
+    Strict mode requires that comparisons of &amp;gt;, &amp;lt;, &amp;gt;= or &amp;lt;= within
an
     #if directive make sense. Also, the argument to #foreach must be
     iterable (this behavior can be modified with the property
     directive.foreach.skip.invalid). Finally, undefined macro




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r803413 - /velocity/tools/trunk/src/test/java/org/apache/velocity/tools/test/blackbox/ViewToolsTests.java</title>
<author><name>cbrisson@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200908.mbox/%3c20090812083021.28C31238887A@eris.apache.org%3e"/>
<id>urn:uuid:%3c20090812083021-28C31238887A@eris-apache-org%3e</id>
<updated>2009-08-12T08:30:21Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: cbrisson
Date: Wed Aug 12 08:30:20 2009
New Revision: 803413

URL: http://svn.apache.org/viewvc?rev=803413&amp;view=rev
Log:
minor fix to ViewToolsTests

Modified:
    velocity/tools/trunk/src/test/java/org/apache/velocity/tools/test/blackbox/ViewToolsTests.java

Modified: velocity/tools/trunk/src/test/java/org/apache/velocity/tools/test/blackbox/ViewToolsTests.java
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/src/test/java/org/apache/velocity/tools/test/blackbox/ViewToolsTests.java?rev=803413&amp;r1=803412&amp;r2=803413&amp;view=diff
==============================================================================
--- velocity/tools/trunk/src/test/java/org/apache/velocity/tools/test/blackbox/ViewToolsTests.java
(original)
+++ velocity/tools/trunk/src/test/java/org/apache/velocity/tools/test/blackbox/ViewToolsTests.java
Wed Aug 12 08:30:20 2009
@@ -172,7 +172,7 @@
         /* check language */
         req.setHeaderField("Accept-Language","en");
         resp = conv.getResponse(req);
-        checkText(resp,"prefLang","en");
+        checkText(resp,"preferredLanguage","en");
         req.setHeaderField("Accept-Language","en-US,en;q=0.8");
         resp = conv.getResponse(req);
         checkText(resp,"preferredLanguage","en");




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r803412 - in /velocity/tools/trunk: examples/showcase/WEB-INF/tools.xml examples/showcase/browser.vm src/main/java/org/apache/velocity/tools/view/BrowserTool.java src/test/java/org/apache/velocity/tools/test/blackbox/ViewToolsTests.java</title>
<author><name>cbrisson@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200908.mbox/%3c20090812082650.9A96B238887A@eris.apache.org%3e"/>
<id>urn:uuid:%3c20090812082650-9A96B238887A@eris-apache-org%3e</id>
<updated>2009-08-12T08:26:50Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: cbrisson
Date: Wed Aug 12 08:26:50 2009
New Revision: 803412

URL: http://svn.apache.org/viewvc?rev=803412&amp;view=rev
Log:
added Accept-Language header handling to BrowserTool

Modified:
    velocity/tools/trunk/examples/showcase/WEB-INF/tools.xml
    velocity/tools/trunk/examples/showcase/browser.vm
    velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/BrowserTool.java
    velocity/tools/trunk/src/test/java/org/apache/velocity/tools/test/blackbox/ViewToolsTests.java

Modified: velocity/tools/trunk/examples/showcase/WEB-INF/tools.xml
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/examples/showcase/WEB-INF/tools.xml?rev=803412&amp;r1=803411&amp;r2=803412&amp;view=diff
==============================================================================
--- velocity/tools/trunk/examples/showcase/WEB-INF/tools.xml (original)
+++ velocity/tools/trunk/examples/showcase/WEB-INF/tools.xml Wed Aug 12 08:26:50 2009
@@ -28,6 +28,11 @@
     &lt;tool key="text" bundles="resources,otherStuff"/&gt;
     &lt;tool key="params" locale="en_US"/&gt;
   &lt;/toolbox&gt;
+    
+  &lt;toolbox scope="session" locale="en_US"&gt;
+    &lt;tool class="org.apache.velocity.tools.view.BrowserTool" languagesFilter="en"/&gt;
+  &lt;/toolbox&gt;
+
   &lt;toolbox scope="application"&gt;
     &lt;tool key="date" format="yyyy-MM-dd" depth="2" skip="month"/&gt;
     &lt;tool key="convert" dateFormat="yyyy-MM-dd"/&gt;

Modified: velocity/tools/trunk/examples/showcase/browser.vm
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/examples/showcase/browser.vm?rev=803412&amp;r1=803411&amp;r2=803412&amp;view=diff
==============================================================================
--- velocity/tools/trunk/examples/showcase/browser.vm (original)
+++ velocity/tools/trunk/examples/showcase/browser.vm Wed Aug 12 08:26:50 2009
@@ -161,5 +161,9 @@
 #demo( 'browser' 'Dom1' $desc )
 #demo( 'browser' 'Dom2' $desc )
 #demo( 'browser' 'Javascript' $desc )
+#demo1('browser' 'setLanguagesFilter' 6 'setter for a coma-separated list of weapp languages
filter')
+#demo( 'browser' 'languagesFilter' 'coma-separated list of weapp languages filter')
+#set( $desc = 'Returns the preferred language tag from Accept-Header, filtered by values
given to the LanguageFilter param' )
+#demo( 'browser' 'preferredLanguage' $desc)
 #demoCustom( 'browser' )
 &lt;/table&gt;

Modified: velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/BrowserTool.java
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/BrowserTool.java?rev=803412&amp;r1=803411&amp;r2=803412&amp;view=diff
==============================================================================
--- velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/BrowserTool.java (original)
+++ velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/BrowserTool.java Wed
Aug 12 08:26:50 2009
@@ -22,8 +22,12 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
+import java.util.*;
 import javax.servlet.http.HttpServletRequest;
+import org.apache.velocity.runtime.log.Log;
 import org.apache.velocity.tools.Scope;
+import org.apache.velocity.tools.ConversionUtils;
+import org.apache.velocity.tools.generic.FormatConfig;
 import org.apache.velocity.tools.config.DefaultKey;
 import org.apache.velocity.tools.config.InvalidScope;
 
@@ -31,8 +35,8 @@
  *  &lt;p&gt;browser-sniffing tool (session or request scope requested, session scope advised).&lt;/p&gt;
  *  &lt;p&gt;&lt;/p&gt;
  * &lt;p&gt;&lt;b&gt;Usage:&lt;/b&gt;&lt;/p&gt;
- * &lt;p&gt;BrowserTool defines properties that are used to test the client browser, operating
system, device...
- * Apart from properties related to versioning, all properties are booleans.&lt;/p&gt;
+ * &lt;p&gt;BrowserTool defines properties that are used to test the client browser, operating
system, device, language...
+ * Apart from properties related to browser version and language, all properties are booleans.&lt;/p&gt;
  * &lt;p&gt;The following properties are available:&lt;/p&gt;
  * &lt;ul&gt;
  * &lt;li&gt;&lt;i&gt;Versioning:&lt;/i&gt;version majorVersion minorVersion geckoVersion&lt;/li&gt;
@@ -46,9 +50,14 @@
  * &lt;li&gt;&lt;i&gt;Devices:&lt;/i&gt;palm audrey iopener wap blackberry&lt;/li&gt;
  * &lt;li&gt;&lt;i&gt;Features:&lt;/i&gt;javascript css css1 css2 dom0 dom1 dom2&lt;/li&gt;
  * &lt;li&gt;&lt;i&gt;Special:&lt;/i&gt;robot (true if the page is requested by a robot,
i.e. when one of the following properties is true:
- * wget getright yahoo altavista lycos infoseek lwp webcrawler linkexchange slurp google
java)
+ * wget getright yahoo altavista lycos infoseek lwp webcrawler linkexchange slurp google
java)&lt;/li&gt;
+ * &lt;li&gt;Language: preferredLanguageTag (a string like 'en', 'da', 'en-US', ...), preferredLocale
(a java Locale)&lt;/li&gt;
  * &lt;/ul&gt;
  *
+ * &lt;p&gt;Language properties are filtered by the languagesFilter tool param, if present.
If no matching language is found, or if there is no
+ * matching language, the tools defaut locale (or the first value of languagesFilter) is
returned.
+ * Their value is guarantied to belong to the set provided in languagesFilter, if any.&lt;/p&gt;
+ *
  * Thanks to Lee Semel (lee@semel.net), the author of the HTTP::BrowserDetect Perl module.
  * See also:
  * * http://www.zytrax.com/tech/web/browser_ids.htm
@@ -61,10 +70,13 @@
  */
 @DefaultKey("browser")
 @InvalidScope(Scope.APPLICATION)
-public class BrowserTool implements java.io.Serializable
+public class BrowserTool extends FormatConfig implements java.io.Serializable
 {
     private static final long serialVersionUID = 1734529350532353339L;
 
+    protected Log LOG;
+
+    /* User-Agent header variables */
     private String userAgent = null;
     private String version = null;
     private int majorVersion = -1;
@@ -73,6 +85,89 @@
     private int geckoMajorVersion = -1;
     private int geckoMinorVersion = -1;
 
+    private static Pattern genericVersion = Pattern.compile(
+            "/"
+            /* Version starts with a slash */
+            +
+            "([A-Za-z]*"
+            /* Eat any letters before the major version */
+            +
+            "( [\\d]* )"
+            /* Major version number is every digit before the first dot */
+            + "\\." /* The first dot */
+            +
+            "( [\\d]* )"
+            /* Minor version number is every digit after the first dot */
+            + "[^\\s]*)" /* Throw away the remaining */
+            , Pattern.COMMENTS);
+    private static Pattern firefoxVersion = Pattern.compile(
+            "/"
+            +
+            "(( [\\d]* )"
+            /* Major version number is every digit before the first dot */
+            + "\\." /* The first dot */
+            +
+            "( [\\d]* )"
+            /* Minor version number is every digit after the first dot */
+            + "[^\\s]*)" /* Throw away the remaining */
+            , Pattern.COMMENTS);
+    private static Pattern ieVersion = Pattern.compile(
+            "compatible;"
+            + "\\s*"
+            + "\\w*" /* Browser name */
+            + "[\\s|/]"
+            +
+            "([A-Za-z]*"
+            /* Eat any letters before the major version */
+            +
+            "( [\\d]* )"
+            /* Major version number is every digit before first dot */
+            + "\\." /* The first dot */
+            +
+            "( [\\d]* )"
+            /* Minor version number is digits after first dot */
+            + "[^\\s]*)" /* Throw away remaining dots and digits */
+            , Pattern.COMMENTS);
+    private static Pattern safariVersion = Pattern.compile(
+            "safari/"
+            +
+            "(( [\\d]* )"
+            /* Major version number is every digit before first dot */
+            + "(?:"
+            + "\\." /* The first dot */
+            +
+            " [\\d]* )?)"
+            /* Minor version number is digits after first dot */
+            , Pattern.COMMENTS);
+    private static Pattern mozillaVersion = Pattern.compile(
+            "netscape/"
+            +
+            "(( [\\d]* )"
+            /* Major version number is every digit before the first dot */
+            + "\\." /* The first dot */
+            +
+            "( [\\d]* )"
+            /* Minor version number is every digit after the first dot */
+            + "[^\\s]*)" /* Throw away the remaining */
+            , Pattern.COMMENTS);
+    private static Pattern fallbackVersion = Pattern.compile(
+            "[\\w]+/"
+            +
+            "( [\\d]+ );"
+            /* Major version number is every digit before the first dot */
+            , Pattern.COMMENTS);
+
+
+    /* Accept-Language header variables */
+    private String acceptLanguage = null;
+    private SortedMap&lt;Float,List&lt;String&gt;&gt; languageRangesByQuality = null;
+    private String starLanguageRange = null;
+    // pametrizable filter of retained laguages
+    private List&lt;String&gt; languagesFilter = null;
+    private String preferredLanguage = null;
+
+    private static Pattern quality = Pattern.compile("^q\\s*=\\s*(\\d(?:0(?:.\\d{0,3})?|1(?:.0{0,3}))?)$");
+
     /**
      * Retrieves the User-Agent header from the request (if any).
      * @see #setUserAgent
@@ -82,14 +177,29 @@
         if (request != null)
         {
             setUserAgent(request.getHeader("User-Agent"));
+            setAcceptLanguage(request.getHeader("Accept-Language"));
         }
         else
         {
             setUserAgent(null);
+            setAcceptLanguage(null);
         }
     }
 
     /**
+     * Set log.
+     */
+    public void setLog(Log log)
+    {
+        if (log == null)
+        {
+            throw new NullPointerException("log should not be set to null");
+        }
+        this.LOG = log;
+    }
+
+
+    /**
      * Sets the User-Agent string to be parsed for info.  If null, the string
      * will be empty and everything will return false or null.  Otherwise,
      * it will set the whole string to lower case before storing to simplify
@@ -107,6 +217,37 @@
         }
     }
 
+    public void setAcceptLanguage(String al)
+    {
+        if(al == null)
+        {
+            acceptLanguage = "";
+        }
+        else
+        {
+            acceptLanguage = al.toLowerCase();
+        }
+    }
+
+    public void setLanguagesFilter(String filter)
+    {
+        if(filter == null || filter.length() == 0)
+        {
+            languagesFilter = null;
+        }
+        else
+        {
+            languagesFilter = Arrays.asList(filter.split(","));
+        }
+        // clear preferred language cache
+        preferredLanguage = null;
+    }
+
+    public String getLanguagesFilter()
+    {
+        return languagesFilter.toString();
+    }
+
     @Override
     public String toString()
     {
@@ -121,8 +262,14 @@
         return test(key);
     }
 
-    public String getUserAgent() {
-	return userAgent;
+    public String getUserAgent()
+    {
+	    return userAgent;
+    }
+
+    public String getAcceptLanguage()
+    {
+        return acceptLanguage;
     }
 
     /* Versioning */
@@ -927,6 +1074,46 @@
         return getDom0(); // good approximation
     }
 
+    /* Languages */
+
+    public String getPreferredLanguage()
+    {
+        if(preferredLanguage != null) return preferredLanguage;
+
+        parseAcceptLanguage();
+        if(languageRangesByQuality.size() == 0)
+        {
+            preferredLanguage = starLanguageRange; // may be null
+        }
+        else
+        {
+            List&lt;List&lt;String&gt;&gt; lists = new ArrayList&lt;List&lt;String&gt;&gt;(languageRangesByQuality.values());
+            Collections.reverse(lists);
+            for(List&lt;String&gt; lst : lists) // sorted by quality (treemap)
+            {
+                for(String l : lst)
+                {
+                    preferredLanguage = filterLanguageTag(l);
+                    if(preferredLanguage != null) break;
+                }
+                if(preferredLanguage != null) break;
+            }
+        }
+        // fallback
+        if(preferredLanguage == null)
+        {
+            preferredLanguage = filterLanguageTag(languagesFilter == null ? getLocale().getDisplayName()
: languagesFilter.get(0));
+        }
+        // preferredLanguage should now never be null
+        assert(preferredLanguage != null);
+        return preferredLanguage;
+    }
+
+    public Locale getPreferredLocale()
+    {
+        return ConversionUtils.toLocale(getPreferredLanguage());
+    }
+
     /* Helpers */
 
     private boolean test(String key)
@@ -944,21 +1131,7 @@
             }
 
             /* generic versionning */
-            Matcher v = Pattern.compile(
-                    "/"
-                    /* Version starts with a slash */
-                    +
-                    "([A-Za-z]*"
-                    /* Eat any letters before the major version */
-                    +
-                    "( [\\d]* )"
-                    /* Major version number is every digit before the first dot */
-                    + "\\." /* The first dot */
-                    +
-                    "( [\\d]* )"
-                    /* Minor version number is every digit after the first dot */
-                    + "[^\\s]*)" /* Throw away the remaining */
-                    , Pattern.COMMENTS).matcher(userAgent);
+            Matcher v = genericVersion.matcher(userAgent);
 
             if (v.find())
             {
@@ -969,7 +1142,7 @@
                 }
                 try
                 {
-                    majorVersion = Integer.parseInt(v.group(2));
+                    majorVersion = Integer.valueOf(v.group(2));
                     String minor = v.group(3);
                     if (minor.startsWith("0"))
                     {
@@ -977,34 +1150,25 @@
                     }
                     else
                     {
-                        minorVersion = Integer.parseInt(minor);
+                        minorVersion = Integer.valueOf(minor);
                     }
                 }
                 catch (NumberFormatException nfe)
-                {}
+                {
+                    LOG.error("BrowserTool: Could not parse browser version for User-Agent:
"+userAgent,nfe);
+                }
             }
 
             /* Firefox versionning */
             if (test("firefox"))
             {
-                Matcher fx = Pattern.compile(
-                        "/"
-                        +
-                        "(( [\\d]* )"
-                        /* Major version number is every digit before the first dot */
-                        + "\\." /* The first dot */
-                        +
-                        "( [\\d]* )"
-                        /* Minor version number is every digit after the first dot */
-                        + "[^\\s]*)" /* Throw away the remaining */
-                        , Pattern.COMMENTS)
-                        .matcher(userAgent);
+                Matcher fx = firefoxVersion.matcher(userAgent);
                 if (fx.find())
                 {
                     version = fx.group(1);
                     try
                     {
-                        majorVersion = Integer.parseInt(fx.group(2));
+                        majorVersion = Integer.valueOf(fx.group(2));
                         String minor = fx.group(3);
                         if (minor.startsWith("0"))
                         {
@@ -1012,41 +1176,27 @@
                         }
                         else
                         {
-                            minorVersion = Integer.parseInt(minor);
+                            minorVersion = Integer.valueOf(minor);
                         }
                     }
                     catch (NumberFormatException nfe)
-                    {}
+                    {
+                        LOG.error("BrowserTool: Could not parse browser version for User-Agent:
"+userAgent,nfe);
+                    }
                 }
             }
 
             /* IE versionning */
-            if (test("compatible"))
+            else if (test("compatible"))
             {
-                Matcher ie = Pattern.compile(
-                        "compatible;"
-                        + "\\s*"
-                        + "\\w*" /* Browser name */
-                        + "[\\s|/]"
-                        +
-                        "([A-Za-z]*"
-                        /* Eat any letters before the major version */
-                        +
-                        "( [\\d]* )"
-                        /* Major version number is every digit before first dot */
-                        + "\\." /* The first dot */
-                        +
-                        "( [\\d]* )"
-                        /* Minor version number is digits after first dot */
-                        + "[^\\s]*)" /* Throw away remaining dots and digits */
-                        , Pattern.COMMENTS)
-                        .matcher(userAgent);
+                Matcher ie = ieVersion.matcher(userAgent);
+
                 if (ie.find())
                 {
                     version = ie.group(1);
                     try
                     {
-                        majorVersion = Integer.parseInt(ie.group(2));
+                        majorVersion = Integer.valueOf(ie.group(2));
                         String minor = ie.group(3);
                         if (minor.startsWith("0"))
                         {
@@ -1054,64 +1204,46 @@
                         }
                         else
                         {
-                            minorVersion = Integer.parseInt(minor);
+                            minorVersion = Integer.valueOf(minor);
                         }
                     }
                     catch (NumberFormatException nfe)
-                    {}
+                    {
+                        LOG.error("BrowserTool: Could not parse browser version for User-Agent:
"+userAgent,nfe);
+                    }
                 }
             }
 
             /* Safari versionning*/
-            if (getSafari())
+            else if (getSafari())
             {
-                Matcher safari = Pattern.compile(
-                        "safari/"
-                        +
-                        "(( [\\d]* )"
-                        /* Major version number is every digit before first dot */
-                        + "(?:"
-                        + "\\." /* The first dot */
-                        +
-                        " [\\d]* )?)"
-                        /* Minor version number is digits after first dot */
-                        , Pattern.COMMENTS)
-                        .matcher(userAgent);
+                Matcher safari = safariVersion.matcher(userAgent);
                 if (safari.find())
                 {
                     version = safari.group(1);
                     try
                     {
-                        int sv = Integer.parseInt(safari.group(2));
+                        int sv = Integer.valueOf(safari.group(2));
                         majorVersion = sv / 100;
                         minorVersion = sv % 100;
                     }
                     catch (NumberFormatException nfe)
-                    {}
+                    {
+                        LOG.error("BrowserTool: Could not parse browser version for User-Agent:
"+userAgent,nfe);
+                    }
                 }
             }
 
             /* Gecko-powered Netscape (i.e. Mozilla) versions */
-            if (getGecko() &amp;&amp; getNetscape() &amp;&amp; test("netscape"))
+            else if (getGecko() &amp;&amp; getNetscape() &amp;&amp; test("netscape"))
             {
-                Matcher netscape = Pattern.compile(
-                        "netscape/"
-                        +
-                        "(( [\\d]* )"
-                        /* Major version number is every digit before the first dot */
-                        + "\\." /* The first dot */
-                        +
-                        "( [\\d]* )"
-                        /* Minor version number is every digit after the first dot */
-                        + "[^\\s]*)" /* Throw away the remaining */
-                        , Pattern.COMMENTS)
-                        .matcher(userAgent);
+                Matcher netscape = mozillaVersion.matcher(userAgent);
                 if (netscape.find())
                 {
                     version = netscape.group(1);
                     try
                     {
-                        majorVersion = Integer.parseInt(netscape.group(2));
+                        majorVersion = Integer.valueOf(netscape.group(2));
                         String minor = netscape.group(3);
                         if (minor.startsWith("0"))
                         {
@@ -1119,34 +1251,32 @@
                         }
                         else
                         {
-                            minorVersion = Integer.parseInt(minor);
+                            minorVersion = Integer.valueOf(minor);
                         }
                     }
                     catch (NumberFormatException nfe)
-                    {}
+                    {
+                        LOG.error("BrowserTool: Could not parse browser version for User-Agent:
"+userAgent,nfe);
+                    }
                 }
             }
 
             /* last try if version not found */
             if (version == null)
             {
-                Matcher mv = Pattern.compile(
-                        "[\\w]+/"
-                        +
-                        "( [\\d]+ );"
-                        /* Major version number is every digit before the first dot */
-                        , Pattern.COMMENTS)
-                        .matcher(userAgent);
+                Matcher mv = fallbackVersion.matcher(userAgent);
                 if (mv.find())
                 {
                     version = mv.group(1);
                     try
                     {
-                        majorVersion = Integer.parseInt(version);
+                        majorVersion = Integer.valueOf(version);
                         minorVersion = 0;
                     }
                     catch (NumberFormatException nfe)
-                    {}
+                    {
+                        LOG.error("BrowserTool: Could not parse browser version for User-Agent:
"+userAgent,nfe);
+                    }
                 }
             }
 
@@ -1161,7 +1291,7 @@
                     geckoVersion = g.group(1);
                     try
                     {
-                    	geckoMajorVersion = Integer.parseInt(g.group(2));
+                    	geckoMajorVersion = Integer.valueOf(g.group(2));
                     	String minor = g.group(3);
                         if (minor.startsWith("0"))
                         {
@@ -1169,19 +1299,88 @@
                         }
                         else
                         {
-                            geckoMinorVersion = Integer.parseInt(minor);
+                            geckoMinorVersion = Integer.valueOf(minor);
                         }
                     }
                     catch (NumberFormatException nfe)
-                    {}
+                    {
+                        LOG.error("BrowserTool: Could not parse browser version for User-Agent:
"+userAgent,nfe);
+                    }
                 }
             }
         }
-        catch (PatternSyntaxException nfe)
+        catch (PatternSyntaxException pse)
         {
-            // where should I log ?!
+            LOG.error("BrowserTool: Could not parse browser version for User-Agent: "+userAgent,pse);
         }
     }
 
+    private void parseAcceptLanguage()
+    {
+        if(languageRangesByQuality != null)
+        {
+            // already done
+            return;
+        }
+
+        languageRangesByQuality = new TreeMap&lt;Float,List&lt;String&gt;&gt;();
+        StringTokenizer languageTokenizer = new StringTokenizer(acceptLanguage, ",");
+        while (languageTokenizer.hasMoreTokens())
+        {
+            String language = languageTokenizer.nextToken().trim();
+            int qValueIndex = language.indexOf(';');
+            if(qValueIndex == -1)
+            {
+                language = language.replace('-','_');
+                List&lt;String&gt; l = languageRangesByQuality.get(1.0f);
+                if(l == null)
+                {
+                    l = new ArrayList&lt;String&gt;();
+                    languageRangesByQuality.put(1.0f,l);
+                }
+                l.add(language);
+            }
+            else
+            {
+                String code = language.substring(0,qValueIndex).trim().replace('-','_');
+                String qval = language.substring(qValueIndex + 1).trim();
+                if("*".equals(qval))
+                {
+                    starLanguageRange = code;
+                }
+                else
+                {
+                    Matcher m = quality.matcher(qval);
+                    if(m.matches())
+                    {
+                        Float q = Float.valueOf(m.group(1));
+                        List&lt;String&gt; al = languageRangesByQuality.get(q);
+                        if(al == null)
+                        {
+                            al = new ArrayList&lt;String&gt;();
+                            languageRangesByQuality.put(q,al);
+                        }
+                        al.add(code);
+                    }
+                    else
+                    {
+                        LOG.error("BrowserTool: could not parse language quality value: "+language);
+                    }
+                }
+            }
+        }
+    }
 
+    private String filterLanguageTag(String languageTag)
+    {
+        languageTag = languageTag.replace('-','_');
+        if(languagesFilter == null) return languageTag;
+        if(languagesFilter.contains(languageTag)) return languageTag;
+        if(languageTag.contains("_"))
+        {
+            String[] parts = languageTag.split("_");
+            if(languagesFilter.contains(parts[0])) return parts[0];
+        }
+        return null;
+    }
 }

Modified: velocity/tools/trunk/src/test/java/org/apache/velocity/tools/test/blackbox/ViewToolsTests.java
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/src/test/java/org/apache/velocity/tools/test/blackbox/ViewToolsTests.java?rev=803412&amp;r1=803411&amp;r2=803412&amp;view=diff
==============================================================================
--- velocity/tools/trunk/src/test/java/org/apache/velocity/tools/test/blackbox/ViewToolsTests.java
(original)
+++ velocity/tools/trunk/src/test/java/org/apache/velocity/tools/test/blackbox/ViewToolsTests.java
Wed Aug 12 08:26:50 2009
@@ -163,12 +163,19 @@
     /******* Tests **********/
 
     public @Test void testBrowserSnifferTool() throws Exception {
+        /* check we are identified as a Java (HttpUnit) client */
         WebConversation conv = new WebConversation();
         WebRequest req = new GetMethodWebRequest(ROOT_URL+"browser.vm");
         WebResponse resp = conv.getResponse(req);
-
-        /* check we are identified as a Java (HttpUnit) client */
         checkText(resp,"Java","true");
+
+        /* check language */
+        req.setHeaderField("Accept-Language","en");
+        resp = conv.getResponse(req);
+        checkText(resp,"prefLang","en");
+        req.setHeaderField("Accept-Language","en-US,en;q=0.8");
+        resp = conv.getResponse(req);
+        checkText(resp,"preferredLanguage","en");
     }
 
     public @Test void testContextTool() throws Exception {




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r800415 - /velocity/tools/trunk/src/main/java/META-INF/velocity-view.tld</title>
<author><name>nbubna@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200908.mbox/%3c20090803150936.8D40C23888E4@eris.apache.org%3e"/>
<id>urn:uuid:%3c20090803150936-8D40C23888E4@eris-apache-org%3e</id>
<updated>2009-08-03T15:09:36Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: nbubna
Date: Mon Aug  3 15:09:36 2009
New Revision: 800415

URL: http://svn.apache.org/viewvc?rev=800415&amp;view=rev
Log:
VELTOOLS-120 patch tld to make it valid (thx to Antonio Petrelli)

Modified:
    velocity/tools/trunk/src/main/java/META-INF/velocity-view.tld

Modified: velocity/tools/trunk/src/main/java/META-INF/velocity-view.tld
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/src/main/java/META-INF/velocity-view.tld?rev=800415&amp;r1=800414&amp;r2=800415&amp;view=diff
==============================================================================
--- velocity/tools/trunk/src/main/java/META-INF/velocity-view.tld (original)
+++ velocity/tools/trunk/src/main/java/META-INF/velocity-view.tld Mon Aug  3 15:09:36 2009
@@ -1,74 +1,74 @@
-&lt;?xml version="1.0" encoding="UTF-8"?&gt;
-&lt;!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd"&gt;
-&lt;!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements.  See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership.  The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License.  You may obtain a copy of the License at
-
-   http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied.  See the License for the
- specific language governing permissions and limitations
- under the License.    
---&gt;
-&lt;taglib&gt;
-  &lt;tlibversion&gt;1.0&lt;/tlibversion&gt;
-  &lt;jspversion&gt;1.2&lt;/jspversion&gt;
-  &lt;shortname&gt;velocity&lt;/shortname&gt;
-  &lt;uri&gt;http://velocity.apache.org/velocity-view&lt;/uri&gt;
-  &lt;display-name&gt;VelocityView Tag&lt;/display-name&gt;
-  &lt;description&gt;&lt;![CDATA[Support for using Velocity and VelocityTools within JSP
files and tags.
-                        This makes it trivial to render VTL (Velocity Template Language)
-                        or process a Velocity template from within JSP using the current
-                        context.  This also provides the typical VelocityView support
-                        for accessing and configuring both custom and provided
-                        VelocityTools.]]&gt;&lt;/description&gt;
-  &lt;tag&gt;
-    &lt;name&gt;view&lt;/name&gt;
-    &lt;tagclass&gt;org.apache.velocity.tools.view.jsp.VelocityViewTag&lt;/tagclass&gt;
-    &lt;bodycontent&gt;tagdependent&lt;/bodycontent&gt;
-    &lt;attribute&gt;
-      &lt;name&gt;id&lt;/name&gt;
-      &lt;required&gt;false&lt;/required&gt;
-      &lt;rtexprvalue&gt;true&lt;/rtexprvalue&gt;
-      &lt;description&gt;&lt;![CDATA[An id unique to this particular usage of the VelocityViewTag
in the application.  This id will then be used to cache the body in a StringResourceLoader
repository and will also identify it in log messages.  Setting this automatically sets the
cache attribute to "true".]]&gt;&lt;/description&gt;
-    &lt;/attribute&gt;
-    &lt;attribute&gt;
-      &lt;name&gt;cache&lt;/name&gt;
-      &lt;required&gt;false&lt;/required&gt;
-      &lt;rtexprvalue&gt;true&lt;/rtexprvalue&gt;
-      &lt;description&gt;&lt;![CDATA[Either "true" or "false" to indicate whether the body
content template should be cached by the StringResourceLoader.  This is automatically set
to true if an id is set.  If set to true without an id value, then the template will be used
as its own id.  It is false by default.]]&gt;&lt;/description&gt;
-    &lt;/attribute&gt;
-    &lt;attribute&gt;
-      &lt;name&gt;var&lt;/name&gt;
-      &lt;required&gt;false&lt;/required&gt;
-      &lt;rtexprvalue&gt;true&lt;/rtexprvalue&gt;
-      &lt;description&gt;&lt;![CDATA[A variable name whose value should be set to the rendered
result of this tag.]]&gt;&lt;/description&gt;
-    &lt;/attribute&gt;
-    &lt;attribute&gt;
-      &lt;name&gt;scope&lt;/name&gt;
-      &lt;required&gt;false&lt;/required&gt;
-      &lt;rtexprvalue&gt;true&lt;/rtexprvalue&gt;
-      &lt;description&gt;&lt;![CDATA[This property is meaningless unless a 'var' attribute
is also set.  When it is, this determines the scope into which the resulting variable is set.]]&gt;&lt;/description&gt;
-    &lt;/attribute&gt;
-    &lt;attribute&gt;
-      &lt;name&gt;template&lt;/name&gt;
-      &lt;required&gt;false&lt;/required&gt;
-      &lt;rtexprvalue&gt;true&lt;/rtexprvalue&gt;
-      &lt;description&gt;&lt;![CDATA[The name of a template to be requested from the configured
Velocity resource loaders and rendered into the page (or variable if the 'var' attribute is
set) using the current context.  If this tag also has body content, then the body will be
rendered first and placed into the context used to render the template as '$bodyContent';
this approximates the "two-pass render" used by the VelocityLayoutServlet.]]&gt;&lt;/description&gt;
-    &lt;/attribute&gt;
-    &lt;attribute&gt;
-      &lt;name&gt;bodyContentKey&lt;/name&gt;
-      &lt;required&gt;false&lt;/required&gt;
-      &lt;rtexprvalue&gt;true&lt;/rtexprvalue&gt;
-      &lt;description&gt;&lt;![CDATA[This property is meaningless unless a 'template' attribute
is set and the tag has body content in it.  When it is, this changes the key under which the
rendered result of the body content is placed into the context for use by the specified template.
 The default value is "bodyContent" and should be sufficient for nearly all users.]]&gt;&lt;/description&gt;
-    &lt;/attribute&gt;
-  &lt;/tag&gt;
-&lt;/taglib&gt;
+&lt;?xml version="1.0" encoding="UTF-8"?&gt;
+&lt;!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd"&gt;
+&lt;!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+--&gt;
+&lt;taglib&gt;
+  &lt;tlib-version&gt;1.0&lt;/tlib-version&gt;
+  &lt;jsp-version&gt;1.2&lt;/jsp-version&gt;
+  &lt;short-name&gt;velocity&lt;/short-name&gt;
+  &lt;uri&gt;http://velocity.apache.org/velocity-view&lt;/uri&gt;
+  &lt;display-name&gt;VelocityView Tag&lt;/display-name&gt;
+  &lt;description&gt;&lt;![CDATA[Support for using Velocity and VelocityTools within JSP
files and tags.
+                        This makes it trivial to render VTL (Velocity Template Language)
+                        or process a Velocity template from within JSP using the current
+                        context.  This also provides the typical VelocityView support
+                        for accessing and configuring both custom and provided
+                        VelocityTools.]]&gt;&lt;/description&gt;
+  &lt;tag&gt;
+    &lt;name&gt;view&lt;/name&gt;
+    &lt;tag-class&gt;org.apache.velocity.tools.view.jsp.VelocityViewTag&lt;/tag-class&gt;
+    &lt;bodycontent&gt;tagdependent&lt;/bodycontent&gt;
+    &lt;attribute&gt;
+      &lt;name&gt;id&lt;/name&gt;
+      &lt;required&gt;false&lt;/required&gt;
+      &lt;rtexprvalue&gt;true&lt;/rtexprvalue&gt;
+      &lt;description&gt;&lt;![CDATA[An id unique to this particular usage of the VelocityViewTag
in the application.  This id will then be used to cache the body in a StringResourceLoader
repository and will also identify it in log messages.  Setting this automatically sets the
cache attribute to "true".]]&gt;&lt;/description&gt;
+    &lt;/attribute&gt;
+    &lt;attribute&gt;
+      &lt;name&gt;cache&lt;/name&gt;
+      &lt;required&gt;false&lt;/required&gt;
+      &lt;rtexprvalue&gt;true&lt;/rtexprvalue&gt;
+      &lt;description&gt;&lt;![CDATA[Either "true" or "false" to indicate whether the body
content template should be cached by the StringResourceLoader.  This is automatically set
to true if an id is set.  If set to true without an id value, then the template will be used
as its own id.  It is false by default.]]&gt;&lt;/description&gt;
+    &lt;/attribute&gt;
+    &lt;attribute&gt;
+      &lt;name&gt;var&lt;/name&gt;
+      &lt;required&gt;false&lt;/required&gt;
+      &lt;rtexprvalue&gt;true&lt;/rtexprvalue&gt;
+      &lt;description&gt;&lt;![CDATA[A variable name whose value should be set to the rendered
result of this tag.]]&gt;&lt;/description&gt;
+    &lt;/attribute&gt;
+    &lt;attribute&gt;
+      &lt;name&gt;scope&lt;/name&gt;
+      &lt;required&gt;false&lt;/required&gt;
+      &lt;rtexprvalue&gt;true&lt;/rtexprvalue&gt;
+      &lt;description&gt;&lt;![CDATA[This property is meaningless unless a 'var' attribute
is also set.  When it is, this determines the scope into which the resulting variable is set.]]&gt;&lt;/description&gt;
+    &lt;/attribute&gt;
+    &lt;attribute&gt;
+      &lt;name&gt;template&lt;/name&gt;
+      &lt;required&gt;false&lt;/required&gt;
+      &lt;rtexprvalue&gt;true&lt;/rtexprvalue&gt;
+      &lt;description&gt;&lt;![CDATA[The name of a template to be requested from the configured
Velocity resource loaders and rendered into the page (or variable if the 'var' attribute is
set) using the current context.  If this tag also has body content, then the body will be
rendered first and placed into the context used to render the template as '$bodyContent';
this approximates the "two-pass render" used by the VelocityLayoutServlet.]]&gt;&lt;/description&gt;
+    &lt;/attribute&gt;
+    &lt;attribute&gt;
+      &lt;name&gt;bodyContentKey&lt;/name&gt;
+      &lt;required&gt;false&lt;/required&gt;
+      &lt;rtexprvalue&gt;true&lt;/rtexprvalue&gt;
+      &lt;description&gt;&lt;![CDATA[This property is meaningless unless a 'template' attribute
is set and the tag has body content in it.  When it is, this changes the key under which the
rendered result of the body content is placed into the context for use by the specified template.
 The default value is "bodyContent" and should be sufficient for nearly all users.]]&gt;&lt;/description&gt;
+    &lt;/attribute&gt;
+  &lt;/tag&gt;
+&lt;/taglib&gt;




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r799457 - in /velocity/engine/trunk/src: java/org/apache/velocity/runtime/parser/node/MapGetExecutor.java java/org/apache/velocity/runtime/parser/node/MapSetExecutor.java test/org/apache/velocity/test/issues/Velocity730TestCase.java</title>
<author><name>nbubna@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200907.mbox/%3c20090730221028.247FB2388871@eris.apache.org%3e"/>
<id>urn:uuid:%3c20090730221028-247FB2388871@eris-apache-org%3e</id>
<updated>2009-07-30T22:10:27Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: nbubna
Date: Thu Jul 30 22:10:27 2009
New Revision: 799457

URL: http://svn.apache.org/viewvc?rev=799457&amp;view=rev
Log:
VELOCITY-730 fix MapGet/SetExecutor flaw

Added:
    velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity730TestCase.java
  (with props)
Modified:
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/MapGetExecutor.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/MapSetExecutor.java

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/MapGetExecutor.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/MapGetExecutor.java?rev=799457&amp;r1=799456&amp;r2=799457&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/MapGetExecutor.java
(original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/MapGetExecutor.java
Thu Jul 30 22:10:27 2009
@@ -45,32 +45,24 @@
 
     protected void discover (final Class clazz)
     {
-        Class [] interfaces = clazz.getInterfaces();
-        for (int i = 0 ; i &lt; interfaces.length; i++)
+        if (property != null &amp;&amp; Map.class.isAssignableFrom(clazz))
         {
-            if (interfaces[i].equals(Map.class))
+            try
             {
-                try
-                {
-                    if (property != null)
-                    {
-                        setMethod(Map.class.getMethod("get", new Class [] { Object.class
}));
-                    }
-                }
-                /**
-                 * pass through application level runtime exceptions
-                 */
-                catch( RuntimeException e )
-                {
-                    throw e;
-                }
-                catch(Exception e)
-                {
-                    String msg = "Exception while looking for get('" + property + "') method";
-                    log.error(msg, e);
-                    throw new VelocityException(msg, e);
-                }
-                break;
+                setMethod(Map.class.getMethod("get", new Class [] { Object.class }));
+            }
+            /**
+             * pass through application level runtime exceptions
+             */
+            catch( RuntimeException e )
+            {
+                throw e;
+            }
+            catch(Exception e)
+            {
+                String msg = "Exception while looking for get('" + property + "') method";
+                log.error(msg, e);
+                throw new VelocityException(msg, e);
             }
         }
     }

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/MapSetExecutor.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/MapSetExecutor.java?rev=799457&amp;r1=799456&amp;r2=799457&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/MapSetExecutor.java
(original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/MapSetExecutor.java
Thu Jul 30 22:10:27 2009
@@ -45,32 +45,24 @@
 
     protected void discover (final Class clazz)
     {
-        Class [] interfaces = clazz.getInterfaces();
-        for (int i = 0 ; i &lt; interfaces.length; i++)
+        if (property != null &amp;&amp; Map.class.isAssignableFrom(clazz))
         {
-            if (interfaces[i].equals(Map.class))
+            try
             {
-                try
-                {
-                    if (property != null)
-                    {
-                        setMethod(Map.class.getMethod("put", new Class [] { Object.class,
Object.class }));
-                    }
-                }
-                /**
-                 * pass through application level runtime exceptions
-                 */
-                catch( RuntimeException e )
-                {
-                    throw e;
-                }
-                catch(Exception e)
-                {
-                    String msg = "Exception while looking for put('" + property + "') method";
-                    log.error(msg, e);
-                    throw new VelocityException(msg, e);
-                }
-                break;
+                setMethod(Map.class.getMethod("put", new Class [] { Object.class, Object.class
}));
+            }
+            /**
+             * pass through application level runtime exceptions
+             */
+            catch( RuntimeException e )
+            {
+                throw e;
+            }
+            catch(Exception e)
+            {
+                String msg = "Exception while looking for put('" + property + "') method";
+                log.error(msg, e);
+                throw new VelocityException(msg, e);
             }
         }
     }

Added: velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity730TestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity730TestCase.java?rev=799457&amp;view=auto
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity730TestCase.java
(added)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity730TestCase.java
Thu Jul 30 22:10:27 2009
@@ -0,0 +1,134 @@
+package org.apache.velocity.test.issues;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import org.apache.velocity.test.BaseTestCase;
+import org.apache.velocity.VelocityContext;
+
+/**
+ * This class tests VELOCITY-730.
+ */
+public class Velocity730TestCase extends BaseTestCase
+{
+    public Velocity730TestCase(String name)
+    {
+        super(name);
+        //DEBUG = true;
+    }
+
+    public void setUpContext(VelocityContext ctx)
+    {
+        ctx.put("foo", new Foo());
+    }
+
+    public void testIt()
+    {
+        String template = "$foo.foo #set( $foo.bar = 'foo' ) $foo.bar";
+        assertEvalEquals("bar foo", template);
+    }
+
+    public static interface MyMap extends Map
+    {
+    }
+
+    public abstract static class MyMapImpl
+    {
+        private HashMap map = new HashMap();
+
+        protected Map map()
+        {
+            return map;
+        }
+
+        public void clear() 
+        {
+            map.clear();
+        }
+
+        public boolean containsKey(Object key) 
+        {
+            return map.containsKey(key);
+        }
+
+        public boolean containsValue(Object value) 
+        {
+            return map.containsValue(value);
+        }
+
+        public boolean isEmpty() 
+        {
+            return map.isEmpty();
+        }
+
+        public Set keySet() 
+        {
+            return map.keySet();
+        }
+
+        public void putAll(Map t) 
+        {
+            map.putAll(t);
+        }
+
+        public Object remove(Object key) 
+        {
+            return map.remove(key);
+        }
+
+        public int size() 
+        {
+            return map.size();
+        }
+
+        public Collection values() 
+        {
+            return map.values();
+        }
+
+        public Set entrySet()
+        {
+            return map.entrySet();
+        }
+    }
+
+    private final static class Foo extends MyMapImpl implements MyMap
+    {
+        public Foo()
+        {
+            super();
+            put("foo","bar");
+        }
+
+        public Object get(Object key) 
+        {
+            return map().get(key);
+        }
+
+        public Object put(Object k, Object v)
+        {
+            return map().put(k, v);
+        }
+    }
+
+}

Propchange: velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity730TestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity730TestCase.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity730TestCase.java
------------------------------------------------------------------------------
    svn:keywords = Revision

Propchange: velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity730TestCase.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r791530 - in /velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view: VelocityView.java VelocityViewServlet.java</title>
<author><name>nbubna@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200907.mbox/%3c20090706160652.ED33A2388865@eris.apache.org%3e"/>
<id>urn:uuid:%3c20090706160652-ED33A2388865@eris-apache-org%3e</id>
<updated>2009-07-06T16:06:52Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: nbubna
Date: Mon Jul  6 16:06:52 2009
New Revision: 791530

URL: http://svn.apache.org/viewvc?rev=791530&amp;view=rev
Log:
VELTOOLS-115 improve exception and http management (particularly when for ResourceNotFoundExceptions),
thanks to Antonio Petrelli

Modified:
    velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/VelocityView.java
    velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/VelocityViewServlet.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=791530&amp;r1=791529&amp;r2=791530&amp;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 Mon
Jul  6 16:06:52 2009
@@ -865,7 +865,11 @@
                 return velocity.getTemplate(name, encoding);
             }
         }
-        catch (Exception e)
+        catch (RuntimeException e)  // FIXME This is useless with Velocity 1.7
+        {
+            throw e;
+        }
+        catch (Exception e)  // FIXME This is useless with Velocity 1.7
         {
             throw new RuntimeException(e);
         }
@@ -896,6 +900,9 @@
                 vw.recycle(writer);
             }
             performMerge(template, context, vw);
+
+            // flush writer but don't close to allow us to play nicely with others.
+            vw.flush();
         }
         finally
         {
@@ -903,10 +910,6 @@
             {
                 try
                 {
-                    // flush and put back into the pool
-                    // don't close to allow us to play
-                    // nicely with others.
-                    vw.flush();
                     /* This hack sets the VelocityWriter's internal ref to the
                      * PrintWriter to null to keep memory free while
                      * the writer is pooled. See bug report #18951 */

Modified: velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/VelocityViewServlet.java
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/VelocityViewServlet.java?rev=791530&amp;r1=791529&amp;r2=791530&amp;view=diff
==============================================================================
--- velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/VelocityViewServlet.java
(original)
+++ velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/VelocityViewServlet.java
Mon Jul  6 16:06:52 2009
@@ -19,9 +19,9 @@
  * under the License.
  */
 
+import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.StringWriter;
-import java.io.IOException;
 import java.io.Writer;
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
@@ -33,6 +33,7 @@
 import org.apache.velocity.Template;
 import org.apache.velocity.context.Context;
 import org.apache.velocity.exception.MethodInvocationException;
+import org.apache.velocity.exception.ResourceNotFoundException;
 import org.apache.velocity.runtime.log.Log;
 
 /**
@@ -199,6 +200,7 @@
      *  @param response HttpServletResponse object for the response
      */
     protected void doRequest(HttpServletRequest request, HttpServletResponse response)
+        throws IOException
     {
         Context context = null;
         try
@@ -216,10 +218,18 @@
 
             // merge the template and context into the response
             mergeTemplate(template, context, response);
+        } catch (IOException e) {
+            error(request, response, e);
+            throw e;
+        }
+        catch (ResourceNotFoundException e)
+        {
+            manageResourceNotFound(request, response, e);
         }
-        catch (Throwable e)
+        catch (RuntimeException e)
         {
             error(request, response, e);
+            throw e;
         }
         finally
         {
@@ -228,7 +238,6 @@
     }
 
 
-
     /**
      * &lt;p&gt;This was a common extension point, but now it is usually
      * simpler to override {@link #fillContext} to add custom things
@@ -243,7 +252,7 @@
      */
     protected Template handleRequest(HttpServletRequest request,
                                      HttpServletResponse response,
-                                     Context ctx) throws Exception
+                                     Context ctx)
     {
         return getTemplate(request, response);
     }
@@ -328,14 +337,21 @@
                          HttpServletResponse response,
                          Throwable e)
     {
+        if (!response.isCommitted())
+        {
+            return;
+        }
+        
         try
         {
+            String path = ServletUtils.getPath(request);
+            getLog().error("Error processing a template for path '" + path + "'", e);
             StringBuilder html = new StringBuilder();
             html.append("&lt;html&gt;\n");
             html.append("&lt;head&gt;&lt;title&gt;Error&lt;/title&gt;&lt;/head&gt;\n");
             html.append("&lt;body&gt;\n");
             html.append("&lt;h2&gt;VelocityView : Error processing a template for path '");
-            html.append(ServletUtils.getPath(request));
+            html.append(path);
             html.append("'&lt;/h2&gt;\n");
 
             Throwable cause = e;
@@ -377,6 +393,36 @@
         }
     }
 
+    /**
+     * Manages the {@link ResourceNotFoundException} to send an HTTP 404 result
+     * when needed.
+     * 
+     * @param request The request object.
+     * @param response The response object.
+     * @param e The exception to check.
+     * @throws IOException If something goes wrong when sending the HTTP error.
+     */
+    protected void manageResourceNotFound(HttpServletRequest request,
+            HttpServletResponse response, ResourceNotFoundException e)
+            throws IOException
+    {
+        String path = ServletUtils.getPath(request);
+        if (getLog().isDebugEnabled())
+        {
+            getLog().debug("Resource not found for path '" + path + "'", e);
+        }
+        String message = e.getMessage();
+        if (!response.isCommitted() &amp;&amp; path != null &amp;&amp;
+            message != null &amp;&amp; message.contains("'" + path + "'"))
+        {
+            response.sendError(HttpServletResponse.SC_NOT_FOUND, path);
+        }
+        else
+        {
+            error(request, response, e);
+            throw e;
+        }
+    }
 
     /**
      * Cleanup routine called at the end of the request processing sequence




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r779263 - in /velocity/tools/trunk: build.properties pom.xml</title>
<author><name>nbubna@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200905.mbox/%3c20090527181827.D0BF42388874@eris.apache.org%3e"/>
<id>urn:uuid:%3c20090527181827-D0BF42388874@eris-apache-org%3e</id>
<updated>2009-05-27T18:18:27Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: nbubna
Date: Wed May 27 18:18:27 2009
New Revision: 779263

URL: http://svn.apache.org/viewvc?rev=779263&amp;view=rev
Log:
revert to snapshot version after release

Modified:
    velocity/tools/trunk/build.properties
    velocity/tools/trunk/pom.xml

Modified: velocity/tools/trunk/build.properties
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/build.properties?rev=779263&amp;r1=779262&amp;r2=779263&amp;view=diff
==============================================================================
--- velocity/tools/trunk/build.properties (original)
+++ velocity/tools/trunk/build.properties Wed May 27 18:18:27 2009
@@ -30,7 +30,7 @@
 
 # project identification
 project.name=VelocityTools
-project.version=2.0-beta4
+project.version=2.0-SNAPSHOT
 project.libname=velocity-tools
 project.id=${project.libname}-${project.version}
 

Modified: velocity/tools/trunk/pom.xml
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/pom.xml?rev=779263&amp;r1=779262&amp;r2=779263&amp;view=diff
==============================================================================
--- velocity/tools/trunk/pom.xml (original)
+++ velocity/tools/trunk/pom.xml Wed May 27 18:18:27 2009
@@ -27,7 +27,7 @@
     &lt;groupId&gt;org.apache.velocity&lt;/groupId&gt;
     &lt;artifactId&gt;velocity-tools&lt;/artifactId&gt;
     &lt;name&gt;VelocityTools&lt;/name&gt;
-    &lt;version&gt;2.0-beta4&lt;/version&gt;
+    &lt;version&gt;2.0-SNAPSHOT&lt;/version&gt;
     &lt;packaging&gt;jar&lt;/packaging&gt;
 
     &lt;organization&gt;




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r779254 - /velocity/tools/tags/2.0-beta4/</title>
<author><name>nbubna@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200905.mbox/%3c20090527173335.530942388863@eris.apache.org%3e"/>
<id>urn:uuid:%3c20090527173335-530942388863@eris-apache-org%3e</id>
<updated>2009-05-27T17:33:35Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: nbubna
Date: Wed May 27 17:33:35 2009
New Revision: 779254

URL: http://svn.apache.org/viewvc?rev=779254&amp;view=rev
Log:
Release Tools 2.0-beta4

Added:
    velocity/tools/tags/2.0-beta4/
      - copied from r774375, velocity/tools/trunk/



</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r779192 - in /velocity/site/site: doap_tools.rdf src/site/news.xml src/site/xdoc/download.xml</title>
<author><name>nbubna@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200905.mbox/%3c20090527144401.B5B71238889C@eris.apache.org%3e"/>
<id>urn:uuid:%3c20090527144401-B5B71238889C@eris-apache-org%3e</id>
<updated>2009-05-27T14:44:01Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: nbubna
Date: Wed May 27 14:44:01 2009
New Revision: 779192

URL: http://svn.apache.org/viewvc?rev=779192&amp;view=rev
Log:
update site for Tools 2.0-beta4 release

Modified:
    velocity/site/site/doap_tools.rdf
    velocity/site/site/src/site/news.xml
    velocity/site/site/src/site/xdoc/download.xml

Modified: velocity/site/site/doap_tools.rdf
URL: http://svn.apache.org/viewvc/velocity/site/site/doap_tools.rdf?rev=779192&amp;r1=779191&amp;r2=779192&amp;view=diff
==============================================================================
--- velocity/site/site/doap_tools.rdf (original)
+++ velocity/site/site/doap_tools.rdf Wed May 27 14:44:01 2009
@@ -28,6 +28,11 @@
     &lt;category rdf:resource="http://projects.apache.org/category/library"/&gt;
     &lt;release&gt;
       &lt;Version&gt;
+        &lt;name&gt;VelocityTools 2.0-beta4&lt;/name&gt;
+        &lt;created&gt;2009-05-27&lt;/created&gt;
+        &lt;revision&gt;2.0 beta4&lt;/revision&gt;
+      &lt;/Version&gt;
+      &lt;Version&gt;
         &lt;name&gt;VelocityTools 2.0-beta3&lt;/name&gt;
         &lt;created&gt;2008-12-01&lt;/created&gt;
         &lt;revision&gt;2.0 beta3&lt;/revision&gt;

Modified: velocity/site/site/src/site/news.xml
URL: http://svn.apache.org/viewvc/velocity/site/site/src/site/news.xml?rev=779192&amp;r1=779191&amp;r2=779192&amp;view=diff
==============================================================================
--- velocity/site/site/src/site/news.xml (original)
+++ velocity/site/site/src/site/news.xml Wed May 27 14:44:01 2009
@@ -24,6 +24,53 @@
         {{{http://velocity.apache.org/download.cgi#engine}here}}.
       ]]&gt;&lt;/text&gt;
     &lt;/item&gt;
+    &lt;item id="tools20beta4"&gt;
+        &lt;date&gt;2009-05-27&lt;/date&gt;
+        &lt;headline&gt;VelocityTools 2.0-beta4 released&lt;/headline&gt;
+      &lt;categories&gt;
+        &lt;category&gt;velocity&lt;/category&gt;
+        &lt;category&gt;tools&lt;/category&gt;
+      &lt;/categories&gt;
+      &lt;text&gt;&lt;![CDATA[
+        The Velocity developers are pleased to make a fourth beta release of
+        VelocityTools 2.0 available for download.
+        
+        This should be useable as a drop in replacement for Tools 1.4 or
+        Tools 2.0-beta3, with a few minor exceptions.
+        The 2.x series of VelocityTools requires Velocity 1.6 and JDK 1.5+.
+
+        Since the last beta release, there have been a number of significant fixes
+        and enhancements.  Here's the key ones:
+
+            * Tools references are no longer read-only by default
+
+            * LinkTool double-encoding problem is fixed
+
+            * Upgraded to depend on Engine 1.6.2
+
+            * Deprecated ListTools due to irrelevance in Engine 1.6.x
+
+            * ResourceTool now gives access to bundle keys
+
+            * MultiViewsTool was changed into new, better IncludeTool
+
+            * Added syntactical sugar to CookieTool
+
+            * Multiple new methods contributed for DisplayTool
+
+            * Added the WebappUberspector for natural #set of attributes in webapp scopes
(e.g. #set( $request.foo = 'bar' ))
+
+            * Refactored JeeConfig to be an interface
+        
+        The Velocity developers are very interested in all feedback regarding
+        Tools 2.0, especially regarding backwards compatibility with apps designed
+        for Tools 1.4 or earlier.  We aim to enable a smooth, incremental transition
+        for developers and their applications.
+
+        Downloads of Tools 2.0-beta4 are available 
+        {{{http://velocity.apache.org/download.cgi#tools}here}}.
+      ]]&gt;&lt;/text&gt;
+    &lt;/item&gt;
     &lt;item id="engine161"&gt;
         &lt;date&gt;2008-12-15&lt;/date&gt;
         &lt;headline&gt;Velocity Engine 1.6.1 released&lt;/headline&gt;

Modified: velocity/site/site/src/site/xdoc/download.xml
URL: http://svn.apache.org/viewvc/velocity/site/site/src/site/xdoc/download.xml?rev=779192&amp;r1=779191&amp;r2=779192&amp;view=diff
==============================================================================
--- velocity/site/site/src/site/xdoc/download.xml (original)
+++ velocity/site/site/src/site/xdoc/download.xml Wed May 27 14:44:01 2009
@@ -197,29 +197,29 @@
       &lt;subsection name="Tools"&gt;
         &lt;p&gt;Binaries:&lt;/p&gt;
         &lt;ul&gt;
-          &lt;li&gt;&lt;a href="[preferred]/velocity/tools/2.0-beta3/velocity-tools-2.0-beta3.zip"&gt;velocity-tools-2.0-beta3.zip&lt;/a&gt;
-              [&lt;a href="http://www.apache.org/dist/velocity/tools/2.0-beta3/velocity-tools-2.0-beta3.zip.asc"&gt;PGP&lt;/a&gt;]
-              [&lt;a href="http://www.apache.org/dist/velocity/tools/2.0-beta3/velocity-tools-2.0-beta3.zip.md5"&gt;MD5&lt;/a&gt;]
-              [&lt;a href="http://www.apache.org/dist/velocity/tools/2.0-beta3/velocity-tools-2.0-beta3.zip.sha1"&gt;SHA1&lt;/a&gt;]
+          &lt;li&gt;&lt;a href="[preferred]/velocity/tools/2.0-beta4/velocity-tools-2.0-beta4.zip"&gt;velocity-tools-2.0-beta4.zip&lt;/a&gt;
+              [&lt;a href="http://www.apache.org/dist/velocity/tools/2.0-beta4/velocity-tools-2.0-beta4.zip.asc"&gt;PGP&lt;/a&gt;]
+              [&lt;a href="http://www.apache.org/dist/velocity/tools/2.0-beta4/velocity-tools-2.0-beta4.zip.md5"&gt;MD5&lt;/a&gt;]
+              [&lt;a href="http://www.apache.org/dist/velocity/tools/2.0-beta4/velocity-tools-2.0-beta4.zip.sha1"&gt;SHA1&lt;/a&gt;]
           &lt;/li&gt;
-          &lt;li&gt;&lt;a href="[preferred]/velocity/tools/2.0-beta3/velocity-tools-2.0-beta3.tar.gz"&gt;velocity-tools-2.0-beta3.tar.gz&lt;/a&gt;
-              [&lt;a href="http://www.apache.org/dist/velocity/tools/2.0-beta3/velocity-tools-2.0-beta3.tar.gz.asc"&gt;PGP&lt;/a&gt;]
-              [&lt;a href="http://www.apache.org/dist/velocity/tools/2.0-beta3/velocity-tools-2.0-beta3.tar.gz.md5"&gt;MD5&lt;/a&gt;]
-              [&lt;a href="http://www.apache.org/dist/velocity/tools/2.0-beta3/velocity-tools-2.0-beta3.tar.gz.sha1"&gt;SHA1&lt;/a&gt;]
+          &lt;li&gt;&lt;a href="[preferred]/velocity/tools/2.0-beta4/velocity-tools-2.0-beta4.tar.gz"&gt;velocity-tools-2.0-beta4.tar.gz&lt;/a&gt;
+              [&lt;a href="http://www.apache.org/dist/velocity/tools/2.0-beta4/velocity-tools-2.0-beta4.tar.gz.asc"&gt;PGP&lt;/a&gt;]
+              [&lt;a href="http://www.apache.org/dist/velocity/tools/2.0-beta4/velocity-tools-2.0-beta4.tar.gz.md5"&gt;MD5&lt;/a&gt;]
+              [&lt;a href="http://www.apache.org/dist/velocity/tools/2.0-beta4/velocity-tools-2.0-beta4.tar.gz.sha1"&gt;SHA1&lt;/a&gt;]
           &lt;/li&gt;
         &lt;/ul&gt;
 
         &lt;p&gt;Sources:&lt;/p&gt;
         &lt;ul&gt;
-          &lt;li&gt;&lt;a href="[preferred]/velocity/tools/2.0-beta3/velocity-tools-2.0-beta3-src.zip"&gt;velocity-tools-2.0-beta3-src.zip&lt;/a&gt;
-              [&lt;a href="http://www.apache.org/dist/velocity/tools/2.0-beta3/velocity-tools-2.0-beta3-src.zip.asc"&gt;PGP&lt;/a&gt;]
-              [&lt;a href="http://www.apache.org/dist/velocity/tools/2.0-beta3/velocity-tools-2.0-beta3-src.zip.md5"&gt;MD5&lt;/a&gt;]
-              [&lt;a href="http://www.apache.org/dist/velocity/tools/2.0-beta3/velocity-tools-2.0-beta3-src.zip.sha1"&gt;SHA1&lt;/a&gt;]
+          &lt;li&gt;&lt;a href="[preferred]/velocity/tools/2.0-beta4/velocity-tools-2.0-beta4-src.zip"&gt;velocity-tools-2.0-beta4-src.zip&lt;/a&gt;
+              [&lt;a href="http://www.apache.org/dist/velocity/tools/2.0-beta4/velocity-tools-2.0-beta4-src.zip.asc"&gt;PGP&lt;/a&gt;]
+              [&lt;a href="http://www.apache.org/dist/velocity/tools/2.0-beta4/velocity-tools-2.0-beta4-src.zip.md5"&gt;MD5&lt;/a&gt;]
+              [&lt;a href="http://www.apache.org/dist/velocity/tools/2.0-beta4/velocity-tools-2.0-beta4-src.zip.sha1"&gt;SHA1&lt;/a&gt;]
           &lt;/li&gt;
-          &lt;li&gt;&lt;a href="[preferred]/velocity/tools/2.0-beta3/velocity-tools-2.0-beta3-src.tar.gz"&gt;velocity-tools-2.0-beta3-src.tar.gz&lt;/a&gt;
-              [&lt;a href="http://www.apache.org/dist/velocity/tools/2.0-beta3/velocity-tools-2.0-beta3-src.tar.gz.asc"&gt;PGP&lt;/a&gt;]
-              [&lt;a href="http://www.apache.org/dist/velocity/tools/2.0-beta3/velocity-tools-2.0-beta3-src.tar.gz.md5"&gt;MD5&lt;/a&gt;]
-              [&lt;a href="http://www.apache.org/dist/velocity/tools/2.0-beta3/velocity-tools-2.0-beta3-src.tar.gz.sha1"&gt;SHA1&lt;/a&gt;]
+          &lt;li&gt;&lt;a href="[preferred]/velocity/tools/2.0-beta4/velocity-tools-2.0-beta4-src.tar.gz"&gt;velocity-tools-2.0-beta4-src.tar.gz&lt;/a&gt;
+              [&lt;a href="http://www.apache.org/dist/velocity/tools/2.0-beta4/velocity-tools-2.0-beta4-src.tar.gz.asc"&gt;PGP&lt;/a&gt;]
+              [&lt;a href="http://www.apache.org/dist/velocity/tools/2.0-beta4/velocity-tools-2.0-beta4-src.tar.gz.md5"&gt;MD5&lt;/a&gt;]
+              [&lt;a href="http://www.apache.org/dist/velocity/tools/2.0-beta4/velocity-tools-2.0-beta4-src.tar.gz.sha1"&gt;SHA1&lt;/a&gt;]
           &lt;/li&gt;
         &lt;/ul&gt;
       &lt;/subsection&gt;




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r778192 - in /velocity/tools/trunk: src/main/java/org/apache/velocity/tools/view/VelocityView.java src/main/java/org/apache/velocity/tools/view/velocity.properties xdocs/changes.xml</title>
<author><name>cbrisson@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200905.mbox/%3c20090524164532.041592388863@eris.apache.org%3e"/>
<id>urn:uuid:%3c20090524164532-041592388863@eris-apache-org%3e</id>
<updated>2009-05-24T16:45:31Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: cbrisson
Date: Sun May 24 16:45:31 2009
New Revision: 778192

URL: http://svn.apache.org/viewvc?rev=778192&amp;view=rev
Log:
activate WebappUberspector by default but deactivate it if not available

Modified:
    velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/VelocityView.java
    velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/velocity.properties
    velocity/tools/trunk/xdocs/changes.xml

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=778192&amp;r1=778191&amp;r2=778192&amp;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 Sun
May 24 16:45:31 2009
@@ -22,6 +22,7 @@
 import java.io.InputStream;
 import java.io.IOException;
 import java.io.Writer;
+import java.util.List;
 import javax.servlet.FilterConfig;
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
@@ -357,7 +358,18 @@
     protected void configure(final JeeConfig config, final VelocityEngine velocity)
     {
         // first get the default properties, and bail if we don't find them
-        velocity.setExtendedProperties(getProperties(DEFAULT_PROPERTIES_PATH, true));
+	ExtendedProperties defaultProperties = getProperties(DEFAULT_PROPERTIES_PATH, true);
+	// if using Velocity engine prior to 1.6.x, remove WebappUberspector
+	// (this hack will disappear once tools require Velocity 1.6.x+)
+	try {
+	    Class.forName("org.apache.velocity.tools.view.WebappUberspector");
+	} catch(Throwable t) {
+	    // remove WebappUberspector from the list of introspectors
+	    List introspectors = defaultProperties.getList(VelocityEngine.UBERSPECT_CLASSNAME);
+	    introspectors.remove("org.apache.velocity.tools.view.WebappUberspector");
+	    defaultProperties.setProperty(VelocityEngine.UBERSPECT_CLASSNAME,introspectors);
+	}
+        velocity.setExtendedProperties(defaultProperties);
 
         // check for application-wide user props in the context init params
         String appPropsPath = servletContext.getInitParameter(PROPERTIES_KEY);

Modified: velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/velocity.properties
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/velocity.properties?rev=778192&amp;r1=778191&amp;r2=778192&amp;view=diff
==============================================================================
--- velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/velocity.properties
(original)
+++ velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/velocity.properties
Sun May 24 16:45:31 2009
@@ -23,7 +23,6 @@
 webapp.resource.loader.class = org.apache.velocity.tools.view.WebappResourceLoader
 string.resource.loader.class = org.apache.velocity.runtime.resource.loader.StringResourceLoader
 
-# uncomment (or copy in your velocity.properties file) the following line if you have Velocity
1.6+
-# and want to access application, session and request attributes via standard setters, like
in:
-#   #set($session.foo = 'bar') foo is: $session.foo
-#runtime.introspector.uberspect = org.apache.velocity.util.introspection.UberspectImpl,org.apache.velocity.tools.view.WebappUberspector
+# allows getting and setting $request, $session and $application attributes using Velocity
syntax,
+# like in #set($session.foo = 'bar'), instead of $session.setAttribute('foo','bar')
+runtime.introspector.uberspect = org.apache.velocity.util.introspection.UberspectImpl,org.apache.velocity.tools.view.WebappUberspector

Modified: velocity/tools/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/xdocs/changes.xml?rev=778192&amp;r1=778191&amp;r2=778192&amp;view=diff
==============================================================================
--- velocity/tools/trunk/xdocs/changes.xml (original)
+++ velocity/tools/trunk/xdocs/changes.xml Sun May 24 16:45:31 2009
@@ -31,16 +31,17 @@
     &lt;subsection name="2.0-dev"&gt;
         &lt;p&gt;This section very briefly and generally describes changes after the 1.x
series.&lt;/p&gt;
         &lt;ul&gt;
-        &lt;li&gt;More convention over configuration and smart defaults&lt;/li&gt;
-        &lt;li&gt;New configuration formats (more concise/flexible/powerful xml, properties,
java)&lt;/li&gt;
-        &lt;li&gt;Entirely new core infrastructure (lazy-loading tools, easier access, standalone
support etc)&lt;/li&gt;
-        &lt;li&gt;Added VelocityViewTag for JSP integration&lt;/li&gt;
-        &lt;li&gt;Added DisplayTool, ConversionTool, ClassTool, LoopTool, FieldTool, a generic
version of LinkTool and more&lt;/li&gt;
-        &lt;li&gt;Refactored and enhanced a number of existing tools&lt;/li&gt;
-        &lt;li&gt;Improved documentation&lt;/li&gt;
-        &lt;li&gt;Deprecated many outdated things&lt;/li&gt;
-        &lt;li&gt;Legacy support for almost all Tools 1.4 configurations and extensions&lt;/li&gt;
-        &lt;li&gt;... and lots more. :)&lt;/li&gt;
+        &lt;li&gt;More convention over configuration and smart defaults (ndb)&lt;/li&gt;
+        &lt;li&gt;New configuration formats (more concise/flexible/powerful xml, properties,
java) (ndb)&lt;/li&gt;
+        &lt;li&gt;Entirely new core infrastructure (lazy-loading tools, easier access, standalone
support etc) (ndb)&lt;/li&gt;
+        &lt;li&gt;Added VelocityViewTag for JSP integration (ndb)&lt;/li&gt;
+        &lt;li&gt;Added DisplayTool, ConversionTool, ClassTool, LoopTool, FieldTool, a generic
version of LinkTool and more (ndb)&lt;/li&gt;
+        &lt;li&gt;Refactored and enhanced a number of existing tools (ndb)&lt;/li&gt;
+        &lt;li&gt;Improved documentation (ndb)&lt;/li&gt;
+        &lt;li&gt;Deprecated many outdated things (ndb)&lt;/li&gt; --&gt;
+        &lt;li&gt;Legacy support for almost all Tools 1.4 configurations and extensions (ndb)&lt;/li&gt;
+        &lt;li&gt;Better integration of $application, $session and $request scope control
objects (cbn)&lt;/li&gt;
+	&lt;li&gt;and lots more...&lt;/li&gt;
         &lt;/ul&gt;
     &lt;/subsection&gt;
 




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r778131 - /velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/ServletUtils.java</title>
<author><name>cbrisson@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200905.mbox/%3c20090524124741.4C00C2388863@eris.apache.org%3e"/>
<id>urn:uuid:%3c20090524124741-4C00C2388863@eris-apache-org%3e</id>
<updated>2009-05-24T12:47:41Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: cbrisson
Date: Sun May 24 12:47:40 2009
New Revision: 778131

URL: http://svn.apache.org/viewvc?rev=778131&amp;view=rev
Log:
display value of depMode in info string

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

Modified: velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/ServletUtils.java
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/ServletUtils.java?rev=778131&amp;r1=778130&amp;r2=778131&amp;view=diff
==============================================================================
--- velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/ServletUtils.java (original)
+++ velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/ServletUtils.java Sun
May 24 12:47:40 2009
@@ -363,7 +363,7 @@
 
         // then make sure it's a file type we recognize
         FileFactoryConfiguration config = null;
-        String source = "ServletUtils.getConfiguration("+path+",ServletContext[,depMode])";
+        String source = "ServletUtils.getConfiguration("+path+",ServletContext[,depMode="+deprecationSupportMode+"])";
         if (path.endsWith(".xml"))
         {
             config = new XmlFactoryConfiguration(deprecationSupportMode, source);




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r778057 - in /velocity/engine/branches/2.0_Exp: src/changes/ src/java/org/apache/velocity/ src/java/org/apache/velocity/app/event/implement/ src/java/org/apache/velocity/runtime/ src/java/org/apache/velocity/runtime/defaults/ src/java/org/a...</title>
<author><name>nbubna@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200905.mbox/%3c20090523225429.CE84D2388872@eris.apache.org%3e"/>
<id>urn:uuid:%3c20090523225429-CE84D2388872@eris-apache-org%3e</id>
<updated>2009-05-23T22:54:29Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: nbubna
Date: Sat May 23 22:54:28 2009
New Revision: 778057

URL: http://svn.apache.org/viewvc?rev=778057&amp;view=rev
Log:
VELOCITY-704 default all scope controls to off, except $foreach and do a few other tiny, scope-related
performance boosts (merge from trunk, r778045)

Modified:
    velocity/engine/branches/2.0_Exp/src/changes/changes.xml
    velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/Template.java
    velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/implement/EscapeReference.java
    velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/RuntimeInstance.java
    velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/defaults/velocity.properties
    velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Directive.java
    velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Scope.java
    velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/resource/ResourceCacheImpl.java
    velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/BreakDirectiveTestCase.java
    velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/EvaluateTestCase.java
    velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/ScopeTestCase.java
    velocity/engine/branches/2.0_Exp/xdocs/docs/developer-guide.xml

Modified: velocity/engine/branches/2.0_Exp/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/changes/changes.xml?rev=778057&amp;r1=778056&amp;r2=778057&amp;view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/changes/changes.xml (original)
+++ velocity/engine/branches/2.0_Exp/src/changes/changes.xml Sat May 23 22:54:28 2009
@@ -75,9 +75,10 @@
     Change the scoping behavior of Velocity, keeping it optional (everything global
     scoped by default) but now providing an explicit namespace in content-containing
     directives (like macros, #foreach, #parse, etc.) in which references that should
-    stay local may be kept.  This is accompanied by numerous related changes, including:
+    stay local may be kept. This is accompanied by numerous related changes, including:
     &amp;lt;ul&amp;gt;
-    &amp;lt;li&amp;gt;A Scope reference is now available within each content directive:
+    &amp;lt;li&amp;gt;A Scope reference can now be automatically made
+              available within each content directive:
         &amp;lt;ul&amp;gt;
         &amp;lt;li&amp;gt;$template in Template.merge and #parse content&amp;lt;li&amp;gt;
         &amp;lt;li&amp;gt;$macro in #macro&amp;lt;/li&amp;gt;
@@ -88,8 +89,9 @@
               (where &amp;amp;lt;amacro&amp;amp;gt; is the name of a macro being called with
a body)&amp;lt;/li&amp;gt;
         &amp;lt;/ul&amp;gt;
     &amp;lt;/li&amp;gt;
-    &amp;lt;li&amp;gt;Allowing the above to be suppressed by setting a velocity property
like:
-        &amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;foreach.provide.scope.control = false&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;
+    &amp;lt;li&amp;gt;For performance and compatibility these are all off by
+    default, *except* for $foreach. The others may be enabled by setting a velocity property
like:
+        &amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;macro.provide.scope.control = true&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;
     &amp;lt;li&amp;gt;When scopes of the same type are nested make the parent Scope available
         through the child (e.g. $foreach.parent or $foreach.topmost).&amp;lt;/li&amp;gt;
     &amp;lt;li&amp;gt;When a Scope reference overrides an existing reference that is not
a Scope,

Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/Template.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/Template.java?rev=778057&amp;r1=778056&amp;r2=778057&amp;view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/Template.java (original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/Template.java Sat May 23
22:54:28 2009
@@ -71,7 +71,7 @@
      * the scope object into the context.
      */
     private String scopeName = "template";
-    private boolean provideScope = true;
+    private boolean provideScope = false;
 
     private VelocityException errorCondition = null;
 

Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/implement/EscapeReference.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/implement/EscapeReference.java?rev=778057&amp;r1=778056&amp;r2=778057&amp;view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/implement/EscapeReference.java
(original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/app/event/implement/EscapeReference.java
Sat May 23 22:54:28 2009
@@ -21,6 +21,8 @@
 
 import org.apache.oro.text.perl.MalformedPerl5PatternException;
 import org.apache.oro.text.perl.Perl5Util;
+//import java.util.regex.Pattern;
+//import java.util.regex.Matcher;
 import org.apache.velocity.app.event.ReferenceInsertionEventHandler;
 import org.apache.velocity.runtime.RuntimeServices;
 import org.apache.velocity.util.RuntimeServicesAware;
@@ -57,12 +59,13 @@
  */
 public abstract class EscapeReference implements ReferenceInsertionEventHandler,RuntimeServicesAware
{
 
-
+//
     private Perl5Util perl = new Perl5Util();
 
     private RuntimeServices rs;
 
     private String matchRegExp = null;
+    //private Pattern pattern = null;
 
     /**
      * Escape the given text.  Override this in a subclass to do the actual
@@ -98,11 +101,13 @@
         }
 
         if (matchRegExp == null)
+        //if (pattern == null)
         {
             return escape(value);
         }
 
         else if (perl.match(matchRegExp,reference))
+        //else if (pattern.matcher(reference).matches())
         {
             return escape(value);
         }

Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/RuntimeInstance.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/RuntimeInstance.java?rev=778057&amp;r1=778056&amp;r2=778057&amp;view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/RuntimeInstance.java
(original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/RuntimeInstance.java
Sat May 23 22:54:28 2009
@@ -196,7 +196,7 @@
      * Settings for provision of root scope for evaluate(...) calls.
      */
     private String evaluateScopeName = "evaluate";
-    private boolean provideEvaluateScope = true;
+    private boolean provideEvaluateScope = false;
 
     /*
      *  Opaque reference to something specificed by the

Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/defaults/velocity.properties
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/defaults/velocity.properties?rev=778057&amp;r1=778056&amp;r2=778057&amp;view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/defaults/velocity.properties
(original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/defaults/velocity.properties
Sat May 23 22:54:28 2009
@@ -75,12 +75,12 @@
 # These are the properties that govern whether or not a Scope object
 # is automatically provided for each of the given scopes to serve as a
 # scope-safe reference namespace and "label" for #break calls. The default
-# for all of these is true.  Note that &lt;bodymacroname&gt; should be replaced by
+# for most of these is false.  Note that &lt;bodymacroname&gt; should be replaced by
 # name of macros that take bodies for which you want to suppress the scope.
 # ----------------------------------------------------------------------------
 # template.provide.scope.control = false
 # evaluate.provide.scope.control = false
-# foreach.provide.scope.control = false
+foreach.provide.scope.control = true
 # macro.provide.scope.control = false
 # define.provide.scope.control = false
 # &lt;bodymacroname&gt;.provide.scope.control = false

Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Directive.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Directive.java?rev=778057&amp;r1=778056&amp;r2=778057&amp;view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Directive.java
(original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Directive.java
Sat May 23 22:54:28 2009
@@ -46,7 +46,7 @@
 {
     private int line = 0;
     private int column = 0;
-    private boolean provideScope = true;
+    private boolean provideScope = false;
     private String templateName;
 
     /**
@@ -147,7 +147,7 @@
         rsvc = rs;
 
         String property = getScopeName()+'.'+RuntimeConstants.PROVIDE_SCOPE_CONTROL;
-        this.provideScope = rsvc.getBoolean(property, true);
+        this.provideScope = rsvc.getBoolean(property, provideScope);
     }
 
     /**
@@ -193,10 +193,15 @@
         {
             String name = getScopeName();
             Object previous = context.get(name);
-            context.put(name, new Scope(this, previous));
+            context.put(name, makeScope(previous));
         }
     }
 
+    protected Scope makeScope(Object prev)
+    {
+        return new Scope(this, prev);
+    }
+
     /**
      * This cleans up any scope control for this directive after rendering,
      * assuming the scope control was turned on.
@@ -208,13 +213,7 @@
             String name = getScopeName();
             Object obj = context.get(name);
             
-            // the user can override the scope with a #set,
-            // since that means they don't care about a replaced value
-            // and obviously aren't too keen on their scope control,
-            // and especially since #set is meant to be handled globally,
-            // we'll assume they know what they're doing and not worry
-            // about replacing anything superseded by this directive's scope
-            if (obj instanceof Scope)
+            try
             {
                 Scope scope = (Scope)obj;
                 if (scope.getParent() != null)
@@ -230,6 +229,15 @@
                     context.remove(name);
                 }
             }
+            catch (ClassCastException cce)
+            {
+                // the user can override the scope with a #set,
+                // since that means they don't care about a replaced value
+                // and obviously aren't too keen on their scope control,
+                // and especially since #set is meant to be handled globally,
+                // we'll assume they know what they're doing and not worry
+                // about replacing anything superseded by this directive's scope
+            }
         }
     }
 

Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Scope.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Scope.java?rev=778057&amp;r1=778056&amp;r2=778057&amp;view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Scope.java
(original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Scope.java
Sat May 23 22:54:28 2009
@@ -33,23 +33,23 @@
 public class Scope extends AbstractMap
 {
     private Map storage;
-    protected final Object replaced;
-    protected final Scope parent;
+    private Object replaced;
+    private Scope parent;
     protected final Object owner;
 
     public Scope(Object owner, Object previous)
     {
         this.owner = owner;
-        if (previous instanceof Scope)
+        if (previous != null)
         {
-            this.parent = (Scope)previous;
-            // keep easy access to the user's object
-            this.replaced = this.parent.replaced;
-        }
-        else
-        {
-            this.parent = null;
-            this.replaced = previous;
+            try
+            {
+                this.parent = (Scope)previous;
+            }
+            catch (ClassCastException cce)
+            {
+                this.replaced = previous;
+            }
         }
     }
 
@@ -137,6 +137,10 @@
      */
     public Object getReplaced()
     {
+        if (replaced == null &amp;&amp; parent != null)
+        {
+            return parent.getReplaced();
+        }
         return replaced;
     }
 

Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/resource/ResourceCacheImpl.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/resource/ResourceCacheImpl.java?rev=778057&amp;r1=778056&amp;r2=778057&amp;view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/resource/ResourceCacheImpl.java
(original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/resource/ResourceCacheImpl.java
Sat May 23 22:54:28 2009
@@ -28,7 +28,7 @@
 import org.apache.commons.collections.map.LRUMap;
 import org.apache.velocity.runtime.RuntimeConstants;
 import org.apache.velocity.runtime.RuntimeServices;
-import org.apache.velocity.util.MapFactory;
+import java.util.concurrent.ConcurrentHashMap;
 
 /**
  * Default implementation of the resource cache for the default
@@ -49,7 +49,7 @@
     /**
      * Cache storage, assumed to be thread-safe.
      */
-    protected Map cache = MapFactory.create(512, 0.5f, 30, false);
+    protected Map cache = new ConcurrentHashMap(512, 0.5f, 30);
 
     /**
      * Runtime services, generally initialized by the

Modified: velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/BreakDirectiveTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/BreakDirectiveTestCase.java?rev=778057&amp;r1=778056&amp;r2=778057&amp;view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/BreakDirectiveTestCase.java
(original)
+++ velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/BreakDirectiveTestCase.java
Sat May 23 22:54:28 2009
@@ -19,6 +19,8 @@
  * under the License.    
  */
 
+import org.apache.velocity.app.VelocityEngine;
+
 /**
  * This class tests the break directive.
  */
@@ -29,6 +31,15 @@
         super(name);
     }
 
+    protected void setUpEngine(VelocityEngine engine)
+    {
+        engine.setProperty("a.provide.scope.control", "true");
+        engine.setProperty("define.provide.scope.control", "true");
+        engine.setProperty("evaluate.provide.scope.control", "true");
+        engine.setProperty("macro.provide.scope.control", "true");
+        engine.setProperty("template.provide.scope.control", "true");
+    }
+
     public void testBadArgs()
     {
         context.put("foo","foo");

Modified: velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/EvaluateTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/EvaluateTestCase.java?rev=778057&amp;r1=778056&amp;r2=778057&amp;view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/EvaluateTestCase.java
(original)
+++ velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/EvaluateTestCase.java
Sat May 23 22:54:28 2009
@@ -131,6 +131,7 @@
      */
     public void testStopAndBreak()
     {
+        engine.setProperty("evaluate.provide.scope.control", "true");
         assertEvalEquals("t ", "t #stop t2 #evaluate('t3')");
         assertEvalEquals("t ", "t #break t2 #evaluate('t3')");
         assertEvalEquals("t t2 t3 ", "t t2 #evaluate('t3 #stop t4') t5");

Modified: velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/ScopeTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/ScopeTestCase.java?rev=778057&amp;r1=778056&amp;r2=778057&amp;view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/ScopeTestCase.java
(original)
+++ velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/ScopeTestCase.java
Sat May 23 22:54:28 2009
@@ -21,6 +21,7 @@
 
 import java.util.HashMap;
 import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
 import org.apache.velocity.runtime.RuntimeConstants;
 import org.apache.velocity.runtime.directive.Scope;
 
@@ -34,6 +35,17 @@
        super(name);
     }
 
+    protected void setUpEngine(VelocityEngine engine)
+    {
+        engine.setProperty("a.provide.scope.control", "true");
+        engine.setProperty("define.provide.scope.control", "true");
+        engine.setProperty("evaluate.provide.scope.control", "true");
+        engine.setProperty("foo.provide.scope.control", "true");
+        engine.setProperty("macro.provide.scope.control", "true");
+        engine.setProperty("template.provide.scope.control", "true");
+        engine.setProperty("vm.provide.scope.control", "true");
+    }
+
     public void testRootTemplateMergeScope()
     {
         addTemplate("foo", "foo#break($template)bar");

Modified: velocity/engine/branches/2.0_Exp/xdocs/docs/developer-guide.xml
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/xdocs/docs/developer-guide.xml?rev=778057&amp;r1=778056&amp;r2=778057&amp;view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/xdocs/docs/developer-guide.xml (original)
+++ velocity/engine/branches/2.0_Exp/xdocs/docs/developer-guide.xml Sat May 23 22:54:28 2009
@@ -1591,10 +1591,12 @@
 &lt;/p&gt;
 
 &lt;p&gt;
-&lt;code&gt;define.provide.scope.control = true&lt;/code&gt;&lt;br/&gt;
-Used to control the automatic provision of the $define scope control
-during #define() calls. The default is true.
-Set it to false if unused and you want a tiny performance boost.
+&lt;code&gt;define.provide.scope.control = false&lt;/code&gt;&lt;br/&gt;
+Used to turn on the automatic provision of the $define scope control
+during #define() calls. The default is false.
+Set it to true if you want a local, managed namespace
+you can put references in when within a #define block or if you want it for
+more advanced #break usage.
 &lt;/p&gt;
 
 &lt;p&gt;
@@ -1602,10 +1604,12 @@
 &lt;/p&gt;
 
 &lt;p&gt;
-&lt;code&gt;evaluate.provide.scope.control = true&lt;/code&gt;&lt;br/&gt;
-Used to control the automatic provision of the $evaluate scope
+&lt;code&gt;evaluate.provide.scope.control = false&lt;/code&gt;&lt;br/&gt;
+Used to turn on the automatic provision of the $evaluate scope
 during #evaluate() or Velocity[Engine].evaluate(...) calls. The default
-is true.  Set it to false if unused and you want a tiny performance boost.
+is false.  Set it to true if you want a local, managed namespace
+you can put references in during an evaluation or if you want it for
+more advanced #break usage.
 &lt;/p&gt;
 
 &lt;p&gt;
@@ -1615,7 +1619,8 @@
 &lt;p&gt;
 &lt;code&gt;foreach.provide.scope.control = true&lt;/code&gt;&lt;br/&gt;
 Used to control the automatic provision of the $foreach scope
-during #foreach calls. The default is true.
+during #foreach calls.  This gives access to the foreach status information
+(e.g. $foreach.index or $foreach.hasNext). The default is true.
 Set it to false if unused and you want a tiny performance boost.
 &lt;/p&gt;
 
@@ -1653,10 +1658,11 @@
 prevents runaway #parse() recursion.
 &lt;/p&gt;
 &lt;p&gt;
-&lt;code&gt;template.provide.scope.control = true&lt;/code&gt;&lt;br/&gt;
-Used to control the automatic provision of the $template scope control
-during #parse calls (and template.merge(...) calls). The default is true.
-Set it to false if unused and you want a tiny performance boost.
+&lt;code&gt;template.provide.scope.control = false&lt;/code&gt;&lt;br/&gt;
+Used to turn on the automatic provision of the $template scope control
+during #parse calls and template.merge(...) calls. The default is false.
+Set it to true if you want a secure namespace for your template variables
+or more advanced #break control.
 &lt;/p&gt;
 
 
@@ -1829,17 +1835,18 @@
 macro feature was introduced in Velocity 1.7.
 &lt;/p&gt;
 &lt;p&gt;
-&lt;code&gt;macro.provide.scope.control = true&lt;/code&gt;&lt;br/&gt;
-Used to control the automatic provision of the $macro scope control
-during #macro calls. The default is true.
-Set it to false if unused and you want a tiny performance boost.
+&lt;code&gt;macro.provide.scope.control = false&lt;/code&gt;&lt;br/&gt;
+Used to turn on the automatic provision of the $macro scope control
+during #macro calls. The default is false.
+Set it to true if you need a local namespace in macros or more
+advanced #break controls.
 &lt;/p&gt;
 &lt;p&gt;
-&lt;code&gt;&amp;lt;somebodymacro&amp;gt;.provide.scope.control = true&lt;/code&gt;&lt;br/&gt;
-Used to control the automatic provision of the $&amp;lt;nameofthemacro&amp;gt; scope control
+&lt;code&gt;&amp;lt;somebodymacro&amp;gt;.provide.scope.control = false&lt;/code&gt;&lt;br/&gt;
+Used to turn on the automatic provision of the $&amp;lt;nameofthemacro&amp;gt; scope control
 during a call to a macro with a body (e.g. #@foo #set($foo.a=$b) ... $foo.a #end).
-The default is true. Set it to false if you heavily use that body macro without
-using the scope control and you want a tiny performance boost.
+The default is false. Set it to true if you happen to need a namespace just
+for your macro's body content or more advanced #break controls.
 &lt;/p&gt;
 
 &lt;p&gt;




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r778056 - in /velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity: runtime/VelocimacroManager.java util/MapFactory.java</title>
<author><name>nbubna@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200905.mbox/%3c20090523225151.B8A0D2388872@eris.apache.org%3e"/>
<id>urn:uuid:%3c20090523225151-B8A0D2388872@eris-apache-org%3e</id>
<updated>2009-05-23T22:51:51Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: nbubna
Date: Sat May 23 22:51:51 2009
New Revision: 778056

URL: http://svn.apache.org/viewvc?rev=778056&amp;view=rev
Log:
MapFactory no longer needed, just use ConcurrentHashMap

Removed:
    velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/util/MapFactory.java
Modified:
    velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/VelocimacroManager.java

Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/VelocimacroManager.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/VelocimacroManager.java?rev=778056&amp;r1=778055&amp;r2=778056&amp;view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/VelocimacroManager.java
(original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/VelocimacroManager.java
Sat May 23 22:51:51 2009
@@ -31,7 +31,7 @@
 import org.apache.velocity.runtime.directive.VelocimacroProxy;
 import org.apache.velocity.runtime.parser.node.Node;
 import org.apache.velocity.runtime.parser.node.SimpleNode;
-import org.apache.velocity.util.MapFactory;
+import java.util.concurrent.ConcurrentHashMap;
 
 /**
  * Manages VMs in namespaces.  Currently, two namespace modes are
@@ -56,7 +56,7 @@
     private boolean registerFromLib = false;
 
     /** Hash of namespace hashes. */
-    private final Map namespaceHash = MapFactory.create(17, 0.5f, 20, false);
+    private final Map namespaceHash = new ConcurrentHashMap(17, 0.5f, 20);
 
     /** reference to global namespace hash */
     private final Map globalNamespace;
@@ -362,7 +362,7 @@
      */
     private Map addNamespace(final String namespace)
     {
-        Map h = MapFactory.create(17, 0.5f, 20, false);
+        Map h = new ConcurrentHashMap(17, 0.5f, 20);
         Object oh;
 
         if ((oh = namespaceHash.put(namespace, h)) != null)




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r778054 - in /velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/util/introspection: ClassMap.java MethodMap.java</title>
<author><name>nbubna@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200905.mbox/%3c20090523224956.0F8462388872@eris.apache.org%3e"/>
<id>urn:uuid:%3c20090523224956-0F8462388872@eris-apache-org%3e</id>
<updated>2009-05-23T22:49:55Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: nbubna
Date: Sat May 23 22:49:55 2009
New Revision: 778054

URL: http://svn.apache.org/viewvc?rev=778054&amp;view=rev
Log:
VELOCITY-718 prevent infinite loop in HashMap.get()

Modified:
    velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/util/introspection/ClassMap.java
    velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/util/introspection/MethodMap.java

Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/util/introspection/ClassMap.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/util/introspection/ClassMap.java?rev=778054&amp;r1=778053&amp;r2=778054&amp;view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/util/introspection/ClassMap.java
(original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/util/introspection/ClassMap.java
Sat May 23 22:49:55 2009
@@ -23,6 +23,7 @@
 import java.lang.reflect.Modifier;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 import org.apache.commons.lang.text.StrBuilder;
 import org.apache.velocity.runtime.log.Log;
 
@@ -215,7 +216,7 @@
          * Cache of Methods, or CACHE_MISS, keyed by method
          * name and actual arguments used to find it.
          */
-        private final Map cache = new HashMap();
+        private final Map cache = new ConcurrentHashMap();
 
         /** Map of methods that are searchable according to method parameters to find a match
*/
         private final MethodMap methodMap = new MethodMap();

Modified: velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/util/introspection/MethodMap.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/util/introspection/MethodMap.java?rev=778054&amp;r1=778053&amp;r2=778054&amp;view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/util/introspection/MethodMap.java
(original)
+++ velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/util/introspection/MethodMap.java
Sat May 23 22:49:55 2009
@@ -21,11 +21,11 @@
 
 import java.lang.reflect.Method;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
 /**
  *
@@ -45,7 +45,7 @@
     /**
      * Keep track of all methods with the same name.
      */
-    Map methodByNameMap = new HashMap();
+    Map methodByNameMap = new ConcurrentHashMap();
 
     /**
      * Add a method to a list of methods by name.




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r778045 - in /velocity/engine/trunk: src/changes/ src/java/org/apache/velocity/ src/java/org/apache/velocity/runtime/ src/java/org/apache/velocity/runtime/defaults/ src/java/org/apache/velocity/runtime/directive/ src/test/org/apache/velocit...</title>
<author><name>nbubna@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200905.mbox/%3c20090523221747.8E9752388892@eris.apache.org%3e"/>
<id>urn:uuid:%3c20090523221747-8E9752388892@eris-apache-org%3e</id>
<updated>2009-05-23T22:17:47Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: nbubna
Date: Sat May 23 22:17:46 2009
New Revision: 778045

URL: http://svn.apache.org/viewvc?rev=778045&amp;view=rev
Log:
VELOCITY-704 default all scope controls to off, except $foreach and do a few other tiny, scope-related
performance boosts

Modified:
    velocity/engine/trunk/src/changes/changes.xml
    velocity/engine/trunk/src/java/org/apache/velocity/Template.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/defaults/velocity.properties
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Directive.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Scope.java
    velocity/engine/trunk/src/test/org/apache/velocity/test/BreakDirectiveTestCase.java
    velocity/engine/trunk/src/test/org/apache/velocity/test/EvaluateTestCase.java
    velocity/engine/trunk/src/test/org/apache/velocity/test/ScopeTestCase.java
    velocity/engine/trunk/xdocs/docs/developer-guide.xml

Modified: velocity/engine/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/changes/changes.xml?rev=778045&amp;r1=778044&amp;r2=778045&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/changes/changes.xml (original)
+++ velocity/engine/trunk/src/changes/changes.xml Sat May 23 22:17:46 2009
@@ -37,9 +37,10 @@
     Change the scoping behavior of Velocity, keeping it optional (everything global
     scoped by default) but now providing an explicit namespace in content-containing
     directives (like macros, #foreach, #parse, etc.) in which references that should
-    stay local may be kept.  This is accompanied by numerous related changes, including:
+    stay local may be kept. This is accompanied by numerous related changes, including:
     &amp;lt;ul&amp;gt;
-    &amp;lt;li&amp;gt;A Scope reference is now available within each content directive:
+    &amp;lt;li&amp;gt;A Scope reference can now be automatically made
+              available within each content directive:
         &amp;lt;ul&amp;gt;
         &amp;lt;li&amp;gt;$template in Template.merge and #parse content&amp;lt;li&amp;gt;
         &amp;lt;li&amp;gt;$macro in #macro&amp;lt;/li&amp;gt;
@@ -50,8 +51,9 @@
               (where &amp;amp;lt;amacro&amp;amp;gt; is the name of a macro being called with
a body)&amp;lt;/li&amp;gt;
         &amp;lt;/ul&amp;gt;
     &amp;lt;/li&amp;gt;
-    &amp;lt;li&amp;gt;Allowing the above to be suppressed by setting a velocity property
like:
-        &amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;foreach.provide.scope.control = false&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;
+    &amp;lt;li&amp;gt;For performance and compatibility these are all off by
+    default, *except* for $foreach. The others may be enabled by setting a velocity property
like:
+        &amp;lt;br/&amp;gt;&amp;lt;code&amp;gt;macro.provide.scope.control = true&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;
     &amp;lt;li&amp;gt;When scopes of the same type are nested make the parent Scope available
         through the child (e.g. $foreach.parent or $foreach.topmost).&amp;lt;/li&amp;gt;
     &amp;lt;li&amp;gt;When a Scope reference overrides an existing reference that is not
a Scope,

Modified: velocity/engine/trunk/src/java/org/apache/velocity/Template.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/Template.java?rev=778045&amp;r1=778044&amp;r2=778045&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/Template.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/Template.java Sat May 23 22:17:46 2009
@@ -71,7 +71,7 @@
      * the scope object into the context.
      */
     private String scopeName = "template";
-    private boolean provideScope = true;
+    private boolean provideScope = false;
 
     private VelocityException errorCondition = null;
 

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java?rev=778045&amp;r1=778044&amp;r2=778045&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java Sat May
23 22:17:46 2009
@@ -194,7 +194,7 @@
      * Settings for provision of root scope for evaluate(...) calls.
      */
     private String evaluateScopeName = "evaluate";
-    private boolean provideEvaluateScope = true;
+    private boolean provideEvaluateScope = false;
 
     /*
      *  Opaque reference to something specificed by the

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/defaults/velocity.properties
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/defaults/velocity.properties?rev=778045&amp;r1=778044&amp;r2=778045&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/defaults/velocity.properties
(original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/defaults/velocity.properties
Sat May 23 22:17:46 2009
@@ -91,12 +91,12 @@
 # These are the properties that govern whether or not a Scope object
 # is automatically provided for each of the given scopes to serve as a
 # scope-safe reference namespace and "label" for #break calls. The default
-# for all of these is true.  Note that &lt;bodymacroname&gt; should be replaced by
+# for most of these is false.  Note that &lt;bodymacroname&gt; should be replaced by
 # name of macros that take bodies for which you want to suppress the scope.
 # ----------------------------------------------------------------------------
 # template.provide.scope.control = false
 # evaluate.provide.scope.control = false
-# foreach.provide.scope.control = false
+foreach.provide.scope.control = true
 # macro.provide.scope.control = false
 # define.provide.scope.control = false
 # &lt;bodymacroname&gt;.provide.scope.control = false

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Directive.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Directive.java?rev=778045&amp;r1=778044&amp;r2=778045&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Directive.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Directive.java Sat
May 23 22:17:46 2009
@@ -45,7 +45,7 @@
 {
     private int line = 0;
     private int column = 0;
-    private boolean provideScope = true;
+    private boolean provideScope = false;
     private String templateName;
 
     /**
@@ -146,7 +146,7 @@
         rsvc = rs;
 
         String property = getScopeName()+'.'+RuntimeConstants.PROVIDE_SCOPE_CONTROL;
-        this.provideScope = rsvc.getBoolean(property, true);
+        this.provideScope = rsvc.getBoolean(property, provideScope);
     }
 
     /**
@@ -176,10 +176,15 @@
         {
             String name = getScopeName();
             Object previous = context.get(name);
-            context.put(name, new Scope(this, previous));
+            context.put(name, makeScope(previous));
         }
     }
 
+    protected Scope makeScope(Object prev)
+    {
+        return new Scope(this, prev);
+    }
+
     /**
      * This cleans up any scope control for this directive after rendering,
      * assuming the scope control was turned on.
@@ -191,13 +196,7 @@
             String name = getScopeName();
             Object obj = context.get(name);
             
-            // the user can override the scope with a #set,
-            // since that means they don't care about a replaced value
-            // and obviously aren't too keen on their scope control,
-            // and especially since #set is meant to be handled globally,
-            // we'll assume they know what they're doing and not worry
-            // about replacing anything superseded by this directive's scope
-            if (obj instanceof Scope)
+            try
             {
                 Scope scope = (Scope)obj;
                 if (scope.getParent() != null)
@@ -213,6 +212,15 @@
                     context.remove(name);
                 }
             }
+            catch (ClassCastException cce)
+            {
+                // the user can override the scope with a #set,
+                // since that means they don't care about a replaced value
+                // and obviously aren't too keen on their scope control,
+                // and especially since #set is meant to be handled globally,
+                // we'll assume they know what they're doing and not worry
+                // about replacing anything superseded by this directive's scope
+            }
         }
     }
 

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Scope.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Scope.java?rev=778045&amp;r1=778044&amp;r2=778045&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Scope.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Scope.java Sat May
23 22:17:46 2009
@@ -33,23 +33,23 @@
 public class Scope extends AbstractMap
 {
     private Map storage;
-    protected final Object replaced;
-    protected final Scope parent;
+    private Object replaced;
+    private Scope parent;
     protected final Object owner;
 
     public Scope(Object owner, Object previous)
     {
         this.owner = owner;
-        if (previous instanceof Scope)
+        if (previous != null)
         {
-            this.parent = (Scope)previous;
-            // keep easy access to the user's object
-            this.replaced = this.parent.replaced;
-        }
-        else
-        {
-            this.parent = null;
-            this.replaced = previous;
+            try
+            {
+                this.parent = (Scope)previous;
+            }
+            catch (ClassCastException cce)
+            {
+                this.replaced = previous;
+            }
         }
     }
 
@@ -135,6 +135,10 @@
      */
     public Object getReplaced()
     {
+        if (replaced == null &amp;&amp; parent != null)
+        {
+            return parent.getReplaced();
+        }
         return replaced;
     }
 

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/BreakDirectiveTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/BreakDirectiveTestCase.java?rev=778045&amp;r1=778044&amp;r2=778045&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/BreakDirectiveTestCase.java (original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/BreakDirectiveTestCase.java Sat
May 23 22:17:46 2009
@@ -19,6 +19,8 @@
  * under the License.    
  */
 
+import org.apache.velocity.app.VelocityEngine;
+
 /**
  * This class tests the break directive.
  */
@@ -29,6 +31,15 @@
         super(name);
     }
 
+    protected void setUpEngine(VelocityEngine engine)
+    {
+        engine.setProperty("a.provide.scope.control", "true");
+        engine.setProperty("define.provide.scope.control", "true");
+        engine.setProperty("evaluate.provide.scope.control", "true");
+        engine.setProperty("macro.provide.scope.control", "true");
+        engine.setProperty("template.provide.scope.control", "true");
+    }
+
     public void testBadArgs()
     {
         context.put("foo","foo");

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/EvaluateTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/EvaluateTestCase.java?rev=778045&amp;r1=778044&amp;r2=778045&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/EvaluateTestCase.java (original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/EvaluateTestCase.java Sat May
23 22:17:46 2009
@@ -141,6 +141,7 @@
      */
     public void testStopAndBreak()
     {
+        engine.setProperty("evaluate.provide.scope.control", "true");
         assertEvalEquals("t ", "t #stop t2 #evaluate('t3')");
         assertEvalEquals("t ", "t #break t2 #evaluate('t3')");
         //assertEvalEquals("t t2 t3 ", "t t2 #evaluate('t3 #stop t4') t5");

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/ScopeTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/ScopeTestCase.java?rev=778045&amp;r1=778044&amp;r2=778045&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/ScopeTestCase.java (original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/ScopeTestCase.java Sat May 23
22:17:46 2009
@@ -21,6 +21,7 @@
 
 import java.util.HashMap;
 import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
 import org.apache.velocity.runtime.RuntimeConstants;
 import org.apache.velocity.runtime.directive.Scope;
 
@@ -34,9 +35,15 @@
        super(name);
     }
 
-    public void setUp() throws Exception
+    protected void setUpEngine(VelocityEngine engine)
     {
-        super.setUp();
+        engine.setProperty("a.provide.scope.control", "true");
+        engine.setProperty("define.provide.scope.control", "true");
+        engine.setProperty("evaluate.provide.scope.control", "true");
+        engine.setProperty("foo.provide.scope.control", "true");
+        engine.setProperty("macro.provide.scope.control", "true");
+        engine.setProperty("template.provide.scope.control", "true");
+        engine.setProperty("vm.provide.scope.control", "true");
         engine.setProperty(RuntimeConstants.SET_NULL_ALLOWED, Boolean.TRUE);
     }
 

Modified: velocity/engine/trunk/xdocs/docs/developer-guide.xml
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/xdocs/docs/developer-guide.xml?rev=778045&amp;r1=778044&amp;r2=778045&amp;view=diff
==============================================================================
--- velocity/engine/trunk/xdocs/docs/developer-guide.xml (original)
+++ velocity/engine/trunk/xdocs/docs/developer-guide.xml Sat May 23 22:17:46 2009
@@ -1614,10 +1614,12 @@
 &lt;/p&gt;
 
 &lt;p&gt;
-&lt;code&gt;define.provide.scope.control = true&lt;/code&gt;&lt;br/&gt;
-Used to control the automatic provision of the $define scope control
-during #define() calls. The default is true.
-Set it to false if unused and you want a tiny performance boost.
+&lt;code&gt;define.provide.scope.control = false&lt;/code&gt;&lt;br/&gt;
+Used to turn on the automatic provision of the $define scope control
+during #define() calls. The default is false.
+Set it to true if you want a local, managed namespace
+you can put references in when within a #define block or if you want it for
+more advanced #break usage.
 &lt;/p&gt;
 
 &lt;p&gt;
@@ -1625,10 +1627,12 @@
 &lt;/p&gt;
 
 &lt;p&gt;
-&lt;code&gt;evaluate.provide.scope.control = true&lt;/code&gt;&lt;br/&gt;
-Used to control the automatic provision of the $evaluate scope
+&lt;code&gt;evaluate.provide.scope.control = false&lt;/code&gt;&lt;br/&gt;
+Used to turn on the automatic provision of the $evaluate scope
 during #evaluate() or Velocity[Engine].evaluate(...) calls. The default
-is true.  Set it to false if unused and you want a tiny performance boost.
+is false.  Set it to true if you want a local, managed namespace
+you can put references in during an evaluation or if you want it for
+more advanced #break usage.
 &lt;/p&gt;
 
 &lt;p&gt;
@@ -1638,7 +1642,8 @@
 &lt;p&gt;
 &lt;code&gt;foreach.provide.scope.control = true&lt;/code&gt;&lt;br/&gt;
 Used to control the automatic provision of the $foreach scope
-during #foreach calls. The default is true.
+during #foreach calls.  This gives access to the foreach status information
+(e.g. $foreach.index or $foreach.hasNext). The default is true.
 Set it to false if unused and you want a tiny performance boost.
 &lt;/p&gt;
 
@@ -1687,10 +1692,11 @@
 prevents runaway #parse() recursion.
 &lt;/p&gt;
 &lt;p&gt;
-&lt;code&gt;template.provide.scope.control = true&lt;/code&gt;&lt;br/&gt;
-Used to control the automatic provision of the $template scope control
-during #parse calls (and template.merge(...) calls). The default is true.
-Set it to false if unused and you want a tiny performance boost.
+&lt;code&gt;template.provide.scope.control = false&lt;/code&gt;&lt;br/&gt;
+Used to turn on the automatic provision of the $template scope control
+during #parse calls and template.merge(...) calls. The default is false.
+Set it to true if you want a secure namespace for your template variables
+or more advanced #break control.
 &lt;/p&gt;
 
 
@@ -1871,17 +1877,18 @@
 macro feature was introduced in Velocity 1.7.
 &lt;/p&gt;
 &lt;p&gt;
-&lt;code&gt;macro.provide.scope.control = true&lt;/code&gt;&lt;br/&gt;
-Used to control the automatic provision of the $macro scope control
-during #macro calls. The default is true.
-Set it to false if unused and you want a tiny performance boost.
+&lt;code&gt;macro.provide.scope.control = false&lt;/code&gt;&lt;br/&gt;
+Used to turn on the automatic provision of the $macro scope control
+during #macro calls. The default is false.
+Set it to true if you need a local namespace in macros or more
+advanced #break controls.
 &lt;/p&gt;
 &lt;p&gt;
-&lt;code&gt;&amp;lt;somebodymacro&amp;gt;.provide.scope.control = true&lt;/code&gt;&lt;br/&gt;
-Used to control the automatic provision of the $&amp;lt;nameofthemacro&amp;gt; scope control
+&lt;code&gt;&amp;lt;somebodymacro&amp;gt;.provide.scope.control = false&lt;/code&gt;&lt;br/&gt;
+Used to turn on the automatic provision of the $&amp;lt;nameofthemacro&amp;gt; scope control
 during a call to a macro with a body (e.g. #@foo #set($foo.a=$b) ... $foo.a #end).
-The default is true. Set it to false if you heavily use that body macro without
-using the scope control and you want a tiny performance boost.
+The default is false. Set it to true if you happen to need a namespace just
+for your macro's body content or more advanced #break controls.
 &lt;/p&gt;
 
 &lt;p&gt;




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r778038 - in /velocity/engine/trunk/src/java/org/apache/velocity/util: MapFactory.java introspection/ClassMap.java introspection/MethodMap.java</title>
<author><name>nbubna@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200905.mbox/%3c20090523215250.D61A12388895@eris.apache.org%3e"/>
<id>urn:uuid:%3c20090523215250-D61A12388895@eris-apache-org%3e</id>
<updated>2009-05-23T21:52:50Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: nbubna
Date: Sat May 23 21:52:50 2009
New Revision: 778038

URL: http://svn.apache.org/viewvc?rev=778038&amp;view=rev
Log:
VELOCITY-718 attempt to prevent infinite HashMap.get() loops

Modified:
    velocity/engine/trunk/src/java/org/apache/velocity/util/MapFactory.java
    velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/ClassMap.java
    velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/MethodMap.java

Modified: velocity/engine/trunk/src/java/org/apache/velocity/util/MapFactory.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/util/MapFactory.java?rev=778038&amp;r1=778037&amp;r2=778038&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/util/MapFactory.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/util/MapFactory.java Sat May 23 21:52:50
2009
@@ -53,7 +53,22 @@
             // not running under JRE 1.5+
         }
     }
-    
+
+    /**
+     * Creates a new instance of a class that implements Map interface
+     * using the JDK defaults for initial size, load factor, etc.
+     * 
+     * Note that there is a small performance penalty because concurrent
+     * maps are created using reflection.
+     * 
+     * @param allowNullKeys if true, the returned Map instance supports null keys       
 
+     * @return one of ConcurrentHashMap, HashMap, Hashtable
+     */
+    public static Map create(boolean allowNullKeys)
+    {
+        return create(16, 0.75f, 16, allowNullKeys);
+    }
+
     /**
      * Creates a new instance of a class that implements Map interface.
      * 

Modified: velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/ClassMap.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/ClassMap.java?rev=778038&amp;r1=778037&amp;r2=778038&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/ClassMap.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/ClassMap.java Sat
May 23 21:52:50 2009
@@ -25,6 +25,7 @@
 import java.util.Map;
 import org.apache.commons.lang.text.StrBuilder;
 import org.apache.velocity.runtime.log.Log;
+import org.apache.velocity.util.MapFactory;
 
 /**
  * A cache of introspection information for a specific class instance.
@@ -215,7 +216,7 @@
          * Cache of Methods, or CACHE_MISS, keyed by method
          * name and actual arguments used to find it.
          */
-        private final Map cache = new HashMap();
+        private final Map cache = MapFactory.create(false);
 
         /** Map of methods that are searchable according to method parameters to find a match
*/
         private final MethodMap methodMap = new MethodMap();

Modified: velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/MethodMap.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/MethodMap.java?rev=778038&amp;r1=778037&amp;r2=778038&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/MethodMap.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/MethodMap.java Sat
May 23 21:52:50 2009
@@ -26,6 +26,7 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import org.apache.velocity.util.MapFactory;
 
 /**
  *
@@ -45,7 +46,7 @@
     /**
      * Keep track of all methods with the same name.
      */
-    Map methodByNameMap = new HashMap();
+    Map methodByNameMap = MapFactory.create(false);
 
     /**
      * Add a method to a list of methods by name.




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r774997 - in /velocity/engine/trunk/src/test/org/apache/velocity/test: ScopeTestCase.java StopDirectiveTestCase.java</title>
<author><name>nbubna@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200905.mbox/%3c20090515035812.F2D562388872@eris.apache.org%3e"/>
<id>urn:uuid:%3c20090515035812-F2D562388872@eris-apache-org%3e</id>
<updated>2009-05-15T03:58:12Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: nbubna
Date: Fri May 15 03:58:12 2009
New Revision: 774997

URL: http://svn.apache.org/viewvc?rev=774997&amp;view=rev
Log:
fix a few jdk5-isms

Modified:
    velocity/engine/trunk/src/test/org/apache/velocity/test/ScopeTestCase.java
    velocity/engine/trunk/src/test/org/apache/velocity/test/StopDirectiveTestCase.java

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/ScopeTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/ScopeTestCase.java?rev=774997&amp;r1=774996&amp;r2=774997&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/ScopeTestCase.java (original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/ScopeTestCase.java Fri May 15
03:58:12 2009
@@ -37,7 +37,7 @@
     public void setUp() throws Exception
     {
         super.setUp();
-        engine.setProperty(RuntimeConstants.SET_NULL_ALLOWED, true);
+        engine.setProperty(RuntimeConstants.SET_NULL_ALLOWED, Boolean.TRUE);
     }
 
     public void testScopeGetLeakIntoInner()

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/StopDirectiveTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/StopDirectiveTestCase.java?rev=774997&amp;r1=774996&amp;r2=774997&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/StopDirectiveTestCase.java (original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/StopDirectiveTestCase.java Fri
May 15 03:58:12 2009
@@ -77,7 +77,7 @@
         assertEvalEquals("a", "a$!log.startCapture()#stop('woogie!')b");
 
         info("Log: "+log.getLog());
-        assertTrue(log.getLog().contains("StopCommand: woogie!"));
+        assertTrue(log.getLog().indexOf("StopCommand: woogie!") &gt;= 0);
     }
 
 }
\ No newline at end of file




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r774412 - in /velocity/engine/trunk/src: java/org/apache/velocity/util/introspection/ test/org/apache/velocity/test/misc/ test/org/apache/velocity/test/util/introspection/</title>
<author><name>nbubna@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200905.mbox/%3c20090513155408.9A0802388866@eris.apache.org%3e"/>
<id>urn:uuid:%3c20090513155408-9A0802388866@eris-apache-org%3e</id>
<updated>2009-05-13T15:54:08Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: nbubna
Date: Wed May 13 15:54:07 2009
New Revision: 774412

URL: http://svn.apache.org/viewvc?rev=774412&amp;view=rev
Log:
VELOCITY-659 revert changes to Uberspect plugin API (fixes gump's complaints)

Modified:
    velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/AbstractChainableUberspector.java
    velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/LinkingUberspector.java
    velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/SecureUberspector.java
    velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/Uberspect.java
    velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/UberspectImpl.java
    velocity/engine/trunk/src/test/org/apache/velocity/test/misc/UberspectTestImpl.java
    velocity/engine/trunk/src/test/org/apache/velocity/test/util/introspection/ChainedUberspectorsTestCase.java

Modified: velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/AbstractChainableUberspector.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/AbstractChainableUberspector.java?rev=774412&amp;r1=774411&amp;r2=774412&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/AbstractChainableUberspector.java
(original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/AbstractChainableUberspector.java
Wed May 13 15:54:07 2009
@@ -66,7 +66,7 @@
      */
     //@SuppressWarnings("unchecked")
     //@Override
-    public Iterator getIterator(Object obj, Info i)
+    public Iterator getIterator(Object obj, Info i) throws Exception
     {
         return (this.inner != null) ? this.inner.getIterator(obj, i) : null;
     }
@@ -79,6 +79,7 @@
      */
     //@Override
     public VelMethod getMethod(Object obj, String methodName, Object[] args, Info i)
+        throws Exception
     {
         return (this.inner != null) ? this.inner.getMethod(obj, methodName, args, i) : null;
     }
@@ -91,6 +92,7 @@
      */
     //@Override
     public VelPropertyGet getPropertyGet(Object obj, String identifier, Info i)
+        throws Exception
     {
         return (this.inner != null) ? this.inner.getPropertyGet(obj, identifier, i) : null;
     }
@@ -103,6 +105,7 @@
      */
     //@Override
     public VelPropertySet getPropertySet(Object obj, String identifier, Object arg, Info
i)
+        throws Exception
     {
         return (this.inner != null) ? this.inner.getPropertySet(obj, identifier, arg, i)
: null;
     }

Modified: velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/LinkingUberspector.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/LinkingUberspector.java?rev=774412&amp;r1=774411&amp;r2=774412&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/LinkingUberspector.java
(original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/LinkingUberspector.java
Wed May 13 15:54:07 2009
@@ -73,7 +73,7 @@
      */
     //@SuppressWarnings("unchecked")
     //@Override
-    public Iterator getIterator(Object obj, Info i)
+    public Iterator getIterator(Object obj, Info i) throws Exception
     {
         Iterator it = leftUberspect.getIterator(obj,i);
         return it != null ? it : rightUberspect.getIterator(obj,i);
@@ -87,6 +87,7 @@
      */
     //@Override
     public VelMethod getMethod(Object obj, String methodName, Object[] args, Info i)
+        throws Exception
     {
         VelMethod method = leftUberspect.getMethod(obj,methodName,args,i);
         return method != null ? method : rightUberspect.getMethod(obj,methodName,args,i);
@@ -100,6 +101,7 @@
      */
     //@Override
     public VelPropertyGet getPropertyGet(Object obj, String identifier, Info i)
+        throws Exception
     {
         VelPropertyGet getter = leftUberspect.getPropertyGet(obj,identifier,i);
         return getter != null ? getter : rightUberspect.getPropertyGet(obj,identifier,i);
@@ -113,6 +115,7 @@
      */
     //@Override
     public VelPropertySet getPropertySet(Object obj, String identifier, Object arg, Info
i)
+        throws Exception
     {
         VelPropertySet setter = leftUberspect.getPropertySet(obj,identifier,arg,i);
         return setter != null ? setter : rightUberspect.getPropertySet(obj,identifier,arg,i);

Modified: velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/SecureUberspector.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/SecureUberspector.java?rev=774412&amp;r1=774411&amp;r2=774412&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/SecureUberspector.java
(original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/SecureUberspector.java
Wed May 13 15:54:07 2009
@@ -73,7 +73,7 @@
      * @param i line, column, template info
      * @return Iterator for object
      */
-    public Iterator getIterator(Object obj, Info i)
+    public Iterator getIterator(Object obj, Info i) throws Exception
     {
         if (obj != null)
         {

Modified: velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/Uberspect.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/Uberspect.java?rev=774412&amp;r1=774411&amp;r2=774412&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/Uberspect.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/Uberspect.java Wed
May 13 15:54:07 2009
@@ -41,7 +41,7 @@
      * @param info
      * @return An Iterator.
      */
-    public Iterator getIterator(Object obj, Info info);
+    public Iterator getIterator(Object obj, Info info) throws Exception;
 
     /**
      *  Returns a general method, corresponding to $foo.bar( $woogie )
@@ -51,7 +51,7 @@
      * @param info
      * @return A Velocity Method.
      */
-    public VelMethod getMethod(Object obj, String method, Object[] args, Info info);
+    public VelMethod getMethod(Object obj, String method, Object[] args, Info info) throws
Exception;
 
     /**
      * Property getter - returns VelPropertyGet appropos for #set($foo = $bar.woogie)
@@ -60,7 +60,7 @@
      * @param info
      * @return A Velocity Getter.
      */
-    public VelPropertyGet getPropertyGet(Object obj, String identifier, Info info);
+    public VelPropertyGet getPropertyGet(Object obj, String identifier, Info info) throws
Exception;
 
     /**
      * Property setter - returns VelPropertySet appropos for #set($foo.bar = "geir")
@@ -70,5 +70,5 @@
      * @param info
      * @return A Velocity Setter.
      */
-    public VelPropertySet getPropertySet(Object obj, String identifier, Object arg, Info
info);
+    public VelPropertySet getPropertySet(Object obj, String identifier, Object arg, Info
info) throws Exception;
 }

Modified: velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/UberspectImpl.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/UberspectImpl.java?rev=774412&amp;r1=774411&amp;r2=774412&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/UberspectImpl.java
(original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/UberspectImpl.java
Wed May 13 15:54:07 2009
@@ -106,6 +106,7 @@
      * @return An {@link Iterator} object.
      */
     public Iterator getIterator(Object obj, Info i)
+        throws Exception
     {
         if (obj.getClass().isArray())
         {
@@ -190,6 +191,7 @@
      * @return A Velocity Method.
      */
     public VelMethod getMethod(Object obj, String methodName, Object[] args, Info i)
+        throws Exception
     {
         if (obj == null)
         {
@@ -236,6 +238,7 @@
      * @throws Exception
      */
     public VelPropertyGet getPropertyGet(Object obj, String identifier, Info i)
+        throws Exception
     {
         if (obj == null)
         {
@@ -290,7 +293,7 @@
      * @throws Exception
      */
     public VelPropertySet getPropertySet(Object obj, String identifier,
-                                         Object arg, Info i)
+                                         Object arg, Info i) throws Exception
     {
         if (obj == null)
         {

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/misc/UberspectTestImpl.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/misc/UberspectTestImpl.java?rev=774412&amp;r1=774411&amp;r2=774412&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/misc/UberspectTestImpl.java (original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/misc/UberspectTestImpl.java Wed
May 13 15:54:07 2009
@@ -32,6 +32,7 @@
 {
 
     public VelMethod getMethod(Object obj, String methodName, Object[] args, Info i)
+        throws Exception
     {
         VelMethod method = super.getMethod(obj, methodName, args, i);
 
@@ -47,6 +48,7 @@
     }
 
     public VelPropertyGet getPropertyGet(Object obj, String identifier, Info i)
+        throws Exception
     {
         VelPropertyGet propertyGet = super.getPropertyGet(obj, identifier, i);
 

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/util/introspection/ChainedUberspectorsTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/util/introspection/ChainedUberspectorsTestCase.java?rev=774412&amp;r1=774411&amp;r2=774412&amp;view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/util/introspection/ChainedUberspectorsTestCase.java
(original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/util/introspection/ChainedUberspectorsTestCase.java
Wed May 13 15:54:07 2009
@@ -84,6 +84,7 @@
     public static class ChainedUberspector extends AbstractChainableUberspector
     {
         public VelPropertySet getPropertySet(Object obj, String identifier, Object arg, Info
info)
+            throws Exception
         {
             identifier = identifier.replaceAll("foo","bar");
             return inner.getPropertySet(obj,identifier,arg,info);
@@ -94,6 +95,7 @@
     public static class LinkedUberspector extends UberspectImpl
     {
         public VelPropertyGet getPropertyGet(Object obj, String identifier, Info info)
+            throws Exception
         {
             identifier = identifier.replaceAll("foo","bar");
             return super.getPropertyGet(obj,identifier,info);




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r774375 - in /velocity/tools/trunk/src/main/java: META-INF/velocity-view.tld org/apache/velocity/tools/view/jsp/VelocityViewTag.java</title>
<author><name>nbubna@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200905.mbox/%3c20090513141004.33876238886D@eris.apache.org%3e"/>
<id>urn:uuid:%3c20090513141004-33876238886D@eris-apache-org%3e</id>
<updated>2009-05-13T14:10:04Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: nbubna
Date: Wed May 13 14:10:03 2009
New Revision: 774375

URL: http://svn.apache.org/viewvc?rev=774375&amp;view=rev
Log:
VelocityViewTag body caching had a variety of problems.  this fixes them, but also turns it
off by default.  either set an id=foo or cache=true to turn it on.

Modified:
    velocity/tools/trunk/src/main/java/META-INF/velocity-view.tld
    velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/jsp/VelocityViewTag.java

Modified: velocity/tools/trunk/src/main/java/META-INF/velocity-view.tld
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/src/main/java/META-INF/velocity-view.tld?rev=774375&amp;r1=774374&amp;r2=774375&amp;view=diff
==============================================================================
--- velocity/tools/trunk/src/main/java/META-INF/velocity-view.tld (original)
+++ velocity/tools/trunk/src/main/java/META-INF/velocity-view.tld Wed May 13 14:10:03 2009
@@ -38,7 +38,13 @@
       &lt;name&gt;id&lt;/name&gt;
       &lt;required&gt;false&lt;/required&gt;
       &lt;rtexprvalue&gt;true&lt;/rtexprvalue&gt;
-      &lt;description&gt;&lt;![CDATA[A id unique to this usage of the VelocityViewTag.  This
id is used to uniquely identify this tag in log messages and hopefully at some point serve
as a key under which any body for this tag may be cached as an already-parsed template for
improved performance. If no id is specified, then a unique is automatically generated, though
that will understandably be less useful in log messages.]]&gt;&lt;/description&gt;
+      &lt;description&gt;&lt;![CDATA[An id unique to this particular usage of the VelocityViewTag
in the application.  This id will then be used to cache the body in a StringResourceLoader
repository and will also identify it in log messages.  Setting this automatically sets the
cache attribute to "true".]]&gt;&lt;/description&gt;
+    &lt;/attribute&gt;
+    &lt;attribute&gt;
+      &lt;name&gt;cache&lt;/name&gt;
+      &lt;required&gt;false&lt;/required&gt;
+      &lt;rtexprvalue&gt;true&lt;/rtexprvalue&gt;
+      &lt;description&gt;&lt;![CDATA[Either "true" or "false" to indicate whether the body
content template should be cached by the StringResourceLoader.  This is automatically set
to true if an id is set.  If set to true without an id value, then the template will be used
as its own id.  It is false by default.]]&gt;&lt;/description&gt;
     &lt;/attribute&gt;
     &lt;attribute&gt;
       &lt;name&gt;var&lt;/name&gt;

Modified: velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/jsp/VelocityViewTag.java
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/jsp/VelocityViewTag.java?rev=774375&amp;r1=774374&amp;r2=774375&amp;view=diff
==============================================================================
--- velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/jsp/VelocityViewTag.java
(original)
+++ velocity/tools/trunk/src/main/java/org/apache/velocity/tools/view/jsp/VelocityViewTag.java
Wed May 13 14:10:03 2009
@@ -28,6 +28,7 @@
 import org.apache.velocity.Template;
 import org.apache.velocity.app.VelocityEngine;
 import org.apache.velocity.runtime.resource.loader.StringResourceLoader;
+import org.apache.velocity.runtime.resource.util.StringResourceRepository;
 import org.apache.velocity.tools.view.ServletUtils;
 import org.apache.velocity.tools.view.ViewToolContext;
 import org.apache.velocity.tools.view.VelocityView;
@@ -50,37 +51,53 @@
 public class VelocityViewTag extends BodyTagSupport
 {
     public static final String DEFAULT_BODY_CONTENT_KEY = "bodyContent";
-    public static final String DEFAULT_NAME =
-        VelocityViewTag.class.getSimpleName();
-
-    private static int count = 0;
     private static final long serialVersionUID = -3329444102562079189L;
 
     protected transient VelocityView view;
     protected transient ViewToolContext context;
+    protected transient StringResourceRepository repository;
+
     protected String var;
     protected String scope;
     protected String template;
     protected String bodyContentKey = DEFAULT_BODY_CONTENT_KEY;
-    private boolean cacheable = true;
-    private boolean uncached = true;
+    private boolean cache = false;
 
-    public VelocityViewTag()
-    {
-        // always try to have some sort of unique id set, since
-        // this serves as a log tag and may serve as a cache name later
-        setId(DEFAULT_NAME + count++);
+    /**
+     * Release any per-invocation resources, resetting any resources or state
+     * that should be cleared between successive invocations of
+     * {@link javax.servlet.jsp.tagext.Tag#doEndTag()} and
+     * {@link javax.servlet.jsp.tagext.Tag#doStartTag()}.
+     */
+    protected void reset()
+    {
+        super.setId(null);
+        var = null;
+        scope = null;
+        template = null;
+        bodyContentKey = DEFAULT_BODY_CONTENT_KEY;
+        cache = false;
     }
 
     public void setId(String id)
     {
-        // always try to have some sort of id set because
-        // this is the log tag and cache name
         if (id == null)
         {
             throw new NullPointerException("id cannot be null");
         }
         super.setId(id);
+        // assume they want this cached
+        cache = true;
+    }
+
+    protected String getLogId()
+    {
+        String id = super.getId();
+        if (id == null)
+        {
+            id = getClass().getSimpleName();
+        }
+        return id;
     }
 
     public void setVar(String var)
@@ -123,6 +140,16 @@
         return this.bodyContentKey;
     }
 
+    public void setCache(String s)
+    {
+        this.cache = "true".equalsIgnoreCase(s);
+    }
+
+    public String getCache()
+    {
+        return String.valueOf(this.cache);
+    }
+
     public VelocityView getVelocityView()
     {
         return this.view;
@@ -143,6 +170,19 @@
         this.context = context;
     }
 
+    public StringResourceRepository getRepository()
+    {
+        if (this.repository == null)
+        {
+            setRepository(StringResourceLoader.getRepository());
+        }
+        return this.repository;
+    }
+
+    public void setRepository(StringResourceRepository repo)
+    {
+        this.repository = repo;
+    }
 
     public int doStartTag() throws JspException
     {
@@ -180,7 +220,7 @@
             catch (Exception e)
             {
                 throw new JspException("Failed to render " + getClass() +
-                                       ": "+getId(), e);
+                                       ": "+getLogId(), e);
             }
         }
         return EVAL_PAGE;
@@ -241,22 +281,34 @@
         return out.toString();
     }
 
+    protected boolean isCached()
+    {
+        return getRepository().getStringResource(getId()) != null;
+    }
+
     protected void renderBody(Writer out) throws Exception
     {
+        String name = getId();
         // if it hasn't been cached, try that
-        if (uncached &amp;&amp; cacheable)
+        if (cache &amp;&amp; !isCached())
         {
-            cache(getId(), getBodyContent().getString());
+            String template = getBodyContent().getString();
+            // if no id was set, use the template as the id
+            if (name == null)
+            {
+                name = template;
+            }
+            cache(name, template);
         }
         // if it can't be cached, eval it
-        if (!cacheable)
+        if (!cache)
         {
             evalBody(out);
         }
         else
         {
             // load template from cache
-            Template template = getVelocityView().getTemplate(getId());
+            Template template = getVelocityView().getTemplate(name);
             template.merge(getViewToolContext(), out);
         }
     }
@@ -264,7 +316,7 @@
     protected void evalBody(Writer out) throws Exception
     {
         VelocityEngine engine = getVelocityView().getVelocityEngine();
-        engine.evaluate(getViewToolContext(), out, getId(),
+        engine.evaluate(getViewToolContext(), out, getLogId(),
                         getBodyContent().getReader());
     }
 
@@ -293,17 +345,31 @@
         throw new IllegalArgumentException("Unknown scope: "+scope);
     }
 
-    private void cache(String name, String template)
+    protected void cache(String name, String template)
     {
         try
         {
-            StringResourceLoader.getRepository().putStringResource(name, template);
-            uncached = false;
+            getRepository().putStringResource(name, template);
         }
         catch (Exception cnfe)
         {
-            cacheable = false;
+            getVelocityView().getLog()
+                .error("Could not cache body in a StringResourceRepository", cnfe);
+            cache = false;
         }
     }
 
+    /**
+     * Release any per-instance resources, releasing any resources or state
+     * before this tag instance is disposed.
+     *
+     * @see javax.servlet.jsp.tagext.Tag#release()
+     */
+    @Override
+    public void release()
+    {
+        super.release();
+        reset();
+    }
+
 }




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r773708 - in /velocity/tools/trunk: build.properties pom.xml</title>
<author><name>nbubna@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200905.mbox/%3c20090511220355.1926F2388975@eris.apache.org%3e"/>
<id>urn:uuid:%3c20090511220355-1926F2388975@eris-apache-org%3e</id>
<updated>2009-05-11T22:03:54Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: nbubna
Date: Mon May 11 22:03:54 2009
New Revision: 773708

URL: http://svn.apache.org/viewvc?rev=773708&amp;view=rev
Log:
upgrade version number for release

Modified:
    velocity/tools/trunk/build.properties
    velocity/tools/trunk/pom.xml

Modified: velocity/tools/trunk/build.properties
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/build.properties?rev=773708&amp;r1=773707&amp;r2=773708&amp;view=diff
==============================================================================
--- velocity/tools/trunk/build.properties (original)
+++ velocity/tools/trunk/build.properties Mon May 11 22:03:54 2009
@@ -30,7 +30,7 @@
 
 # project identification
 project.name=VelocityTools
-project.version=2.0-SNAPSHOT
+project.version=2.0-beta4
 project.libname=velocity-tools
 project.id=${project.libname}-${project.version}
 

Modified: velocity/tools/trunk/pom.xml
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/pom.xml?rev=773708&amp;r1=773707&amp;r2=773708&amp;view=diff
==============================================================================
--- velocity/tools/trunk/pom.xml (original)
+++ velocity/tools/trunk/pom.xml Mon May 11 22:03:54 2009
@@ -27,7 +27,7 @@
     &lt;groupId&gt;org.apache.velocity&lt;/groupId&gt;
     &lt;artifactId&gt;velocity-tools&lt;/artifactId&gt;
     &lt;name&gt;VelocityTools&lt;/name&gt;
-    &lt;version&gt;2.0-SNAPSHOT&lt;/version&gt;
+    &lt;version&gt;2.0-beta4&lt;/version&gt;
     &lt;packaging&gt;jar&lt;/packaging&gt;
 
     &lt;organization&gt;




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r773707 - /velocity/tools/trunk/xdocs/frameworks.xml</title>
<author><name>nbubna@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200905.mbox/%3c20090511220251.34A6323889D7@eris.apache.org%3e"/>
<id>urn:uuid:%3c20090511220251-34A6323889D7@eris-apache-org%3e</id>
<updated>2009-05-11T22:02:51Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: nbubna
Date: Mon May 11 22:02:50 2009
New Revision: 773707

URL: http://svn.apache.org/viewvc?rev=773707&amp;view=rev
Log:
document a few more config options

Modified:
    velocity/tools/trunk/xdocs/frameworks.xml

Modified: velocity/tools/trunk/xdocs/frameworks.xml
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/xdocs/frameworks.xml?rev=773707&amp;r1=773706&amp;r2=773707&amp;view=diff
==============================================================================
--- velocity/tools/trunk/xdocs/frameworks.xml (original)
+++ velocity/tools/trunk/xdocs/frameworks.xml Mon May 11 22:02:50 2009
@@ -103,6 +103,23 @@
                 setting (e.g. ValueParser, ResourceTool) to provide old behavior
                 where it has otherwise changed.
               &lt;/dd&gt;
+              &lt;dt&gt;org.apache.velocity.tools.loadDefaults&lt;/dt&gt;
+              &lt;dd&gt;Tells VelocityView whether or not it should include the default
+                  tools.xml configurations provided in the VelocityTools jar(s).
+                  This is true by default.
+              &lt;/dd&gt;
+              &lt;dt&gt;org.apache.velocity.tools.cleanConfiguration&lt;/dt&gt;
+              &lt;dd&gt;Tells VelocityView to test all the tool configurations
+                  and remove any invalid ones, rather than allow them to
+                  throw errors.  This is false by default.
+              &lt;/dd&gt;
+              &lt;dt&gt;org.apache.velocity.tools.userCanOverwriteTools&lt;/dt&gt;
+              &lt;dd&gt;Tells VelocityView to construct the context in such
+                  a way that any user-set variables with the same keys 
+                  as any of the configured tools are given primacy
+                  when resolving references.  This is true by default,
+                  unlike in Tools 1.x.
+              &lt;/dd&gt;
             &lt;/dl&gt;
             &lt;p&gt;
             The VelocityView instance is typically the heart of any




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r773701 - in /velocity/tools/trunk/src/test/java/org/apache/velocity/tools: ./ generic/</title>
<author><name>nbubna@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200905.mbox/%3c20090511214726.DE1BD23889C1@eris.apache.org%3e"/>
<id>urn:uuid:%3c20090511214726-DE1BD23889C1@eris-apache-org%3e</id>
<updated>2009-05-11T21:47:26Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: nbubna
Date: Mon May 11 21:47:26 2009
New Revision: 773701

URL: http://svn.apache.org/viewvc?rev=773701&amp;view=rev
Log:
VELTOOLS-114 move generic tool tests to proper directory

Added:
    velocity/tools/trunk/src/test/java/org/apache/velocity/tools/generic/
    velocity/tools/trunk/src/test/java/org/apache/velocity/tools/generic/AlternatorToolTests.java
      - copied unchanged from r773575, velocity/tools/trunk/src/test/java/org/apache/velocity/tools/AlternatorToolTests.java
    velocity/tools/trunk/src/test/java/org/apache/velocity/tools/generic/ClassToolTests.java
      - copied unchanged from r773575, velocity/tools/trunk/src/test/java/org/apache/velocity/tools/ClassToolTests.java
    velocity/tools/trunk/src/test/java/org/apache/velocity/tools/generic/DisplayToolTests.java
      - copied unchanged from r773575, velocity/tools/trunk/src/test/java/org/apache/velocity/tools/DisplayToolTests.java
    velocity/tools/trunk/src/test/java/org/apache/velocity/tools/generic/LinkToolTests.java
      - copied unchanged from r773678, velocity/tools/trunk/src/test/java/org/apache/velocity/tools/LinkToolTests.java
    velocity/tools/trunk/src/test/java/org/apache/velocity/tools/generic/LoopToolTests.java
      - copied unchanged from r773575, velocity/tools/trunk/src/test/java/org/apache/velocity/tools/LoopToolTests.java
    velocity/tools/trunk/src/test/java/org/apache/velocity/tools/generic/XmlToolTests.java
      - copied unchanged from r773575, velocity/tools/trunk/src/test/java/org/apache/velocity/tools/XmlToolTests.java
Removed:
    velocity/tools/trunk/src/test/java/org/apache/velocity/tools/AlternatorToolTests.java
    velocity/tools/trunk/src/test/java/org/apache/velocity/tools/ClassToolTests.java
    velocity/tools/trunk/src/test/java/org/apache/velocity/tools/DisplayToolTests.java
    velocity/tools/trunk/src/test/java/org/apache/velocity/tools/LinkToolTests.java
    velocity/tools/trunk/src/test/java/org/apache/velocity/tools/LoopToolTests.java
    velocity/tools/trunk/src/test/java/org/apache/velocity/tools/XmlToolTests.java



</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r773695 - /velocity/tools/trunk/src/main/java/org/apache/velocity/tools/generic/LinkTool.java</title>
<author><name>nbubna@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/velocity-commits/200905.mbox/%3c20090511210116.78D3D2388842@eris.apache.org%3e"/>
<id>urn:uuid:%3c20090511210116-78D3D2388842@eris-apache-org%3e</id>
<updated>2009-05-11T21:01:16Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: nbubna
Date: Mon May 11 21:01:16 2009
New Revision: 773695

URL: http://svn.apache.org/viewvc?rev=773695&amp;view=rev
Log:
only do the decoding if we have params

Modified:
    velocity/tools/trunk/src/main/java/org/apache/velocity/tools/generic/LinkTool.java

Modified: velocity/tools/trunk/src/main/java/org/apache/velocity/tools/generic/LinkTool.java
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/src/main/java/org/apache/velocity/tools/generic/LinkTool.java?rev=773695&amp;r1=773694&amp;r2=773695&amp;view=diff
==============================================================================
--- velocity/tools/trunk/src/main/java/org/apache/velocity/tools/generic/LinkTool.java (original)
+++ velocity/tools/trunk/src/main/java/org/apache/velocity/tools/generic/LinkTool.java Mon
May 11 21:01:16 2009
@@ -1618,7 +1618,11 @@
         {
             return null;
         }
-        return decodeQueryPercents(uri.toString());
+        if (query != null)
+        {
+            return decodeQueryPercents(uri.toString());
+        }
+        return uri.toString();
     }
 
     /**




</pre>
</div>
</content>
</entry>
</feed>
