Package org.apache.synapse
Interface MessageContext
-
- All Known Implementing Classes:
Axis2MessageContext
public interface MessageContext
The Synapse Message Context is available to all mediators through which it flows. It allows one to call to the underlying SynapseEnvironment (i.e. the SOAP engine - such as Axis2) where required. It also allows one to access the current SynapseConfiguration. Additionally it holds per message properties (i.e. local properties valid for the lifetime of the message), and the current SOAPEnvelope
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description SynapseConfiguration
getConfiguration()
Get a reference to the current SynapseConfigurationMap<String,Object>
getContextEntries()
Return all the entries which are in the MessageContext.Stack<ContinuationState>
getContinuationStateStack()
Get the ContinuationStateStack.Mediator
getDefaultConfiguration(String key)
Returns the InvokeMediator (which is wrapped with connector default configuration)Endpoint
getEndpoint(String key)
Return the endpoint with the given key from the configuration, or the local message context.Object
getEntry(String key)
Get the value of a property set on the message instance, from the local registry or the remote registry - by cascading throughorg.apache.axiom.soap.SOAPEnvelope
getEnvelope()
Get the SOAP envelope of this messageSynapseEnvironment
getEnvironment()
Returns a reference to the host Synapse EnvironmentMediator
getFaultSequence()
Return the fault sequence from the configuration, or the local message context This method looks up for the sequence named Constants.FAULT_SEQUENCE_KEY from the local message context to make this look up transactional - i.e.Stack<FaultHandler>
getFaultStack()
org.apache.axis2.addressing.EndpointReference
getFaultTo()
Get the faultTo EPR if availableorg.apache.axiom.om.OMElement
getFormat(String key)
Return the format with the given key from the configuration.org.apache.axis2.addressing.EndpointReference
getFrom()
Get the from EPR if availableObject
getLocalEntry(String key)
Get the value of a property set on the message instance or from the local registryMediator
getMainSequence()
Return the main sequence from the configuration, or the local message context This method looks up for the sequence named Constants.MAIN_SEQUENCE_KEY from the local message context to make this look up transactional - i.e.int
getMessageFlowTracingState()
This is used to check whether the message flow tracing enabled for current message contextString
getMessageID()
Get the message id if availableString
getMessageString()
Get Message properties as a StringObject
getProperty(String key)
Get the value of a custom (local) property set on the message instanceSet
getPropertyKeySet()
Returns the Set of keys over the properties on this message contextorg.apache.axis2.addressing.RelatesTo
getRelatesTo()
Get the relatesTo of this messageorg.apache.axis2.addressing.EndpointReference
getReplyTo()
Get the replyTo EPR if availableMediator
getSequence(String key)
Return the sequence with the given key from the configuration, or the local message context.Mediator
getSequenceTemplate(String key)
Return the Sequence Template with the given key from the configuration, or the local message context.org.apache.commons.logging.Log
getServiceLog()
Return the service level Log for this message context or nullString
getSoapAction()
Returns the SOAPAction of the messageorg.apache.axis2.addressing.EndpointReference
getTo()
Get the To EPRint
getTracingState()
This is used to check whether the tracing should be enabled on the current mediator or notString
getWSAAction()
Returns the WSAActionString
getWSAMessageID()
Gets the message nameboolean
isContinuationEnabled()
is ContinuationStateStack stack Operations enabledboolean
isDoingGET()
Is this message over GET?boolean
isDoingMTOM()
If this message using MTOM?boolean
isDoingPOX()
Is this message over POX?boolean
isDoingSWA()
If this message using SWA?boolean
isFaultResponse()
Is this message a response to a fault message?boolean
isResponse()
Is this message a response to a synchronous message sent out through Synapse?boolean
isSOAP11()
Is this message a SOAP 1.1 message?void
pushContinuationState(ContinuationState continuationState)
void
pushFaultHandler(FaultHandler fault)
void
setConfiguration(SynapseConfiguration cfg)
Set or replace the Synapse Configuration instance to be used.void
setContextEntries(Map<String,Object> entries)
Sets the entries to the current context and not to the configuration.void
setContinuationEnabled(boolean continuationEnabled)
Enable/disable ContinuationStateStack operationsvoid
setDoingGET(boolean b)
Marks this message as over REST/GETvoid
setDoingMTOM(boolean b)
Marks as using MTOMvoid
setDoingPOX(boolean b)
Marks this message as over POXvoid
setDoingSWA(boolean b)
Marks as using SWAvoid
setEnvelope(org.apache.axiom.soap.SOAPEnvelope envelope)
Sets the given envelope as the current SOAPEnvelope for this messagevoid
setEnvironment(SynapseEnvironment se)
Sets the SynapseEnvironment reference to this contextvoid
setFaultResponse(boolean b)
Marks this message as a fault responsevoid
setFaultTo(org.apache.axis2.addressing.EndpointReference reference)
Set the faultTo EPRvoid
setFrom(org.apache.axis2.addressing.EndpointReference reference)
Set the from EPRvoid
setMessageFlowTracingState(int tracingState)
This is used to set the value of message flow tracing enable for a particular messagevoid
setMessageID(String string)
Set the message idvoid
setProperty(String key, Object value)
Set a custom (local) property with the given name on the message instancevoid
setRelatesTo(org.apache.axis2.addressing.RelatesTo[] reference)
Sets the relatesTo references for this messagevoid
setReplyTo(org.apache.axis2.addressing.EndpointReference reference)
Set the replyTo EPRvoid
setResponse(boolean b)
Mark this message as a response or not.void
setSoapAction(String string)
Set the SOAPActionvoid
setTo(org.apache.axis2.addressing.EndpointReference reference)
Set the To EPRvoid
setTracingState(int tracingState)
This is used to set the value of tracing enable variablevoid
setWSAAction(String actionURI)
Sets the WSAActionvoid
setWSAMessageID(String messageID)
Set the message
-
-
-
Method Detail
-
getConfiguration
SynapseConfiguration getConfiguration()
Get a reference to the current SynapseConfiguration- Returns:
- the current synapse configuration
-
setConfiguration
void setConfiguration(SynapseConfiguration cfg)
Set or replace the Synapse Configuration instance to be used. May be used to programatically change the configuration at runtime etc.- Parameters:
cfg
- The new synapse configuration instance
-
getEnvironment
SynapseEnvironment getEnvironment()
Returns a reference to the host Synapse Environment- Returns:
- the Synapse Environment
-
setEnvironment
void setEnvironment(SynapseEnvironment se)
Sets the SynapseEnvironment reference to this context- Parameters:
se
- the reference to the Synapse Environment
-
getContextEntries
Map<String,Object> getContextEntries()
Return all the entries which are in the MessageContext. This does not represent all the declared entries in the configuration, rather only the entries that the context has already used. This will not lookup for the entries in the Configuration.- Returns:
- the set of local entries in the context
-
setContextEntries
void setContextEntries(Map<String,Object> entries)
Sets the entries to the current context and not to the configuration. This can be used to forcibly override an existing set of resources in the configuration, because the resource lookup will look for the context first. But this only sets the entries to the current context- Parameters:
entries
- the set of local entries to be set
-
getMainSequence
Mediator getMainSequence()
Return the main sequence from the configuration, or the local message context This method looks up for the sequence named Constants.MAIN_SEQUENCE_KEY from the local message context to make this look up transactional - i.e. a request and response message pair will not see a difference in the main sequence if the main sequence was dynamic and changed in between at the registry- Returns:
- the main sequence to be used for mediation
-
getFaultSequence
Mediator getFaultSequence()
Return the fault sequence from the configuration, or the local message context This method looks up for the sequence named Constants.FAULT_SEQUENCE_KEY from the local message context to make this look up transactional - i.e. a request and response message pair will not see a difference in the fault sequence if the fault sequence was dynamic and changed in between at the registry- Returns:
- the fault sequence to be used for mediation
-
getSequence
Mediator getSequence(String key)
Return the sequence with the given key from the configuration, or the local message context. This method looks up for the sequence with the given key from the local message context to make this look up transactional - i.e. a request and response message pair will not see a difference in the said sequence if it was dynamic and changed in between at the registry- Parameters:
key
- the sequence key to be looked up- Returns:
- the sequence mediator mapped to the key
-
getFormat
org.apache.axiom.om.OMElement getFormat(String key)
Return the format with the given key from the configuration.- Parameters:
key
-- Returns:
- the format mapped with the key
-
getSequenceTemplate
Mediator getSequenceTemplate(String key)
Return the Sequence Template with the given key from the configuration, or the local message context. This method looks up for the Template with the given key from the local message context to make this look up transactional - i.e. a request and response message pair will not see a difference in the said sequence if it was dynamic and changed in between at the registry- Parameters:
key
- the sequence key to be looked up- Returns:
- the Template mediator mapped to the key
-
getEndpoint
Endpoint getEndpoint(String key)
Return the endpoint with the given key from the configuration, or the local message context. This method looks up for the endpoint with the given key from the local message context to make this look up transactional - i.e. a request and response message pair will not see a difference in the said endpoint if it was dynamic and changed in between at the registry- Parameters:
key
- the endpoint key to be looked up- Returns:
- the endpoint mapped to the key
-
getProperty
Object getProperty(String key)
Get the value of a custom (local) property set on the message instance- Parameters:
key
- key to look up property- Returns:
- value for the given key
-
getEntry
Object getEntry(String key)
Get the value of a property set on the message instance, from the local registry or the remote registry - by cascading through- Parameters:
key
- key to look up property- Returns:
- value for the given key
-
getLocalEntry
Object getLocalEntry(String key)
Get the value of a property set on the message instance or from the local registry- Parameters:
key
- key to look up property- Returns:
- value for the given key
-
setProperty
void setProperty(String key, Object value)
Set a custom (local) property with the given name on the message instance- Parameters:
key
- key to be usedvalue
- value to be saved
-
getPropertyKeySet
Set getPropertyKeySet()
Returns the Set of keys over the properties on this message context- Returns:
- a Set of keys over message properties
-
getEnvelope
org.apache.axiom.soap.SOAPEnvelope getEnvelope()
Get the SOAP envelope of this message- Returns:
- the SOAP envelope of the message
-
setEnvelope
void setEnvelope(org.apache.axiom.soap.SOAPEnvelope envelope) throws org.apache.axis2.AxisFault
Sets the given envelope as the current SOAPEnvelope for this message- Parameters:
envelope
- the envelope to be set- Throws:
org.apache.axis2.AxisFault
- on exception
-
getFaultTo
org.apache.axis2.addressing.EndpointReference getFaultTo()
Get the faultTo EPR if available- Returns:
- FaultTo epr if available
-
setFaultTo
void setFaultTo(org.apache.axis2.addressing.EndpointReference reference)
Set the faultTo EPR- Parameters:
reference
- epr representing the FaultTo address
-
getFrom
org.apache.axis2.addressing.EndpointReference getFrom()
Get the from EPR if available- Returns:
- From epr if available
-
setFrom
void setFrom(org.apache.axis2.addressing.EndpointReference reference)
Set the from EPR- Parameters:
reference
- epr representing the From address
-
getMessageID
String getMessageID()
Get the message id if available- Returns:
- message id if available
-
setMessageID
void setMessageID(String string)
Set the message id- Parameters:
string
- message id to be set
-
getRelatesTo
org.apache.axis2.addressing.RelatesTo getRelatesTo()
Get the relatesTo of this message- Returns:
- RelatesTo of the message if available
-
setRelatesTo
void setRelatesTo(org.apache.axis2.addressing.RelatesTo[] reference)
Sets the relatesTo references for this message- Parameters:
reference
- the relatesTo references array
-
getReplyTo
org.apache.axis2.addressing.EndpointReference getReplyTo()
Get the replyTo EPR if available- Returns:
- ReplyTo epr of the message if available
-
setReplyTo
void setReplyTo(org.apache.axis2.addressing.EndpointReference reference)
Set the replyTo EPR- Parameters:
reference
- epr representing the ReplyTo address
-
getTo
org.apache.axis2.addressing.EndpointReference getTo()
Get the To EPR- Returns:
- To epr of the message if available
-
setTo
void setTo(org.apache.axis2.addressing.EndpointReference reference)
Set the To EPR- Parameters:
reference
- the To EPR
-
setWSAAction
void setWSAAction(String actionURI)
Sets the WSAAction- Parameters:
actionURI
- the WSAAction
-
getWSAAction
String getWSAAction()
Returns the WSAAction- Returns:
- the WSAAction
-
getSoapAction
String getSoapAction()
Returns the SOAPAction of the message- Returns:
- the SOAPAction
-
setSoapAction
void setSoapAction(String string)
Set the SOAPAction- Parameters:
string
- the SOAP Action
-
setWSAMessageID
void setWSAMessageID(String messageID)
Set the message- Parameters:
messageID
- message id to be set
-
getWSAMessageID
String getWSAMessageID()
Gets the message name- Returns:
- the WSA MessageID
-
isDoingMTOM
boolean isDoingMTOM()
If this message using MTOM?- Returns:
- true if using MTOM
-
isDoingSWA
boolean isDoingSWA()
If this message using SWA?- Returns:
- true if using SWA
-
setDoingMTOM
void setDoingMTOM(boolean b)
Marks as using MTOM- Parameters:
b
- true to mark as using MTOM
-
setDoingSWA
void setDoingSWA(boolean b)
Marks as using SWA- Parameters:
b
- true to mark as using SWA
-
isDoingPOX
boolean isDoingPOX()
Is this message over POX?- Returns:
- true if over POX
-
setDoingPOX
void setDoingPOX(boolean b)
Marks this message as over POX- Parameters:
b
- true to mark as POX
-
isDoingGET
boolean isDoingGET()
Is this message over GET?- Returns:
- true if over GET
-
setDoingGET
void setDoingGET(boolean b)
Marks this message as over REST/GET- Parameters:
b
- true to mark as REST/GET
-
isSOAP11
boolean isSOAP11()
Is this message a SOAP 1.1 message?- Returns:
- true if this is a SOAP 1.1 message
-
setResponse
void setResponse(boolean b)
Mark this message as a response or not.- Parameters:
b
- true to set this as a response- See Also:
isResponse()
-
isResponse
boolean isResponse()
Is this message a response to a synchronous message sent out through Synapse?- Returns:
- true if this message is a response message
-
setFaultResponse
void setFaultResponse(boolean b)
Marks this message as a fault response- Parameters:
b
- true to mark this as a fault response- See Also:
isFaultResponse()
-
isFaultResponse
boolean isFaultResponse()
Is this message a response to a fault message?- Returns:
- true if this is a response to a fault message
-
getTracingState
int getTracingState()
This is used to check whether the tracing should be enabled on the current mediator or not- Returns:
- indicate whether tracing is on, off or unset
-
setTracingState
void setTracingState(int tracingState)
This is used to set the value of tracing enable variable- Parameters:
tracingState
- Set whether the tracing is enabled or not
-
getFaultStack
Stack<FaultHandler> getFaultStack()
-
pushFaultHandler
void pushFaultHandler(FaultHandler fault)
-
getContinuationStateStack
Stack<ContinuationState> getContinuationStateStack()
Get the ContinuationStateStack.- Returns:
- ContinuationStateStack
-
pushContinuationState
void pushContinuationState(ContinuationState continuationState)
-
isContinuationEnabled
boolean isContinuationEnabled()
is ContinuationStateStack stack Operations enabled- Returns:
- whether ContinuationStateStack operations are enabled
-
setContinuationEnabled
void setContinuationEnabled(boolean continuationEnabled)
Enable/disable ContinuationStateStack operations- Parameters:
continuationEnabled
-
-
getServiceLog
org.apache.commons.logging.Log getServiceLog()
Return the service level Log for this message context or null- Returns:
- the service level Log for the message
-
getDefaultConfiguration
Mediator getDefaultConfiguration(String key)
Returns the InvokeMediator (which is wrapped with connector default configuration)- Parameters:
key
- the default configuration ref to be looked up- Returns:
- the sequence mediator mapped to the key
-
getMessageString
String getMessageString()
Get Message properties as a String- Returns:
- String with message property information
-
getMessageFlowTracingState
int getMessageFlowTracingState()
This is used to check whether the message flow tracing enabled for current message context- Returns:
- indicate whether message flow tracing is on, off or unset
-
setMessageFlowTracingState
void setMessageFlowTracingState(int tracingState)
This is used to set the value of message flow tracing enable for a particular message- Parameters:
tracingState
- Set whether the message flowtracing is enabled or not
-
-