Class URLResourceLoader
- java.lang.Object
-
- org.apache.velocity.runtime.resource.loader.ResourceLoader
-
- org.apache.velocity.runtime.resource.loader.URLResourceLoader
-
public class URLResourceLoader extends ResourceLoader
This is a simple URL-based loader.- Since:
- 1.5
- Version:
- $Id: URLResourceLoader.java 191743 2005-06-21 23:22:20Z dlr $
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String[]
roots
protected java.util.HashMap
templateRoots
private int
timeout
private java.lang.reflect.Method[]
timeoutMethods
-
Fields inherited from class org.apache.velocity.runtime.resource.loader.ResourceLoader
className, isCachingOn, log, modificationCheckInterval, rsvc
-
-
Constructor Summary
Constructors Constructor Description URLResourceLoader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getLastModified(Resource resource)
Checks to see when a resource was last modifiedjava.io.InputStream
getResourceStream(java.lang.String name)
Get an InputStream so that the Runtime can build a template with it.int
getTimeout()
Returns the current, custom timeout setting.void
init(org.apache.commons.collections.ExtendedProperties configuration)
Initialize the template loader with a a resources class.boolean
isSourceModified(Resource resource)
Checks to see if a resource has been deleted, moved or modified.private void
tryToSetTimeout(java.net.URLConnection conn)
-
Methods inherited from class org.apache.velocity.runtime.resource.loader.ResourceLoader
commonInit, getClassName, getModificationCheckInterval, isCachingOn, resourceExists, setCachingOn, setModificationCheckInterval
-
-
-
-
Method Detail
-
init
public void init(org.apache.commons.collections.ExtendedProperties configuration)
Description copied from class:ResourceLoader
Initialize the template loader with a a resources class.- Specified by:
init
in classResourceLoader
- See Also:
ResourceLoader.init(org.apache.commons.collections.ExtendedProperties)
-
getResourceStream
public java.io.InputStream getResourceStream(java.lang.String name) throws ResourceNotFoundException
Get an InputStream so that the Runtime can build a template with it.- Specified by:
getResourceStream
in classResourceLoader
- Parameters:
name
- name of template to fetch bytestream of- Returns:
- InputStream containing the template
- Throws:
ResourceNotFoundException
- if template not found in the file template path.
-
isSourceModified
public boolean isSourceModified(Resource resource)
Checks to see if a resource has been deleted, moved or modified.- Specified by:
isSourceModified
in classResourceLoader
- Parameters:
resource
- Resource The resource to check for modification- Returns:
- boolean True if the resource has been modified, moved, or unreachable
-
getLastModified
public long getLastModified(Resource resource)
Checks to see when a resource was last modified- Specified by:
getLastModified
in classResourceLoader
- Parameters:
resource
- Resource the resource to check- Returns:
- long The time when the resource was last modified or 0 if the file can't be reached
-
getTimeout
public int getTimeout()
Returns the current, custom timeout setting. If negative, there is no custom timeout.- Since:
- 1.6
-
tryToSetTimeout
private void tryToSetTimeout(java.net.URLConnection conn)
-
-