jvanzyl     00/12/19 13:46:53

  Modified:    src/java/org/apache/velocity/runtime Runtime.java
               src/java/org/apache/velocity/runtime/resource
                        ResourceManager.java
               src/java/org/apache/velocity/runtime/resource/loader
                        FileResourceLoader.java ResourceLoader.java
  Log:
  - minor fixes with the resource manager.
  
  Revision  Changes    Path
  1.77      +5 -5      
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.76
  retrieving revision 1.77
  diff -u -r1.76 -r1.77
  --- Runtime.java      2000/12/19 18:07:45     1.76
  +++ Runtime.java      2000/12/19 21:46:48     1.77
  @@ -201,7 +201,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.76 2000/12/19 18:07:45 jvanzyl Exp $
  + * @version $Id: Runtime.java,v 1.77 2000/12/19 21:46:48 jvanzyl Exp $
    */
   public class Runtime implements RuntimeConstants
   {    
  @@ -269,7 +269,7 @@
                   initializeDirectives();
                   initializeParserPool();
                   initializeGlobalCache();
  -
  +                
                   /*
                    *  initialize the VM Factory.  It will use the properties 
                    * accessable from Runtime, so keep this here at the end.
  @@ -562,7 +562,7 @@
        */
       public static void setSourceProperty(String key, String value)
       {
  -        info ("   ** Resource Loader Property Override : " + key + " = " + value);
  +        info ("   ** !!! Resource Loader Property Override : " + key + " = " + 
value);
           ResourceManager.setSourceProperty(key, value);
       }
   
  @@ -859,9 +859,9 @@
        * @param strKey  property key
        * @return   value of key or null
        */
  -    public static String getString( String strKey)
  +    public static String getString(String key)
       {
  -        return VelocityResources.getString( strKey );
  +        return VelocityResources.getString( key );
       }
   
       /**
  
  
  
  1.4       +7 -1      
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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ResourceManager.java      2000/12/19 16:16:43     1.3
  +++ ResourceManager.java      2000/12/19 21:46:50     1.4
  @@ -71,7 +71,7 @@
    * Runtime.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
  - * @version $Id: ResourceManager.java,v 1.3 2000/12/19 16:16:43 jvanzyl Exp $
  + * @version $Id: ResourceManager.java,v 1.4 2000/12/19 21:46:50 jvanzyl Exp $
    */
   public class ResourceManager
   {
  @@ -126,6 +126,7 @@
               Map initializer = (Map) sourceInitializerList.get(i);
               String loaderClass = (String) initializer.get("class");
               resourceLoader = ResourceLoaderFactory.getLoader(loaderClass);
  +            resourceLoader.commonInit(initializer);
               resourceLoader.init(initializer);
               resourceLoaders.add(resourceLoader);
           }
  @@ -234,10 +235,15 @@
                    * make a resource with.
                    */
                   
  +                //! Bug this is being run more then once!
  +                
                   for (int i = 0; i < resourceLoaders.size(); i++)
                   {
                       resourceLoader = (ResourceLoader) resourceLoaders.get(i);
                       resource.setResourceLoader(resourceLoader);
  +                    
  +                    Runtime.info("Attempting to find " + resourceName + 
  +                        " with " + resourceLoader.getClassName());
                       
                       if (resource.process())
                           break;
  
  
  
  1.2       +6 -1      
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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FileResourceLoader.java   2000/12/19 05:30:06     1.1
  +++ FileResourceLoader.java   2000/12/19 21:46:52     1.2
  @@ -73,7 +73,7 @@
    * That'll change once we decide how we want to do configuration
    * 
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
  - * $Revision: 1.1 $
  + * $Revision: 1.2 $
    */
   public class FileResourceLoader extends ResourceLoader
   {
  @@ -125,6 +125,11 @@
               return new BufferedInputStream(
                   new FileInputStream(file.getAbsolutePath()));
           }
  +        else
  +        {
  +            Runtime.error("FileResourceLoader Error: cannot find resource " +
  +                file.getAbsolutePath());
  +        }                
           
           return null;
       }
  
  
  
  1.2       +19 -3     
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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ResourceLoader.java       2000/12/19 05:30:06     1.1
  +++ ResourceLoader.java       2000/12/19 21:46:52     1.2
  @@ -65,7 +65,7 @@
    * extend.
    * 
    * @autor <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
  - * $Id: ResourceLoader.java,v 1.1 2000/12/19 05:30:06 jvanzyl Exp $
  + * $Id: ResourceLoader.java,v 1.2 2000/12/19 21:46:52 jvanzyl Exp $
    */
   public abstract class ResourceLoader
   {
  @@ -80,19 +80,27 @@
        * that are created with this loader.
        */
       protected long modificationCheckInterval = 2;
  -    
  +   
  +    /**
  +     * Class name for this loader, for logging/debuggin
  +     * purposes.
  +     */
  +     protected String className;
  +   
       /**
        * This initialization is used by all resource
        * loaders and must be called to set up common
        * properties shared by all resource loaders
        */
  -    protected void commonInit(Map initializer)
  +    public void commonInit(Map initializer)
       {
           isCachingOn = new Boolean((String)initializer
               .get("cache")).booleanValue();
           
           modificationCheckInterval = Long.parseLong((String)initializer
               .get("modificationCheckInterval"));
  +            
  +        className = (String)initializer.get("class");
       }
   
       /** 
  @@ -120,6 +128,14 @@
        * in order to locate the InputStream source.
        */
       public abstract long getLastModified(Resource resource);
  +
  +    /**
  +     * Return the class name of this resource Loader
  +     */
  +    public String getClassName()
  +    {
  +        return className;
  +    }        
   
       /**
        * Set the caching state. If true, then this loader
  
  
  

Reply via email to