org.webmacro.resource
Class TemplateLoaderHelper

java.lang.Object
  extended byorg.webmacro.resource.TemplateLoaderHelper

public class TemplateLoaderHelper
extends java.lang.Object

Helper class for template loaders to actuall load a Template. This class should be used for loading templates from URLs or files. Thus, the template loader only has to care for locating the template.
This class will take care of loading the template and setting up a correct reload context, depending on the protocol used.

Author:
Sebastian Kanthak (sebastian.kanthak@muehlheim.de)

Constructor Summary
TemplateLoaderHelper()
          Construct a new TemplateLoaderHelper object
 
Method Summary
 void init(Broker b, Settings config)
          Initialize this object
 Template load(java.io.File file, CacheElement ce)
          Load a template from a file.
 Template load(java.net.URL url, CacheElement ce)
          Load a template from an url.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateLoaderHelper

public TemplateLoaderHelper()
Construct a new TemplateLoaderHelper object

Method Detail

init

public void init(Broker b,
                 Settings config)
          throws InitException
Initialize this object

Parameters:
b - broker to use
config - configuration to initialize from
Throws:
InitException

load

public Template load(java.io.File file,
                     CacheElement ce)
              throws ResourceException
Load a template from a file. This will load the template from the specified file and set up an appropriate reload context, if ce is not null. It will use the check-for-reload delay specified for protocol file.

Parameters:
file - file to load template from
ce - cache element for reload context or null, if no caching is used.
Returns:
loaded template
Throws:
ResourceException - if template could not be loaded or parsed.

load

public Template load(java.net.URL url,
                     CacheElement ce)
              throws ResourceException
Load a template from an url. This will load the template from the specified url and set up an appropriate reload context, if ce is not null. It will use the check-for-reload delay specified for the url's protocol. If protocl is "file", the more efficient file operations of java are used.

Parameters:
url - url to load template from
ce - cache element for reload context or null, if no caching is used.
Returns:
loaded template
Throws:
ResourceException - if template could not be loaded or parsed.