org.apache.velocity.runtime.resource.loader
Class FileResourceLoader
public class FileResourceLoader
A loader for templates stored on the file system.
Version:
- Jason van Zyl
private Vector | paths - The paths to search for templates.
|
private Hashtable | templatePaths - Used to map the path that a template was found on
so that we can properly check the modification
times of the files.
|
private InputStream | findTemplate(String path, String template) - Try to find a template given a normalized path.
|
long | getLastModified(Resource resource) - Get the last modified time of the InputStream source
that was used to create the template.
|
InputStream | getResourceStream(String templateName) - Get an InputStream so that the Runtime can build a
template with it.
|
void | init(ExtendedProperties configuration) - Initialize the template loader with a
a resources class.
|
boolean | isSourceModified(Resource resource) - How to keep track of all the modified times
across the paths.
|
paths
private Vector paths
The paths to search for templates.
templatePaths
private Hashtable templatePaths
Used to map the path that a template was found on
so that we can properly check the modification
times of the files.
findTemplate
private InputStream findTemplate(String path,
String template)
Try to find a template given a normalized path.
- InputStream input stream that will be parsed
getLastModified
public long getLastModified(Resource resource)
Get the last modified time of the InputStream source
that was used to create the template. We need the template
here because we have to extract the name of the template
in order to locate the InputStream source.
- getLastModified in interface ResourceLoader
getResourceStream
public InputStream getResourceStream(String templateName)
throws ResourceNotFoundException
Get an InputStream so that the Runtime can build a
template with it.
- getResourceStream in interface ResourceLoader
- InputStream containing the template
ResourceNotFoundException
- if template not found
in the file template path.
init
public void init(ExtendedProperties configuration)
Initialize the template loader with a
a resources class.
- init in interface ResourceLoader
isSourceModified
public boolean isSourceModified(Resource resource)
How to keep track of all the modified times
across the paths. Note that a file might have
appeared in a directory which is earlier in the
path; so we should search the path and see if
the file we find that way is the same as the one
that we have cached.
- isSourceModified in interface ResourceLoader
Copyright B) 2002 Apache Software Foundation. All Rights Reserved.