Package org.apache.synapse.mediators.bsf
Class OpenJDKNashornJavaScriptMessageContext
- java.lang.Object
-
- org.apache.synapse.mediators.bsf.OpenJDKNashornJavaScriptMessageContext
-
- All Implemented Interfaces:
ScriptMessageContext,org.apache.synapse.MessageContext
public class OpenJDKNashornJavaScriptMessageContext extends Object implements ScriptMessageContext
NashornJavaScriptMessageContext implements the ScriptMessageContext specific to Nashorn java script engine.
-
-
Constructor Summary
Constructors Constructor Description OpenJDKNashornJavaScriptMessageContext(org.apache.synapse.MessageContext mc, org.apache.bsf.xml.XMLHelper xmlHelper, ScriptEngine engine)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddHeader(boolean mustUnderstand, Object content)Add a new SOAP header to the message.org.apache.synapse.config.SynapseConfigurationgetConfiguration()Map<String,Object>getContextEntries()Stack<org.apache.synapse.ContinuationState>getContinuationStateStack()org.apache.synapse.MediatorgetDefaultConfiguration(String arg0)org.apache.synapse.endpoints.EndpointgetEndpoint(String key)ObjectgetEntry(String key)org.apache.axiom.soap.SOAPEnvelopegetEnvelope()ObjectgetEnvelopeXML()Get the XML representation of the complete SOAP envelope.org.apache.synapse.core.SynapseEnvironmentgetEnvironment()org.apache.synapse.MediatorgetFaultSequence()Stack<org.apache.synapse.FaultHandler>getFaultStack()org.apache.axis2.addressing.EndpointReferencegetFaultTo()org.apache.axiom.om.OMElementgetFormat(String s)org.apache.axis2.addressing.EndpointReferencegetFrom()ObjectgetJsonText()Get the Message Payload as a text.ObjectgetLocalEntry(String key)org.apache.synapse.MediatorgetMainSequence()intgetMessageFlowTracingState()StringgetMessageID()StringgetMessageString()org.apache.axiom.om.OMElementgetParsedOMElement(InputStream stream)Returns the parsed xml document.ObjectgetPayloadJSON()Get the JSON object representation of the JSON message body of the request.StringgetPayloadText()Get the Message Payload as a text.ObjectgetPayloadXML()Get the XML representation of SOAP Body payload.ObjectgetProperty(String key)SetgetPropertyKeySet()org.apache.axis2.addressing.RelatesTogetRelatesTo()org.apache.axis2.addressing.EndpointReferencegetReplyTo()org.apache.synapse.MediatorgetSequence(String key)org.apache.synapse.MediatorgetSequenceTemplate(String key)org.apache.commons.logging.LoggetServiceLog()StringgetSoapAction()org.apache.axis2.addressing.EndpointReferencegetTo()intgetTracingState()StringgetWSAAction()StringgetWSAMessageID()org.apache.axiom.om.xpath.AXIOMXPathgetXpathResult(String expression)Returns the Axiom xpath.booleanisContinuationEnabled()booleanisDoingGET()booleanisDoingMTOM()booleanisDoingPOX()booleanisDoingSWA()booleanisFaultResponse()booleanisResponse()booleanisSOAP11()ObjectjsonObject(org.apache.synapse.MessageContext messageContext)Returns the JavaScript Object saved in this message context.ObjectjsonSerializerCallMember(String key, String value)DocumentparseXml(String text)Returns the parsed xml document.voidpushContinuationState(org.apache.synapse.ContinuationState continuationState)voidpushFaultHandler(org.apache.synapse.FaultHandler fault)voidremoveProperty(String key, String scope)Remove property from the message.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)voidsetFrom(String reference)This 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.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)voidsetTo(String reference)This is used to set the value which specifies the receiver of the message.voidsetTo(org.apache.axis2.addressing.EndpointReference reference)voidsetTracingState(int tracingState)voidsetWSAAction(String actionURI)voidsetWSAMessageID(String messageID)
-
-
-
Constructor Detail
-
OpenJDKNashornJavaScriptMessageContext
public OpenJDKNashornJavaScriptMessageContext(org.apache.synapse.MessageContext mc, org.apache.bsf.xml.XMLHelper xmlHelper, ScriptEngine engine) throws ScriptException- Throws:
ScriptException
-
-
Method Detail
-
getPayloadXML
public Object 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
-
setPayloadXML
public void setPayloadXML(Object payload) throws org.apache.axiom.om.OMException, ScriptException
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
public Object 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
-
setPayloadJSON
public void setPayloadJSON(Object jsonPayload) throws ScriptException
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.
-
getJsonText
public Object getJsonText()
Get the Message Payload as a text.- Specified by:
getJsonTextin interfaceScriptMessageContext- Returns:
- Payload as text
-
getPayloadText
public String getPayloadText()
Get the Message Payload as a text.- Specified by:
getPayloadTextin interfaceScriptMessageContext- Returns:
- Payload as text
-
setJsonObject
public boolean setJsonObject(org.apache.synapse.MessageContext messageContext, Object jsonObject)Saves the JavaScript Object to the message context.- Specified by:
setJsonObjectin interfaceScriptMessageContext- Parameters:
messageContext- The message context of the sequencejsonObject- JavaScript Object which is passed to be saved in message context- Returns:
- true
-
setJsonText
public boolean setJsonText(org.apache.synapse.MessageContext messageContext, Object jsonObject)Saves the JSON String to the message context.- Specified by:
setJsonTextin interfaceScriptMessageContext- Parameters:
messageContext- The message context of the sequencejsonObject- JavaScript string which is passed to be saved in message context- Returns:
- false if messageContext is null return true otherwise
-
jsonObject
public Object jsonObject(org.apache.synapse.MessageContext messageContext)
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
public void setScriptEngine(ScriptEngine scriptEngine)
Set a script engine.- Specified by:
setScriptEnginein interfaceScriptMessageContext- Parameters:
scriptEngine- a ScriptEngine instance
-
parseXml
public Document parseXml(String text) throws ScriptException
Returns the parsed xml document.- Parameters:
text- xml string or document needed to be parser- Returns:
- parsed document
- Throws:
ScriptException
-
getParsedOMElement
public org.apache.axiom.om.OMElement getParsedOMElement(InputStream stream)
Returns the parsed xml document.- Parameters:
stream- input stream of xml string or document needed to be parsed- Returns:
- parsed document
-
getXpathResult
public org.apache.axiom.om.xpath.AXIOMXPath getXpathResult(String expression) throws org.jaxen.JaxenException
Returns the Axiom xpath.- Parameters:
expression- Xpath expression- Returns:
- Axiom xpath is returned
- Throws:
org.jaxen.JaxenException
-
addHeader
public void addHeader(boolean mustUnderstand, Object content) throws ScriptExceptionAdd 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
public Object getEnvelopeXML() throws ScriptException
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
-
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
public Map<String,Object> getContextEntries()
- Specified by:
getContextEntriesin interfaceorg.apache.synapse.MessageContext
-
setContextEntries
public void setContextEntries(Map<String,Object> entries)
- Specified by:
setContextEntriesin interfaceorg.apache.synapse.MessageContext
-
getProperty
public Object getProperty(String key)
- Specified by:
getPropertyin interfaceorg.apache.synapse.MessageContext
-
getEntry
public Object getEntry(String key)
- Specified by:
getEntryin interfaceorg.apache.synapse.MessageContext
-
getLocalEntry
public Object getLocalEntry(String key)
- Specified by:
getLocalEntryin interfaceorg.apache.synapse.MessageContext
-
setProperty
public void setProperty(String key, Object value)
Add a new property to the message.- Specified by:
setPropertyin interfaceorg.apache.synapse.MessageContext- Parameters:
key- unique identifier of propertyvalue- value of property
-
setProperty
public void setProperty(String key, Object value, String scope)
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
public void removeProperty(String key, String scope)
Remove property from the message.- Specified by:
removePropertyin interfaceScriptMessageContext- Parameters:
key- unique identifier of propertyscope- scope of the property
-
getPropertyKeySet
public Set 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
public org.apache.synapse.Mediator getSequence(String key)
- Specified by:
getSequencein interfaceorg.apache.synapse.MessageContext
-
getFormat
public org.apache.axiom.om.OMElement getFormat(String s)
- Specified by:
getFormatin interfaceorg.apache.synapse.MessageContext
-
getEndpoint
public org.apache.synapse.endpoints.Endpoint getEndpoint(String key)
- 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(String reference)
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
-
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(String reference)
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
-
setFrom
public void setFrom(org.apache.axis2.addressing.EndpointReference reference)
- Specified by:
setFromin interfaceorg.apache.synapse.MessageContext
-
getMessageID
public String getMessageID()
- Specified by:
getMessageIDin interfaceorg.apache.synapse.MessageContext
-
setMessageID
public void setMessageID(String string)
- 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(String reference)
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
-
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(String reference)
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
-
setTo
public void setTo(org.apache.axis2.addressing.EndpointReference reference)
- Specified by:
setToin interfaceorg.apache.synapse.MessageContext
-
getWSAAction
public String getWSAAction()
- Specified by:
getWSAActionin interfaceorg.apache.synapse.MessageContext
-
setWSAAction
public void setWSAAction(String actionURI)
- Specified by:
setWSAActionin interfaceorg.apache.synapse.MessageContext
-
getSoapAction
public String getSoapAction()
- Specified by:
getSoapActionin interfaceorg.apache.synapse.MessageContext
-
setSoapAction
public void setSoapAction(String string)
- Specified by:
setSoapActionin interfaceorg.apache.synapse.MessageContext
-
getWSAMessageID
public String getWSAMessageID()
- Specified by:
getWSAMessageIDin interfaceorg.apache.synapse.MessageContext
-
setWSAMessageID
public void setWSAMessageID(String messageID)
- Specified by:
setWSAMessageIDin interfaceorg.apache.synapse.MessageContext
-
isDoingMTOM
public boolean isDoingMTOM()
- Specified by:
isDoingMTOMin interfaceorg.apache.synapse.MessageContext
-
setDoingMTOM
public void setDoingMTOM(boolean b)
- Specified by:
setDoingMTOMin interfaceorg.apache.synapse.MessageContext
-
isDoingSWA
public boolean isDoingSWA()
- Specified by:
isDoingSWAin 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
-
isResponse
public boolean isResponse()
- Specified by:
isResponsein interfaceorg.apache.synapse.MessageContext
-
setResponse
public void setResponse(boolean b)
- Specified by:
setResponsein interfaceorg.apache.synapse.MessageContext
-
isFaultResponse
public boolean isFaultResponse()
- Specified by:
isFaultResponsein interfaceorg.apache.synapse.MessageContext
-
setFaultResponse
public void setFaultResponse(boolean b)
- Specified by:
setFaultResponsein 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
public Stack<org.apache.synapse.FaultHandler> 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
public Stack<org.apache.synapse.ContinuationState> getContinuationStateStack()
- Specified by:
getContinuationStateStackin 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
public org.apache.synapse.Mediator getSequenceTemplate(String key)
- Specified by:
getSequenceTemplatein interfaceorg.apache.synapse.MessageContext
-
getDefaultConfiguration
public org.apache.synapse.Mediator getDefaultConfiguration(String arg0)
- Specified by:
getDefaultConfigurationin interfaceorg.apache.synapse.MessageContext
-
getMessageString
public String getMessageString()
- Specified by:
getMessageStringin interfaceorg.apache.synapse.MessageContext
-
getMessageFlowTracingState
public int getMessageFlowTracingState()
- Specified by:
getMessageFlowTracingStatein interfaceorg.apache.synapse.MessageContext
-
setMessageFlowTracingState
public void setMessageFlowTracingState(int state)
- Specified by:
setMessageFlowTracingStatein interfaceorg.apache.synapse.MessageContext
-
-