Package net.shibboleth.shared.spring.velocity

# Class SpringResourceLoader

java.lang.Object
org.apache.velocity.runtime.resource.loader.ResourceLoader
net.shibboleth.shared.spring.velocity.SpringResourceLoader

public class SpringResourceLoader extends org.apache.velocity.runtime.resource.loader.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:
  6.0.0
See Also:
  - `VelocityEngineFactory.setResourceLoaderPath(java.lang.String)`
  - `ResourceLoader`
  - `FileResourceLoader`

## Field Summary

Fields
Modifier and Type
Field
Description
`private final org.slf4j.Logger`
`log`
Class logger.
`static final String`
`NAME`
Constant identifying resource loader name.
`private ResourceLoader`
`resourceLoader`
Underlying Spring resource loader.
`private String[]`
`resourceLoaderPaths`
Resource loader paths.
`static final String`
`SPRING_RESOURCE_LOADER`
Constant identifying `ResourceLoader` instance.
`static final String`
`SPRING_RESOURCE_LOADER_CACHE`
Constant identifying caching property.
`static final String`
`SPRING_RESOURCE_LOADER_CLASS`
Constant identifying resource loader class name.
`static final String`
`SPRING_RESOURCE_LOADER_PATH`
Constant identifying resource loader path.

### Fields inherited from class org.apache.velocity.runtime.resource.loader.ResourceLoader

`className, isCachingOn, modificationCheckInterval, rsvc`

## Constructor Summary

Constructors
Constructor
Description
`SpringResourceLoader()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`long`
`getLastModified(org.apache.velocity.runtime.resource.Resource resource)`
`Reader`
`getResourceReader(String source, String encoding)`
`void`
`init(org.apache.velocity.util.ExtProperties configuration)`
`boolean`
`isSourceModified(org.apache.velocity.runtime.resource.Resource resource)`

### Methods inherited from class org.apache.velocity.runtime.resource.loader.ResourceLoader

`buildReader, commonInit, getClassName, getModificationCheckInterval, isCachingOn, resourceExists, setCachingOn, setModificationCheckInterval`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### NAME

@Nonnull @NotEmpty public static final String NAME
Constant identifying resource loader name.

See Also:
  - Constant Field Values

### SPRING_RESOURCE_LOADER_CLASS

@Nonnull @NotEmpty public static final String SPRING_RESOURCE_LOADER_CLASS
Constant identifying resource loader class name.

See Also:
  - Constant Field Values

### SPRING_RESOURCE_LOADER_CACHE

@Nonnull @NotEmpty public static final String SPRING_RESOURCE_LOADER_CACHE
Constant identifying caching property.

See Also:
  - Constant Field Values

### SPRING_RESOURCE_LOADER

@Nonnull @NotEmpty public static final String SPRING_RESOURCE_LOADER
Constant identifying `ResourceLoader` instance.

See Also:
  - Constant Field Values

### SPRING_RESOURCE_LOADER_PATH

@Nonnull @NotEmpty public static final String SPRING_RESOURCE_LOADER_PATH
Constant identifying resource loader path.

See Also:
  - Constant Field Values

### log

@Nonnull private final org.slf4j.Logger log
Class logger.

### resourceLoader

@Nullable private ResourceLoader resourceLoader
Underlying Spring resource loader.

### resourceLoaderPaths

@Nonnull private String[] resourceLoaderPaths
Resource loader paths.

## Constructor Details

### SpringResourceLoader

public SpringResourceLoader()
Constructor.

## Method Details

### init

public void init(org.apache.velocity.util.ExtProperties configuration)

Specified by:
  `init` in class `org.apache.velocity.runtime.resource.loader.ResourceLoader`

### getResourceReader

public Reader getResourceReader(String source, String encoding) throws org.apache.velocity.exception.ResourceNotFoundException

Specified by:
  `getResourceReader` in class `org.apache.velocity.runtime.resource.loader.ResourceLoader`
Throws:
  `org.apache.velocity.exception.ResourceNotFoundException`

### isSourceModified

public boolean isSourceModified(org.apache.velocity.runtime.resource.Resource resource)

Specified by:
  `isSourceModified` in class `org.apache.velocity.runtime.resource.loader.ResourceLoader`

### getLastModified

public long getLastModified(org.apache.velocity.runtime.resource.Resource resource)

Specified by:
  `getLastModified` in class `org.apache.velocity.runtime.resource.loader.ResourceLoader`