Class JSScriptProcessor
java.lang.Object
org.springframework.extensions.webscripts.processor.BaseProcessor
org.springframework.extensions.webscripts.processor.BaseRegisterableScriptProcessor
org.springframework.extensions.webscripts.processor.AbstractScriptProcessor
org.springframework.extensions.webscripts.processor.JSScriptProcessor
- All Implemented Interfaces:
EventListener,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware,org.springframework.context.ApplicationListener,Processor,ScriptResourceLoader,ScriptProcessor
JS Script Processor for Surf Web Framework
- Author:
- davidc, kevinr
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classWrap Factory for Rhino Script Engine -
Field Summary
Fields inherited from class org.springframework.extensions.webscripts.processor.BaseProcessor
processorExtensions -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexecuteScript(String path, Map<String, Object> model) Execute scriptexecuteScript(ScriptContent location, Map<String, Object> model) Execute scriptfindScript(String path) Find a script at the specified path (within registered Web Script stores)The file extension that the processor is associated with, null if none.getName()Get the name of the processorvoidinit()Inits the processorprotected voidInits the processor.protected org.mozilla.javascript.ScriptableinitScope(org.mozilla.javascript.Context cx, boolean secure, boolean sealed) Initializes a scope for script execution.protected booleanloadScriptResource(String resource) Load a script content from the specific resource path.voidreset()Reset script cachevoidsetCompile(boolean compile) voidsetConfigService(org.springframework.extensions.config.ConfigService configService) Sets the config service.voidsetShareSealedScopes(boolean shareSealedScopes) unwrapValue(Object value) Unwrap value returned by script TODO: Remove this method when value conversion is truly hidden within script engineMethods inherited from class org.springframework.extensions.webscripts.processor.AbstractScriptProcessor
addProcessorModelExtensions, getScriptLoader, getSearchPath, initLoaders, register, setSearchPathMethods inherited from class org.springframework.extensions.webscripts.processor.BaseRegisterableScriptProcessor
getScriptProcessorRegistry, onApplicationEvent, setApplicationContext, setScriptProcessorRegistryMethods inherited from class org.springframework.extensions.webscripts.processor.BaseProcessor
registerProcessorExtensionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContextMethods inherited from interface org.springframework.context.ApplicationListener
supportsAsyncExecution
-
Constructor Details
-
JSScriptProcessor
public JSScriptProcessor()
-
-
Method Details
-
setConfigService
public void setConfigService(org.springframework.extensions.config.ConfigService configService) Sets the config service.- Parameters:
configService- The ConfigService
-
setCompile
public void setCompile(boolean compile) - Parameters:
compile- the compile flag to set
-
getExtension
Description copied from interface:ProcessorThe file extension that the processor is associated with, null if none.- Specified by:
getExtensionin interfaceProcessor- Returns:
- the extension
-
getName
Description copied from interface:ProcessorGet the name of the processor -
init
public void init()Description copied from class:BaseRegisterableScriptProcessorInits the processor- Overrides:
initin classAbstractScriptProcessor
-
findScript
Description copied from interface:ScriptProcessorFind a script at the specified path (within registered Web Script stores)- Specified by:
findScriptin interfaceScriptProcessor- Parameters:
path- script path- Returns:
- script location (or null, if not found)
-
executeScript
Description copied from interface:ScriptProcessorExecute script- Specified by:
executeScriptin interfaceScriptProcessor- Parameters:
path- script pathmodel- model- Returns:
- script result
-
executeScript
Description copied from interface:ScriptProcessorExecute script- Specified by:
executeScriptin interfaceScriptProcessor- Parameters:
location- script locationmodel- model- Returns:
- script result
-
loadScriptResource
Load a script content from the specific resource path.- Specified by:
loadScriptResourcein interfaceScriptResourceLoader- Parameters:
resource- Script resource to load. Supports either classpath: prefix syntax or a resource path within the webscript stores.- Returns:
- the content from the resource, null if not recognised format
-
unwrapValue
Description copied from interface:ScriptProcessorUnwrap value returned by script TODO: Remove this method when value conversion is truly hidden within script engine- Specified by:
unwrapValuein interfaceScriptProcessor- Parameters:
value- value to unwrap- Returns:
- unwrapped value
-
reset
public void reset()Description copied from interface:ScriptProcessorReset script cache- Specified by:
resetin interfaceScriptProcessor
-
initProcessor
protected void initProcessor()Inits the processor. -
initScope
protected org.mozilla.javascript.Scriptable initScope(org.mozilla.javascript.Context cx, boolean secure, boolean sealed) Initializes a scope for script execution. The easiest way to embed Rhino is just to create a new scope this way whenever you need one. However, initStandardObjects() is an expensive method to call and it allocates a fair amount of memory.- Parameters:
cx- the thread execution contextsecure- Do we consider the script secure? Whenfalsethis ensures the script may not access insecure java.* libraries or import any other classes for direct access - only the configured root host objects will be available to the script writer.sealed- Should the scope be sealed, making it immutable? This should betrueif a scope is to be reused.- Returns:
- the scope object
-
isDebugMode
protected boolean isDebugMode()
-