Class ScriptProcessorRegistry
java.lang.Object
org.springframework.extensions.webscripts.ScriptProcessorRegistry
Registry of Script Processors.
If no processors are registered, the default script processor is the javascript processor.
- Author:
- muzquiano, Kevin Roast
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindValidScriptPath(String path) Returns a variation on the provided path that exists and is processable by one of the processors in this registry.protected ScriptProcessorGets the default script processor.getExtensionForProcessor(ScriptProcessor scriptProcessor) Gets the extension for given processor.String[]Returns the extensions with registered processorsgetScriptProcessor(String path) Returns the script processor that matches the file extension for the given path.getScriptProcessor(ScriptContent scriptContent) Returns the best fit script processor for the given script content object.getScriptProcessorByExtension(String extension) Gets the script processor registered for the given extensionvoidregisterScriptProcessor(ScriptProcessor scriptProcessor) Registers a script processorvoidregisterScriptProcessor(ScriptProcessor scriptProcessor, String extension, String name) Registers a script processorvoidreset()Resets all of the registered script processorsvoidsetDefaultScriptProcessor(String defaultScriptProcessorName) Sets the name of the default script processor
-
Constructor Details
-
ScriptProcessorRegistry
public ScriptProcessorRegistry()
-
-
Method Details
-
setDefaultScriptProcessor
Sets the name of the default script processor- Parameters:
defaultScriptProcessorName- the name of the default script processor
-
registerScriptProcessor
Registers a script processor- Parameters:
scriptProcessor- the script processor to register
-
registerScriptProcessor
Registers a script processor- Parameters:
scriptProcessor- the script processor to registerextension- Stringname- String
-
getDefaultScriptProcessor
Gets the default script processor.- Returns:
- the default script processor
-
getScriptProcessor
Returns the script processor that matches the file extension for the given path. If a script processor cannot be matched to the path, the default script processor will be returned.- Parameters:
path- the path- Returns:
- the script processor
-
getScriptProcessor
Returns the best fit script processor for the given script content object. If a script processor cannot be matched, the default script processor will be returned.- Parameters:
scriptContent- ScriptContent- Returns:
- the script processor
-
getScriptProcessorByExtension
Gets the script processor registered for the given extension- Parameters:
extension- the extension- Returns:
- the script processor by extension or null if no match
-
findValidScriptPath
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 script 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.js - matches to file testfile.js using javascript procesor testfile - matches for all extensions, potentially looking at testfile.js, testfile.groovy, 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:
scriptProcessor- the script processor- Returns:
- the extension for processor
-
reset
public void reset()Resets all of the registered script processors
-