public class ScriptMediator
extends org.apache.synapse.mediators.AbstractMediator
<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.| Modifier and Type | Field and Description |
|---|---|
protected ScriptEngine |
jsEngine
The BSF engine created to validate each JSON payload
|
protected ScriptEngine |
scriptEngine
The BSF engine created to process each message through the script
|
| Constructor and Description |
|---|
ScriptMediator(String language,
Map<org.apache.synapse.mediators.Value,Object> includeKeysMap,
org.apache.synapse.mediators.Value key,
String function,
ClassLoader classLoader)
Create a script mediator for the given language and given script entry key and function
|
ScriptMediator(String language,
String scriptSourceCode,
ClassLoader classLoader)
Create a script mediator for the given language and given script source
|
| Modifier and Type | Method and Description |
|---|---|
String |
getFunction() |
Map<org.apache.synapse.mediators.Value,Object> |
getIncludeMap() |
org.apache.synapse.mediators.Value |
getKey() |
String |
getLanguage() |
ClassLoader |
getLoader() |
String |
getScriptSrc() |
protected void |
initInlineScript()
Initialise the Mediator for the inline script
|
protected void |
initScriptEngine() |
boolean |
mediate(org.apache.synapse.MessageContext synCtx)
Perform Script mediation
|
protected void |
prepareExternalScript(org.apache.synapse.MessageContext synCtx)
Prepares the mediator for the invocation of an external script
|
void |
setLoader(ClassLoader loader) |
auditLog, auditWarn, configure, disableStatistics, divertMediationRoute, enableStatistics, getAspectConfiguration, getCommentsList, getDescription, getInputType, getLog, getMediatorPosition, getOutputType, getRegisteredMediationFlowPoint, getShortDescription, getTraceState, getType, handleException, handleException, isBreakPoint, isContentAware, isSkipEnabled, isStatisticsEnable, isTraceOn, isTraceOrDebugOn, registerMediationFlowPoint, setBreakPoint, setCommentsList, setDescription, setEffectiveTraceState, setMediatorPosition, setShortDescription, setSkipEnabled, setTraceState, shouldTrace, traceOrDebug, traceOrDebugWarn, unregisterMediationFlowPointprotected ScriptEngine scriptEngine
protected ScriptEngine jsEngine
public ScriptMediator(String language, String scriptSourceCode, ClassLoader classLoader)
language - the BSF languagescriptSourceCode - the source code of the scriptpublic ScriptMediator(String language, Map<org.apache.synapse.mediators.Value,Object> includeKeysMap, org.apache.synapse.mediators.Value key, String function, ClassLoader classLoader)
language - the BSF languageincludeKeysMap - Include script keyskey - the registry entry key to load the scriptfunction - the function to be invokedpublic boolean mediate(org.apache.synapse.MessageContext synCtx)
synCtx - the Synapse message contextprotected void initInlineScript()
protected void prepareExternalScript(org.apache.synapse.MessageContext synCtx)
throws ScriptException
synCtx - MessageContext scriptScriptException - For any errors , when compile the scriptprotected void initScriptEngine()
public String getLanguage()
public org.apache.synapse.mediators.Value getKey()
public String getFunction()
public String getScriptSrc()
public ClassLoader getLoader()
public void setLoader(ClassLoader loader)
Copyright © 2005–2015 Apache Software Foundation. All rights reserved.