Home » synapse-1.2-src » org.apache.synapse.mediators.bsf » [javadoc | source]
org.apache.synapse.mediators.bsf
public class: ScriptMediator [javadoc | source]
java.lang.Object
   org.apache.synapse.mediators.AbstractMediator
      org.apache.synapse.mediators.bsf.ScriptMediator

All Implemented Interfaces:
    Mediator

A Synapse mediator that calls a function in any scripting language supported by the BSF. The ScriptMediator supports scripts specified in-line or those loaded through a registry

   <script [key="entry-key"]
     [function="script-function-name"] language="javascript|groovy|ruby">
     (text | xml)?
   </script>

The function is an optional attribute defining the name of the script function to call, if not specified it defaults to a function named 'mediate'. The function takes a single parameter which is the Synapse MessageContext. The function may return a boolean, if it does not then true is assumed.
Field Summary
protected  ScriptEngine scriptEngine    The BSF engine created to process each message through the script 
Fields inherited from org.apache.synapse.mediators.AbstractMediator:
log,  trace,  traceState
Constructor:
 public ScriptMediator(String language,
    String scriptSourceCode) 
    Create a script mediator for the given language and given script source
    Parameters:
    language - the BSF language
    scriptSourceCode - the source code of the script
 public ScriptMediator(String language,
    Map includeKeysMap,
    String key,
    String function) 
    Create a script mediator for the given language and given script entry key and function
    Parameters:
    language - the BSF language
    key - the registry entry key to load the script
    function - the function to be invoked
Method from org.apache.synapse.mediators.bsf.ScriptMediator Summary:
getFunction,   getIncludeMap,   getKey,   getLanguage,   getScriptSrc,   initInlineScript,   initScriptEngine,   mediate,   mediateForInlineScript,   mediateWithExternalScript,   prepareExternalScript,   setIncludeMap
Methods from org.apache.synapse.mediators.AbstractMediator:
auditLog,   auditWarn,   getTraceState,   getType,   handleException,   handleException,   isTraceOn,   isTraceOrDebugOn,   setEffectiveTraceState,   setTraceState,   shouldTrace,   traceOrDebug,   traceOrDebugWarn
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.synapse.mediators.bsf.ScriptMediator Detail:
 public String getFunction() 
 public Map getIncludeMap() 
 public String getKey() 
 public String getLanguage() 
 public String getScriptSrc() 
 protected  void initInlineScript() 
    Initialise the Mediator for the inline script
 protected  void initScriptEngine() 
 public boolean mediate(MessageContext synCtx) 
    Perform Script mediation
 protected Object mediateForInlineScript(MessageContext synCtx) throws ScriptException 
    Perform mediation with static inline script of the given scripting language
 protected Object mediateWithExternalScript(MessageContext synCtx) throws ScriptException, NoSuchMethodException 
    Mediation implementation when the script to be executed should be loaded from the registry
 protected synchronized  void prepareExternalScript(MessageContext synCtx) throws ScriptException 
    Prepares the mediator for the invocation of an external script
 public  void setIncludeMap(Map includeMap)