Class FileResourceLoader
java.lang.Object
org.apache.velocity.runtime.resource.loader.ResourceLoader
org.apache.velocity.runtime.resource.loader.FileResourceLoader
A loader for templates stored on the file system. Treats the template
as relative to the configured root path. If the root path is empty
treats the template name as an absolute path.
- Version:
- $Id$
- Author:
- Will Glass-Husain, Aki Nieminen, Jason van Zyl
-
Field Summary
Fields inherited from class org.apache.velocity.runtime.resource.loader.ResourceLoader
className, isCachingOn, log, modificationCheckInterval, rsvc
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionlong
getLastModified
(Resource resource) Get the last modified time of the InputStream source that was used to create the template.getResourceReader
(String templateName, String encoding) Get a Reader so that the Runtime can build a template with it.void
init
(ExtProperties 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.boolean
resourceExists
(String name) Overrides superclass for better performance.Methods inherited from class org.apache.velocity.runtime.resource.loader.ResourceLoader
buildReader, commonInit, getClassName, getModificationCheckInterval, isCachingOn, setCachingOn, setModificationCheckInterval
-
Constructor Details
-
FileResourceLoader
public FileResourceLoader()
-
-
Method Details
-
init
Description copied from class:ResourceLoader
Initialize the template loader with a a resources class.- Specified by:
init
in classResourceLoader
- Parameters:
configuration
-- See Also:
-
getResourceReader
public Reader getResourceReader(String templateName, String encoding) throws ResourceNotFoundException Get a Reader so that the Runtime can build a template with it.- Specified by:
getResourceReader
in classResourceLoader
- Parameters:
templateName
- name of template to getencoding
-- Returns:
- Reader containing the template
- Throws:
ResourceNotFoundException
- if template not found in the file template path.- Since:
- 2.0
-
resourceExists
Overrides superclass for better performance.- Overrides:
resourceExists
in classResourceLoader
- Parameters:
name
- The name of a resource.- Returns:
- true if a resource exists and can be accessed.
- Since:
- 1.6
-
isSourceModified
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.- Specified by:
isSourceModified
in classResourceLoader
- Parameters:
resource
-- Returns:
- True if the source has been modified.
-
getLastModified
Description copied from class:ResourceLoader
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.- Specified by:
getLastModified
in classResourceLoader
- Parameters:
resource
-- Returns:
- Time in millis when the resource has been modified.
- See Also:
-