public class JarResourceLoader extends ResourceLoader
ResourceLoader to load templates from multiple Jar files.
The configuration of the JarResourceLoader is straightforward - You simply add the JarResourceLoader to the configuration via
resource.loaders = jar
resource.loader.jar.class = org.apache.velocity.runtime.resource.loader.JarResourceLoader
resource.loader.jar.path = list of JAR <URL>s
So for example, if you had a jar file on your local filesystem, you could simply do
resource.loader.jar.path = jar:file:/opt/myfiles/jar1.jar
Note that jar specification for the .path
configuration property
conforms to the same rules for the java.net.JarUrlConnection class.
For a working example, see the unit test case, org.apache.velocity.test.MultiLoaderTestCase class
className, isCachingOn, log, modificationCheckInterval, rsvc
Constructor and Description |
---|
JarResourceLoader() |
Modifier and Type | Method and Description |
---|---|
long |
getLastModified(Resource resource)
Get the last modified time of the InputStream source
that was used to create the template.
|
Reader |
getResourceReader(String source,
String encoding)
Get a Reader so that the Runtime can build a
template with it.
|
void |
init(ExtProperties configuration)
Called by Velocity to initialize the loader
|
boolean |
isSourceModified(Resource resource)
Given a template, check to see if the source of InputStream
has been modified.
|
buildReader, commonInit, getClassName, getModificationCheckInterval, isCachingOn, resourceExists, setCachingOn, setModificationCheckInterval
public void init(ExtProperties configuration)
init
in class ResourceLoader
configuration
- public Reader getResourceReader(String source, String encoding) throws ResourceNotFoundException
getResourceReader
in class ResourceLoader
source
- name of template to getencoding
- asked encodingResourceNotFoundException
- if template not found
in the file template path.public boolean isSourceModified(Resource resource)
ResourceLoader
isSourceModified
in class ResourceLoader
ResourceLoader.isSourceModified(org.apache.velocity.runtime.resource.Resource)
public long getLastModified(Resource resource)
ResourceLoader
getLastModified
in class ResourceLoader
ResourceLoader.getLastModified(org.apache.velocity.runtime.resource.Resource)
Copyright © 2000–2020 The Apache Software Foundation. All rights reserved.