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 void
addHeader(boolean mustUnderstand, Object content)
Add a new SOAP header to the message.org.apache.synapse.config.SynapseConfiguration
getConfiguration()
Map<String,Object>
getContextEntries()
Stack<org.apache.synapse.ContinuationState>
getContinuationStateStack()
org.apache.synapse.Mediator
getDefaultConfiguration(String arg0)
org.apache.synapse.endpoints.Endpoint
getEndpoint(String key)
Object
getEntry(String key)
org.apache.axiom.soap.SOAPEnvelope
getEnvelope()
Object
getEnvelopeXML()
Get the XML representation of the complete SOAP envelope.org.apache.synapse.core.SynapseEnvironment
getEnvironment()
org.apache.synapse.Mediator
getFaultSequence()
Stack<org.apache.synapse.FaultHandler>
getFaultStack()
org.apache.axis2.addressing.EndpointReference
getFaultTo()
org.apache.axiom.om.OMElement
getFormat(String s)
org.apache.axis2.addressing.EndpointReference
getFrom()
Object
getJsonText()
Get the Message Payload as a text.Object
getLocalEntry(String key)
org.apache.synapse.Mediator
getMainSequence()
int
getMessageFlowTracingState()
String
getMessageID()
String
getMessageString()
org.apache.axiom.om.OMElement
getParsedOMElement(InputStream stream)
Returns the parsed xml document.Object
getPayloadJSON()
Get the JSON object representation of the JSON message body of the request.String
getPayloadText()
Get the Message Payload as a text.Object
getPayloadXML()
Get the XML representation of SOAP Body payload.Object
getProperty(String key)
Set
getPropertyKeySet()
org.apache.axis2.addressing.RelatesTo
getRelatesTo()
org.apache.axis2.addressing.EndpointReference
getReplyTo()
org.apache.synapse.Mediator
getSequence(String key)
org.apache.synapse.Mediator
getSequenceTemplate(String key)
org.apache.commons.logging.Log
getServiceLog()
String
getSoapAction()
org.apache.axis2.addressing.EndpointReference
getTo()
int
getTracingState()
String
getWSAAction()
String
getWSAMessageID()
org.apache.axiom.om.xpath.AXIOMXPath
getXpathResult(String expression)
Returns the Axiom xpath.boolean
isContinuationEnabled()
boolean
isDoingGET()
boolean
isDoingMTOM()
boolean
isDoingPOX()
boolean
isDoingSWA()
boolean
isFaultResponse()
boolean
isResponse()
boolean
isSOAP11()
Object
jsonObject(org.apache.synapse.MessageContext messageContext)
Returns the JavaScript Object saved in this message context.Object
jsonSerializerCallMember(String key, String value)
Document
parseXml(String text)
Returns the parsed xml document.void
pushContinuationState(org.apache.synapse.ContinuationState continuationState)
void
pushFaultHandler(org.apache.synapse.FaultHandler fault)
void
removeProperty(String key, String scope)
Remove property from the message.void
setConfiguration(org.apache.synapse.config.SynapseConfiguration cfg)
void
setContextEntries(Map<String,Object> entries)
void
setContinuationEnabled(boolean contStateStackEnabled)
void
setDoingGET(boolean b)
void
setDoingMTOM(boolean b)
void
setDoingPOX(boolean b)
void
setDoingSWA(boolean b)
void
setEnvelope(org.apache.axiom.soap.SOAPEnvelope envelope)
void
setEnvironment(org.apache.synapse.core.SynapseEnvironment se)
void
setFaultResponse(boolean b)
void
setFaultTo(String reference)
This is used to set the value which specifies the receiver of the faults relating to the message.void
setFaultTo(org.apache.axis2.addressing.EndpointReference reference)
void
setFrom(String reference)
This is used to set the value which specifies the sender of the message.void
setFrom(org.apache.axis2.addressing.EndpointReference reference)
boolean
setJsonObject(org.apache.synapse.MessageContext messageContext, Object jsonObject)
Saves the JavaScript Object to the message context.boolean
setJsonText(org.apache.synapse.MessageContext messageContext, Object jsonObject)
Saves the JSON String to the message context.void
setMessageFlowTracingState(int state)
void
setMessageID(String string)
void
setPayloadJSON(Object jsonPayload)
Saves the payload of this message context as a JSON payload.void
setPayloadXML(Object payload)
Set the SOAP body payload from XML.void
setProperty(String key, Object value)
Add a new property to the message.void
setProperty(String key, Object value, String scope)
Add a new property to the message.void
setRelatesTo(org.apache.axis2.addressing.RelatesTo[] reference)
void
setReplyTo(String reference)
This is used to set the value which specifies the receiver of the replies to the message.void
setReplyTo(org.apache.axis2.addressing.EndpointReference reference)
void
setResponse(boolean b)
void
setScriptEngine(ScriptEngine scriptEngine)
Set a script engine.void
setSoapAction(String string)
void
setTo(String reference)
This is used to set the value which specifies the receiver of the message.void
setTo(org.apache.axis2.addressing.EndpointReference reference)
void
setTracingState(int tracingState)
void
setWSAAction(String actionURI)
void
setWSAMessageID(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:
getPayloadXML
in 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:
setPayloadXML
in 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:
getPayloadJSON
in 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:
setPayloadJSON
in 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:
getJsonText
in interfaceScriptMessageContext
- Returns:
- Payload as text
-
getPayloadText
public String getPayloadText()
Get the Message Payload as a text.- Specified by:
getPayloadText
in 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:
setJsonObject
in 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:
setJsonText
in 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:
jsonObject
in 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:
setScriptEngine
in 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 ScriptException
Add a new SOAP header to the message.- Specified by:
addHeader
in interfaceScriptMessageContext
- Parameters:
mustUnderstand
- the value for thesoapenv:mustUnderstand
attributecontent
- 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:
getEnvelopeXML
in 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:
getConfiguration
in interfaceorg.apache.synapse.MessageContext
-
setConfiguration
public void setConfiguration(org.apache.synapse.config.SynapseConfiguration cfg)
- Specified by:
setConfiguration
in interfaceorg.apache.synapse.MessageContext
-
getEnvironment
public org.apache.synapse.core.SynapseEnvironment getEnvironment()
- Specified by:
getEnvironment
in interfaceorg.apache.synapse.MessageContext
-
setEnvironment
public void setEnvironment(org.apache.synapse.core.SynapseEnvironment se)
- Specified by:
setEnvironment
in interfaceorg.apache.synapse.MessageContext
-
getContextEntries
public Map<String,Object> getContextEntries()
- Specified by:
getContextEntries
in interfaceorg.apache.synapse.MessageContext
-
setContextEntries
public void setContextEntries(Map<String,Object> entries)
- Specified by:
setContextEntries
in interfaceorg.apache.synapse.MessageContext
-
getProperty
public Object getProperty(String key)
- Specified by:
getProperty
in interfaceorg.apache.synapse.MessageContext
-
getEntry
public Object getEntry(String key)
- Specified by:
getEntry
in interfaceorg.apache.synapse.MessageContext
-
getLocalEntry
public Object getLocalEntry(String key)
- Specified by:
getLocalEntry
in interfaceorg.apache.synapse.MessageContext
-
setProperty
public void setProperty(String key, Object value)
Add a new property to the message.- Specified by:
setProperty
in 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:
setProperty
in 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:
removeProperty
in interfaceScriptMessageContext
- Parameters:
key
- unique identifier of propertyscope
- scope of the property
-
getPropertyKeySet
public Set getPropertyKeySet()
- Specified by:
getPropertyKeySet
in interfaceorg.apache.synapse.MessageContext
-
getMainSequence
public org.apache.synapse.Mediator getMainSequence()
- Specified by:
getMainSequence
in interfaceorg.apache.synapse.MessageContext
-
getFaultSequence
public org.apache.synapse.Mediator getFaultSequence()
- Specified by:
getFaultSequence
in interfaceorg.apache.synapse.MessageContext
-
getSequence
public org.apache.synapse.Mediator getSequence(String key)
- Specified by:
getSequence
in interfaceorg.apache.synapse.MessageContext
-
getFormat
public org.apache.axiom.om.OMElement getFormat(String s)
- Specified by:
getFormat
in interfaceorg.apache.synapse.MessageContext
-
getEndpoint
public org.apache.synapse.endpoints.Endpoint getEndpoint(String key)
- Specified by:
getEndpoint
in interfaceorg.apache.synapse.MessageContext
-
getEnvelope
public org.apache.axiom.soap.SOAPEnvelope getEnvelope()
- Specified by:
getEnvelope
in interfaceorg.apache.synapse.MessageContext
-
setEnvelope
public void setEnvelope(org.apache.axiom.soap.SOAPEnvelope envelope) throws org.apache.axis2.AxisFault
- Specified by:
setEnvelope
in interfaceorg.apache.synapse.MessageContext
- Throws:
org.apache.axis2.AxisFault
-
getFaultTo
public org.apache.axis2.addressing.EndpointReference getFaultTo()
- Specified by:
getFaultTo
in 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:
setFaultTo
in 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:
setFaultTo
in interfaceorg.apache.synapse.MessageContext
-
getFrom
public org.apache.axis2.addressing.EndpointReference getFrom()
- Specified by:
getFrom
in 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:
setFrom
in interfaceScriptMessageContext
- Parameters:
reference
- specifies the sender of the message
-
setFrom
public void setFrom(org.apache.axis2.addressing.EndpointReference reference)
- Specified by:
setFrom
in interfaceorg.apache.synapse.MessageContext
-
getMessageID
public String getMessageID()
- Specified by:
getMessageID
in interfaceorg.apache.synapse.MessageContext
-
setMessageID
public void setMessageID(String string)
- Specified by:
setMessageID
in interfaceorg.apache.synapse.MessageContext
-
getRelatesTo
public org.apache.axis2.addressing.RelatesTo getRelatesTo()
- Specified by:
getRelatesTo
in interfaceorg.apache.synapse.MessageContext
-
setRelatesTo
public void setRelatesTo(org.apache.axis2.addressing.RelatesTo[] reference)
- Specified by:
setRelatesTo
in interfaceorg.apache.synapse.MessageContext
-
getReplyTo
public org.apache.axis2.addressing.EndpointReference getReplyTo()
- Specified by:
getReplyTo
in 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:
setReplyTo
in interfaceScriptMessageContext
- Parameters:
reference
- specifies the receiver of the replies to the message
-
setReplyTo
public void setReplyTo(org.apache.axis2.addressing.EndpointReference reference)
- Specified by:
setReplyTo
in interfaceorg.apache.synapse.MessageContext
-
getTo
public org.apache.axis2.addressing.EndpointReference getTo()
- Specified by:
getTo
in 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:
setTo
in interfaceScriptMessageContext
- Parameters:
reference
- specifies the receiver of the message
-
setTo
public void setTo(org.apache.axis2.addressing.EndpointReference reference)
- Specified by:
setTo
in interfaceorg.apache.synapse.MessageContext
-
getWSAAction
public String getWSAAction()
- Specified by:
getWSAAction
in interfaceorg.apache.synapse.MessageContext
-
setWSAAction
public void setWSAAction(String actionURI)
- Specified by:
setWSAAction
in interfaceorg.apache.synapse.MessageContext
-
getSoapAction
public String getSoapAction()
- Specified by:
getSoapAction
in interfaceorg.apache.synapse.MessageContext
-
setSoapAction
public void setSoapAction(String string)
- Specified by:
setSoapAction
in interfaceorg.apache.synapse.MessageContext
-
getWSAMessageID
public String getWSAMessageID()
- Specified by:
getWSAMessageID
in interfaceorg.apache.synapse.MessageContext
-
setWSAMessageID
public void setWSAMessageID(String messageID)
- Specified by:
setWSAMessageID
in interfaceorg.apache.synapse.MessageContext
-
isDoingMTOM
public boolean isDoingMTOM()
- Specified by:
isDoingMTOM
in interfaceorg.apache.synapse.MessageContext
-
setDoingMTOM
public void setDoingMTOM(boolean b)
- Specified by:
setDoingMTOM
in interfaceorg.apache.synapse.MessageContext
-
isDoingSWA
public boolean isDoingSWA()
- Specified by:
isDoingSWA
in interfaceorg.apache.synapse.MessageContext
-
setDoingSWA
public void setDoingSWA(boolean b)
- Specified by:
setDoingSWA
in interfaceorg.apache.synapse.MessageContext
-
isDoingPOX
public boolean isDoingPOX()
- Specified by:
isDoingPOX
in interfaceorg.apache.synapse.MessageContext
-
setDoingPOX
public void setDoingPOX(boolean b)
- Specified by:
setDoingPOX
in interfaceorg.apache.synapse.MessageContext
-
isDoingGET
public boolean isDoingGET()
- Specified by:
isDoingGET
in interfaceorg.apache.synapse.MessageContext
-
setDoingGET
public void setDoingGET(boolean b)
- Specified by:
setDoingGET
in interfaceorg.apache.synapse.MessageContext
-
isSOAP11
public boolean isSOAP11()
- Specified by:
isSOAP11
in interfaceorg.apache.synapse.MessageContext
-
isResponse
public boolean isResponse()
- Specified by:
isResponse
in interfaceorg.apache.synapse.MessageContext
-
setResponse
public void setResponse(boolean b)
- Specified by:
setResponse
in interfaceorg.apache.synapse.MessageContext
-
isFaultResponse
public boolean isFaultResponse()
- Specified by:
isFaultResponse
in interfaceorg.apache.synapse.MessageContext
-
setFaultResponse
public void setFaultResponse(boolean b)
- Specified by:
setFaultResponse
in interfaceorg.apache.synapse.MessageContext
-
getTracingState
public int getTracingState()
- Specified by:
getTracingState
in interfaceorg.apache.synapse.MessageContext
-
setTracingState
public void setTracingState(int tracingState)
- Specified by:
setTracingState
in interfaceorg.apache.synapse.MessageContext
-
getFaultStack
public Stack<org.apache.synapse.FaultHandler> getFaultStack()
- Specified by:
getFaultStack
in interfaceorg.apache.synapse.MessageContext
-
pushFaultHandler
public void pushFaultHandler(org.apache.synapse.FaultHandler fault)
- Specified by:
pushFaultHandler
in interfaceorg.apache.synapse.MessageContext
-
pushContinuationState
public void pushContinuationState(org.apache.synapse.ContinuationState continuationState)
- Specified by:
pushContinuationState
in interfaceorg.apache.synapse.MessageContext
-
getContinuationStateStack
public Stack<org.apache.synapse.ContinuationState> getContinuationStateStack()
- Specified by:
getContinuationStateStack
in interfaceorg.apache.synapse.MessageContext
-
isContinuationEnabled
public boolean isContinuationEnabled()
- Specified by:
isContinuationEnabled
in interfaceorg.apache.synapse.MessageContext
-
setContinuationEnabled
public void setContinuationEnabled(boolean contStateStackEnabled)
- Specified by:
setContinuationEnabled
in interfaceorg.apache.synapse.MessageContext
-
getServiceLog
public org.apache.commons.logging.Log getServiceLog()
- Specified by:
getServiceLog
in interfaceorg.apache.synapse.MessageContext
-
getSequenceTemplate
public org.apache.synapse.Mediator getSequenceTemplate(String key)
- Specified by:
getSequenceTemplate
in interfaceorg.apache.synapse.MessageContext
-
getDefaultConfiguration
public org.apache.synapse.Mediator getDefaultConfiguration(String arg0)
- Specified by:
getDefaultConfiguration
in interfaceorg.apache.synapse.MessageContext
-
getMessageString
public String getMessageString()
- Specified by:
getMessageString
in interfaceorg.apache.synapse.MessageContext
-
getMessageFlowTracingState
public int getMessageFlowTracingState()
- Specified by:
getMessageFlowTracingState
in interfaceorg.apache.synapse.MessageContext
-
setMessageFlowTracingState
public void setMessageFlowTracingState(int state)
- Specified by:
setMessageFlowTracingState
in interfaceorg.apache.synapse.MessageContext
-
-