|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.velocity.runtime.resource.loader.ResourceLoader
org.apache.velocity.tools.view.WebappResourceLoader
public class WebappResourceLoader
Resource loader that uses the ServletContext of a webapp to load Velocity templates. (it's much easier to use with servlets than the standard FileResourceLoader, in particular the use of war files is transparent). The default search path is '/' (relative to the webapp root), but you can change this behaviour by specifying one or more paths by mean of as many webapp.resource.loader.path properties as needed in the velocity.properties file. All paths must be relative to the root of the webapp. To enable caching and cache refreshing the webapp.resource.loader.cache and webapp.resource.loader.modificationCheckInterval properties need to be set in the velocity.properties file ... auto-reloading of global macros requires the webapp.resource.loader.cache property to be set to 'false'.
Field Summary | |
---|---|
protected String[] |
paths
The root paths for templates (relative to webapp's root). |
protected javax.servlet.ServletContext |
servletContext
|
protected HashMap |
templatePaths
|
Fields inherited from class org.apache.velocity.runtime.resource.loader.ResourceLoader |
---|
className, isCachingOn, log, modificationCheckInterval, rsvc |
Constructor Summary | |
---|---|
WebappResourceLoader()
|
Method Summary | |
---|---|
long |
getLastModified(Resource resource)
Checks to see when a resource was last modified |
InputStream |
getResourceStream(String name)
Get an InputStream so that the Runtime can build a template with it. |
void |
init(org.apache.commons.collections.ExtendedProperties configuration)
This is abstract in the base class, so we need it. |
boolean |
isSourceModified(Resource resource)
Checks to see if a resource has been deleted, moved or modified. |
Methods inherited from class org.apache.velocity.runtime.resource.loader.ResourceLoader |
---|
commonInit, getClassName, getModificationCheckInterval, isCachingOn, resourceExists, setCachingOn, setModificationCheckInterval |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected String[] paths
protected HashMap templatePaths
protected javax.servlet.ServletContext servletContext
Constructor Detail |
---|
public WebappResourceLoader()
Method Detail |
---|
public void init(org.apache.commons.collections.ExtendedProperties configuration)
init
in class ResourceLoader
configuration
- the ExtendedProperties
associated with
this resource loader.public InputStream getResourceStream(String name) throws ResourceNotFoundException
getResourceStream
in class ResourceLoader
name
- name of template to get
ResourceNotFoundException
- if template not found
in classpath.public boolean isSourceModified(Resource resource)
isSourceModified
in class ResourceLoader
resource
- Resource The resource to check for modification
public long getLastModified(Resource resource)
getLastModified
in class ResourceLoader
resource
- Resource the resource to check
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |