jvanzyl     00/10/31 15:45:02

  Modified:    src/java/org/apache/velocity Context.java Template.java
               src/java/org/apache/velocity/runtime/directive Foreach.java
               src/java/org/apache/velocity/runtime/loader
                        TemplateFactory.java
               src/java/org/apache/velocity/util/introspection
                        ClassMethodMap.java Introspector.java
  Log:
  - update the initialization system, by cloning the context for
    the initialization phase, then throwing it away and use the
    original context for the rendering phase.
  
  Revision  Changes    Path
  1.5       +18 -2     jakarta-velocity/src/java/org/apache/velocity/Context.java
  
  Index: Context.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/Context.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Context.java      2000/10/20 02:19:50     1.4
  +++ Context.java      2000/10/31 23:44:52     1.5
  @@ -66,9 +66,9 @@
    * an valid object derived from Object. These objects
    * are stored in a Hashtable. 
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
  - * @version $Id: Context.java,v 1.4 2000/10/20 02:19:50 jvanzyl Exp $
  + * @version $Id: Context.java,v 1.5 2000/10/31 23:44:52 jvanzyl Exp $
    */
  -public class Context
  +public class Context implements Cloneable
   {
       /**
        * Random access storage for context data.
  @@ -127,4 +127,20 @@
       {
           return context.remove(key);
       }        
  +
  +    public Object clone()
  +    {
  +        Context clone = null;
  +        
  +        try
  +        {
  +            clone = (Context) super.clone();
  +            clone.context = (Hashtable) context.clone();
  +        }
  +        catch (CloneNotSupportedException cnse)
  +        {
  +        }
  +        
  +        return clone;
  +    }
   }
  
  
  
  1.12      +3 -2      jakarta-velocity/src/java/org/apache/velocity/Template.java
  
  Index: Template.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/Template.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Template.java     2000/10/22 01:53:14     1.11
  +++ Template.java     2000/10/31 23:44:52     1.12
  @@ -82,7 +82,7 @@
    * </pre>
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
  - * @version $Id: Template.java,v 1.11 2000/10/22 01:53:14 jvanzyl Exp $
  + * @version $Id: Template.java,v 1.12 2000/10/31 23:44:52 jvanzyl Exp $
    */
   public class Template
   {
  @@ -146,7 +146,8 @@
           {
               if (!initialized)
               {
  -                document.init(context, null);
  +                Context initContext = (Context) context.clone();
  +                document.init(initContext, null);
                   initialized = true;
               }
           }                
  
  
  
  1.14      +1 -0      
jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Foreach.java
  
  Index: Foreach.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/directive/Foreach.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Foreach.java      2000/10/22 01:27:36     1.13
  +++ Foreach.java      2000/10/31 23:44:54     1.14
  @@ -133,6 +133,7 @@
           // Figure out what type of object the list
           // element is so that we don't have to do it
           // everytime the node is traversed.
  +        //if (listObject instanceof Object[])
           if (listObject instanceof Object[])
           {
               node.setInfo(ARRAY);
  
  
  
  1.3       +1 -2      
jakarta-velocity/src/java/org/apache/velocity/runtime/loader/TemplateFactory.java
  
  Index: TemplateFactory.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/loader/TemplateFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TemplateFactory.java      2000/09/30 22:34:49     1.2
  +++ TemplateFactory.java      2000/10/31 23:44:56     1.3
  @@ -55,13 +55,12 @@
    */
   
   import org.apache.velocity.runtime.Runtime;
  -import org.apache.velocity.runtime.configuration.Configuration;
   
   /**
    * Factory to grab a template loader.
    * 
    * @author Dave Bryson
  - * $Revision: 1.2 $
  + * $Revision: 1.3 $
    */
   public class TemplateFactory
   {
  
  
  
  1.3       +16 -2     
jakarta-velocity/src/java/org/apache/velocity/util/introspection/ClassMethodMap.java
  
  Index: ClassMethodMap.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/util/introspection/ClassMethodMap.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ClassMethodMap.java       2000/10/31 04:50:46     1.2
  +++ ClassMethodMap.java       2000/10/31 23:44:58     1.3
  @@ -97,14 +97,18 @@
        * a methodKey and add it to the
        * directHits Map.
        */
  -    public Method findMethod(String methodKey)
  +    public Method findMethod(String name, Object[] params)
       {
  +        String methodKey = makeMethodKey(name, params);
  +        
  +        //if (!directHits.containsKey(methodKey))
  +        
           return (Method) directHits.get(methodKey);
       }
       
       /**
        * Populate the Map of direct hits. These
  -     * are taken from all the public method
  +     * are taken from all the public methods
        * that our class provides.
        */
       private void populateDirectHits()
  @@ -130,6 +134,16 @@
           
           for (int j = 0; j < parameterTypes.length; j++)
               methodKey.append(parameterTypes[j].getName());
  +
  +        return methodKey.toString();
  +    }
  +
  +    private static String makeMethodKey(String method, Object[] params)
  +    {
  +        StringBuffer methodKey = new StringBuffer().append(method);
  +        
  +        for (int j = 0; j < params.length; j++)
  +            methodKey.append(params[j].getClass().getName());
   
           return methodKey.toString();
       }
  
  
  
  1.2       +2 -18     
jakarta-velocity/src/java/org/apache/velocity/util/introspection/Introspector.java
  
  Index: Introspector.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/util/introspection/Introspector.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Introspector.java 2000/10/31 02:48:49     1.1
  +++ Introspector.java 2000/10/31 23:44:59     1.2
  @@ -82,7 +82,7 @@
    * This mapping is performed for all the methods in a class
    * and stored for 
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
  - * @version $Id: Introspector.java,v 1.1 2000/10/31 02:48:49 jvanzyl Exp $
  + * @version $Id: Introspector.java,v 1.2 2000/10/31 23:44:59 jvanzyl Exp $
    */
   
   // isAssignable checks for arguments that are subclasses
  @@ -107,24 +107,8 @@
   
       private static Method findMethod(Class c, String name, Object[] params)
       {
  -        // Get the class method map for the class in
  -        // question.
           ClassMethodMap classMethodMap = (ClassMethodMap) 
classMethodMaps.get(c.getName());
  -        
  -        // Return the method based method key.
  -        Method method = classMethodMap.findMethod(makeMethodKey(name, params));
  -        
  -        return method;
  -    }
  -
  -    private static String makeMethodKey(String method, Object[] params)
  -    {
  -        StringBuffer methodKey = new StringBuffer().append(method);
  -        
  -        for (int j = 0; j < params.length; j++)
  -            methodKey.append(params[j].getClass().getName());
  -    
  -        return methodKey.toString();
  +        return classMethodMap.findMethod(name, params);
       }
   
       private static class Test
  
  
  

Reply via email to