Home » axis2-1.5-src » org.apache » axis2 » context » [javadoc | source]
org.apache.axis2.context
public class: MessageContext [javadoc | source]
java.lang.Object
   org.apache.axis2.context.AbstractContext
      org.apache.axis2.context.MessageContext

All Implemented Interfaces:
    SafeSerializable, Externalizable

Direct Known Subclasses:
    ScriptMessageContext

Axis2 states are held in two information models, called description hierarchy and context hierarchy. Description hierarchy hold deployment configuration and it's values does not change unless deployment configuration change occurs where Context hierarchy hold run time information. Both hierarchies consists four levels, Global, Service Group, Operation and Message. Please look at "Information Model" section of "Axis2 Architecture Guide" for more information.

MessageContext hold run time information about one Message invocation. It hold reference to OperationContext, ServiceGroupContext, and Configuration Context tied with current message. For an example if you need accesses to other messages of the current invocation, you can get to them via OperationContext. Addition to class attributes define in Message context, message context stores the information as name value pairs. Those name value pairs,and class attributes tweak the execution behavior of message context and some of them can be find in org.apache.axis2.Constants class. (TODO we should provide list of supported options). You may set them at any level of context hierarchy and they will affect invocations related to their child elements.

Field Summary
public static  ThreadLocal currentMessageContext    A place to store the current MessageContext 
protected  Options options   
    serial: Options - on the message
 
public static final  int IN_FLOW     
public static final  int IN_FAULT_FLOW     
public static final  int OUT_FLOW     
public static final  int OUT_FAULT_FLOW     
public static final  String REMOTE_ADDR     
public static final  String TRANSPORT_ADDR     
public static final  String TRANSPORT_HEADERS     
public transient  Attachments attachments    message attachments NOTE: Serialization of message attachments is handled as part of the overall message serialization. If this needs to change, then investigate having the Attachment class implement the java.io.Externalizable interface. 
public static final  String TRANSPORT_OUT    Field TRANSPORT_OUT 
public static final  String TRANSPORT_IN    Field TRANSPORT_IN 
public static final  String CHARACTER_SET_ENCODING    Field CHARACTER_SET_ENCODING 
public static final  String UTF_8    Field UTF_8. This is the 'utf-8' value for CHARACTER_SET_ENCODING property. 
public static final  String UTF_16    Field UTF_16. This is the 'utf-16' value for CHARACTER_SET_ENCODING property. 
public static final  String TRANSPORT_SUCCEED    Field TRANSPORT_SUCCEED 
public static final  String DEFAULT_CHAR_SET_ENCODING    Field DEFAULT_CHAR_SET_ENCODING. This is the default value for CHARACTER_SET_ENCODING property. 
public  int FLOW   
    serial: The - direction flow in use to figure out which path the message is in (send or receive)
 
public static final  String TRANSPORT_NON_BLOCKING    To invoke fireAndforget method we have to hand over transport sending logic to a thread other wise user has to wait till it get transport response (in the case of HTTP its HTTP 202) 
public static final  String DISABLE_ASYNC_CALLBACK_ON_TRANSPORT_ERROR    This property allows someone (e.g. RM) to disable an async callback from being invoked if a fault occurs during message transmission. If this is not set, it can be assumed that the fault will be delivered via Callback.onError(...). 
public  boolean outputWritten   
    serial: outputWritten -
 
Fields inherited from org.apache.axis2.context.AbstractContext:
COPY_PROPERTIES,  lastTouchedTime,  parent,  properties
Constructor:
 public MessageContext() 
 MessageContext(ConfigurationContext configContext) 
    Constructor has package access
    Parameters:
    configContext - the associated ConfigurationContext
