edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.dataConnector
Class TemplateEngine

java.lang.Object
  extended by edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.dataConnector.TemplateEngine

public class TemplateEngine
extends Object

A velocity based template engine that pulls information from a resolution context for use within the template.


Nested Class Summary
static interface TemplateEngine.CharacterEscapingStrategy
          Represents a domain specific strategy for escaping values used within a template.
 
Constructor Summary
TemplateEngine(org.apache.velocity.app.VelocityEngine engine)
          Constructor.
 
Method Summary
 String createStatement(String templateName, ShibbolethResolutionContext resolutionContext, List<String> dependencies, TemplateEngine.CharacterEscapingStrategy escapingStrategy)
          Create a statement from a give template by replacing it's macro's with information within the resolution context.
protected  org.apache.velocity.VelocityContext createVelocityContext(ShibbolethResolutionContext resolutionContext, List<String> dependencies, TemplateEngine.CharacterEscapingStrategy escapingStrategy)
          Creates the velocity context from the given resolution context.
protected  List<Object> prepareAttributeValues(BaseAttribute attribute, TemplateEngine.CharacterEscapingStrategy escapingStrategy)
          Prepares an attributes values for use within a template.
 void registerTemplate(String templateName, String template)
          Registers a template under a given name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateEngine

public TemplateEngine(org.apache.velocity.app.VelocityEngine engine)
Constructor.

Parameters:
engine - velocity engine used to evaluate templates
Method Detail

registerTemplate

public void registerTemplate(String templateName,
                             String template)
Registers a template under a given name.

Parameters:
templateName - name to register the template under
template - template to register

createStatement

public String createStatement(String templateName,
                              ShibbolethResolutionContext resolutionContext,
                              List<String> dependencies,
                              TemplateEngine.CharacterEscapingStrategy escapingStrategy)
                       throws AttributeResolutionException
Create a statement from a give template by replacing it's macro's with information within the resolution context.

Parameters:
templateName - name of the template
resolutionContext - the current resolution context
dependencies - the list of resolution plug-in dependencies that will provider attributes
escapingStrategy - strategy used to escape values, may be null if no escaping is necessary
Returns:
constructed statement
Throws:
AttributeResolutionException - thrown if the given template can not be populated because it is malformed or the given data connectors or attribute definitions error out during resolution

createVelocityContext

protected org.apache.velocity.VelocityContext createVelocityContext(ShibbolethResolutionContext resolutionContext,
                                                                    List<String> dependencies,
                                                                    TemplateEngine.CharacterEscapingStrategy escapingStrategy)
                                                             throws AttributeResolutionException
Creates the velocity context from the given resolution context.

Parameters:
resolutionContext - the resolution context containing the currently resolved attribute information
dependencies - resolution plug-in dependencies that will provide attributes to the velocity context
escapingStrategy - strategy used to escape values
Returns:
the velocity context to use when evaluating the template
Throws:
AttributeResolutionException - thrown if a resolution plugin errors out while resolving its attributes

prepareAttributeValues

protected List<Object> prepareAttributeValues(BaseAttribute attribute,
                                              TemplateEngine.CharacterEscapingStrategy escapingStrategy)
Prepares an attributes values for use within a template.

Parameters:
attribute - attribute whose values are to be prepared
escapingStrategy - character escaping strategy to be sued
Returns:
prepared values


Copyright © 2006-2009 Internet2. All Rights Reserved.