info.magnolia.freemarker.loaders
Class AbstractDelegatingTemplateLoader

java.lang.Object
  extended by info.magnolia.freemarker.loaders.AbstractDelegatingTemplateLoader
All Implemented Interfaces:
freemarker.cache.TemplateLoader
Direct Known Subclasses:
LazyFileTemplateLoader, LazyWebappTemplateLoader

public abstract class AbstractDelegatingTemplateLoader
extends Object
implements freemarker.cache.TemplateLoader

An abstract TemplateLoader that will attempt to initialize its delegate TemplateLoader and use a null object implementation until it succeeds. This allows us to wrap existing, constructor-configured TemplateLoader implementations, into content2bean-able beans, thus making them configurable in Magnolia's config repository.

Version:
$Id: $
Author:
gjoseph

Constructor Summary
AbstractDelegatingTemplateLoader()
           
 
Method Summary
 void closeTemplateSource(Object templateSource)
           
 Object findTemplateSource(String name)
           
protected  freemarker.cache.TemplateLoader getDelegate()
          First attempts to initialize a new delegate if needed.
 long getLastModified(Object templateSource)
           
 Reader getReader(Object templateSource, String encoding)
           
protected abstract  freemarker.cache.TemplateLoader newDelegate()
          Implementations should return null if it is too early to instantiate the delegate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDelegatingTemplateLoader

public AbstractDelegatingTemplateLoader()
Method Detail

findTemplateSource

public Object findTemplateSource(String name)
                          throws IOException
Specified by:
findTemplateSource in interface freemarker.cache.TemplateLoader
Throws:
IOException

getLastModified

public long getLastModified(Object templateSource)
Specified by:
getLastModified in interface freemarker.cache.TemplateLoader

getReader

public Reader getReader(Object templateSource,
                        String encoding)
                 throws IOException
Specified by:
getReader in interface freemarker.cache.TemplateLoader
Throws:
IOException

closeTemplateSource

public void closeTemplateSource(Object templateSource)
                         throws IOException
Specified by:
closeTemplateSource in interface freemarker.cache.TemplateLoader
Throws:
IOException

getDelegate

protected freemarker.cache.TemplateLoader getDelegate()
First attempts to initialize a new delegate if needed. If it doesn't succeed, use the NullTemplateLoader.


newDelegate

protected abstract freemarker.cache.TemplateLoader newDelegate()
Implementations should return null if it is too early to instantiate the delegate.



Copyright © 2003–2014 Magnolia International Ltd.. All rights reserved.