no.sesat.search.view.velocity
Class VelocityEngineFactory

java.lang.Object
  extended by no.sesat.search.view.velocity.VelocityEngineFactory
All Implemented Interfaces:
SiteKeyedFactory

public final class VelocityEngineFactory
extends Object
implements SiteKeyedFactory

Custom Factory around Velocity Engines and Templates. Each instance maps to an VelocityEngine instance. All template operations (getting and merging) are done through this class rather than directly against Velocity's API. Developer Aid
Ola-marius extended the engine so to run in debug mode that outlines (& titles) each rendered template. See Debugging Velocity Templates

Version:
$Id: VelocityEngineFactory.java 7225 2009-04-09 00:32:20Z ssmiweve $

Nested Class Summary
static interface VelocityEngineFactory.Context
          The context the AnalysisRules must work against.
 
Method Summary
 org.apache.velocity.app.VelocityEngine getEngine()
           
static org.apache.velocity.Template getTemplate(org.apache.velocity.app.VelocityEngine engine, Site site, String templateName)
          Find the appropriate velocity Template by its name against a given engine and site.
static VelocityEngineFactory instanceOf(VelocityEngineFactory.Context cxt)
          Main method to retrieve the correct VelocityEngine to further obtain AnalysisRule.
static org.apache.velocity.VelocityContext newContextInstance()
           
 boolean remove(Site site)
          Remove the factory the maps to the given site.
static VelocityEngineFactory valueOf(Site site)
          Utility wrapper to the instanceOf(Context).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getTemplate

public static org.apache.velocity.Template getTemplate(org.apache.velocity.app.VelocityEngine engine,
                                                       Site site,
                                                       String templateName)
                                                throws org.apache.velocity.exception.ResourceNotFoundException
Find the appropriate velocity Template by its name against a given engine and site. Will throw a ResourceNotFoundException if not found.

Parameters:
engine - the VelocityEngine appropriate for the current site.
site - the current site.
templateName - the name of the template. must not contain ".vm" suffix.
Returns:
returns the template.
Throws:
org.apache.velocity.exception.ResourceNotFoundException - if the template was not found.

newContextInstance

public static org.apache.velocity.VelocityContext newContextInstance()

instanceOf

public static VelocityEngineFactory instanceOf(VelocityEngineFactory.Context cxt)
Main method to retrieve the correct VelocityEngine to further obtain AnalysisRule.

Parameters:
cxt - the contextual needs the VelocityEngine must use to operate.
Returns:
VelocityEngine for this site.

valueOf

public static VelocityEngineFactory valueOf(Site site)
Utility wrapper to the instanceOf(Context). Makes the presumption we will be using the UrlResourceLoader to load all resources.

Parameters:
site - the site the VelocityEngine will work for.
Returns:
VelocityEngine for this site.

getEngine

public org.apache.velocity.app.VelocityEngine getEngine()

remove

public boolean remove(Site site)
Description copied from interface: SiteKeyedFactory
Remove the factory the maps to the given site. *

Specified by:
remove in interface SiteKeyedFactory
Parameters:
site - remove factory corresponding to this site.
Returns:
true if a factory was successfully removed.


Copyright © 2005-2009 Schibsted ASA. All Rights Reserved.