Class SpringResourceLoader


  • public class SpringResourceLoader
    extends ResourceLoader
    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:
    VelocityEngineFactory.setResourceLoaderPath(java.lang.String), ResourceLoader, FileResourceLoader
    • Constructor Detail

      • SpringResourceLoader

        public SpringResourceLoader()
    • Method Detail

      • isSourceModified

        public boolean isSourceModified​(Resource resource)
        Description copied from class: ResourceLoader
        Given a template, check to see if the source of InputStream has been modified.
        Specified by:
        isSourceModified in class ResourceLoader
        Returns:
        True if the resource has been modified.
      • getLastModified

        public long getLastModified​(Resource resource)
        Description copied from class: ResourceLoader
        Get 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:
        getLastModified in class ResourceLoader
        Returns:
        Time in millis when the resource has been modified.