velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wgl...@apache.org
Subject svn commit: r544371 - in /velocity/engine/trunk/src/java/org/apache/velocity/runtime: RuntimeInstance.java RuntimeServices.java
Date Tue, 05 Jun 2007 04:28:35 GMT
Author: wglass
Date: Mon Jun  4 21:28:34 2007
New Revision: 544371

URL: http://svn.apache.org/viewvc?view=rev&rev=544371
Log:
Allow custom directives to be instantiated and added in code, not just configured via properties
file.  VELOCITY-547.

Modified:
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeServices.java

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java?view=diff&rev=544371&r1=544370&r2=544371
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeInstance.java Mon Jun
 4 21:28:34 2007
@@ -825,6 +825,34 @@
     }
 
     /**
+     * Programatically add a directive.
+     * @param directive
+     */
+    public void addDirective(Directive directive) 
+    {
+        runtimeDirectives.put(directive.getName(), directive);
+    }
+
+    /**
+     * Retrieve a previously instantiated directive.
+     * @param name name of the directive
+     * @return
+     */
+    public Directive getDirective(String name) 
+    {
+        return (Directive) runtimeDirectives.get(name);
+    }
+
+    /**
+     * Remove a directive.
+     * @param name name of the directive.
+     */
+    public void removeDirective(String name) 
+    {
+        runtimeDirectives.remove(name);
+    }
+
+    /**
      *  instantiates and loads the directive with some basic checks
      *
      *  @param directiveClass classname of directive to load
@@ -838,7 +866,7 @@
             if (o instanceof Directive)
             {
                 Directive directive = (Directive) o;
-                runtimeDirectives.put(directive.getName(), directive);
+                addDirective(directive);
             }
             else
             {

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeServices.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeServices.java?view=diff&rev=544371&r1=544370&r2=544371
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeServices.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/RuntimeServices.java Mon Jun
 4 21:28:34 2007
@@ -400,4 +400,11 @@
      * @return A new parser instance.
      */
     public Parser createNewParser();
+
+    /**
+     * Retrieve a previously instantiated directive.
+     * @param name name of the directive
+     * @return
+     */
+    public Directive getDirective(String name);
 }



Mime
View raw message