|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--org.apache.velocity.runtime.resource.loader.ResourceLoader
|
+--org.apache.velocity.runtime.resource.loader.JarResourceLoader
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.loader = jar
jar.resource.loader.class = org.apache.velocity.runtime.resource.loader.JarResourceLoader
jar.resource.loader.path = list of JAR <URL>s
So for example, if you had a jar file on your local filesystem, you could simply do
jar.resource.loader.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
| Field Summary | |
private java.util.Hashtable |
entryDirectory
Maps entries to the parent JAR File Key = the entry *excluding* plain directories Value = the JAR URL |
private java.util.Hashtable |
jarfiles
Maps JAR URLs to the actual JAR Key = the JAR URL Value = the JAR |
| Fields inherited from class org.apache.velocity.runtime.resource.loader.ResourceLoader |
className, isCachingOn, modificationCheckInterval, rsvc |
| Constructor Summary | |
JarResourceLoader()
|
|
| Method Summary | |
private void |
addEntries(java.util.Hashtable entries)
Copy all the entries into the entryDirectory It will overwrite any duplicate keys. |
private void |
closeJar(java.lang.String path)
Closes a Jar file and set its URLConnection to null. |
long |
getLastModified(Resource resource)
Get the last modified time of the InputStream source that was used to create the template. |
java.io.InputStream |
getResourceStream(java.lang.String source)
Get an InputStream so that the Runtime can build a template with it. |
void |
init(org.apache.commons.collections.ExtendedProperties 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. |
private void |
loadJar(java.lang.String path)
|
| Methods inherited from class org.apache.velocity.runtime.resource.loader.ResourceLoader |
commonInit, getClassName, getModificationCheckInterval, isCachingOn, setCachingOn, setModificationCheckInterval |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
private java.util.Hashtable entryDirectory
private java.util.Hashtable jarfiles
| Constructor Detail |
public JarResourceLoader()
| Method Detail |
public void init(org.apache.commons.collections.ExtendedProperties configuration)
init in class ResourceLoaderprivate void loadJar(java.lang.String path)
private void closeJar(java.lang.String path)
private void addEntries(java.util.Hashtable entries)
public java.io.InputStream getResourceStream(java.lang.String source)
throws ResourceNotFoundException
getResourceStream in class ResourceLoadername - name of template to getResourceNotFoundException - if template not found
in the file template path.public boolean isSourceModified(Resource resource)
ResourceLoaderisSourceModified in class ResourceLoaderpublic long getLastModified(Resource resource)
ResourceLoadergetLastModified in class ResourceLoader
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||