|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.velocity.runtime.resource.loader.ResourceLoader | +--org.apache.velocity.tools.view.servlet.WebappLoader
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.
Field Summary | |
protected java.lang.String[] |
paths
The root paths for templates (relative to webapp's root). |
protected javax.servlet.ServletContext |
servletContext
|
Fields inherited from class org.apache.velocity.runtime.resource.loader.ResourceLoader |
className, isCachingOn, modificationCheckInterval, rsvc |
Constructor Summary | |
WebappLoader()
|
Method Summary | |
long |
getLastModified(org.apache.velocity.runtime.resource.Resource resource)
Defaults to return 0 |
java.io.InputStream |
getResourceStream(java.lang.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(org.apache.velocity.runtime.resource.Resource resource)
Defaults to return false. |
Methods inherited from class org.apache.velocity.runtime.resource.loader.ResourceLoader |
commonInit, getClassName, getModificationCheckInterval, isCachingOn, setCachingOn, setModificationCheckInterval |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.lang.String[] paths
protected javax.servlet.ServletContext servletContext
Constructor Detail |
public WebappLoader()
Method Detail |
public void init(org.apache.commons.collections.ExtendedProperties configuration)
init
in class org.apache.velocity.runtime.resource.loader.ResourceLoader
configuration
- the ExtendedProperties
associated with
this resource loader.public java.io.InputStream getResourceStream(java.lang.String name) throws org.apache.velocity.exception.ResourceNotFoundException
getResourceStream
in class org.apache.velocity.runtime.resource.loader.ResourceLoader
name
- name of template to get
org.apache.velocity.exception.ResourceNotFoundException
- if template not found
in classpath.public boolean isSourceModified(org.apache.velocity.runtime.resource.Resource resource)
isSourceModified
in class org.apache.velocity.runtime.resource.loader.ResourceLoader
public long getLastModified(org.apache.velocity.runtime.resource.Resource resource)
getLastModified
in class org.apache.velocity.runtime.resource.loader.ResourceLoader
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |