org.springframework.extensions.webscripts
Class TemplateProcessorRegistry

java.lang.Object
  extended by org.springframework.extensions.webscripts.TemplateProcessorRegistry

public class TemplateProcessorRegistry
extends Object

Registry of Template Processors If no processors are registered, the default script processor is the freemarker processor.

Author:
muzquiano

Constructor Summary
TemplateProcessorRegistry()
           
 
Method Summary
 String findValidTemplatePath(String path)
          Returns a variation on the provided path that exists and is processable by one of the processors in this registry.
protected  TemplateProcessor getDefaultTemplateProcessor()
          Gets the default template processor.
 String getExtensionForProcessor(TemplateProcessor templateProcessor)
          Gets the extension for given processor.
 String[] getRegisteredExtensions()
          Returns the extensions with registered processors
 TemplateProcessor getTemplateProcessor(String path)
          Returns the best fit template processor for the given path If a template processor cannot be matched to the path, the default template processor will be returned.
 TemplateProcessor getTemplateProcessorByExtension(String extension)
          Gets the template processor registered for the given extension
 void registerTemplateProcessor(TemplateProcessor templateProcessor)
          Registers a template processor
 void registerTemplateProcessor(TemplateProcessor templateProcessor, String extension, String name)
          Registers a template processor
 void reset()
          Resets all of the registered template processors
 void setDefaultTemplateProcessor(String defaultTemplateProcessorName)
          Sets the name of the default template processor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateProcessorRegistry

public TemplateProcessorRegistry()
Method Detail

setDefaultTemplateProcessor

public void setDefaultTemplateProcessor(String defaultTemplateProcessorName)
Sets the name of the default template processor

Parameters:
defaultTemplateProcessor - the name of the default template processor

registerTemplateProcessor

public void registerTemplateProcessor(TemplateProcessor templateProcessor)
Registers a template processor

Parameters:
templateProcessor - the template processor to register

registerTemplateProcessor

public void registerTemplateProcessor(TemplateProcessor templateProcessor,
                                      String extension,
                                      String name)
Registers a template processor

Parameters:
templateProcessor - the template processor to register
extension -
name -

getDefaultTemplateProcessor

protected TemplateProcessor getDefaultTemplateProcessor()
Gets the default template processor.

Returns:
the default template processor

getTemplateProcessor

public TemplateProcessor getTemplateProcessor(String path)
Returns the best fit template processor for the given path If a template processor cannot be matched to the path, the default template processor will be returned.

Parameters:
path - the path
Returns:
the template processor

getTemplateProcessorByExtension

public TemplateProcessor getTemplateProcessorByExtension(String extension)
Gets the template processor registered for the given extension

Parameters:
extension - the extension
Returns:
the template processor by extension

findValidTemplatePath

public String findValidTemplatePath(String path)
Returns a variation on the provided path that exists and is processable by one of the processors in this registry. First attempts to find a template processor that contains the content located at the given path (using extension information, if available). If no match is found, iterates over the file extensions and attempts to find a match. Path can therefore be values like: testfile.ftl - matches to file testfile.ftl using freemarker procesor testfile - matches for all extensions, potentially looking at testfile.ftl, testfile.php, etc. The extension annotated path is returned which will correctly dispatch to the discovered processor.

Parameters:
path - the path
Returns:
a valid processor file path or null if no match

getRegisteredExtensions

public String[] getRegisteredExtensions()
Returns the extensions with registered processors

Returns:
the registered extensions

getExtensionForProcessor

public String getExtensionForProcessor(TemplateProcessor templateProcessor)
Gets the extension for given processor.

Parameters:
templateProcessor - the template processor
Returns:
the extension for processor

reset

public void reset()
Resets all of the registered template processors



Copyright © 2009 SpringSource, Inc. All Rights Reserved.