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 java.lang.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(java.lang.Object templateSource)
           
 java.lang.Object findTemplateSource(java.lang.String name)
           
protected  freemarker.cache.TemplateLoader getDelegate()
          First attempts to initialize a new delegate if needed.
 long getLastModified(java.lang.Object templateSource)
           
 java.io.Reader getReader(java.lang.Object templateSource, java.lang.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 java.lang.Object findTemplateSource(java.lang.String name)
                                    throws java.io.IOException
Specified by:
findTemplateSource in interface freemarker.cache.TemplateLoader
Throws:
java.io.IOException

getLastModified

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

getReader

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

closeTemplateSource

public void closeTemplateSource(java.lang.Object templateSource)
                         throws java.io.IOException
Specified by:
closeTemplateSource in interface freemarker.cache.TemplateLoader
Throws:
java.io.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-2011 Magnolia International Ltd.. All Rights Reserved.