Package org.restlet.ext.freemarker
Class ContextTemplateLoader
- java.lang.Object
-
- org.restlet.ext.freemarker.ContextTemplateLoader
-
- All Implemented Interfaces:
freemarker.cache.TemplateLoader
public class ContextTemplateLoader extends java.lang.Object implements freemarker.cache.TemplateLoader
FreeMarker template loader based on a Context's client dispatcher. You can set an instance on a FreeMarker configuration via theConfiguration.setTemplateLoader(TemplateLoader)
method.- Author:
- Jerome Louvel
-
-
Constructor Summary
Constructors Constructor Description ContextTemplateLoader(org.restlet.Context context, java.lang.String baseUri)
Constructor.ContextTemplateLoader(org.restlet.Context context, org.restlet.data.Reference baseRef)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
closeTemplateSource(java.lang.Object templateSource)
Close the template source.java.lang.Object
findTemplateSource(java.lang.String name)
Finds the object that acts as the source of the template with the given name.long
getLastModified(java.lang.Object templateSource)
Returns the modification time.java.io.Reader
getReader(java.lang.Object templateSource, java.lang.String characterSet)
Returns the reader for the template source.
-
-
-
Constructor Detail
-
ContextTemplateLoader
public ContextTemplateLoader(org.restlet.Context context, org.restlet.data.Reference baseRef)
Constructor.- Parameters:
context
- The Restlet context.baseRef
- The base reference.
-
ContextTemplateLoader
public ContextTemplateLoader(org.restlet.Context context, java.lang.String baseUri)
Constructor.- Parameters:
context
- The Restlet context.baseUri
- The base URI.
-
-
Method Detail
-
closeTemplateSource
public void closeTemplateSource(java.lang.Object templateSource) throws java.io.IOException
Close the template source.- Specified by:
closeTemplateSource
in interfacefreemarker.cache.TemplateLoader
- Parameters:
templateSource
- The template sourceRepresentation
.- Throws:
java.io.IOException
-
findTemplateSource
public java.lang.Object findTemplateSource(java.lang.String name) throws java.io.IOException
Finds the object that acts as the source of the template with the given name.- Specified by:
findTemplateSource
in interfacefreemarker.cache.TemplateLoader
- Parameters:
name
- The template name.- Returns:
- The template source
Representation
. - Throws:
java.io.IOException
-
getLastModified
public long getLastModified(java.lang.Object templateSource)
Returns the modification time.- Specified by:
getLastModified
in interfacefreemarker.cache.TemplateLoader
- Parameters:
templateSource
- The template sourceRepresentation
.- Returns:
- The modification time.
-
getReader
public java.io.Reader getReader(java.lang.Object templateSource, java.lang.String characterSet) throws java.io.IOException
Returns the reader for the template source.- Specified by:
getReader
in interfacefreemarker.cache.TemplateLoader
- Parameters:
templateSource
- The template sourceRepresentation
.characterSet
- The reader character set.- Throws:
java.io.IOException
-
-