geirm       00/11/26 21:00:51

  Modified:    src/java/org/apache/velocity/runtime Runtime.java
  Log:
  Added another init entry point, init( Property ), so you can init Runtime with a 
living properties object....
  
  Revision  Changes    Path
  1.55      +45 -1     
jakarta-velocity/src/java/org/apache/velocity/runtime/Runtime.java
  
  Index: Runtime.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/Runtime.java,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- Runtime.java      2000/11/27 04:28:54     1.54
  +++ Runtime.java      2000/11/27 05:00:50     1.55
  @@ -160,7 +160,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Jeff Bowden</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Geir Magusson Jr.</a>
  - * @version $Id: Runtime.java,v 1.54 2000/11/27 04:28:54 geirm Exp $
  + * @version $Id: Runtime.java,v 1.55 2000/11/27 05:00:50 geirm Exp $
    */
   public class Runtime implements RuntimeConstants
   {
  @@ -262,6 +262,35 @@
       /**
        * Initializes the Velocity Runtime.
        */
  +
  +    public synchronized static void init( Properties p )
  +        throws Exception
  +    {
  +        if (initializedPublic)
  +            return;
  +        
  +        /*
  +         *  set the default properties
  +         */
  +
  +        setDefaultProperties();
  +
  +        /*
  +         *  now add the new ones from the calling app
  +         */
  +        
  +        if (p != null)
  +            addPropertiesFromProperties( p );
  +        
  +        /*
  +         *  now call init to do the real work
  +         */
  +
  +        init();
  +
  +        initializedPublic = true; 
  +    }
  +
       public synchronized static void init(String propertiesFileName)
           throws Exception
       {
  @@ -346,6 +375,21 @@
               
           info ("Override Properties : " + sourceName );
               
  +        return addPropertiesFromProperties( p );
  +    }
  +
  +    /**
  +     *  adds / replaces properties in VelocityResources from a properties object. 
  +     */
  +    private static boolean addPropertiesFromProperties( Properties p )
  +        throws Exception
  +    {
  +        if( p == null)
  +            return false;
  +        /*
  +         *   iterate them out
  +         */
  +
           for (Enumeration e = p.keys(); e.hasMoreElements() ; ) 
           {
               String s = (String) e.nextElement();
  
  
  

Reply via email to