Author: cbrisson
Date: Mon Jul 11 12:10:02 2011
New Revision: 1145136
URL: http://svn.apache.org/viewvc?rev=1145136&view=rev
Log:
backport tools 2.0 post release changes to branch 2.0.x
Modified:
velocity/tools/branches/2.0.x/build.properties
velocity/tools/branches/2.0.x/build.xml
velocity/tools/branches/2.0.x/download.xml
velocity/tools/branches/2.0.x/examples.xml
velocity/tools/branches/2.0.x/pom.xml
velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/ConversionUtils.java
velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/generic/DisplayTool.java
velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/generic/LoopTool.java
velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/view/VelocityViewServlet.java
velocity/tools/branches/2.0.x/src/test/java/org/apache/velocity/tools/generic/LoopToolTests.java
velocity/tools/branches/2.0.x/test.xml
velocity/tools/branches/2.0.x/xdocs/changes.xml
Modified: velocity/tools/branches/2.0.x/build.properties
URL:
http://svn.apache.org/viewvc/velocity/tools/branches/2.0.x/build.properties?rev=1145136&r1=1145135&r2=1145136&view=diff
==============================================================================
--- velocity/tools/branches/2.0.x/build.properties (original)
+++ velocity/tools/branches/2.0.x/build.properties Mon Jul 11 12:10:02 2011
@@ -30,7 +30,7 @@ compile.target=1.5
# project identification
project.name=VelocityTools
-project.version=2.0
+project.version=2.0.1-SNAPSHOT
project.libname=velocity-tools
project.id=${project.libname}-${project.version}
@@ -138,14 +138,15 @@ jar.commons-digester.version= 1.8
jar.commons-lang.version= 2.2
jar.commons-logging.version= 1.1
jar.commons-validator.version= 1.3.1
-jar.dom4j.version= 1.1
+jar.dom4j.version= 1.6.1
+jar.jaxen.version= 1.1-beta-6
jar.oro.version= 2.0.8
jar.servletapi.version= 2.3
jar.sslext.version = 1.2-0
jar.struts-core.version = 1.3.8
jar.struts-taglib.version = 1.3.8
jar.struts-tiles.version = 1.3.8
-jar.velocity.version= 1.6.2
+jar.velocity.version= 1.6.4
# Jars to be downloaded for building documentation
#
@@ -180,6 +181,7 @@ commons-lang.jar=${lib.dir}/commons-lang
commons-logging.jar=${lib.dir}/commons-logging-${jar.commons-logging.version}.jar
commons-validator.jar=${lib.dir}/commons-validator-${jar.commons-validator.version}.jar
dom4j.jar=${lib.dir}/dom4j-${jar.dom4j.version}.jar
+jaxen.jar=${lib.dir}/jaxen-${jar.jaxen.version}.jar
servlet.jar=${lib.dir}/servletapi-${jar.servletapi.version}.jar
struts-core.jar=${lib.dir}/struts-core-${jar.struts-core.version}.jar
struts-taglib.jar=${lib.dir}/struts-taglib-${jar.struts-taglib.version}.jar
Modified: velocity/tools/branches/2.0.x/build.xml
URL:
http://svn.apache.org/viewvc/velocity/tools/branches/2.0.x/build.xml?rev=1145136&r1=1145135&r2=1145136&view=diff
==============================================================================
--- velocity/tools/branches/2.0.x/build.xml (original)
+++ velocity/tools/branches/2.0.x/build.xml Mon Jul 11 12:10:02 2011
@@ -109,6 +109,14 @@
<include name="**/*.jar"/>
</fileset>
</path>
+
+ <!-- construct patternset of source files -->
+ <patternset id="source.files">
+ <include name="org/**/*.java"/>
+ <exclude
name="org/apache/velocity/tools/generic/log/CommonsLogLogSystem.java"
unless="use.velocity-1.x"/>
+ <exclude
name="org/apache/velocity/tools/view/servlet/ServletLogger.java"
unless="use.velocity-1.x"/>
+ </patternset>
+
</target>
<!-- Prepare Documentation Environment -->
@@ -150,7 +158,7 @@
encoding="${compile.encoding}"
destdir="${classes.dir}">
<classpath refid="compile.classpath" />
- <include name="org/**"/>
+ <patternset refid="source.files"/>
</javac>
<copy todir="${classes.dir}" filtering="yes">
@@ -174,7 +182,7 @@
encoding="${compile.encoding}"
destdir="${classes.dir}">
<classpath refid="compile.classpath" />
- <include name="org/**"/>
+ <patternset refid="source.files"/>
<exclude name="**/struts/**"/>
</javac>
@@ -201,7 +209,7 @@
encoding="${compile.encoding}"
destdir="${classes.dir}">
<classpath refid="compile.classpath" />
- <include name="org/**"/>
+ <patternset refid="source.files"/>
<exclude name="**/struts/**"/>
<exclude name="**/view/**"/>
</javac>
Modified: velocity/tools/branches/2.0.x/download.xml
URL:
http://svn.apache.org/viewvc/velocity/tools/branches/2.0.x/download.xml?rev=1145136&r1=1145135&r2=1145136&view=diff
==============================================================================
--- velocity/tools/branches/2.0.x/download.xml (original)
+++ velocity/tools/branches/2.0.x/download.xml Mon Jul 11 12:10:02 2011
@@ -61,6 +61,7 @@
<target name="docs-download"
depends="base-download"
description="Download dependencies needed to render VelocityTools
documentation from the central repository">
+ <antcall target="dom4j-download" />
<antcall target="velocity-dvsl-download" />
</target>
@@ -78,6 +79,7 @@
<!-- whitebox tests downloads -->
<target name="whitebox-test-download" depends="base-download">
<antcall target="junit-download"/>
+ <antcall target="jaxen-download" />
</target>
<!-- blackbox tests downloads -->
@@ -244,6 +246,13 @@
<antcall target="http-m2-download"/>
</target>
+ <target name="jaxen-download">
+ <property name="download.groupId" value="jaxen" />
+ <property name="download.artifactId" value="jaxen" />
+ <property name="download.version" value="${jar.jaxen.version}" />
+ <antcall target="http-m2-download"/>
+ </target>
+
<target name="oro-download">
<property name="download.groupId" value="oro" />
<property name="download.artifactId" value="oro" />
Modified: velocity/tools/branches/2.0.x/examples.xml
URL:
http://svn.apache.org/viewvc/velocity/tools/branches/2.0.x/examples.xml?rev=1145136&r1=1145135&r2=1145136&view=diff
==============================================================================
--- velocity/tools/branches/2.0.x/examples.xml (original)
+++ velocity/tools/branches/2.0.x/examples.xml Mon Jul 11 12:10:02 2011
@@ -70,6 +70,7 @@
</target>
<target name="showcase-dependencies" depends="simple-dependencies">
<copy todir="${lib}" file="${dom4j.jar}"/>
+ <copy todir="${lib}" file="${jaxen.jar}"/>
<copy todir="${lib}" file="${servlet.jar}"/>
</target>
Modified: velocity/tools/branches/2.0.x/pom.xml
URL:
http://svn.apache.org/viewvc/velocity/tools/branches/2.0.x/pom.xml?rev=1145136&r1=1145135&r2=1145136&view=diff
==============================================================================
--- velocity/tools/branches/2.0.x/pom.xml (original)
+++ velocity/tools/branches/2.0.x/pom.xml Mon Jul 11 12:10:02 2011
@@ -27,7 +27,7 @@
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-tools</artifactId>
<name>VelocityTools</name>
- <version>2.0</version>
+ <version>2.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<organization>
@@ -455,7 +455,7 @@
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
- <version>1.6.2</version>
+ <version>1.6.4</version>
</dependency>
<dependency>
<groupId>httpunit</groupId>
Modified:
velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/ConversionUtils.java
URL:
http://svn.apache.org/viewvc/velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/ConversionUtils.java?rev=1145136&r1=1145135&r2=1145136&view=diff
==============================================================================
---
velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/ConversionUtils.java
(original)
+++
velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/ConversionUtils.java
Mon Jul 11 12:10:02 2011
@@ -32,6 +32,8 @@ import java.util.Date;
import java.util.Calendar;
import java.util.Locale;
import java.util.TimeZone;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ConcurrentHashMap;
/**
* Utility methods for parsing or otherwise converting between types.
@@ -50,6 +52,9 @@ public class ConversionUtils
//NOTE: '3' belongs to a non-public "scientific" style
private static final int STYLE_INTEGER = 4;
+ // cache custom formats
+ private static ConcurrentMap<String,NumberFormat> customFormatsCache = new
ConcurrentHashMap<String,NumberFormat>();
+
private ConversionUtils() {}
public ConversionUtils getInstance()
@@ -83,7 +88,13 @@ public class ConversionUtils
if (style < 0)
{
// we have a custom format
- nf = new DecimalFormat(format, new DecimalFormatSymbols(locale));
+ String cacheKey = format + "%" + locale.toString();
+ nf = customFormatsCache.get(cacheKey);
+ if( nf == null )
+ {
+ nf = new DecimalFormat(format, new
DecimalFormatSymbols(locale));
+ customFormatsCache.put(cacheKey,nf);
+ }
}
else
{
Modified:
velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/generic/DisplayTool.java
URL:
http://svn.apache.org/viewvc/velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/generic/DisplayTool.java?rev=1145136&r1=1145135&r2=1145136&view=diff
==============================================================================
---
velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/generic/DisplayTool.java
(original)
+++
velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/generic/DisplayTool.java
Mon Jul 11 12:10:02 2011
@@ -101,6 +101,8 @@ public class DisplayTool extends LocaleC
*/
protected void configure(ValueParser values)
{
+ super.configure(values);
+
String listDelim = values.getString(LIST_DELIM_KEY);
if (listDelim != null)
{
Modified:
velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/generic/LoopTool.java
URL:
http://svn.apache.org/viewvc/velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/generic/LoopTool.java?rev=1145136&r1=1145135&r2=1145136&view=diff
==============================================================================
---
velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/generic/LoopTool.java
(original)
+++
velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/generic/LoopTool.java
Mon Jul 11 12:10:02 2011
@@ -94,6 +94,7 @@ public class LoopTool
{
private Stack<ManagedIterator> iterators = new Stack<ManagedIterator>();
private ManagedIterator last;
+ private Map<String,Object> lastSyncedValues;
/**
* <p>Tells the LoopTool to watch the specified Array, Collection, Map,
@@ -401,6 +402,14 @@ public class LoopTool
return iterator.get(key);
}
}
+ if (lastSyncedValues != null)
+ {
+ Object syncedValue = lastSyncedValues.get(key);
+ if (syncedValue != null)
+ {
+ return syncedValue;
+ }
+ }
// shortest key would be "last_X" where X is the loop name
if (key == null || key.length() < 6)
{
@@ -553,7 +562,9 @@ public class LoopTool
*/
protected ManagedIterator pop()
{
- return iterators.pop();
+ ManagedIterator i = iterators.pop();
+ this.lastSyncedValues = i.getLastSyncedValues();
+ return i;
}
@@ -739,9 +750,6 @@ public class LoopTool
}
}
}
-
- // ok, looks like we have a next that met all the conditions
- shiftSynced();
return true;
}
@@ -839,6 +847,8 @@ public class LoopTool
Object value = this.next;
// clear the cache
this.next = null;
+ // call next on synced ones
+ shiftSynced();
// return the no-longer-cached value
return value;
}
@@ -905,7 +915,7 @@ public class LoopTool
* <p>Adds another iterator to be kept in sync with the one
* being managed by this instance. The values of the parallel
* iterator can be retrieved from the LoopTool under the
- * name s"synced" (e.g. $loop.synched or $loop.get('synced'))
+ * name s"synced" (e.g. $loop.synced or $loop.get('synced'))
* and are automatically updated for each iteration by this instance.
* </p><p><b>NOTE</b>: if you are sync'ing multiple iterators
* with the same managed iterator, you must use
@@ -948,6 +958,20 @@ public class LoopTool
return this;
}
+ public Map<String,Object> getLastSyncedValues()
+ {
+ if (synced == null)
+ {
+ return null;
+ }
+ Map<String,Object> syncs = new HashMap<String,Object>();
+ for (String key : synced.keySet())
+ {
+ syncs.put(key, synced.get(key).get());
+ }
+ return syncs;
+ }
+
@Override
public String toString()
{
Modified:
velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/view/VelocityViewServlet.java
URL:
http://svn.apache.org/viewvc/velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/view/VelocityViewServlet.java?rev=1145136&r1=1145135&r2=1145136&view=diff
==============================================================================
---
velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/view/VelocityViewServlet.java
(original)
+++
velocity/tools/branches/2.0.x/src/main/java/org/apache/velocity/tools/view/VelocityViewServlet.java
Mon Jul 11 12:10:02 2011
@@ -337,14 +337,16 @@ public class VelocityViewServlet extends
HttpServletResponse response,
Throwable e)
{
- if (!response.isCommitted())
+ String path = ServletUtils.getPath(request);
+ if (response.isCommitted())
{
+ getLog().error("An error occured but the response headers have
already been sent.");
+ getLog().error("Error processing a template for path '" + path +
"'", e);
return;
}
try
{
- String path = ServletUtils.getPath(request);
getLog().error("Error processing a template for path '" + path +
"'", e);
StringBuilder html = new StringBuilder();
html.append("<html>\n");
Modified:
velocity/tools/branches/2.0.x/src/test/java/org/apache/velocity/tools/generic/LoopToolTests.java
URL:
http://svn.apache.org/viewvc/velocity/tools/branches/2.0.x/src/test/java/org/apache/velocity/tools/generic/LoopToolTests.java?rev=1145136&r1=1145135&r2=1145136&view=diff
==============================================================================
---
velocity/tools/branches/2.0.x/src/test/java/org/apache/velocity/tools/generic/LoopToolTests.java
(original)
+++
velocity/tools/branches/2.0.x/src/test/java/org/apache/velocity/tools/generic/LoopToolTests.java
Mon Jul 11 12:10:02 2011
@@ -306,16 +306,18 @@ public class LoopToolTests {
// is, of course, impossible in a template, but it
// makes writing a reasonable test for this method a lot
// easier.
- //NOTE: this reliese on the default name for synced iterators
+ //NOTE: this relies on the default name for synced iterators
// being "synced", for i being "loop0", and for j being "loop1"
Iterator i = loop.watch(ARRAY).sync(other);
Iterator j = loop.watch(other).sync(ARRAY);
while (i.hasNext() && j.hasNext())
{
+ Object ival = i.next();
+ Object jval = j.next();
// i and loop.synced (aka loop.get("loop1","synced")) should match
- assertEquals(i.next(), loop.get("synced"));
+ assertEquals(ival, loop.get("synced"));
// j and loop.get("loop0","synced") should match
- assertEquals(j.next(), loop.get("loop0", "synced"));
+ assertEquals(jval, loop.get("loop0", "synced"));
}
}
Modified: velocity/tools/branches/2.0.x/test.xml
URL:
http://svn.apache.org/viewvc/velocity/tools/branches/2.0.x/test.xml?rev=1145136&r1=1145135&r2=1145136&view=diff
==============================================================================
--- velocity/tools/branches/2.0.x/test.xml (original)
+++ velocity/tools/branches/2.0.x/test.xml Mon Jul 11 12:10:02 2011
@@ -156,12 +156,16 @@
<junit fork="false"
printSummary="yes"
haltonerror="${test.haltonerror}"
- haltonfailure="${test.haltonfailure}">
+ haltonfailure="${test.haltonfailure}"
+ showoutput="true"
+ >
<classpath>
<path refid="test.classpath"/>
<pathelement location="${test.classes.dir}"/>
</classpath>
- <batchtest todir="${test.rst.dir}">
+ <test name="${testcase}" if="testcase" todir="${test.rst.dir}"/>
+ <sysproperty key="testcase" value="${testcase}"/>
+ <batchtest todir="${test.rst.dir}" unless="testcase">
<fileset dir="${test.classes.dir}">
<include name="org/apache/velocity/tools/**/*Tests.class"/>
<exclude name="org/apache/velocity/tools/test/blackbox/**/*"/>
Modified: velocity/tools/branches/2.0.x/xdocs/changes.xml
URL:
http://svn.apache.org/viewvc/velocity/tools/branches/2.0.x/xdocs/changes.xml?rev=1145136&r1=1145135&r2=1145136&view=diff
==============================================================================
--- velocity/tools/branches/2.0.x/xdocs/changes.xml (original)
+++ velocity/tools/branches/2.0.x/xdocs/changes.xml Mon Jul 11 12:10:02 2011
@@ -28,6 +28,17 @@
<section name="VelocityTools Changes">
<p>This document tracks the changes in VelocityTools between releases.</p>
+ <subsection name="2.0.1-SNAPSHOT">
+ <p>This section describes changes after the 2.0 release.</p>
+ <ul>
+ <li>Upgraded to Dom4j 1.6.1 and Velocity Engine 1.6.4. (ndb)</li>
+ <li>fixed VELTOOLS-129 (thanks to Michael Osipov) (ndb)</li>
+ <li>fixed VELTOOLS-128 fix sync problems (ndb)</li>
+ <li>correct handling and better reporting of commited responses in
error() (cb)</li>
+ <li>Added a custom number formats cache in ConversionUtils (cb)</li>
+ </ul>
+ </subsection>
+
<subsection name="2.0">
<p>This section very briefly and generally describes changes after the
1.x series.</p>
<ul>