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 javax.script.ScriptEngine |
jsEngine
The BSF engine created to validate each JSON payload
|
protected javax.script.ScriptEngine |
scriptEngine
The BSF engine created to process each message through the script
|
| Constructor and Description |
|---|
ScriptMediator(java.lang.String language,
java.util.Map<org.apache.synapse.mediators.Value,java.lang.Object> includeKeysMap,
org.apache.synapse.mediators.Value key,
java.lang.String function,
java.lang.ClassLoader classLoader)
Create a script mediator for the given language and given script entry key and function.
|
ScriptMediator(java.lang.String language,
java.lang.String scriptSourceCode,
java.lang.ClassLoader classLoader)
Create a script mediator for the given language and given script source.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getFunction() |
java.util.Map<org.apache.synapse.mediators.Value,java.lang.Object> |
getIncludeMap() |
org.apache.synapse.mediators.Value |
getKey() |
java.lang.String |
getLanguage() |
java.lang.ClassLoader |
getLoader() |
ScriptEngineWrapper |
getNewScriptEngine() |
java.lang.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(java.lang.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, unregisterMediationFlowPointprotected javax.script.ScriptEngine scriptEngine
protected javax.script.ScriptEngine jsEngine
public ScriptMediator(java.lang.String language,
java.lang.String scriptSourceCode,
java.lang.ClassLoader classLoader)
language - the BSF languagescriptSourceCode - the source code of the scriptpublic ScriptMediator(java.lang.String language,
java.util.Map<org.apache.synapse.mediators.Value,java.lang.Object> includeKeysMap,
org.apache.synapse.mediators.Value key,
java.lang.String function,
java.lang.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 javax.script.ScriptException
synCtx - MessageContext scriptjavax.script.ScriptException - For any errors , when compile the scriptprotected void initScriptEngine()
public java.lang.String getLanguage()
public org.apache.synapse.mediators.Value getKey()
public java.lang.String getFunction()
public java.lang.String getScriptSrc()
public java.util.Map<org.apache.synapse.mediators.Value,java.lang.Object> getIncludeMap()
public java.lang.ClassLoader getLoader()
public void setLoader(java.lang.ClassLoader loader)
public ScriptEngineWrapper getNewScriptEngine()
public boolean isContentAltering()
isContentAltering in interface org.apache.synapse.MediatorisContentAltering in class org.apache.synapse.mediators.AbstractMediatorCopyright © 2005-2022 Apache Software Foundation. All Rights Reserved.