Package org.apache.synapse.core.axis2
Class Axis2MessageContext
- java.lang.Object
-
- org.apache.synapse.core.axis2.Axis2MessageContext
-
- All Implemented Interfaces:
MessageContext
public class Axis2MessageContext extends Object implements MessageContext
This is the MessageContext implementation that synapse uses almost all the time because Synapse is implemented on top of the Axis2
-
-
Constructor Summary
Constructors Constructor Description Axis2MessageContext(org.apache.axis2.context.MessageContext axisMsgCtx, SynapseConfiguration synCfg, SynapseEnvironment synEnv)Constructor for the Axis2MessageContext inside Synapse
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HashMap<String,Object>getAnalyticsMetadata()org.apache.axis2.context.MessageContextgetAxis2MessageContext()SynapseConfigurationgetConfiguration()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.MediatorgetDefaultConfiguration(String key)Returns the InvokeMediator (which is wrapped with connector default configuration)EndpointgetEndpoint(String key)Return the endpoint with the given key from the configuration, or the local message context.ObjectgetEntry(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.SOAPEnvelopegetEnvelope()Get the SOAP envelope of this messageSynapseEnvironmentgetEnvironment()Returns a reference to the host Synapse EnvironmentMediatorgetFaultSequence()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.EndpointReferencegetFaultTo()Get the faultTo EPR if availableorg.apache.axiom.om.OMElementgetFormat(String key)Return the format with the given key from the configuration.org.apache.axis2.addressing.EndpointReferencegetFrom()Get the from EPR if availableObjectgetLocalEntry(String key)Get the value of a property set on the message instance or from the local registryMediatorgetMainSequence()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.intgetMediatorPosition()intgetMessageFlowTracingState()This is used to check whether the message flow tracing enabled for current message contextStringgetMessageID()Get the message id if availableStringgetMessageString()Get Message properties as a StringMap<String,Object>getProperties()Get a read-only view of all the properties currently set on this message contextObjectgetProperty(String key)Get the value of a custom (local) property set on the message instanceSetgetPropertyKeySet()Returns the Set of keys over the properties on this message contextorg.apache.axis2.addressing.RelatesTogetRelatesTo()Get the relatesTo of this messageorg.apache.axis2.addressing.EndpointReferencegetReplyTo()Get the replyTo EPR if availableMediatorgetSequence(String key)Return the sequence with the given key from the configuration, or the local message context.MediatorgetSequenceTemplate(String key)Return the Sequence Template with the given key from the configuration, or the local message context.org.apache.commons.logging.LoggetServiceLog()Return the service level Log for this message context or nullStringgetSoapAction()Returns the SOAPAction of the messageorg.apache.axis2.addressing.EndpointReferencegetTo()Get the To EPRintgetTracingState()This is used to check whether the tracing should be enabled on the current mediator or notStringgetWSAAction()Returns the WSAActionStringgetWSAMessageID()Gets the message namebooleanisContinuationEnabled()is ContinuationStateStack stack Operations enabledbooleanisDoingGET()Is this message over GET?booleanisDoingMTOM()If this message using MTOM?booleanisDoingPOX()Is this message over POX?booleanisDoingSWA()If this message using SWA?booleanisFaultResponse()Is this message a response to a fault message?booleanisPaused()booleanisResponse()Is this message a response to a synchronous message sent out through Synapse?booleanisServerSide()booleanisSOAP11()Is this message a SOAP 1.1 message?voidpushContinuationState(ContinuationState continuationState)voidpushFaultHandler(FaultHandler fault)voidremoveAnalyticsMetadata(String key)voidsetAnalyticsMetadata(String key, Object value)Stores the value provided in the message context which will be published with analyticsvoidsetAxis2MessageContext(org.apache.axis2.context.MessageContext axisMsgCtx)voidsetConfiguration(SynapseConfiguration synCfg)Set or replace the Synapse Configuration instance to be used.voidsetContextEntries(Map<String,Object> entries)Sets the entries to the current context and not to the configuration.voidsetContinuationEnabled(boolean continuationEnabled)Enable/disable ContinuationStateStack operationsvoidsetDoingGET(boolean b)Marks this message as over REST/GETvoidsetDoingMTOM(boolean b)Marks as using MTOMvoidsetDoingPOX(boolean b)Marks this message as over POXvoidsetDoingSWA(boolean b)Marks as using SWAvoidsetEnvelope(org.apache.axiom.soap.SOAPEnvelope envelope)Sets the given envelope as the current SOAPEnvelope for this messagevoidsetEnvironment(SynapseEnvironment synEnv)Sets the SynapseEnvironment reference to this contextvoidsetFaultResponse(boolean b)Marks this message as a fault responsevoidsetFaultTo(org.apache.axis2.addressing.EndpointReference reference)Set the faultTo EPRvoidsetFrom(org.apache.axis2.addressing.EndpointReference reference)Set the from EPRvoidsetMediatorPosition(int mediatorPosition)voidsetMessageFlowTracingState(int messageFlowTracingState)This is used to set the value of message flow tracing enable for a particular messagevoidsetMessageID(String string)Set the message idvoidsetPaused(boolean value)voidsetProperty(String key, Object value)Set a custom (local) property with the given name on the message instancevoidsetRelatesTo(org.apache.axis2.addressing.RelatesTo[] reference)Sets the relatesTo references for this messagevoidsetReplyTo(org.apache.axis2.addressing.EndpointReference reference)Set the replyTo EPRvoidsetResponse(boolean b)Mark this message as a response or not.voidsetServerSide(boolean value)voidsetServiceLog(org.apache.commons.logging.Log serviceLog)Set the service logvoidsetSoapAction(String string)Set the SOAPActionvoidsetTo(org.apache.axis2.addressing.EndpointReference reference)Set the To EPRvoidsetTracingState(int tracingState)This is used to set the value of tracing enable variablevoidsetWSAAction(String actionURI)Sets the WSAActionvoidsetWSAMessageID(String messageID)Set the messageStringtoString()
-
-
-
Constructor Detail
-
Axis2MessageContext
public Axis2MessageContext(org.apache.axis2.context.MessageContext axisMsgCtx, SynapseConfiguration synCfg, SynapseEnvironment synEnv)Constructor for the Axis2MessageContext inside Synapse- Parameters:
axisMsgCtx- MessageContext representing the relevant Axis MCsynCfg- SynapseConfiguraion describing SynapsesynEnv- SynapseEnvironment describing the environment of Synapse
-
-
Method Detail
-
getConfiguration
public SynapseConfiguration getConfiguration()
Description copied from interface:MessageContextGet a reference to the current SynapseConfiguration- Specified by:
getConfigurationin interfaceMessageContext- Returns:
- the current synapse configuration
-
setConfiguration
public void setConfiguration(SynapseConfiguration synCfg)
Description copied from interface:MessageContextSet or replace the Synapse Configuration instance to be used. May be used to programatically change the configuration at runtime etc.- Specified by:
setConfigurationin interfaceMessageContext- Parameters:
synCfg- The new synapse configuration instance
-
getEnvironment
public SynapseEnvironment getEnvironment()
Description copied from interface:MessageContextReturns a reference to the host Synapse Environment- Specified by:
getEnvironmentin interfaceMessageContext- Returns:
- the Synapse Environment
-
setEnvironment
public void setEnvironment(SynapseEnvironment synEnv)
Description copied from interface:MessageContextSets the SynapseEnvironment reference to this context- Specified by:
setEnvironmentin interfaceMessageContext- Parameters:
synEnv- the reference to the Synapse Environment
-
getContextEntries
public Map<String,Object> getContextEntries()
Description copied from interface:MessageContextReturn 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.- Specified by:
getContextEntriesin interfaceMessageContext- Returns:
- the set of local entries in the context
-
setContextEntries
public void setContextEntries(Map<String,Object> entries)
Description copied from interface:MessageContextSets 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- Specified by:
setContextEntriesin interfaceMessageContext- Parameters:
entries- the set of local entries to be set
-
getMainSequence
public Mediator getMainSequence()
Description copied from interface:MessageContextReturn 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- Specified by:
getMainSequencein interfaceMessageContext- Returns:
- the main sequence to be used for mediation
-
getFaultSequence
public Mediator getFaultSequence()
Description copied from interface:MessageContextReturn 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- Specified by:
getFaultSequencein interfaceMessageContext- Returns:
- the fault sequence to be used for mediation
-
getSequence
public Mediator getSequence(String key)
Description copied from interface:MessageContextReturn 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- Specified by:
getSequencein interfaceMessageContext- Parameters:
key- the sequence key to be looked up- Returns:
- the sequence mediator mapped to the key
-
getDefaultConfiguration
public Mediator getDefaultConfiguration(String key)
Description copied from interface:MessageContextReturns the InvokeMediator (which is wrapped with connector default configuration)- Specified by:
getDefaultConfigurationin interfaceMessageContext- Parameters:
key- the default configuration ref to be looked up- Returns:
- the sequence mediator mapped to the key
-
getFormat
public org.apache.axiom.om.OMElement getFormat(String key)
Description copied from interface:MessageContextReturn the format with the given key from the configuration.- Specified by:
getFormatin interfaceMessageContext- Returns:
- the format mapped with the key
-
getSequenceTemplate
public Mediator getSequenceTemplate(String key)
Description copied from interface:MessageContextReturn 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- Specified by:
getSequenceTemplatein interfaceMessageContext- Parameters:
key- the sequence key to be looked up- Returns:
- the Template mediator mapped to the key
-
getEndpoint
public Endpoint getEndpoint(String key)
Description copied from interface:MessageContextReturn 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- Specified by:
getEndpointin interfaceMessageContext- Parameters:
key- the endpoint key to be looked up- Returns:
- the endpoint mapped to the key
-
getEntry
public Object getEntry(String key)
Description copied from interface:MessageContextGet the value of a property set on the message instance, from the local registry or the remote registry - by cascading through- Specified by:
getEntryin interfaceMessageContext- Parameters:
key- key to look up property- Returns:
- value for the given key
-
getLocalEntry
public Object getLocalEntry(String key)
Description copied from interface:MessageContextGet the value of a property set on the message instance or from the local registry- Specified by:
getLocalEntryin interfaceMessageContext- Parameters:
key- key to look up property- Returns:
- value for the given key
-
getProperties
public Map<String,Object> getProperties()
Get a read-only view of all the properties currently set on this message context- Returns:
- an unmodifiable map of message context properties
-
getProperty
public Object getProperty(String key)
Description copied from interface:MessageContextGet the value of a custom (local) property set on the message instance- Specified by:
getPropertyin interfaceMessageContext- Parameters:
key- key to look up property- Returns:
- value for the given key
-
setProperty
public void setProperty(String key, Object value)
Description copied from interface:MessageContextSet a custom (local) property with the given name on the message instance- Specified by:
setPropertyin interfaceMessageContext- Parameters:
key- key to be usedvalue- value to be saved
-
getPropertyKeySet
public Set getPropertyKeySet()
Description copied from interface:MessageContextReturns the Set of keys over the properties on this message context- Specified by:
getPropertyKeySetin interfaceMessageContext- Returns:
- a Set of keys over message properties
-
getFaultTo
public org.apache.axis2.addressing.EndpointReference getFaultTo()
Description copied from interface:MessageContextGet the faultTo EPR if available- Specified by:
getFaultToin interfaceMessageContext- Returns:
- FaultTo epr if available
-
setFaultTo
public void setFaultTo(org.apache.axis2.addressing.EndpointReference reference)
Description copied from interface:MessageContextSet the faultTo EPR- Specified by:
setFaultToin interfaceMessageContext- Parameters:
reference- epr representing the FaultTo address
-
getFrom
public org.apache.axis2.addressing.EndpointReference getFrom()
Description copied from interface:MessageContextGet the from EPR if available- Specified by:
getFromin interfaceMessageContext- Returns:
- From epr if available
-
setFrom
public void setFrom(org.apache.axis2.addressing.EndpointReference reference)
Description copied from interface:MessageContextSet the from EPR- Specified by:
setFromin interfaceMessageContext- Parameters:
reference- epr representing the From address
-
getEnvelope
public org.apache.axiom.soap.SOAPEnvelope getEnvelope()
Description copied from interface:MessageContextGet the SOAP envelope of this message- Specified by:
getEnvelopein interfaceMessageContext- Returns:
- the SOAP envelope of the message
-
setEnvelope
public void setEnvelope(org.apache.axiom.soap.SOAPEnvelope envelope) throws org.apache.axis2.AxisFaultDescription copied from interface:MessageContextSets the given envelope as the current SOAPEnvelope for this message- Specified by:
setEnvelopein interfaceMessageContext- Parameters:
envelope- the envelope to be set- Throws:
org.apache.axis2.AxisFault- on exception
-
getMessageID
public String getMessageID()
Description copied from interface:MessageContextGet the message id if available- Specified by:
getMessageIDin interfaceMessageContext- Returns:
- message id if available
-
setMessageID
public void setMessageID(String string)
Description copied from interface:MessageContextSet the message id- Specified by:
setMessageIDin interfaceMessageContext- Parameters:
string- message id to be set
-
getRelatesTo
public org.apache.axis2.addressing.RelatesTo getRelatesTo()
Description copied from interface:MessageContextGet the relatesTo of this message- Specified by:
getRelatesToin interfaceMessageContext- Returns:
- RelatesTo of the message if available
-
setRelatesTo
public void setRelatesTo(org.apache.axis2.addressing.RelatesTo[] reference)
Description copied from interface:MessageContextSets the relatesTo references for this message- Specified by:
setRelatesToin interfaceMessageContext- Parameters:
reference- the relatesTo references array
-
getReplyTo
public org.apache.axis2.addressing.EndpointReference getReplyTo()
Description copied from interface:MessageContextGet the replyTo EPR if available- Specified by:
getReplyToin interfaceMessageContext- Returns:
- ReplyTo epr of the message if available
-
setReplyTo
public void setReplyTo(org.apache.axis2.addressing.EndpointReference reference)
Description copied from interface:MessageContextSet the replyTo EPR- Specified by:
setReplyToin interfaceMessageContext- Parameters:
reference- epr representing the ReplyTo address
-
getTo
public org.apache.axis2.addressing.EndpointReference getTo()
Description copied from interface:MessageContextGet the To EPR- Specified by:
getToin interfaceMessageContext- Returns:
- To epr of the message if available
-
setTo
public void setTo(org.apache.axis2.addressing.EndpointReference reference)
Description copied from interface:MessageContextSet the To EPR- Specified by:
setToin interfaceMessageContext- Parameters:
reference- the To EPR
-
setWSAAction
public void setWSAAction(String actionURI)
Description copied from interface:MessageContextSets the WSAAction- Specified by:
setWSAActionin interfaceMessageContext- Parameters:
actionURI- the WSAAction
-
getWSAAction
public String getWSAAction()
Description copied from interface:MessageContextReturns the WSAAction- Specified by:
getWSAActionin interfaceMessageContext- Returns:
- the WSAAction
-
setWSAMessageID
public void setWSAMessageID(String messageID)
Description copied from interface:MessageContextSet the message- Specified by:
setWSAMessageIDin interfaceMessageContext- Parameters:
messageID- message id to be set
-
getWSAMessageID
public String getWSAMessageID()
Description copied from interface:MessageContextGets the message name- Specified by:
getWSAMessageIDin interfaceMessageContext- Returns:
- the WSA MessageID
-
getSoapAction
public String getSoapAction()
Description copied from interface:MessageContextReturns the SOAPAction of the message- Specified by:
getSoapActionin interfaceMessageContext- Returns:
- the SOAPAction
-
setSoapAction
public void setSoapAction(String string)
Description copied from interface:MessageContextSet the SOAPAction- Specified by:
setSoapActionin interfaceMessageContext- Parameters:
string- the SOAP Action
-
isDoingMTOM
public boolean isDoingMTOM()
Description copied from interface:MessageContextIf this message using MTOM?- Specified by:
isDoingMTOMin interfaceMessageContext- Returns:
- true if using MTOM
-
isDoingSWA
public boolean isDoingSWA()
Description copied from interface:MessageContextIf this message using SWA?- Specified by:
isDoingSWAin interfaceMessageContext- Returns:
- true if using SWA
-
setDoingMTOM
public void setDoingMTOM(boolean b)
Description copied from interface:MessageContextMarks as using MTOM- Specified by:
setDoingMTOMin interfaceMessageContext- Parameters:
b- true to mark as using MTOM
-
setDoingSWA
public void setDoingSWA(boolean b)
Description copied from interface:MessageContextMarks as using SWA- Specified by:
setDoingSWAin interfaceMessageContext- Parameters:
b- true to mark as using SWA
-
isDoingPOX
public boolean isDoingPOX()
Description copied from interface:MessageContextIs this message over POX?- Specified by:
isDoingPOXin interfaceMessageContext- Returns:
- true if over POX
-
setDoingPOX
public void setDoingPOX(boolean b)
Description copied from interface:MessageContextMarks this message as over POX- Specified by:
setDoingPOXin interfaceMessageContext- Parameters:
b- true to mark as POX
-
isDoingGET
public boolean isDoingGET()
Description copied from interface:MessageContextIs this message over GET?- Specified by:
isDoingGETin interfaceMessageContext- Returns:
- true if over GET
-
setDoingGET
public void setDoingGET(boolean b)
Description copied from interface:MessageContextMarks this message as over REST/GET- Specified by:
setDoingGETin interfaceMessageContext- Parameters:
b- true to mark as REST/GET
-
isSOAP11
public boolean isSOAP11()
Description copied from interface:MessageContextIs this message a SOAP 1.1 message?- Specified by:
isSOAP11in interfaceMessageContext- Returns:
- true if this is a SOAP 1.1 message
-
setResponse
public void setResponse(boolean b)
Description copied from interface:MessageContextMark this message as a response or not.- Specified by:
setResponsein interfaceMessageContext- Parameters:
b- true to set this as a response- See Also:
MessageContext.isResponse()
-
isResponse
public boolean isResponse()
Description copied from interface:MessageContextIs this message a response to a synchronous message sent out through Synapse?- Specified by:
isResponsein interfaceMessageContext- Returns:
- true if this message is a response message
-
setFaultResponse
public void setFaultResponse(boolean b)
Description copied from interface:MessageContextMarks this message as a fault response- Specified by:
setFaultResponsein interfaceMessageContext- Parameters:
b- true to mark this as a fault response- See Also:
MessageContext.isFaultResponse()
-
isFaultResponse
public boolean isFaultResponse()
Description copied from interface:MessageContextIs this message a response to a fault message?- Specified by:
isFaultResponsein interfaceMessageContext- Returns:
- true if this is a response to a fault message
-
getTracingState
public int getTracingState()
Description copied from interface:MessageContextThis is used to check whether the tracing should be enabled on the current mediator or not- Specified by:
getTracingStatein interfaceMessageContext- Returns:
- indicate whether tracing is on, off or unset
-
setTracingState
public void setTracingState(int tracingState)
Description copied from interface:MessageContextThis is used to set the value of tracing enable variable- Specified by:
setTracingStatein interfaceMessageContext- Parameters:
tracingState- Set whether the tracing is enabled or not
-
getFaultStack
public Stack<FaultHandler> getFaultStack()
- Specified by:
getFaultStackin interfaceMessageContext
-
pushFaultHandler
public void pushFaultHandler(FaultHandler fault)
- Specified by:
pushFaultHandlerin interfaceMessageContext
-
pushContinuationState
public void pushContinuationState(ContinuationState continuationState)
- Specified by:
pushContinuationStatein interfaceMessageContext
-
getContinuationStateStack
public Stack<ContinuationState> getContinuationStateStack()
Description copied from interface:MessageContextGet the ContinuationStateStack.- Specified by:
getContinuationStateStackin interfaceMessageContext- Returns:
- ContinuationStateStack
-
getServiceLog
public org.apache.commons.logging.Log getServiceLog()
Return the service level Log for this message context or null- Specified by:
getServiceLogin interfaceMessageContext- Returns:
- the service level Log for the message
-
setServiceLog
public void setServiceLog(org.apache.commons.logging.Log serviceLog)
Set the service log- Parameters:
serviceLog- log to be used on a per-service basis
-
getAxis2MessageContext
public org.apache.axis2.context.MessageContext getAxis2MessageContext()
-
setAxis2MessageContext
public void setAxis2MessageContext(org.apache.axis2.context.MessageContext axisMsgCtx)
-
setPaused
public void setPaused(boolean value)
-
isPaused
public boolean isPaused()
-
isServerSide
public boolean isServerSide()
-
setServerSide
public void setServerSide(boolean value)
-
isContinuationEnabled
public boolean isContinuationEnabled()
Description copied from interface:MessageContextis ContinuationStateStack stack Operations enabled- Specified by:
isContinuationEnabledin interfaceMessageContext- Returns:
- whether ContinuationStateStack operations are enabled
-
setContinuationEnabled
public void setContinuationEnabled(boolean continuationEnabled)
Description copied from interface:MessageContextEnable/disable ContinuationStateStack operations- Specified by:
setContinuationEnabledin interfaceMessageContext
-
setMediatorPosition
public void setMediatorPosition(int mediatorPosition)
-
getMediatorPosition
public int getMediatorPosition()
-
getMessageString
public String getMessageString()
Description copied from interface:MessageContextGet Message properties as a String- Specified by:
getMessageStringin interfaceMessageContext- Returns:
- String with message property information
-
getMessageFlowTracingState
public int getMessageFlowTracingState()
Description copied from interface:MessageContextThis is used to check whether the message flow tracing enabled for current message context- Specified by:
getMessageFlowTracingStatein interfaceMessageContext- Returns:
- indicate whether message flow tracing is on, off or unset
-
setMessageFlowTracingState
public void setMessageFlowTracingState(int messageFlowTracingState)
Description copied from interface:MessageContextThis is used to set the value of message flow tracing enable for a particular message- Specified by:
setMessageFlowTracingStatein interfaceMessageContext- Parameters:
messageFlowTracingState- Set whether the message flowtracing is enabled or not
-
setAnalyticsMetadata
public void setAnalyticsMetadata(String key, Object value)
Stores the value provided in the message context which will be published with analytics- Parameters:
key- key for the analyticvalue- analytic value
-
removeAnalyticsMetadata
public void removeAnalyticsMetadata(String key)
-
-