Method from org.apache.axis2.context.MessageContext Summary:
activate,   activateWithOperationContext,   addAttachment,   addAttachment,   addExecutedPhase,   addRelatesTo,   containsSelfManagedDataKey,   extractCopyMessageContext,   getAttachment,   getAttachmentMap,   getAxisMessage,   getAxisOperation,   getAxisService,   getAxisServiceGroup,   getConfigurationContext,   getCurrentHandlerIndex,   getCurrentMessageContext,   getCurrentPhaseIndex,   getEffectivePolicy,   getEnvelope,   getExecutedPhases,   getExecutionChain,   getFLOW,   getFailureReason,   getFaultTo,   getFrom,   getInboundContentLength,   getIncomingTransportName,   getLocalProperty,   getLocalProperty,   getLogCorrelationID,   getLogIDString,   getMessageID,   getModuleParameter,   getOperationContext,   getOptions,   getParameter,   getProperties,   getProperty,   getRelatesTo,   getRelatesTo,   getRelationships,   getReplyTo,   getRootContext,   getSelfManagedData,   getServiceContext,   getServiceContextID,   getServiceGroupContext,   getServiceGroupContextId,   getSessionContext,   getSoapAction,   getTo,   getTransportIn,   getTransportOut,   getWSAAction,   isDoingMTOM,   isDoingREST,   isDoingSwA,   isEngaged,   isFault,   isHeaderPresent,   isNewThreadRequired,   isOutputWritten,   isPaused,   isProcessingFault,   isPropertyTrue,   isPropertyTrue,   isResponseWritten,   isSOAP11,   isServerSide,   pause,   readExternal,   removeAttachment,   removeFirstExecutedPhase,   removeSelfManagedData,   resetExecutedPhases,   setAttachmentMap,   setAxisMessage,   setAxisOperation,   setAxisService,   setAxisServiceGroup,   setConfigurationContext,   setCurrentHandlerIndex,   setCurrentMessageContext,   setCurrentPhaseIndex,   setDoingMTOM,   setDoingREST,   setDoingSwA,   setEnvelope,   setExecutedPhasesExplicit,   setExecutionChain,   setFLOW,   setFailureReason,   setFaultTo,   setFrom,   setIncomingTransportName,   setIsSOAP11Explicit,   setMessageID,   setNewThreadRequired,   setOperationContext,   setOptions,   setOptionsExplicit,   setOutputWritten,   setPaused,   setProcessingFault,   setRelationships,   setReplyTo,   setResponseWritten,   setSelfManagedData,   setSelfManagedDataMapExplicit,   setServerSide,   setServiceContext,   setServiceContextID,   setServiceGroupContext,   setServiceGroupContextId,   setSessionContext,   setSoapAction,   setTo,   setTransportIn,   setTransportOut,   setWSAAction,   setWSAMessageId,   toString,   writeExternal
Methods from org.apache.axis2.context.AbstractContext:
clearPropertyDifferences,   flush,   getLastTouchedTime,   getLocalProperty,   getParent,   getProperties,   getProperty,   getPropertyDifferences,   getPropertyNames,   getPropertyNonReplicable,   getRootContext,   isAncestor,   mergeProperties,   removeProperty,   removePropertyNonReplicable,   setLastTouchedTime,   setNonReplicableProperty,   setParent,   setProperties,   setProperty,   touch
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.axis2.context.MessageContext Detail:
 public  void activate(ConfigurationContext cc) 
    This method checks to see if additional work needs to be done in order to complete the object reconstitution. Some parts of the object restored from the readExternal() cannot be completed until we have a configurationContext from the active engine. The configurationContext is used to help this object to plug back into the engine's configuration and deployment objects.
 public  void activateWithOperationContext(OperationContext operationCtx) 
    This method checks to see if additional work needs to be done in order to complete the object reconstitution. Some parts of the object restored from the readExternal() cannot be completed until we have an object that gives us a view of the active object graph from the active engine.

    NOTE: when activating an object, you only need to call one of the activate methods (activate() or activateWithOperationContext()) but not both.

 public String addAttachment(DataHandler dataHandler) 
    Adds an attachment to the attachment Map of this message context. This attachment gets serialised as a MIME attachment when sending the message if SOAP with Attachments is enabled. Content ID of the MIME part will be auto generated by Axis2.
 public  void addAttachment(String contentID,
    DataHandler dataHandler) 
    Adds an attachment to the attachment Map of this message context. This attachment gets serialised as a MIME attachment when sending the message if SOAP with Attachments is enabled.
 public  void addExecutedPhase(Handler phase) 
    Add a Phase to the collection of executed phases for the path. Phases will be inserted in a LIFO data structure.
 public  void addRelatesTo(RelatesTo reference) 
    Add a RelatesTo
 public boolean containsSelfManagedDataKey(Class clazz,
    Object key) 
    Check to see if the key for the self managed data is available
 public MessageContext extractCopyMessageContext() 
    Return a Read-Only copy of this message context that has been extracted from the object hierachy. In other words, the message context copy does not have links to the object graph.

    NOTE: The copy shares certain objects with the original. The intent is to use the copy to read values but not modify them, especially since the copy is not part of the normal *Context and Axis* object graph.

 public DataHandler getAttachment(String contentID) 
    Access the DataHandler of the attachment contained in the map corresponding to the given content ID. Returns "NULL" if a attachment cannot be found by the given content ID.
 public Attachments getAttachmentMap() 
    You can directly access the attachment map of the message context from here. Returned attachment map can be empty.
 public AxisMessage getAxisMessage() 
 public AxisOperation getAxisOperation() 
 public AxisService getAxisService() 
 public AxisServiceGroup getAxisServiceGroup() 
 public ConfigurationContext getConfigurationContext() 
 public int getCurrentHandlerIndex() 
 public static MessageContext getCurrentMessageContext() 
 public int getCurrentPhaseIndex() 
 public Policy getEffectivePolicy() 
 public SOAPEnvelope getEnvelope() 
 public Iterator getExecutedPhases() 
    Get an iterator over the executed phase list.
 public ArrayList getExecutionChain() 
 public int getFLOW() 
 public Exception getFailureReason() 
    Obtain the Exception which caused the processing chain to halt.
 public EndpointReference getFaultTo() 
 public EndpointReference getFrom() 
 public long getInboundContentLength() throws IOException 
 public String getIncomingTransportName() 
 public Object getLocalProperty(String name) 
    Retrieves a property value. The order of search is as follows: search in my own map and then look at my options. Does not search up the hierarchy.
 public Object getLocalProperty(String name,
    boolean searchOptions) 
 public String getLogCorrelationID() 
    Get a "raw" version of the logCorrelationID. The logCorrelationID is guaranteed to be unique and may be persisted along with the rest of the message context.
 public String getLogIDString() 
    Get a formatted version of the logCorrelationID.
 public String getMessageID() 
 public Parameter getModuleParameter(String key,
    String moduleName,
    HandlerDescription handler) 
    Retrieves both module specific configuration parameters as well as other parameters. The order of search is as follows:
    1. Search in module configurations inside corresponding operation description if its there
    2. Search in corresponding operation if its there
    3. Search in module configurations inside corresponding service description if its there
    4. Next search in Corresponding Service description if its there
    5. Next search in module configurations inside axisConfiguration
    6. Search in AxisConfiguration for parameters
    7. Next get the corresponding module and search for the parameters
    8. Search in HandlerDescription for the parameter

    and the way of specifying module configuration is as follows N/A

 public OperationContext getOperationContext() 
 public Options getOptions() 
 public Parameter getParameter(String key) 
    Retrieves configuration descriptor parameters at any level. The order of search is as follows:
    1. Search in message description if it exists
    2. If parameter is not found or if axisMessage is null, search in AxisOperation
    3. If parameter is not found or if operationContext is null, search in AxisService
    4. If parameter is not found or if axisService is null, search in AxisConfiguration
 public Map getProperties() 
    Retrieves all property values. The order of search is as follows: search in my own options and then look in my context hierarchy. Since its possible that the entire hierarchy is not present, it will start at whatever level has been set and start there. The returned map is unmodifiable, so any changes to the properties have to be done by calling #setProperty(String,Object) . In addition, any changes to the properties are not reflected on this map.
 public Object getProperty(String name) 
    Retrieves a property value. The order of search is as follows: search in my own map and then look in my context hierarchy, and then in options. Since its possible that the entire hierarchy is not present, I will start at whatever level has been set.
 public RelatesTo getRelatesTo() 
 public RelatesTo getRelatesTo(String type) 
    Get any RelatesTos of a particular type associated with this MessageContext TODO: Shouldn't this return a List?
 public RelatesTo[] getRelationships() 
 public EndpointReference getReplyTo() 
 public ConfigurationContext getRootContext() 
 public Object getSelfManagedData(Class clazz,
    Object key) 
    Retrieve a value of self managed data previously saved with the specified key.
 public ServiceContext getServiceContext() 
 public String getServiceContextID() 
 public ServiceGroupContext getServiceGroupContext() 
 public String getServiceGroupContextId() 
 public SessionContext getSessionContext() 
 public String getSoapAction() 
 public EndpointReference getTo() 
 public TransportInDescription getTransportIn() 
 public TransportOutDescription getTransportOut() 
 public String getWSAAction() 
 public boolean isDoingMTOM() 
 public boolean isDoingREST() 
 public boolean isDoingSwA() 
 public boolean isEngaged(String moduleName) 
 public boolean isFault() 
 public boolean isHeaderPresent() 
