org.apache.velocity.runtime.resource
Class ResourceManager

java.lang.Object
  |
  +--org.apache.velocity.runtime.resource.ResourceManager

public class ResourceManager
extends java.lang.Object

Class to manage the text resource for the Velocity Runtime.

Version:
$Id: ResourceManager.java,v 1.22 2001/04/07 08:50:36 dlr Exp $
Author:
Jason van Zyl, Paulo Gaspar, Geir Magnusson Jr.

Field Summary
private static java.util.Hashtable globalCache
          Hashtable used to store templates that have been processed.
static int RESOURCE_CONTENT
          A static content resource.
static int RESOURCE_TEMPLATE
          A template resources.
private static boolean resourceLoaderInitializersActive
          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 java.util.ArrayList resourceLoaders
          The List of templateLoaders that the Runtime will use to locate the InputStream source of a template.
private static java.util.ArrayList sourceInitializerList
          This is a list of the template input stream source initializers, basically properties for a particular template stream source.
private static java.util.Hashtable sourceInitializerMap
          This is a map of public name of the template stream source to it's initializer.
 
Constructor Summary
ResourceManager()
           
 
Method Summary
private static void assembleResourceLoaderInitializers()
          This will produce a List of Hashtables, each hashtable contains the intialization info for a particular resource loader.
static Resource getResource(java.lang.String resourceName, int resourceType)
          Gets the named resource.
static void initialize()
          Initialize the ResourceManager.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

RESOURCE_TEMPLATE

public static final int RESOURCE_TEMPLATE
A template resources.

RESOURCE_CONTENT

public static final int RESOURCE_CONTENT
A static content resource.

globalCache

private static java.util.Hashtable globalCache
Hashtable used to store templates that have been processed. Our simple caching mechanism.

resourceLoaders

private static java.util.ArrayList resourceLoaders
The List of templateLoaders that the Runtime will use to locate the InputStream source of a template.

sourceInitializerList

private static java.util.ArrayList sourceInitializerList
This is a list of the template input stream source initializers, basically properties for a particular template stream source. The order in this list reflects numbering of the properties i.e. .resource.loader. =

sourceInitializerMap

private static java.util.Hashtable sourceInitializerMap
This is a map of public name of the template stream source to it's initializer. This is so that clients of velocity can set properties of a template source stream with its public name. So for example, a client could set the File.resource.path property and this would change the resource.path property for the file template stream source.

resourceLoaderInitializersActive

private static boolean resourceLoaderInitializersActive
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.
Constructor Detail

ResourceManager

public ResourceManager()
Method Detail

initialize

public static void initialize()
                       throws java.lang.Exception
Initialize the ResourceManager. It is assumed that assembleSourceInitializers() has been called before this is run.

assembleResourceLoaderInitializers

private static void assembleResourceLoaderInitializers()
This will produce a List of Hashtables, each hashtable contains the intialization info for a particular resource loader. This Hastable will be passed in when initializing the the template loader.

getResource

public static Resource getResource(java.lang.String resourceName,
                                   int resourceType)
                            throws ResourceNotFoundException,
                                   ParseErrorException,
                                   java.lang.Exception
Gets the named resource. Returned class type corresponds to specified type (i.e. Template to RESOURCE_TEMPLATE).
Parameters:
resourceName - The name of the resource to retrieve.
resourceType - The type of resource (RESOURCE_TEMPLATE, RESOURCE_CONTENT, etc.).
Returns:
Resource with the template parsed and ready.
Throws:
ResourceNotFoundException - if template not found from any available source.
ParseErrorException - if template cannot be parsed due to syntax (or other) error.
java.lang.Exception - if a problem in parse


Copyright © 2001 Apache Software Foundation. All Rights Reserved.