Class ScriptProcessorRegistry
- java.lang.Object
-
- org.springframework.extensions.webscripts.ScriptProcessorRegistry
-
public class ScriptProcessorRegistry extends java.lang.ObjectRegistry of Script Processors.If no processors are registered, the default script processor is the javascript processor.
- Author:
- muzquiano, Kevin Roast
-
-
Constructor Summary
Constructors Constructor Description ScriptProcessorRegistry()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringfindValidScriptPath(java.lang.String path)Returns a variation on the provided path that exists and is processable by one of the processors in this registry.protected ScriptProcessorgetDefaultScriptProcessor()Gets the default script processor.java.lang.StringgetExtensionForProcessor(ScriptProcessor scriptProcessor)Gets the extension for given processor.java.lang.String[]getRegisteredExtensions()Returns the extensions with registered processorsScriptProcessorgetScriptProcessor(java.lang.String path)Returns the script processor that matches the file extension for the given path.ScriptProcessorgetScriptProcessor(ScriptContent scriptContent)Returns the best fit script processor for the given script content object.ScriptProcessorgetScriptProcessorByExtension(java.lang.String extension)Gets the script processor registered for the given extensionvoidregisterScriptProcessor(ScriptProcessor scriptProcessor)Registers a script processorvoidregisterScriptProcessor(ScriptProcessor scriptProcessor, java.lang.String extension, java.lang.String name)Registers a script processorvoidreset()Resets all of the registered script processorsvoidsetDefaultScriptProcessor(java.lang.String defaultScriptProcessorName)Sets the name of the default script processor
-
-
-
Method Detail
-
setDefaultScriptProcessor
public void setDefaultScriptProcessor(java.lang.String defaultScriptProcessorName)
Sets the name of the default script processor- Parameters:
defaultScriptProcessorName- the name of the default script processor
-
registerScriptProcessor
public void registerScriptProcessor(ScriptProcessor scriptProcessor)
Registers a script processor- Parameters:
scriptProcessor- the script processor to register
-
registerScriptProcessor
public void registerScriptProcessor(ScriptProcessor scriptProcessor, java.lang.String extension, java.lang.String name)
Registers a script processor- Parameters:
scriptProcessor- the script processor to registerextension- Stringname- String
-
getDefaultScriptProcessor
protected ScriptProcessor getDefaultScriptProcessor()
Gets the default script processor.- Returns:
- the default script processor
-
getScriptProcessor
public ScriptProcessor getScriptProcessor(java.lang.String path)
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
public ScriptProcessor getScriptProcessor(ScriptContent scriptContent)
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
public ScriptProcessor getScriptProcessorByExtension(java.lang.String extension)
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
public java.lang.String findValidScriptPath(java.lang.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 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
public java.lang.String[] getRegisteredExtensions()
Returns the extensions with registered processors- Returns:
- the registered extensions
-
getExtensionForProcessor
public java.lang.String getExtensionForProcessor(ScriptProcessor scriptProcessor)
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
-
-