You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2010/05/14 17:05:54 UTC

svn commit: r944307 - in /cxf/trunk: parent/pom.xml tools/common/src/main/java/org/apache/cxf/tools/common/VelocityGenerator.java

Author: dkulp
Date: Fri May 14 15:05:54 2010
New Revision: 944307

URL: http://svn.apache.org/viewvc?rev=944307&view=rev
Log:
Update to protect the velocity engine init from being hit by multiple
threads.

Modified:
    cxf/trunk/parent/pom.xml
    cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/VelocityGenerator.java

Modified: cxf/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/parent/pom.xml?rev=944307&r1=944306&r2=944307&view=diff
==============================================================================
--- cxf/trunk/parent/pom.xml (original)
+++ cxf/trunk/parent/pom.xml Fri May 14 15:05:54 2010
@@ -836,7 +836,7 @@
             <dependency>
                 <groupId>org.apache.velocity</groupId>
                 <artifactId>velocity</artifactId>
-                <version>1.6.2</version>
+                <version>1.6.4</version>
             </dependency>
             <dependency>
                 <groupId>wsdl4j</groupId>

Modified: cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/VelocityGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/VelocityGenerator.java?rev=944307&r1=944306&r2=944307&view=diff
==============================================================================
--- cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/VelocityGenerator.java (original)
+++ cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/VelocityGenerator.java Fri May 14 15:05:54 2010
@@ -42,6 +42,8 @@ import org.apache.velocity.runtime.Runti
 
 public final class VelocityGenerator {
     private static final Logger LOG = LogUtils.getL7dLogger(VelocityGenerator.class);
+    private static boolean initialized;
+    
     private final Map<String, Object> attributes = new HashMap<String, Object>();
     private String baseDir;
     
@@ -52,7 +54,7 @@ public final class VelocityGenerator {
         initVelocity(log);
     }
 
-    private String getVelocityLogFile(String logfile) {
+    private static String getVelocityLogFile(String logfile) {
         String logdir = System.getProperty("user.home");
         if (logdir == null || logdir.length() == 0) {
             logdir = System.getProperty("user.dir");
@@ -60,7 +62,11 @@ public final class VelocityGenerator {
         return logdir + File.separator + logfile;
     }
 
-    private void initVelocity(boolean log) throws ToolException {
+    private static synchronized void initVelocity(boolean log) throws ToolException {
+        if (initialized) {
+            return;
+        }
+        initialized = true;
         try {
             Properties props = new Properties();
             String clzName = "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader";