public class ScriptMediator
extends org.apache.synapse.mediators.AbstractMediator
<script [key="entry-key"] [function="script-function-name"] language="nashornJs|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() |
ScriptEngineWrapper |
getNewScriptEngine() |
String |
getScriptSrc() |
protected void |
initInlineScript()
Initialise the Mediator for the inline script
|
protected void |
initScriptEngine() |
boolean |
isContentAltering() |
boolean |
mediate(org.apache.synapse.MessageContext synCtx)
Perform Script mediation.
|
protected ScriptEngineWrapper |
prepareExternalScript(org.apache.synapse.MessageContext synCtx)
Prepares the mediator for the invocation of an external script
|
void |
setLoader(ClassLoader loader) |
auditLog, auditWarn, configure, disableStatistics, disableTracing, divertMediationRoute, enableStatistics, enableTracing, getAspectConfiguration, getCommentsList, getDescription, getInputType, getLastSequenceFaultHandler, getLog, getMediatorName, getMediatorPosition, getOutputType, getRegisteredMediationFlowPoint, getShortDescription, getTraceState, getType, handleException, handleException, isBreakPoint, isContentAware, isSkipEnabled, isStatisticsEnable, isTraceOn, isTraceOrDebugOn, isTracingEnabled, registerMediationFlowPoint, reportCloseStatistics, reportOpenStatistics, setBreakPoint, setCommentsList, setComponentStatisticsId, setDescription, setEffectiveTraceState, setMediatorPosition, setShortDescription, setSkipEnabled, setTraceState, shouldCaptureTracing, shouldTrace, shouldTrace, traceOrDebug, traceOrDebugWarn, unregisterMediationFlowPoint
protected 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 ScriptEngineWrapper 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)
public ScriptEngineWrapper getNewScriptEngine()
public boolean isContentAltering()
isContentAltering
in interface org.apache.synapse.Mediator
isContentAltering
in class org.apache.synapse.mediators.AbstractMediator
Copyright © 2005–2018 Apache Software Foundation. All rights reserved.