Deprecated! The - bonus you used to get from this is now built in to SOAPEnvelope.getHeader()

    Gets the first child of the envelope, check if it is a soap:Body, which means there is no header. We do this basically to make sure we don't parse and build the om tree of the whole envelope looking for the soap header. If this method returns true, there still is no guarantee that there is a soap:Header present, use getHeader() and also check for null on getHeader() to be absolutely sure.
 public boolean isNewThreadRequired() 
 public boolean isOutputWritten() 
 public boolean isPaused() 
 public boolean isProcessingFault() 
 public boolean isPropertyTrue(String name) 
    Check if a given property is true. Will return false if the property does not exist or is not an explicit "true" value.
 public boolean isPropertyTrue(String name,
    boolean defaultVal) 
    Check if a given property is true. Will return the passed default if the property does not exist.
 public boolean isResponseWritten() 
 public boolean isSOAP11() 
 public boolean isServerSide() 
 public  void pause() 
    Pause the execution of the current handler chain
 public  void readExternal(ObjectInput inObject) throws ClassNotFoundException, IOException 
    Restore the contents of the MessageContext that was previously saved.

    NOTE: The field data must read back in the same order and type as it was written. Some data will need to be validated when resurrected.

 public  void removeAttachment(String contentID) 
    Removes the attachment with the given content ID from the Attachments Map Do nothing if a attachment cannot be found by the given content ID.
 public  void removeFirstExecutedPhase() 
    Remove the first Phase in the collection of executed phases
 public  void removeSelfManagedData(Class clazz,
    Object key) 
    Removes the mapping of the specified key if the specified key has been set for self managed data
 public  void resetExecutedPhases() 
    Reset the list of executed phases. This is needed because the OutInAxisOperation currently invokes receive() even when a fault occurs, and we will have already executed the flowComplete on those before receiveFault() is called.
 public  void setAttachmentMap(Attachments attachments) 
    Setting of the attachments map should be performed at the receipt of a message only. This method is only meant to be used by the Axis2 internals.
 public  void setAxisMessage(AxisMessage axisMessage) 
 public  void setAxisOperation(AxisOperation axisOperation) 
 public  void setAxisService(AxisService axisService) 
 public  void setAxisServiceGroup(AxisServiceGroup axisServiceGroup) 
 public  void setConfigurationContext(ConfigurationContext context) 
 public  void setCurrentHandlerIndex(int currentHandlerIndex) 
 public static  void setCurrentMessageContext(MessageContext ctx) 
 public  void setCurrentPhaseIndex(int currentPhaseIndex) 
 public  void setDoingMTOM(boolean b) 
 public  void setDoingREST(boolean b) 
 public  void setDoingSwA(boolean b) 
 public  void setEnvelope(SOAPEnvelope envelope) throws AxisFault 
 public  void setExecutedPhasesExplicit(LinkedList inb) 
 public  void setExecutionChain(ArrayList executionChain) 
    Set the execution chain of Handler in this MessageContext. Doing this causes the current handler/phase indexes to reset to 0, since we have new Handlers to execute (this usually only happens at initialization and when a fault occurs).
 public  void setFLOW(int FLOW) 
 public  void setFailureReason(Exception failureReason) 
    Set the failure reason. Only AxisEngine should ever do this.
 public  void setFaultTo(EndpointReference reference) 
 public  void setFrom(EndpointReference reference) 
 public  void setIncomingTransportName(String incomingTransportName) 
 public  void setIsSOAP11Explicit(boolean t) 
 public  void setMessageID(String messageId) 
 public  void setNewThreadRequired(boolean b) 
 public  void setOperationContext(OperationContext context) 
 public  void setOptions(Options options) 
    Set the options for myself. I make the given options my own options' parent so that that becomes the default. That allows the user to override specific options on a given message context and not affect the overall options.
 public  void setOptionsExplicit(Options op) 
 public  void setOutputWritten(boolean b) 
 public  void setPaused(boolean paused) 
 public  void setProcessingFault(boolean b) 
 public  void setRelationships(RelatesTo[] list) 
 public  void setReplyTo(EndpointReference reference) 
    Set ReplyTo destination
 public  void setResponseWritten(boolean b) 
 public  void setSelfManagedData(Class clazz,
    Object key,
    Object value) 
    Add a key-value pair of self managed data to the set associated with this message context.

    This is primarily intended to allow handlers to manage their own message-specific data when the message context is saved/restored.

 public  void setSelfManagedDataMapExplicit(LinkedHashMap map) 
 public  void setServerSide(boolean b) 
 public  void setServiceContext(ServiceContext context) 
 public  void setServiceContextID(String serviceContextID) 
    Sets the service context id.
 public  void setServiceGroupContext(ServiceGroupContext serviceGroupContext) 
 public  void setServiceGroupContextId(String serviceGroupContextId) 
 public  void setSessionContext(SessionContext sessionContext) 
 public  void setSoapAction(String soapAction) 
 public  void setTo(EndpointReference to) 
 public  void setTransportIn(TransportInDescription in) 
 public  void setTransportOut(TransportOutDescription out) 
 public  void setWSAAction(String actionURI) 
    setWSAAction
 public  void setWSAMessageId(String messageID) 
 public String toString() 
 public  void writeExternal(ObjectOutput o) throws IOException 
    Save the contents of this MessageContext instance.

    NOTE: Transient fields and static fields are not saved. Also, objects that represent "static" data are not saved, except for enough information to be able to find matching objects when the message context is re-constituted.