|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.synapse.mediators.AbstractMediator org.apache.synapse.mediators.bsf.ScriptMediator
public class ScriptMediator
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 javax.script.ScriptEngine |
scriptEngine
The BSF engine created to process each message through the script |
Fields inherited from class org.apache.synapse.mediators.AbstractMediator |
---|
log, trace, traceState |
Constructor Summary | |
---|---|
ScriptMediator(String language,
Map<Value,Object> includeKeysMap,
Value key,
String function)
Create a script mediator for the given language and given script entry key and function |
|
ScriptMediator(String language,
String scriptSourceCode)
Create a script mediator for the given language and given script source |
Method Summary | |
---|---|
String |
getFunction()
|
Map<Value,Object> |
getIncludeMap()
|
Value |
getKey()
|
String |
getLanguage()
|
String |
getScriptSrc()
|
protected void |
initInlineScript()
Initialise the Mediator for the inline script |
protected void |
initScriptEngine()
|
boolean |
mediate(MessageContext synCtx)
Perform Script mediation |
protected void |
prepareExternalScript(MessageContext synCtx)
Prepares the mediator for the invocation of an external script |
Methods inherited from class org.apache.synapse.mediators.AbstractMediator |
---|
auditLog, auditWarn, configure, disableStatistics, enableStatistics, getAspectConfiguration, getDescription, getLog, getTraceState, getType, handleException, handleException, isStatisticsEnable, isTraceOn, isTraceOrDebugOn, setDescription, setEffectiveTraceState, setTraceState, shouldTrace, traceOrDebug, traceOrDebugWarn |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected javax.script.ScriptEngine scriptEngine
Constructor Detail |
---|
public ScriptMediator(String language, String scriptSourceCode)
language
- the BSF languagescriptSourceCode
- the source code of the scriptpublic ScriptMediator(String language, Map<Value,Object> includeKeysMap, Value key, String function)
language
- the BSF languageincludeKeysMap
- Include script keyskey
- the registry entry key to load the scriptfunction
- the function to be invokedMethod Detail |
---|
public boolean mediate(MessageContext synCtx)
synCtx
- the Synapse message context
protected void initInlineScript()
protected void prepareExternalScript(MessageContext synCtx) throws javax.script.ScriptException
synCtx
- MessageContext script
javax.script.ScriptException
- For any errors , when compile the scriptprotected void initScriptEngine()
public String getLanguage()
public Value getKey()
public String getFunction()
public String getScriptSrc()
public Map<Value,Object> getIncludeMap()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |