velocity-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject cvs commit: jakarta-velocity/src/java/org/apache/velocity/runtime/resource/loader DataSourceResourceLoader.java FileResourceLoader.java JarResourceLoader.java ResourceLoader.java
Date Sat, 03 Mar 2001 20:33:23 GMT
jvanzyl     01/03/03 12:33:23

  Modified:    src/java/org/apache/velocity/runtime Runtime.java
               src/java/org/apache/velocity/runtime/configuration
                        Configurations.java
               src/java/org/apache/velocity/runtime/resource
                        ResourceManager.java
               src/java/org/apache/velocity/runtime/resource/loader
                        DataSourceResourceLoader.java
                        FileResourceLoader.java JarResourceLoader.java
                        ResourceLoader.java
  Removed:     src/java/org/apache/velocity/runtime/configuration
                        VelocityResources.java
  Log:
  - changes to the configuration mechanism in the runtime, the resource
    manager and the resource loaders.
  
    there is now one class, o.a.v.r.configuration.Configuration
    that will hold the velocity runtime information and this primary
    Configuration can be called upon in the resource loader to make
    a subset of itself.
  
    this is a nice way to pass a Configuration object to each
    of the resource loaders when they initialize and it cleans
    up a lot of code in the resource manager because the Configuration
    class takes care of all the dirty work in make the Configuration
    subset.
  
    the basic upshot is that within the resource loader you can
    now use convenient methods like:
  
    1) Vector paths = configuration.getVector("resource.path");
    2) String class = configuration.getString("class");
  
    So for 1) you might have something in the vel.props like:
  
    resource.loader.1.resource.path = /path1
    resource.loader.1.resource.path = /path2
    resource.loader.1.resource.path = /path3
  
    and you can grab them in one shot with the Configuration class.
  
    i'm now going to add support to the file resource loader to
    take advantage of this. it will soon be able to deal with
    multiple resource paths. this will also be the case for
    the jar resource loader that daveb is working on.
  
  Revision  Changes    Path
  1.89      +62 -23    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.88
  retrieving revision 1.89
  diff -u -r1.88 -r1.89
  --- Runtime.java	2001/03/03 04:45:04	1.88
  +++ Runtime.java	2001/03/03 20:33:20	1.89
  @@ -94,7 +94,7 @@
   import org.apache.velocity.exception.ResourceNotFoundException;
   import org.apache.velocity.exception.ParseErrorException;
   
  -import org.apache.velocity.runtime.configuration.VelocityResources;
  +import org.apache.velocity.runtime.configuration.Configuration;
   
   /**
    * This is the Runtime system for Velocity. It is the
  @@ -172,7 +172,7 @@
    * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
    * @author <a href="mailto:jlb@houseofdistraction.com">Jeff Bowden</a>
    * @author <a href="mailto:geirm@optonline.net">Geir Magusson Jr.</a>
  - * @version $Id: Runtime.java,v 1.88 2001/03/03 04:45:04 jvanzyl Exp $
  + * @version $Id: Runtime.java,v 1.89 2001/03/03 20:33:20 jvanzyl Exp $
    */
   public class Runtime implements RuntimeConstants
   {    
  @@ -181,18 +181,30 @@
        */
       private static VelocimacroFactory vmFactory = new VelocimacroFactory();
   
  -    /** The Runtime logger */
  +    /** 
  +     * The Runtime logger.
  +     */
       private static Logger logger;
   
  -    /** The caching system used by the Velocity Runtime */
  +    /** 
  +     * The caching system used by the Velocity Runtime 
  +     */
       private static Hashtable globalCache;
       
  -    /** The Runtime parser pool */
  +    /** 
  +     * The Runtime parser pool 
  +     */
       private static SimplePool parserPool;
       
  -    /** Indicate whether the Runtime has been fully initialized */
  +    /** 
  +     * Indicate whether the Runtime has been fully initialized.
  +     */
       private static boolean initialized;
   
  +    /**
  +     * These are the properties that are laid down over top
  +     * of the default properties when requested.
  +     */
       private static Properties overridingProperties = null;
   
       /**
  @@ -213,6 +225,22 @@
        */
       private static Hashtable runtimeDirectives;
   
  +    /**
  +     * Object that houses the configuration options for
  +     * the velocity runtime. The Configuration object allows
  +     * the convenient retrieval of a subset of properties.
  +     * For example all the properties for a resource loader
  +     * can be retrieved from the main Configuration object
  +     * using something like the following:
  +     *
  +     * Configuration loaderConfiguration = 
  +     *         configuration.subset(loaderID);
  +     *
  +     * And a configuration is a lot more convenient to deal
  +     * with then conventional properties objects, or Maps.
  +     */
  +    private static Configuration configuration = new Configuration();
  +
       /*
        * This is the primary initialization method in the Velocity
        * Runtime. The systems that are setup/initialized here are
  @@ -384,7 +412,7 @@
               InputStream inputStream = classLoader
                   .getResourceAsStream( DEFAULT_RUNTIME_PROPERTIES );
               
  -            VelocityResources.setPropertiesInputStream( inputStream );
  +            configuration.setPropertiesInputStream( inputStream );
               
               info ("Default Properties File: " + 
                   new File(DEFAULT_RUNTIME_PROPERTIES).getPath());
  @@ -426,7 +454,7 @@
            * Always lay down the default properties first as
            * to provide a solid base.
            */
  -        if (VelocityResources.isInitialized() == false)
  +        if (configuration.isInitialized() == false)
           {
               setDefaultProperties();
           }            
  @@ -437,7 +465,7 @@
               for (Enumeration e = overridingProperties.keys(); e.hasMoreElements() ; ) 
               {
                   String s = (String) e.nextElement();
  -                VelocityResources.setProperty( s, overridingProperties.getProperty(s) );
  +                configuration.setProperty( s, overridingProperties.getProperty(s) );
                   info ("   ** Property Override : " + s + " = " + 
                       overridingProperties.getProperty(s));
               }
  @@ -455,7 +483,7 @@
            * Grab the log file entry from the velocity
            * properties file.
            */
  -        String logFile = VelocityResources.getString(RUNTIME_LOG);
  +        String logFile = configuration.getString(RUNTIME_LOG);
   
           /*
            * Initialize the logger. We will eventually move all
  @@ -689,14 +717,14 @@
       }
   
       /**
  -     * Added this to check and make sure that the VelocityResources
  +     * Added this to check and make sure that the configuration
        * is initialized before trying to get properties from it.
        * This occurs when there are errors during initialization
        * and the default properties have yet to be layed down.
        */
       private static boolean showStackTrace()
       {
  -        if (VelocityResources.isInitialized())
  +        if (configuration.isInitialized())
           {
               return getBoolean(RUNTIME_LOG_WARN_STACKTRACE, false);
           }            
  @@ -787,7 +815,7 @@
   
       /**
        * String property accessor method with default to hide the
  -     * VelocityResources implementation.
  +     * configuration implementation.
        * 
        * @param String key property key
        * @param String defaultValue  default value to return if key not 
  @@ -796,7 +824,7 @@
        */
       public static String getString( String key, String defaultValue)
       {
  -        return VelocityResources.getString(key, defaultValue);
  +        return configuration.getString(key, defaultValue);
       }
   
       /**
  @@ -853,7 +881,7 @@
        * R U N T I M E  A C C E S S O R  M E T H O D S
        * --------------------------------------------------------------------
        * These are the getXXX() methods that are a simple wrapper
  -     * around the VelocityResources object. This is an attempt
  +     * around the configuration object. This is an attempt
        * to make a the Velocity Runtime the single access point
        * for all things Velocity, and allow the Runtime to
        * adhere as closely as possible the the Mediator pattern
  @@ -862,28 +890,28 @@
        */
   
       /**
  -     * String property accessor method to hide the VelocityResources implementation
  +     * String property accessor method to hide the configuration implementation
        * @param key  property key
        * @return   value of key or null
        */
       public static String getString(String key)
       {
  -        return VelocityResources.getString( key );
  +        return configuration.getString( key );
       }
   
       /**
  -     * Int property accessor method to hide the VelocityResources implementation.
  +     * Int property accessor method to hide the configuration implementation.
        *
        * @param String key property key
        * @return int value
        */
       public static int getInt( String key )
       {
  -        return VelocityResources.getInt( key );
  +        return configuration.getInt( key );
       }
   
       /**
  -     * Int property accessor method to hide the VelocityResources implementation.
  +     * Int property accessor method to hide the configuration implementation.
        *
        * @param key  property key
        * @param int default value
  @@ -891,11 +919,11 @@
        */
       public static int getInt( String key, int defaultValue )
       {
  -        return VelocityResources.getInt( key, defaultValue );
  +        return configuration.getInt( key, defaultValue );
       }
   
       /**
  -     * Boolean property accessor method to hide the VelocityResources implementation.
  +     * Boolean property accessor method to hide the configuration implementation.
        * 
        * @param String key  property key
        * @param boolean default default value if property not found
  @@ -903,6 +931,17 @@
        */
       public static boolean getBoolean( String key, boolean def )
       {
  -        return VelocityResources.getBoolean( key, def );
  +        return configuration.getBoolean( key, def );
       }
  +
  +    /**
  +     * Return the velocity runtime configuration object.
  +     *
  +     * @return Configuration configuration object which houses
  +     *                       the velocity runtime properties.
  +     */
  +    public static Configuration getConfiguration()
  +    {
  +        return configuration;
  +    }        
   }
  
  
  
  1.2       +34 -1     jakarta-velocity/src/java/org/apache/velocity/runtime/configuration/Configurations.java
  
  Index: Configurations.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/configuration/Configurations.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Configurations.java	2000/11/02 02:51:26	1.1
  +++ Configurations.java	2001/03/03 20:33:21	1.2
  @@ -82,7 +82,7 @@
    * configuration syntax.
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version $Id: Configurations.java,v 1.1 2000/11/02 02:51:26 daveb Exp $
  + * @version $Id: Configurations.java,v 1.2 2001/03/03 20:33:21 jvanzyl Exp $
    */
   public class Configurations
   {
  @@ -182,6 +182,39 @@
               }
           }
           return matchingKeys.elements();
  +    }
  +
  +    public Configurations subset(String prefix)
  +    {
  +        Configurations c = new Configurations(new ExtendedProperties());
  +        Enumeration keys = this.repository.keys();
  +        boolean validSubset = false;
  +        
  +        while( keys.hasMoreElements() )
  +        {
  +            Object key = keys.nextElement();
  +            
  +            if( key instanceof String &&
  +                ((String) key).startsWith(prefix) )
  +            {
  +                if (!validSubset)
  +                {
  +                    validSubset = true;
  +                }
  +                
  +                String newKey = ((String)key).substring(prefix.length() + 1);
  +                c.getRepository().put(newKey, repository.get(key));
  +            }
  +        }
  +        
  +        if (validSubset)
  +        {
  +            return c;
  +        }
  +        else
  +        {
  +            return null;
  +        }
       }
   
       /**
  
  
  
  1.10      +63 -36    jakarta-velocity/src/java/org/apache/velocity/runtime/resource/ResourceManager.java
  
  Index: ResourceManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/resource/ResourceManager.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ResourceManager.java	2001/02/26 03:33:19	1.9
  +++ ResourceManager.java	2001/03/03 20:33:22	1.10
  @@ -61,7 +61,7 @@
   
   import org.apache.velocity.Template;
   import org.apache.velocity.runtime.Runtime;
  -import org.apache.velocity.runtime.configuration.VelocityResources;
  +import org.apache.velocity.runtime.configuration.Configuration;
   import org.apache.velocity.runtime.resource.ResourceFactory;
   import org.apache.velocity.runtime.resource.loader.ResourceLoader;
   import org.apache.velocity.runtime.resource.loader.ResourceLoaderFactory;
  @@ -75,13 +75,24 @@
    * Runtime.
    *
    * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
  - * @version $Id: ResourceManager.java,v 1.9 2001/02/26 03:33:19 geirm Exp $
  + * @version $Id: ResourceManager.java,v 1.10 2001/03/03 20:33:22 jvanzyl Exp $
    */
   public class ResourceManager
   {
  +    /**
  +     * A template resources.
  +     */
       public static final int RESOURCE_TEMPLATE = 1;
  +    
  +    /**
  +     * A static content resource.
  +     */
       public static final int RESOURCE_CONTENT = 2;
   
  +    /**
  +     * Hashtable used to store templates that have been
  +     * processed. Our simple caching mechanism.
  +     */
       private static Hashtable globalCache = new Hashtable();
       
       /**
  @@ -112,6 +123,12 @@
        */
       private static Hashtable sourceInitializerMap = new Hashtable();
   
  +    /**
  +     * Each loader needs a configuration object for
  +     * its initialization, this flags keeps track of whether
  +     * or not the configuration objects have been created
  +     * for the resource loaders.
  +     */
       private static boolean resourceLoaderInitializersActive = false;
   
       /**
  @@ -127,11 +144,11 @@
           
           for (int i = 0; i < sourceInitializerList.size(); i++)
           {
  -            Map initializer = (Map) sourceInitializerList.get(i);
  -            String loaderClass = (String) initializer.get("class");
  +            Configuration configuration = (Configuration) sourceInitializerList.get(i);
  +            String loaderClass = configuration.getString("class");
               resourceLoader = ResourceLoaderFactory.getLoader(loaderClass);
  -            resourceLoader.commonInit(initializer);
  -            resourceLoader.init(initializer);
  +            resourceLoader.commonInit(configuration);
  +            resourceLoader.init(configuration);
               resourceLoaders.add(resourceLoader);
           }
       }
  @@ -146,43 +163,47 @@
       private static void assembleResourceLoaderInitializers()
       {
           if (resourceLoaderInitializersActive)
  +        {
               return;
  +        }            
           
  -        for (int i = 0; i < 10; i++)
  +        for (int i = 1; i < 10; i++)
           {
               String loaderID = "resource.loader." + new Integer(i).toString();
  -            Enumeration e = VelocityResources.getKeys(loaderID);
               
  -            if (!e.hasMoreElements())
  +            /*
  +             * Create a resources class specifically for
  +             * the loader if we have a valid subset of
  +             * resources. VelocityResources.subset(prefix)
  +             * will return null if we do not have a valid
  +             * subset of resources.
  +             */
  +            if (Runtime.getConfiguration().subset(loaderID) == null)
               {
                   continue;
  -            }
  -            
  -            Hashtable sourceInitializer = new Hashtable();
  +            }                
               
  -            while (e.hasMoreElements())
  -            {
  -                String property = (String) e.nextElement();
  -                String value = VelocityResources.getString(property);
  -                
  -                property = property.substring(loaderID.length() + 1);
  -                sourceInitializer.put(property, value);
  -                
  -                /*
  -                 * Make a Map of the public names for the sources
  -                 * to the sources property identifier so that external
  -                 * clients can set source properties. For example:
  -                 * File.resource.path would get translated into
  -                 * template.loader.1.resource.path and the translated
  -                 * name would be used to set the property.
  -                 */
  -                if (property.equalsIgnoreCase("public.name"))
  -                {
  -                    sourceInitializerMap.put(value.toLowerCase(), sourceInitializer);
  -                }
  -            }    
  -            sourceInitializerList.add(sourceInitializer);
  -        }
  +            Configuration loaderConfiguration = new Configuration(
  +                Runtime.getConfiguration().subset(loaderID));
  +
  +            /*
  +             * Add resources to the list of resource loader
  +             * initializers.
  +             */
  +            sourceInitializerList.add(loaderConfiguration);
  +
  +            /*
  +             * Make a Map of the public names for the sources
  +             * to the sources property identifier so that external
  +             * clients can set source properties. For example:
  +             * File.resource.path would get translated into
  +             * template.loader.1.resource.path and the translated
  +             * name would be used to set the property.
  +             */
  +            sourceInitializerMap.put(
  +                loaderConfiguration.getString("public.name").toLowerCase(), 
  +                    loaderConfiguration);
  +        }            
       }
   
       /**
  @@ -354,10 +375,16 @@
       public static void setSourceProperty(String key, String value)
       {
           if (resourceLoaderInitializersActive == false)
  +        {
               assembleResourceLoaderInitializers();
  +        }            
               
           String publicName = key.substring(0, key.indexOf("."));
           String property = key.substring(key.indexOf(".") + 1);
  -        ((Map)sourceInitializerMap.get(publicName.toLowerCase())).put(property, value);
  +        
  +        Configuration loaderConfiguration = (Configuration) 
  +            sourceInitializerMap.get(publicName.toLowerCase());
  +        
  +        loaderConfiguration.getConfig().getRepository().put(property, value);
       }
   }
  
  
  
  1.3       +9 -12     jakarta-velocity/src/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java
  
  Index: DataSourceResourceLoader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/resource/loader/DataSourceResourceLoader.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DataSourceResourceLoader.java	2001/02/26 03:37:56	1.2
  +++ DataSourceResourceLoader.java	2001/03/03 20:33:22	1.3
  @@ -64,6 +64,7 @@
   import javax.naming.InitialContext;
   
   import org.apache.velocity.runtime.Runtime;
  +import org.apache.velocity.runtime.configuration.Configuration;
   import org.apache.velocity.runtime.resource.Resource;
   
   import org.apache.velocity.exception.ResourceNotFoundException;
  @@ -93,7 +94,7 @@
    *
    * @author <a href="mailto:david.kinnvall@alertir.com">David Kinnvall</a>
    * @author <a href="Paulo Gaspar <paulo.gaspar@krankikom.de">Paulo Gaspar</a>
  - * @version $Id: DataSourceResourceLoader.java,v 1.2 2001/02/26 03:37:56 geirm Exp $
  + * @version $Id: DataSourceResourceLoader.java,v 1.3 2001/03/03 20:33:22 jvanzyl Exp $
    */
   public class DataSourceResourceLoader extends ResourceLoader
   {
  @@ -105,18 +106,14 @@
        private InitialContext ctx;
        private DataSource dataSource;
   
  -     /*
  -      * This should probably be moved into the super class,
  -      * the stand init stuff. For the properties that all
  -      * loaders will probably share.
  -      */
  -     public void init(Map initializer)
  +     public void init(Configuration configuration)
        {
  -         dataSourceName  = (String) initializer.get("resource.datasource");
  -         tableName       = (String) initializer.get("resource.table");
  -         keyColumn       = (String) initializer.get("resource.keycolumn");
  -         templateColumn  = (String) initializer.get("resource.templatecolumn");
  -         timestampColumn = (String) initializer.get("resource.timestampcolumn");
  +         dataSourceName  = configuration.get("resource.datasource");
  +         tableName       = configuration.get("resource.table");
  +         keyColumn       = configuration.get("resource.keycolumn");
  +         templateColumn  = configuration.get("resource.templatecolumn");
  +         timestampColumn = configuration.get("resource.timestampcolumn");
  +         
            Runtime.info("Resources Loaded From: " + dataSourceName + "/" + tableName);
            Runtime.info( "Resource Loader using columns: " + keyColumn + ", "
                          + templateColumn + " and " + timestampColumn);
  
  
  
  1.4       +19 -15    jakarta-velocity/src/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java
  
  Index: FileResourceLoader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FileResourceLoader.java	2001/02/26 03:33:21	1.3
  +++ FileResourceLoader.java	2001/03/03 20:33:22	1.4
  @@ -64,6 +64,7 @@
   import java.util.Hashtable;
   
   import org.apache.velocity.util.StringUtils;
  +import org.apache.velocity.runtime.configuration.Configuration;
   import org.apache.velocity.runtime.Runtime;
   import org.apache.velocity.runtime.resource.Resource;
   
  @@ -76,22 +77,15 @@
    * That'll change once we decide how we want to do configuration
    * 
    * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
  - * $Revision: 1.3 $
  + * $Revision: 1.4 $
    */
   public class FileResourceLoader extends ResourceLoader
   {
       private String path;
   
  -    /*
  -     * This should probably be moved into the super class,
  -     * the stand init stuff. For the properties that all
  -     * loaders will probably share.
  -     */
  -    public void init(Map initializer)
  +    public void init(Configuration configuration)
       {
  -        path = (String) initializer.get("resource.path");
  -        Runtime.info("Resources Loaded From: " +  new File(path).getAbsolutePath());
  -        Runtime.info("Resource Loader Initialized.");
  +        path = configuration.getString("resource.path");
       }
   
       /**
  @@ -171,16 +165,22 @@
           if ( file.canRead() )
           {
               if (file.lastModified() != resource.getLastModified())
  +            {
                   return true;
  +            }                
               else
  +            {
                   return false;
  +            }                
           }
           
  -        // If the file is now unreadable, or it has
  -        // just plain disappeared then we'll just say
  -        // that it's modified :-) When the loader attempts
  -        // to load the stream it will fail and the error
  -        // will be reported then.
  +        /*
  +         * If the file is now unreadable, or it has
  +         * just plain disappeared then we'll just say
  +         * that it's modified :-) When the loader attempts
  +         * to load the stream it will fail and the error
  +         * will be reported then.
  +         */
           
           return true;
       }
  @@ -190,8 +190,12 @@
           File file = new File(path, resource.getName());
       
           if (file.canRead())
  +        {
               return file.lastModified();
  +        }            
           else
  +        {
               return 0;
  +        }            
       }
   }
  
  
  
  1.3       +4 -11     jakarta-velocity/src/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java
  
  Index: JarResourceLoader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JarResourceLoader.java	2001/03/03 16:18:19	1.2
  +++ JarResourceLoader.java	2001/03/03 20:33:22	1.3
  @@ -75,7 +75,7 @@
   
   import org.apache.velocity.util.StringUtils;
   import org.apache.velocity.runtime.Runtime;
  -import org.apache.velocity.runtime.configuration.VelocityResources;
  +import org.apache.velocity.runtime.configuration.Configuration;
   import org.apache.velocity.runtime.resource.Resource;
   
   import org.apache.velocity.exception.ResourceNotFoundException;
  @@ -88,7 +88,7 @@
    * Jason Van Zyl's FileResourceLoader.java
    * 
    * @author <a href="mailto:daveb@miceda-data.com">Dave Bryson</a>
  - * $Revision: 1.2 $
  + * $Revision: 1.3 $
    */
   public class JarResourceLoader extends ResourceLoader
   {
  @@ -102,16 +102,9 @@
        */
       protected JarFile jarFile = null;
       
  -    /*
  -     * This should probably be moved into the super class,
  -     * the stand init stuff. For the properties that all
  -     * loaders will probably share.
  -     * @param initialize the Map of paths to load
  -     */
  -    public void init(Map initializer)
  +    public void init(Configuration configuration)
       {
  -        String path = (String) initializer.get("resource.path");
  -        
  +        String path = configuration.getString("resource.path");
           setJarUrl( path );
           
           Runtime.info("Resources Loaded From: " +  path);
  
  
  
  1.5       +10 -12    jakarta-velocity/src/java/org/apache/velocity/runtime/resource/loader/ResourceLoader.java
  
  Index: ResourceLoader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/resource/loader/ResourceLoader.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ResourceLoader.java	2001/02/26 03:33:22	1.4
  +++ ResourceLoader.java	2001/03/03 20:33:22	1.5
  @@ -58,6 +58,7 @@
   import java.util.Map;
   
   import org.apache.velocity.runtime.Runtime;
  +import org.apache.velocity.runtime.configuration.Configuration;
   import org.apache.velocity.runtime.resource.Resource;
   
   import org.apache.velocity.exception.ResourceNotFoundException;
  @@ -67,7 +68,7 @@
    * extend.
    * 
    * @autor <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
  - * $Id: ResourceLoader.java,v 1.4 2001/02/26 03:33:22 geirm Exp $
  + * $Id: ResourceLoader.java,v 1.5 2001/03/03 20:33:22 jvanzyl Exp $
    */
   public abstract class ResourceLoader
   {
  @@ -94,28 +95,25 @@
        * loaders and must be called to set up common
        * properties shared by all resource loaders
        */
  -    public void commonInit(Map initializer)
  +    public void commonInit(Configuration configuration)
       {
  -        isCachingOn = new Boolean((String)initializer
  -            .get("cache")).booleanValue();
  -        
  -        modificationCheckInterval = Long.parseLong((String)initializer
  -            .get("modificationCheckInterval"));
  -            
  -        className = (String)initializer.get("class");
  +        isCachingOn = configuration.getBoolean("cache");
  +        modificationCheckInterval = configuration.getLong("modificationCheckInterval");
  +        className = configuration.getString("class");
       }
   
       /** 
        * Initialize the template loader with a
  -     * Map.
  +     * a resources class.
        */
  -    public abstract void init(Map initializer);
  +    public abstract void init(Configuration configuration);
   
       /** 
        * Get the InputStream that the Runtime will parse
        * to create a template.
        */
  -    public abstract InputStream getResourceStream( String source ) throws ResourceNotFoundException;
  +    public abstract InputStream getResourceStream( String source ) 
  +        throws ResourceNotFoundException;
   
       /**
        * Given a template, check to see if the source of InputStream
  
  
  

Mime
View raw message