velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nbu...@apache.org
Subject svn commit: r537481 - in /velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools: ./ config/ generic/ struts/ view/i18n/ view/tools/
Date Sat, 12 May 2007 16:50:44 GMT
Author: nbubna
Date: Sat May 12 09:50:43 2007
New Revision: 537481

URL: http://svn.apache.org/viewvc?view=rev&rev=537481
Log:
s/setup(Map)/configure(Map) to simplify backwards compatibility

Modified:
    velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/ToolInfo.java
    velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/ToolConfiguration.java
    velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/AlternatorTool.java
    velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/DateTool.java
    velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/NumberTool.java
    velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/RenderTool.java
    velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/ResourceTool.java
    velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/ActionMessagesTool.java
    velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/ErrorsTool.java
    velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/FormTool.java
    velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/MessageResourcesTool.java
    velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/ValidatorTool.java
    velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/i18n/MultiViewsTool.java
    velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/AbstractPagerTool.java
    velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ContextTool.java

Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/ToolInfo.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/ToolInfo.java?view=diff&rev=537481&r1=537480&r2=537481
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/ToolInfo.java (original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/ToolInfo.java Sat
May 12 09:50:43 2007
@@ -37,14 +37,14 @@
 //TODO: make this class serializable
 public class ToolInfo
 {
-    public static final String SETUP_METHOD_NAME = "setup";
+    public static final String CONFIGURE_METHOD_NAME = "configure";
 
     private String key;
     private Class clazz;
     private boolean restrictToIsExact;
     private String restrictTo;
     private Map<String,Object> properties;
-    private Method setup = null;
+    private Method configure = null;
 
     /**
      * Creates a new instance using the minimum required info
@@ -70,7 +70,7 @@
 
     /**
      * Tries to create an instance of the specified Class, then looks for a
-     * setup(Map<String,Object>) method.
+     * configure(Map<String,Object>) method.
      *
      * @param clazz the java.lang.Class of the tool
      */
@@ -90,20 +90,20 @@
             throw new IllegalArgumentException("Could not create an instance of "+clazz,
e);
         }
 
-        // search for a setup(Map params) method in the class
+        // search for a configure(Map params) method in the class
         try
         {
-            this.setup = Utils.findMethod(clazz, SETUP_METHOD_NAME,
+            this.configure = Utils.findMethod(clazz, CONFIGURE_METHOD_NAME,
                                           new Class[]{ Map.class });
         }
         catch (SecurityException se)
         {
             // fail early, rather than wait until
             String msg = "Unable to gain access to '" +
-                         SETUP_METHOD_NAME + "(Map)'" +
+                         CONFIGURE_METHOD_NAME + "(Map)'" +
                          " method for '" + clazz.getName() +
                          "' under the current security manager."+
-                         "  This tool cannot be properly setup for use.";
+                         "  This tool cannot be properly configured for use.";
             throw new IllegalStateException(msg, se);
         }
 
@@ -204,9 +204,9 @@
         return properties;
     }
 
-    public boolean hasSetup()
+    public boolean hasConfigure()
     {
-        return (this.setup != null);
+        return (this.configure != null);
     }
 
     /**
@@ -238,7 +238,7 @@
 
     /**
      * Returns a new instance of the tool. If the tool
-     * has an setup(Map) method, the new instance
+     * has an configure(Map) method, the new instance
      * will be initialized using the given properties combined with
      * whatever "constant" properties have been put into this
      * ToolInfo.
@@ -250,11 +250,11 @@
 
         /* if the tool is configurable and we have properties... */
         Map<String,Object> combinedProps = combine(this.properties, dynamicProperties);
-        if (hasSetup())
+        if (hasConfigure())
         {
             if (combinedProps != null)
             {
-                setup(tool, combinedProps);
+                configure(tool, combinedProps);
             }
         }
 
@@ -294,24 +294,24 @@
     }
 
 
-    protected void setup(Object tool, Map<String,Object> properties)
+    protected void configure(Object tool, Map<String,Object> properties)
     {
         try
         {
-            // call the setup method on the instance
-            setup.invoke(tool, new Object[]{ properties });
+            // call the configure method on the instance
+            configure.invoke(tool, new Object[]{ properties });
         }
         catch (IllegalAccessException iae)
         {
             String msg = "Unable to invoke " +
-                         SETUP_METHOD_NAME + "(Map>) on "+tool;
+                         CONFIGURE_METHOD_NAME + "(Map) on "+tool;
             // restricting access to this method by this class ist verboten
             throw new IllegalStateException(msg, iae);
         }
         catch (InvocationTargetException ite)
         {
             String msg = "Exception when invoking " +
-                         SETUP_METHOD_NAME + "(Map) on "+tool;
+                         CONFIGURE_METHOD_NAME + "(Map) on "+tool;
             // convert to a runtime exception, and re-throw
             throw new RuntimeException(msg, ite.getCause());
         }

Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/ToolConfiguration.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/ToolConfiguration.java?view=diff&rev=537481&r1=537480&r2=537481
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/ToolConfiguration.java
(original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/ToolConfiguration.java
Sat May 12 09:50:43 2007
@@ -131,23 +131,22 @@
         try
         {
             clazz.getMethod("init", new Class[]{ Object.class });
-            // if we get here, then we found it
-            return true;
+            // ok, if they have init, but not configure
+            // then we consider them "old"
+            try
+            {
+                clazz.getMethod("configure", new Class[]{ Map.class });
+                return false;
+            }
+            catch (NoSuchMethodException nsme)
+            {
+                return true;
+            }
         }
         catch (NoSuchMethodException nsme)
         {
-            // ignore
+            return false;
         }
-        try
-        {
-            clazz.getMethod("configure", new Class[]{ Map.class });
-            return true;
-        }
-        catch (NoSuchMethodException nsme)
-        {
-            // ignore
-        }
-        return false;
     }
 
     public String getRestrictTo()

Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/AlternatorTool.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/AlternatorTool.java?view=diff&rev=537481&r1=537480&r2=537481
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/AlternatorTool.java
(original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/AlternatorTool.java
Sat May 12 09:50:43 2007
@@ -70,7 +70,7 @@
      * if not, set the default to true.
      * @since VelocityTools 1.3
      */
-    public void setup(Map params)
+    public void configure(Map params)
     {
         ValueParser parser = new ValueParser(params);
         // it's true by default in Alternator

Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/DateTool.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/DateTool.java?view=diff&rev=537481&r1=537480&r2=537481
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/DateTool.java
(original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/DateTool.java
Sat May 12 09:50:43 2007
@@ -103,7 +103,7 @@
      * Looks for configuration values in the given params.
      * @since VelocityTools 1.3
      */
-    public void setup(Map params)
+    public void configure(Map params)
     {
         if (!configLocked)
         {

Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/NumberTool.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/NumberTool.java?view=diff&rev=537481&r1=537480&r2=537481
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/NumberTool.java
(original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/NumberTool.java
Sat May 12 09:50:43 2007
@@ -100,7 +100,7 @@
      * Looks for configuration values in the given params.
      * @since VelocityTools 1.4
      */
-    public void setup(Map params)
+    public void configure(Map params)
     {
         if (!configLocked)
         {

Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/RenderTool.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/RenderTool.java?view=diff&rev=537481&r1=537480&r2=537481
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/RenderTool.java
(original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/RenderTool.java
Sat May 12 09:50:43 2007
@@ -101,7 +101,7 @@
      * Looks for parse depth and catch.exceptions parameters.
      * @since VelocityTools 1.3
      */
-    public void setup(Map params)
+    public void configure(Map params)
     {
         ValueParser parser = new ValueParser(params);
         int depth = parser.getInt(KEY_PARSE_DEPTH, DEFAULT_PARSE_DEPTH);

Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/ResourceTool.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/ResourceTool.java?view=diff&rev=537481&r1=537480&r2=537481
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/ResourceTool.java
(original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/ResourceTool.java
Sat May 12 09:50:43 2007
@@ -101,7 +101,7 @@
     }
 
 
-    public void setup(Map params)
+    public void configure(Map params)
     {
         ValueParser parser = new ValueParser(params);
         String[] bundles = parser.getStrings(BUNDLES_KEY);

Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/ActionMessagesTool.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/ActionMessagesTool.java?view=diff&rev=537481&r1=537480&r2=537481
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/ActionMessagesTool.java
(original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/ActionMessagesTool.java
Sat May 12 09:50:43 2007
@@ -79,10 +79,10 @@
      * @param obj the current ViewContext
      * @throws IllegalArgumentException if the param is not a ViewContext
      */
-    public void setup(Map params)
+    public void configure(Map params)
     {
-        //setup superclass instance members
-        super.setup(params);
+        //configure superclass instance members
+        super.configure(params);
 
         this.LOG = (Log)params.get("log");
         this.actionMsgs = StrutsUtils.getMessages(this.request);

Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/ErrorsTool.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/ErrorsTool.java?view=diff&rev=537481&r1=537480&r2=537481
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/ErrorsTool.java
(original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/ErrorsTool.java
Sat May 12 09:50:43 2007
@@ -62,10 +62,10 @@
      * @param obj the current ViewContext
      * @throws IllegalArgumentException if the param is not a ViewContext
      */
-    public void setup(Map params)
+    public void configure(Map params)
     {
-        //setup superclass instance members
-        super.setup(params);
+        //configure superclass instance members
+        super.configure(params);
 
         this.actionMsgs = StrutsUtils.getErrors(this.request);
     }

Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/FormTool.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/FormTool.java?view=diff&rev=537481&r1=537480&r2=537481
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/FormTool.java
(original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/FormTool.java
Sat May 12 09:50:43 2007
@@ -86,7 +86,7 @@
      * @param obj the current ViewContext
      * @throws IllegalArgumentException if the param is not a ViewContext
      */
-    public void setup(Map params)
+    public void configure(Map params)
     {
         this.request = (HttpServletRequest)params.get(ViewContext.REQUEST);
         this.session = request.getSession(false);

Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/MessageResourcesTool.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/MessageResourcesTool.java?view=diff&rev=537481&r1=537480&r2=537481
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/MessageResourcesTool.java
(original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/MessageResourcesTool.java
Sat May 12 09:50:43 2007
@@ -49,7 +49,7 @@
      * @param obj the current ViewContext
      * @throws IllegalArgumentException if the param is not a ViewContext
      */
-    public void setup(Map params)
+    public void configure(Map params)
     {
         this.request = (HttpServletRequest)params.get(ViewContext.REQUEST);
         this.application = (ServletContext)params.get(ViewContext.SERVLET_CONTEXT_KEY);

Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/ValidatorTool.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/ValidatorTool.java?view=diff&rev=537481&r1=537480&r2=537481
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/ValidatorTool.java
(original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/struts/ValidatorTool.java
Sat May 12 09:50:43 2007
@@ -159,7 +159,7 @@
      * @param obj the current ViewContext
      * @throws IllegalArgumentException if the param is not a ViewContext
      */
-    public void setup(Map params)
+    public void configure(Map params)
     {
         this.context = (ViewContext)params.get(ViewToolContext.CONTEXT_KEY);
         this.request = (HttpServletRequest)params.get(ViewContext.REQUEST);

Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/i18n/MultiViewsTool.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/i18n/MultiViewsTool.java?view=diff&rev=537481&r1=537480&r2=537481
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/i18n/MultiViewsTool.java
(original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/i18n/MultiViewsTool.java
Sat May 12 09:50:43 2007
@@ -79,7 +79,7 @@
      * @param obj the current ViewContext
      * @throws IllegalArgumentException if the param is not a ViewContext
      */
-    public void setup(Map params)
+    public void configure(Map params)
     {
         Context vc = (Context)params.get(ViewToolContext.CONTEXT_KEY);
         this.engine = (VelocityEngine)params.get(ViewToolContext.ENGINE_KEY);

Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/AbstractPagerTool.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/AbstractPagerTool.java?view=diff&rev=537481&r1=537480&r2=537481
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/AbstractPagerTool.java
(original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/AbstractPagerTool.java
Sat May 12 09:50:43 2007
@@ -146,7 +146,7 @@
         setup(request);
     }
 
-    public void setup(Map params)
+    public void configure(Map params)
     {
         init(params.get(ToolContext.CONTEXT_KEY));
     }

Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ContextTool.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ContextTool.java?view=diff&rev=537481&r1=537480&r2=537481
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ContextTool.java
(original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/view/tools/ContextTool.java
Sat May 12 09:50:43 2007
@@ -82,7 +82,7 @@
      * Also looks for a safe-mode configuration setting. By default,
      * safe-mode is true and thus keys with '.' in them are hidden.
      */
-    public void setup(Map params)
+    public void configure(Map params)
     {
         if (params != null)
         {



Mime
View raw message