org.springframework.extensions.webscripts.processor
Class JSScriptProcessor

java.lang.Object
  extended by org.springframework.extensions.webscripts.processor.BaseProcessor
      extended by org.springframework.extensions.webscripts.processor.BaseRegisterableScriptProcessor
          extended by org.springframework.extensions.webscripts.processor.AbstractScriptProcessor
              extended by org.springframework.extensions.webscripts.processor.JSScriptProcessor
All Implemented Interfaces:
EventListener, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationListener, Processor, ScriptResourceLoader, ScriptProcessor

public class JSScriptProcessor
extends AbstractScriptProcessor
implements ScriptResourceLoader

JS Script Processor for Alfresco Web Framework

Author:
davidc, kevinr

Nested Class Summary
static class JSScriptProcessor.PresentationWrapFactory
          Wrap Factory for Rhino Script Engine
 
Field Summary
 
Fields inherited from class org.springframework.extensions.webscripts.processor.BaseProcessor
processorExtensions
 
Constructor Summary
JSScriptProcessor()
           
 
Method Summary
 Object executeScript(ScriptContent location, Map<String,Object> model)
          Execute script
 Object executeScript(String path, Map<String,Object> model)
          Execute script
 ScriptContent findScript(String path)
          Find a script at the specified path (within registered Web Script stores)
 String getExtension()
          The file extension that the processor is associated with, null if none.
 String getName()
          Get the name of the processor
 void init()
          Inits the processor
protected  void initProcessor()
          Inits the processor.
 String loadScriptResource(String resource)
          Load a script content from the specific resource path.
 void reset()
          Reset script cache
 void setCompile(boolean compile)
           
 Object unwrapValue(Object value)
          Unwrap value returned by script TODO: Remove this method when value conversion is truly hidden within script engine
 
Methods inherited from class org.springframework.extensions.webscripts.processor.AbstractScriptProcessor
addProcessorModelExtensions, getScriptLoader, getSearchPath, initLoaders, register, setSearchPath
 
Methods inherited from class org.springframework.extensions.webscripts.processor.BaseRegisterableScriptProcessor
getScriptProcessorRegistry, onApplicationEvent, setApplicationContext, setScriptProcessorRegistry
 
Methods inherited from class org.springframework.extensions.webscripts.processor.BaseProcessor
registerProcessorExtension
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContext
 

Constructor Detail

JSScriptProcessor

public JSScriptProcessor()
Method Detail

setCompile

public void setCompile(boolean compile)
Parameters:
compile - the compile flag to set

getExtension

public String getExtension()
Description copied from interface: Processor
The file extension that the processor is associated with, null if none.

Specified by:
getExtension in interface Processor
Returns:
the extension

getName

public String getName()
Description copied from interface: Processor
Get the name of the processor

Specified by:
getName in interface Processor
Returns:
the name of the processor

init

public void init()
Description copied from class: BaseRegisterableScriptProcessor
Inits the processor

Overrides:
init in class AbstractScriptProcessor

findScript

public ScriptContent findScript(String path)
Description copied from interface: ScriptProcessor
Find a script at the specified path (within registered Web Script stores)

Specified by:
findScript in interface ScriptProcessor
Parameters:
path - script path
Returns:
script location (or null, if not found)

executeScript

public Object executeScript(String path,
                            Map<String,Object> model)
Description copied from interface: ScriptProcessor
Execute script

Specified by:
executeScript in interface ScriptProcessor
Parameters:
path - script path
model - model
Returns:
script result

executeScript

public Object executeScript(ScriptContent location,
                            Map<String,Object> model)
Description copied from interface: ScriptProcessor
Execute script

Specified by:
executeScript in interface ScriptProcessor
Parameters:
location - script location
model - model
Returns:
script result

loadScriptResource

public String loadScriptResource(String resource)
Load a script content from the specific resource path.

Specified by:
loadScriptResource in interface ScriptResourceLoader
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
Throws:
ConfigServiceRuntimeException - on any IO or ContentIO error

unwrapValue

public Object unwrapValue(Object value)
Description copied from interface: ScriptProcessor
Unwrap value returned by script TODO: Remove this method when value conversion is truly hidden within script engine

Specified by:
unwrapValue in interface ScriptProcessor
Parameters:
value - value to unwrap
Returns:
unwrapped value

reset

public void reset()
Description copied from interface: ScriptProcessor
Reset script cache

Specified by:
reset in interface ScriptProcessor

initProcessor

protected void initProcessor()
Inits the processor.



Copyright © 2009 SpringSource, Inc. All Rights Reserved.