You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by nb...@apache.org on 2007/10/14 08:12:37 UTC

svn commit: r584490 - /velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/AbstractLockConfig.java

Author: nbubna
Date: Sat Oct 13 23:12:37 2007
New Revision: 584490

URL: http://svn.apache.org/viewvc?rev=584490&view=rev
Log:
update the lock config key and deprecate the old one, also allow subclasses to lock or unlock the config directly

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

Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/AbstractLockConfig.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/AbstractLockConfig.java?rev=584490&r1=584489&r2=584490&view=diff
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/AbstractLockConfig.java (original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/generic/AbstractLockConfig.java Sat Oct 13 23:12:37 2007
@@ -34,10 +34,20 @@
      * The key used for specifying whether or not to prevent templates
      * from reconfiguring this tool.  The default is true.
      */
-    public static final String LOCK_CONFIG_KEY = "lock-config";
+    public static final String LOCK_CONFIG_KEY = "lockConfig";
+    @Deprecated
+    public static final String OLD_LOCK_CONFIG_KEY = "lock-config";
 
     private boolean configLocked = false;
 
+    /**
+     * Only allow subclass access to this.
+     */
+    protected void setLockConfig(boolean lock)
+    {
+        this.configLocked = lock;
+    }
+
     public boolean isConfigLocked()
     {
         return this.configLocked;
@@ -53,9 +63,16 @@
             ValueParser values = new ValueParser(params);
             configure(values);
 
-            // by default, lock down this method after use
-            // to prevent templates from re-configuring this instance
-            configLocked = values.getBoolean(LOCK_CONFIG_KEY, true);
+            // first check under the new key
+            Boolean lock = values.getBoolean(LOCK_CONFIG_KEY);
+            if (lock == null)
+            {
+                // now check the old key (for now)
+                // by default, lock down this method after use
+                // to prevent templates from re-configuring this instance
+                lock = values.getBoolean(OLD_LOCK_CONFIG_KEY, Boolean.TRUE);
+            }
+            configLocked = lock.booleanValue();
         }
     }