Package org.apache.synapse.mediators.bsf
Class CommonScriptMessageContext
java.lang.Object
org.apache.synapse.mediators.bsf.CommonScriptMessageContext
- All Implemented Interfaces:
ScriptMessageContext,org.apache.synapse.MessageContext
CommonScriptMessageContext decorates the Synapse MessageContext adding methods to use the
message payload XML in a way natural to the scripting languages.
-
Constructor Summary
ConstructorsConstructorDescriptionCommonScriptMessageContext(org.apache.synapse.MessageContext mc, org.apache.bsf.xml.XMLHelper xmlHelper) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a new SOAP header to the message.org.apache.synapse.config.SynapseConfigurationStack<org.apache.synapse.ContinuationState> org.apache.synapse.Mediatororg.apache.synapse.endpoints.EndpointgetEndpoint(String key) org.apache.axiom.soap.SOAPEnvelopeGet the XML representation of the complete SOAP envelope.org.apache.synapse.core.SynapseEnvironmentorg.apache.synapse.MediatorStack<org.apache.synapse.FaultHandler> org.apache.axis2.addressing.EndpointReferenceorg.apache.axiom.om.OMElementorg.apache.axis2.addressing.EndpointReferencegetFrom()Get the Message Payload as a text.getLocalEntry(String key) org.apache.synapse.MediatorintGet the JSON object representation of the JSON message body of the request.Get the Message Payload as a text.Get the XML representation of SOAP Body payload.getProperty(String key) org.apache.axis2.addressing.RelatesToorg.apache.axis2.addressing.EndpointReferenceorg.apache.synapse.MediatorgetSequence(String key) org.apache.synapse.Mediatororg.apache.commons.logging.Logorg.apache.axis2.addressing.EndpointReferencegetTo()intgetVariable(String key) booleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanisSOAP11()jsonObject(org.apache.synapse.MessageContext messageContext) Returns the JavaScript Object saved in this message context.voidpushContinuationState(org.apache.synapse.ContinuationState continuationState) voidpushFaultHandler(org.apache.synapse.FaultHandler fault) voidremoveProperty(String key, String scope) Remove property from the message.voidrestoreContinuationStateStack(Stack<org.apache.synapse.ContinuationState> continuationStateStack) voidsetConfiguration(org.apache.synapse.config.SynapseConfiguration cfg) voidsetContextEntries(Map<String, Object> entries) voidsetContinuationEnabled(boolean contStateStackEnabled) voidsetDoingGET(boolean b) voidsetDoingMTOM(boolean b) voidsetDoingPOX(boolean b) voidsetDoingSWA(boolean b) voidsetEnvelope(org.apache.axiom.soap.SOAPEnvelope envelope) voidsetEnvironment(org.apache.synapse.core.SynapseEnvironment se) voidsetFaultResponse(boolean b) voidsetFaultTo(String reference) This is used to set the value which specifies the receiver of the faults relating to the message.voidsetFaultTo(org.apache.axis2.addressing.EndpointReference reference) voidThis is used to set the value which specifies the sender of the message.voidsetFrom(org.apache.axis2.addressing.EndpointReference reference) booleansetJsonObject(org.apache.synapse.MessageContext messageContext, Object jsonObject) Saves the JavaScript Object to the message context.booleansetJsonText(org.apache.synapse.MessageContext messageContext, Object jsonObject) Saves the JSON String to the message context.voidsetMessageFlowTracingState(int state) voidsetMessageID(String string) voidsetPayloadJSON(Object jsonPayload) Saves the payload of this message context as a JSON payload.voidsetPayloadJSON0(Object jsonPayload) Saves the payload of this message context as a JSON payload.voidsetPayloadXML(Object payload) Set the SOAP body payload from XML.voidsetProperty(String key, Object value) Add a new property to the message.voidsetProperty(String key, Object value, String scope) Add a new property to the message.voidsetRelatesTo(org.apache.axis2.addressing.RelatesTo[] reference) voidsetReplyTo(String reference) This is used to set the value which specifies the receiver of the replies to the message.voidsetReplyTo(org.apache.axis2.addressing.EndpointReference reference) voidsetResponse(boolean b) voidsetScriptEngine(ScriptEngine scriptEngine) Set a script engine.voidsetSoapAction(String string) voidThis is used to set the value which specifies the receiver of the message.voidsetTo(org.apache.axis2.addressing.EndpointReference reference) voidsetTracingState(int tracingState) voidsetVariable(String key, Object value) voidsetWSAAction(String actionURI) voidsetWSAMessageID(String messageID)
-
Constructor Details
-
CommonScriptMessageContext
public CommonScriptMessageContext(org.apache.synapse.MessageContext mc, org.apache.bsf.xml.XMLHelper xmlHelper)
-
-
Method Details
-
getPayloadXML
Get the XML representation of SOAP Body payload. The payload is the first element inside the SOAP tags- Specified by:
getPayloadXMLin interfaceScriptMessageContext- Returns:
- the XML SOAP Body
- Throws:
ScriptException- in-case of an error in getting the XML representation of SOAP Body payload
-
setPayloadXML
Set the SOAP body payload from XML.- Specified by:
setPayloadXMLin interfaceScriptMessageContext- Parameters:
payload- Message payload- Throws:
ScriptException- For errors in converting xml To OMorg.apache.axiom.om.OMException- For errors in OM manipulation
-
getPayloadJSON
Get the JSON object representation of the JSON message body of the request.- Specified by:
getPayloadJSONin interfaceScriptMessageContext- Returns:
- JSON object of the message body
-
getJsonText
Get the Message Payload as a text.- Specified by:
getJsonTextin interfaceScriptMessageContext- Returns:
- Payload as text
-
getPayloadText
Get the Message Payload as a text.- Specified by:
getPayloadTextin interfaceScriptMessageContext- Returns:
- Payload as text
-
setPayloadJSON0
Saves the payload of this message context as a JSON payload.- Parameters:
jsonPayload- Javascript native object to be set as the message body- Throws:
ScriptException- in case of creating a JSON object out of the javascript native object.
-
setJsonObject
Saves the JavaScript Object to the message context.- Specified by:
setJsonObjectin interfaceScriptMessageContext- Parameters:
messageContext- The message context of the sequencejsonObject- JavaScript Object saved in this message context- Returns:
- true
-
setJsonText
Saves the JSON String to the message context.- Specified by:
setJsonTextin interfaceScriptMessageContext- Parameters:
messageContext- The message context of the sequencejsonObject- JavaScript Object saved in this message context- Returns:
- false if messageContext is null return true otherwise
-
jsonObject
Returns the JavaScript Object saved in this message context.- Specified by:
jsonObjectin interfaceScriptMessageContext- Parameters:
messageContext- The message context of the sequence- Returns:
- o JavaScript Object saved in this message context
-
setScriptEngine
Set a script engine.- Specified by:
setScriptEnginein interfaceScriptMessageContext- Parameters:
scriptEngine- a ScriptEngine instance
-
addHeader
Add a new SOAP header to the message.- Specified by:
addHeaderin interfaceScriptMessageContext- Parameters:
mustUnderstand- the value for thesoapenv:mustUnderstandattributecontent- the XML for the new header- Throws:
ScriptException- if an error occurs when converting the XML to OM
-
getEnvelopeXML
Get the XML representation of the complete SOAP envelope.- Specified by:
getEnvelopeXMLin interfaceScriptMessageContext- Returns:
- return an object that represents the payload in the current scripting language
- Throws:
ScriptException- in-case of an error in getting the XML representation of SOAP envelope
-
setTo
This is used to set the value which specifies the receiver of the message.- Specified by:
setToin interfaceScriptMessageContext- Parameters:
reference- specifies the receiver of the message
-
setFaultTo
This is used to set the value which specifies the receiver of the faults relating to the message.- Specified by:
setFaultToin interfaceScriptMessageContext- Parameters:
reference- specifies the receiver of the faults relating to the message
-
setFrom
This is used to set the value which specifies the sender of the message.- Specified by:
setFromin interfaceScriptMessageContext- Parameters:
reference- specifies the sender of the message
-
setReplyTo
This is used to set the value which specifies the receiver of the replies to the message.- Specified by:
setReplyToin interfaceScriptMessageContext- Parameters:
reference- specifies the receiver of the replies to the message
-
getConfiguration
public org.apache.synapse.config.SynapseConfiguration getConfiguration()- Specified by:
getConfigurationin interfaceorg.apache.synapse.MessageContext
-
setConfiguration
public void setConfiguration(org.apache.synapse.config.SynapseConfiguration cfg) - Specified by:
setConfigurationin interfaceorg.apache.synapse.MessageContext
-
getEnvironment
public org.apache.synapse.core.SynapseEnvironment getEnvironment()- Specified by:
getEnvironmentin interfaceorg.apache.synapse.MessageContext
-
setEnvironment
public void setEnvironment(org.apache.synapse.core.SynapseEnvironment se) - Specified by:
setEnvironmentin interfaceorg.apache.synapse.MessageContext
-
getContextEntries
- Specified by:
getContextEntriesin interfaceorg.apache.synapse.MessageContext
-
setContextEntries
- Specified by:
setContextEntriesin interfaceorg.apache.synapse.MessageContext
-
getProperty
- Specified by:
getPropertyin interfaceorg.apache.synapse.MessageContext
-
getEntry
- Specified by:
getEntryin interfaceorg.apache.synapse.MessageContext
-
getLocalEntry
- Specified by:
getLocalEntryin interfaceorg.apache.synapse.MessageContext
-
setProperty
Add a new property to the message.- Specified by:
setPropertyin interfaceorg.apache.synapse.MessageContext- Parameters:
key- unique identifier of propertyvalue- value of property
-
setProperty
Add a new property to the message.- Specified by:
setPropertyin interfaceScriptMessageContext- Parameters:
key- unique identifier of propertyvalue- value of propertyscope- scope of the property
-
removeProperty
Remove property from the message.- Specified by:
removePropertyin interfaceScriptMessageContext- Parameters:
key- unique identifier of propertyscope- scope of the property
-
getPropertyKeySet
- Specified by:
getPropertyKeySetin interfaceorg.apache.synapse.MessageContext
-
getMainSequence
public org.apache.synapse.Mediator getMainSequence()- Specified by:
getMainSequencein interfaceorg.apache.synapse.MessageContext
-
getFaultSequence
public org.apache.synapse.Mediator getFaultSequence()- Specified by:
getFaultSequencein interfaceorg.apache.synapse.MessageContext
-
getSequence
- Specified by:
getSequencein interfaceorg.apache.synapse.MessageContext
-
getFormat
- Specified by:
getFormatin interfaceorg.apache.synapse.MessageContext
-
getEndpoint
- Specified by:
getEndpointin interfaceorg.apache.synapse.MessageContext
-
getEnvelope
public org.apache.axiom.soap.SOAPEnvelope getEnvelope()- Specified by:
getEnvelopein interfaceorg.apache.synapse.MessageContext
-
setEnvelope
public void setEnvelope(org.apache.axiom.soap.SOAPEnvelope envelope) throws org.apache.axis2.AxisFault - Specified by:
setEnvelopein interfaceorg.apache.synapse.MessageContext- Throws:
org.apache.axis2.AxisFault
-
getFaultTo
public org.apache.axis2.addressing.EndpointReference getFaultTo()- Specified by:
getFaultToin interfaceorg.apache.synapse.MessageContext
-
setFaultTo
public void setFaultTo(org.apache.axis2.addressing.EndpointReference reference) - Specified by:
setFaultToin interfaceorg.apache.synapse.MessageContext
-
getFrom
public org.apache.axis2.addressing.EndpointReference getFrom()- Specified by:
getFromin interfaceorg.apache.synapse.MessageContext
-
setFrom
public void setFrom(org.apache.axis2.addressing.EndpointReference reference) - Specified by:
setFromin interfaceorg.apache.synapse.MessageContext
-
getMessageID
- Specified by:
getMessageIDin interfaceorg.apache.synapse.MessageContext
-
setMessageID
- Specified by:
setMessageIDin interfaceorg.apache.synapse.MessageContext
-
getRelatesTo
public org.apache.axis2.addressing.RelatesTo getRelatesTo()- Specified by:
getRelatesToin interfaceorg.apache.synapse.MessageContext
-
setRelatesTo
public void setRelatesTo(org.apache.axis2.addressing.RelatesTo[] reference) - Specified by:
setRelatesToin interfaceorg.apache.synapse.MessageContext
-
getReplyTo
public org.apache.axis2.addressing.EndpointReference getReplyTo()- Specified by:
getReplyToin interfaceorg.apache.synapse.MessageContext
-
setReplyTo
public void setReplyTo(org.apache.axis2.addressing.EndpointReference reference) - Specified by:
setReplyToin interfaceorg.apache.synapse.MessageContext
-
getTo
public org.apache.axis2.addressing.EndpointReference getTo()- Specified by:
getToin interfaceorg.apache.synapse.MessageContext
-
setTo
public void setTo(org.apache.axis2.addressing.EndpointReference reference) - Specified by:
setToin interfaceorg.apache.synapse.MessageContext
-
setWSAAction
- Specified by:
setWSAActionin interfaceorg.apache.synapse.MessageContext
-
getWSAAction
- Specified by:
getWSAActionin interfaceorg.apache.synapse.MessageContext
-
getSoapAction
- Specified by:
getSoapActionin interfaceorg.apache.synapse.MessageContext
-
setSoapAction
- Specified by:
setSoapActionin interfaceorg.apache.synapse.MessageContext
-
setWSAMessageID
- Specified by:
setWSAMessageIDin interfaceorg.apache.synapse.MessageContext
-
getWSAMessageID
- Specified by:
getWSAMessageIDin interfaceorg.apache.synapse.MessageContext
-
isDoingMTOM
public boolean isDoingMTOM()- Specified by:
isDoingMTOMin interfaceorg.apache.synapse.MessageContext
-
isDoingSWA
public boolean isDoingSWA()- Specified by:
isDoingSWAin interfaceorg.apache.synapse.MessageContext
-
setDoingMTOM
public void setDoingMTOM(boolean b) - Specified by:
setDoingMTOMin interfaceorg.apache.synapse.MessageContext
-
setDoingSWA
public void setDoingSWA(boolean b) - Specified by:
setDoingSWAin interfaceorg.apache.synapse.MessageContext
-
isDoingPOX
public boolean isDoingPOX()- Specified by:
isDoingPOXin interfaceorg.apache.synapse.MessageContext
-
setDoingPOX
public void setDoingPOX(boolean b) - Specified by:
setDoingPOXin interfaceorg.apache.synapse.MessageContext
-
isDoingGET
public boolean isDoingGET()- Specified by:
isDoingGETin interfaceorg.apache.synapse.MessageContext
-
setDoingGET
public void setDoingGET(boolean b) - Specified by:
setDoingGETin interfaceorg.apache.synapse.MessageContext
-
isSOAP11
public boolean isSOAP11()- Specified by:
isSOAP11in interfaceorg.apache.synapse.MessageContext
-
setResponse
public void setResponse(boolean b) - Specified by:
setResponsein interfaceorg.apache.synapse.MessageContext
-
isResponse
public boolean isResponse()- Specified by:
isResponsein interfaceorg.apache.synapse.MessageContext
-
setFaultResponse
public void setFaultResponse(boolean b) - Specified by:
setFaultResponsein interfaceorg.apache.synapse.MessageContext
-
isFaultResponse
public boolean isFaultResponse()- Specified by:
isFaultResponsein interfaceorg.apache.synapse.MessageContext
-
getTracingState
public int getTracingState()- Specified by:
getTracingStatein interfaceorg.apache.synapse.MessageContext
-
setTracingState
public void setTracingState(int tracingState) - Specified by:
setTracingStatein interfaceorg.apache.synapse.MessageContext
-
getFaultStack
- Specified by:
getFaultStackin interfaceorg.apache.synapse.MessageContext
-
pushFaultHandler
public void pushFaultHandler(org.apache.synapse.FaultHandler fault) - Specified by:
pushFaultHandlerin interfaceorg.apache.synapse.MessageContext
-
pushContinuationState
public void pushContinuationState(org.apache.synapse.ContinuationState continuationState) - Specified by:
pushContinuationStatein interfaceorg.apache.synapse.MessageContext
-
getContinuationStateStack
- Specified by:
getContinuationStateStackin interfaceorg.apache.synapse.MessageContext
-
restoreContinuationStateStack
public void restoreContinuationStateStack(Stack<org.apache.synapse.ContinuationState> continuationStateStack) - Specified by:
restoreContinuationStateStackin interfaceorg.apache.synapse.MessageContext
-
isContinuationEnabled
public boolean isContinuationEnabled()- Specified by:
isContinuationEnabledin interfaceorg.apache.synapse.MessageContext
-
setContinuationEnabled
public void setContinuationEnabled(boolean contStateStackEnabled) - Specified by:
setContinuationEnabledin interfaceorg.apache.synapse.MessageContext
-
getServiceLog
public org.apache.commons.logging.Log getServiceLog()- Specified by:
getServiceLogin interfaceorg.apache.synapse.MessageContext
-
getSequenceTemplate
- Specified by:
getSequenceTemplatein interfaceorg.apache.synapse.MessageContext
-
setPayloadJSON
Saves the payload of this message context as a JSON payload.- Specified by:
setPayloadJSONin interfaceScriptMessageContext- Parameters:
jsonPayload- Javascript native object to be set as the message body- Throws:
ScriptException- in case of creating a JSON object out of the javascript native object.
-
getDefaultConfiguration
- Specified by:
getDefaultConfigurationin interfaceorg.apache.synapse.MessageContext
-
getMessageString
- Specified by:
getMessageStringin interfaceorg.apache.synapse.MessageContext
-
setMessageFlowTracingState
public void setMessageFlowTracingState(int state) - Specified by:
setMessageFlowTracingStatein interfaceorg.apache.synapse.MessageContext
-
getMessageFlowTracingState
public int getMessageFlowTracingState()- Specified by:
getMessageFlowTracingStatein interfaceorg.apache.synapse.MessageContext
-
getVariable
- Specified by:
getVariablein interfaceorg.apache.synapse.MessageContext
-
setVariable
- Specified by:
setVariablein interfaceorg.apache.synapse.MessageContext
-
getVariableKeySet
- Specified by:
getVariableKeySetin interfaceorg.apache.synapse.MessageContext
-