Class TemplateProcessorRegistry
java.lang.Object
org.springframework.extensions.webscripts.TemplateProcessorRegistry
Registry of Template Processors.
If no processors are registered, the default script processor is the freemarker processor.
- Author:
- muzquiano, Kevin Roast
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindValidTemplatePath(String path) Returns a variation on the provided path that exists and is processable by one of the processors in this registry.protected TemplateProcessorGets the default template processor.getExtensionForProcessor(TemplateProcessor templateProcessor) Gets the extension for given processor.String[]Returns the extensions with registered processorsgetTemplateProcessor(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.getTemplateProcessorByExtension(String extension) Gets the template processor registered for the given extensionvoidregisterTemplateProcessor(TemplateProcessor templateProcessor) Registers a template processorvoidregisterTemplateProcessor(TemplateProcessor templateProcessor, String extension, String name) Registers a template processorvoidreset()Resets all of the registered template processorsvoidsetDefaultTemplateProcessor(String defaultTemplateProcessorName) Sets the name of the default template processor
-
Constructor Details
-
TemplateProcessorRegistry
public TemplateProcessorRegistry()
-
-
Method Details
-
setDefaultTemplateProcessor
Sets the name of the default template processor- Parameters:
defaultTemplateProcessorName- the name of the default template processor
-
registerTemplateProcessor
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 registerextension- Stringname- String
-
getDefaultTemplateProcessor
Gets the default template processor.- Returns:
- the default template processor
-
getTemplateProcessor
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
Gets the template processor registered for the given extension- Parameters:
extension- the extension- Returns:
- the template processor by extension
-
findValidTemplatePath
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
Returns the extensions with registered processors- Returns:
- the registered extensions
-
getExtensionForProcessor
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
-