Package org.springframework.ui.freemarker

# Class SpringTemplateLoader

java.lang.Object
org.springframework.ui.freemarker.SpringTemplateLoader

All Implemented Interfaces:
  `freemarker.cache.TemplateLoader`

public class SpringTemplateLoader extends Object implements freemarker.cache.TemplateLoader
FreeMarker `TemplateLoader` adapter that loads template files via a Spring `ResourceLoader`.

Used by `FreeMarkerConfigurationFactory` for any resource loader path that cannot be resolved to a `File`.

Since:
  14.03.2004
Author:
  Juergen Hoeller
See Also:
  - `FreeMarkerConfigurationFactory.setTemplateLoaderPath(java.lang.String)`
  - `Configuration.setDirectoryForTemplateLoading(java.io.File)`

## Field Summary

Fields
Modifier and Type
Field
Description
`protected final org.apache.commons.logging.Log`
`logger`

## Constructor Summary

Constructors
Constructor
Description
`SpringTemplateLoader(org.springframework.core.io.ResourceLoader resourceLoader, String templateLoaderPath)`
Create a new `SpringTemplateLoader`.

## Method Summary

Modifier and Type
Method
Description
`void`
`closeTemplateSource(Object templateSource)`
`Object`
`findTemplateSource(String name)`
`long`
`getLastModified(Object templateSource)`
`Reader`
`getReader(Object templateSource, String encoding)`

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

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

## Field Details

### logger

protected final org.apache.commons.logging.Log logger

## Constructor Details

### SpringTemplateLoader

public SpringTemplateLoader(org.springframework.core.io.ResourceLoader resourceLoader, String templateLoaderPath)
Create a new `SpringTemplateLoader`.

Parameters:
  `resourceLoader` - the Spring ResourceLoader to use
  `templateLoaderPath` - the template loader path to use

## Method Details

### findTemplateSource

@Nullable public Object findTemplateSource(String name) throws IOException

Specified by:
  `findTemplateSource` in interface `freemarker.cache.TemplateLoader`
Throws:
  `IOException`

### getReader

public Reader getReader(Object templateSource, String encoding) throws IOException

Specified by:
  `getReader` in interface `freemarker.cache.TemplateLoader`
Throws:
  `IOException`

### getLastModified

public long getLastModified(Object templateSource)

Specified by:
  `getLastModified` in interface `freemarker.cache.TemplateLoader`

### closeTemplateSource

public void closeTemplateSource(Object templateSource) throws IOException

Specified by:
  `closeTemplateSource` in interface `freemarker.cache.TemplateLoader`
Throws:
  `IOException`