velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nbu...@apache.org
Subject svn commit: r559892 - /velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/ToolManager.java
Date Thu, 26 Jul 2007 17:27:21 GMT
Author: nbubna
Date: Thu Jul 26 10:27:18 2007
New Revision: 559892

URL: http://svn.apache.org/viewvc?view=rev&rev=559892
Log:
automatically look for tool.xml or tools.properties in root directory or classpath

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

Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/ToolManager.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/ToolManager.java?view=diff&rev=559892&r1=559891&r2=559892
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/ToolManager.java (original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/ToolManager.java Thu
Jul 26 10:27:18 2007
@@ -45,6 +45,9 @@
  */
 public class ToolManager
 {
+    public static final String DEFAULT_XML_CONFIG_PATH = "tools.xml";
+    public static final String DEFAULT_PROPS_CONFIG_PATH = "tools.properties";
+
     private VelocityEngine engine;
     private ToolboxFactory factory;
     private Toolbox application;
@@ -60,15 +63,25 @@
 
     public ToolManager(boolean startWithDefault)
     {
-        //TODO? should we look for a tools.xml in the current dir or classpath root?
+        this.factory = new ToolboxFactory();
+
+        FactoryConfiguration config = new FactoryConfiguration();
         if (startWithDefault)
         {
-            this.factory = FactoryConfiguration.createDefaultFactory();
-        }
-        else
-        {
-            this.factory = new ToolboxFactory();
+            config.addConfiguration(FactoryConfiguration.getDefault());
         }
+
+        // look for a tools.xml in the current dir or classpath root
+        FileFactoryConfiguration xml = new XmlFactoryConfiguration();
+        xml.read(DEFAULT_XML_CONFIG_PATH, false);
+        config.addConfiguration(xml);
+
+        // look for a tools.properties in the current dir or classpath root
+        FileFactoryConfiguration props = new PropertiesFactoryConfiguration();
+        props.read(DEFAULT_PROPS_CONFIG_PATH, false);
+        config.addConfiguration(props);
+
+        configure(config);
     }
 
     public void configure(FactoryConfiguration config)



Mime
View raw message