Package org.apache.velocity.spring
Class SpringResourceLoader
java.lang.Object
org.apache.velocity.runtime.resource.loader.ResourceLoader
org.apache.velocity.spring.SpringResourceLoader
Velocity ResourceLoader adapter that loads via a Spring ResourceLoader.
 Used by VelocityEngineFactory for any resource loader path that cannot
 be resolved to a 
java.io.File.
 Note that this loader does not allow for modification detection:
 Use Velocity's default FileResourceLoader for java.io.File
 resources.
 
Expects "spring.resource.loader" and "spring.resource.loader.path"
 application attributes in the Velocity runtime: the former of type
 org.springframework.core.io.ResourceLoader, the latter a String.
- Since:
 - 2020-05-29
 - Author:
 - Juergen Hoeller, Claude Brisson
 - See Also:
 
- 
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.slf4j.Loggerstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class org.apache.velocity.runtime.resource.loader.ResourceLoader
className, isCachingOn, log, modificationCheckInterval, rsvc - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionlonggetLastModified(Resource resource) Get the last modified time of the InputStream source that was used to create the template.getResourceReader(String source, String encoding) Get the Reader that the Runtime will parse to create a template.voidinit(ExtProperties configuration) Initialize the template loader with a a resources class.booleanisSourceModified(Resource resource) Given a template, check to see if the source of InputStream has been modified.Methods inherited from class org.apache.velocity.runtime.resource.loader.ResourceLoader
buildReader, commonInit, getClassName, getModificationCheckInterval, isCachingOn, resourceExists, setCachingOn, setModificationCheckInterval 
- 
Field Details
- 
NAME
- See Also:
 
 - 
SPRING_RESOURCE_LOADER_CLASS
- See Also:
 
 - 
SPRING_RESOURCE_LOADER_CACHE
- See Also:
 
 - 
SPRING_RESOURCE_LOADER
- See Also:
 
 - 
SPRING_RESOURCE_LOADER_PATH
- See Also:
 
 - 
logger
protected final org.slf4j.Logger logger 
 - 
 - 
Constructor Details
- 
SpringResourceLoader
public SpringResourceLoader() 
 - 
 - 
Method Details
- 
init
Description copied from class:ResourceLoaderInitialize the template loader with a a resources class.- Specified by:
 initin classResourceLoader- Parameters:
 configuration-
 - 
getResourceReader
Get the Reader that the Runtime will parse to create a template.- Specified by:
 getResourceReaderin classResourceLoader- Parameters:
 source- resource nameencoding- resource encoding- Returns:
 - The reader for the requested resource.
 - Throws:
 ResourceNotFoundException- Since:
 - 2.0
 
 - 
isSourceModified
Description copied from class:ResourceLoaderGiven a template, check to see if the source of InputStream has been modified.- Specified by:
 isSourceModifiedin classResourceLoader- Parameters:
 resource-- Returns:
 - True if the resource has been modified.
 
 - 
getLastModified
Description copied from class:ResourceLoaderGet the last modified time of the InputStream source that was used to create the template. We need the template here because we have to extract the name of the template in order to locate the InputStream source.- Specified by:
 getLastModifiedin classResourceLoader- Parameters:
 resource-- Returns:
 - Time in millis when the resource has been modified.
 
 
 -