Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.axis2.context
Class OperationContext

    java.lang.Object
      org.apache.axis2.context.AbstractContext
          org.apache.axis2.context.OperationContext

All Implemented Interfaces:
  Externalizable, Serializable, SafeSerializable

    public class OperationContext

extends AbstractContext
implements Externalizable, SafeSerializable

An OperationContext represents a running "instance" of an operation, which is represented by an AxisOperation object. This concept is needed to allow messages to be grouped into operations as in WSDL 2.0-speak operations are essentially arbitrary message exchange patterns. So as messages are being exchanged the OperationContext remembers the state of where in the message exchange pattern it is in.

The base implementation of OperationContext supports MEPs which have one input message and/or one output message. That is, it supports the all the MEPs that are in the WSDL 2.0 specification. In order to support another MEP one must extend this class and register its creation in the OperationContexFactory.

See Also:
  Serialized Form

Field Summary

Fields inherited from class org.apache.axis2.context.AbstractContext
`COPY_PROPERTIES, lastTouchedTime, parent, properties`

Constructor Summary
`OperationContext()` Simple constructor (needed for deserialization, shouldn't be used otherwise!)
`OperationContext(AxisOperation axisOperation, ServiceContext serviceContext)` Constructs a new OperationContext.

Method Summary
`void` | `activate(ConfigurationContext cc)` This method checks to see if additional work needs to be done in order to complete the object reconstitution.
`void` | `addMessageContext(MessageContext msgContext)` When a new message is added to the `MEPContext` the logic should be included remove the MEPContext from the table in the `EngineContext`.
`void` | `cleanup()` Removes the pointers to this `OperationContext` in the `ConfigurationContext`'s OperationContextMap so that this `OperationContext` will eventually get garbage collected along with the `MessageContext`'s it contains.
`AxisOperation` | `getAxisOperation()`
`ConfigurationContext` | `getConfigurationContext()` Returns the EngineContext in which the parent ServiceContext lives.
`String` | `getLogCorrelationIDString()` Get the ID associated with this object instance.
`MessageContext` | `getMessageContext(String messageLabel)` Get the message context identified by a given label.
`HashMap<String,MessageContext>` | `getMessageContexts()`
`String` | `getOperationName()` Get the name associated with the operation.
`ConfigurationContext` | `getRootContext()`
`ServiceContext` | `getServiceContext()` Returns the ServiceContext in which this OperationContext lives.
`String` | `getServiceGroupName()` Get the name associated with the service group.
`String` | `getServiceName()` Get the name associated with the service.
`boolean` | `isComplete()` Checks to see if the MEP is complete.
`boolean` | `isEquivalent(OperationContext ctx)` Compares key parts of the state from the current instance of this class with the specified instance to see if they are equivalent.
`void` | `isolateMessageContext(MessageContext mc)` Isolate the specified message context object to prepare for serialization.
`void` | `readExternal(ObjectInput inObject)` Restore the contents of the object that was previously saved.
`void` | `removeMessageContext(String label)` Remove the indicated message context.
`void` | `restoreMessageContext(MessageContext msg)` Restore the specified MessageContext object in the table used to hold the message contexts associated with this operation.
`void` | `setComplete(boolean complete)`
`void` | `setKey(String key)`
`void` | `writeExternal(ObjectOutput o)` Save the contents of this object.

Methods inherited from class org.apache.axis2.context.AbstractContext
`clearPropertyDifferences, flush, getLastTouchedTime, getLocalProperty, getParent, getProperties, getProperty, getPropertyDifferences, getPropertyNames, getPropertyNonReplicable, isAncestor, mergeProperties, removeProperty, removePropertyNonReplicable, setLastTouchedTime, setNonReplicableProperty, setParent, setProperties, setProperty, touch`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### OperationContext

    public OperationContext()

  Simple constructor (needed for deserialization, shouldn't be used otherwise!)

### OperationContext

    public OperationContext(AxisOperation axisOperation,
                            ServiceContext serviceContext)

  Constructs a new OperationContext.

  Parameters:
    `axisOperation` - the AxisOperation whose running instances' state this OperationContext represents.
    `serviceContext` - the parent ServiceContext representing any state related to the set of all operations of the service.

Method Detail

### addMessageContext

    public void addMessageContext(MessageContext msgContext)
                           throws AxisFault

  When a new message is added to the `MEPContext` the logic should be included remove the MEPContext from the table in the `EngineContext`. Example: IN_IN_OUT At the second IN message the MEPContext should be removed from the AxisOperation.

  Parameters:
    `msgContext` -
  Throws:
    `AxisFault`

### cleanup

    public void cleanup()

  Removes the pointers to this `OperationContext` in the `ConfigurationContext`'s OperationContextMap so that this `OperationContext` will eventually get garbage collected along with the `MessageContext`'s it contains. Note that if the caller wants to make sure its safe to clean up this OperationContext he should call isComplete() first. However, in cases like IN_OPTIONAL_OUT and OUT_OPTIONAL_IN, it is possibe this will get called without the MEP being complete due to the optional nature of the MEP.

### getAxisOperation

    public AxisOperation getAxisOperation()

  Returns:
    Returns the axisOperation.

### getConfigurationContext

    public ConfigurationContext getConfigurationContext()

  Returns the EngineContext in which the parent ServiceContext lives.

  Returns:
    Returns parent ServiceContext's parent EngineContext.

### getMessageContext

    public MessageContext getMessageContext(String messageLabel)
                                     throws AxisFault

  Get the message context identified by a given label.

  Parameters:
    `messageLabel` - The label of the message context to retrieve. This should be one of the `MESSAGE_LABEL_xxx` constants defined in `WSDLConstants`.
  Returns:
    the message context for the given label, or `null` if no message context was found
  Throws:
    `AxisFault` - never

### removeMessageContext

    public void removeMessageContext(String label)
                              throws AxisFault

  Remove the indicated message context. Example Usage: The exchange is aborted and we need to undo the work and free resources.

  Parameters:
    `label` -
  Throws:
    `AxisFault`

### getMessageContexts

    public HashMap<String,MessageContext> getMessageContexts()

### getServiceContext

    public ServiceContext getServiceContext()

  Returns the ServiceContext in which this OperationContext lives.

  Returns:
    Returns parent ServiceContext.

### isComplete

    public boolean isComplete()

  Checks to see if the MEP is complete. i.e. whether all the messages that are associated with the MEP has arrived and MEP is complete.

### setComplete

    public void setComplete(boolean complete)

### setKey

    public void setKey(String key)

### writeExternal

    public void writeExternal(ObjectOutput o)
                       throws IOException

  Save the contents of this object.

  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.

  Specified by:
    `writeExternal` in interface `Externalizable`
  Parameters:
    `out` - The stream to write the object contents to
  Throws:
    `IOException`

### readExternal

    public void readExternal(ObjectInput inObject)
                      throws IOException,
                             ClassNotFoundException

  Restore the contents of the object 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.

  Specified by:
    `readExternal` in interface `Externalizable`
  Parameters:
    `in` - The stream to read the object contents from
  Throws:
    `IOException`
    `ClassNotFoundException`

### activate

    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.

  Parameters:
    `cc` - The configuration context object representing the active configuration

### isolateMessageContext

    public void isolateMessageContext(MessageContext mc)

  Isolate the specified message context object to prepare for serialization. Instead of saving the entire message context object, just setup some metadata about the message context.

  Note: this will remove the specified message context object from the message context table.

  Parameters:
    `mc` - The message context object

### restoreMessageContext

    public void restoreMessageContext(MessageContext msg)

  Restore the specified MessageContext object in the table used to hold the message contexts associated with this operation.

  Parameters:
    `msg` - The message context object

### getOperationName

    public String getOperationName()

  Get the name associated with the operation.

  Returns:
    The name String

### getServiceName

    public String getServiceName()

  Get the name associated with the service.

  Returns:
    The name String

### getServiceGroupName

    public String getServiceGroupName()

  Get the name associated with the service group.

  Returns:
    The name String

### isEquivalent

    public boolean isEquivalent(OperationContext ctx)

  Compares key parts of the state from the current instance of this class with the specified instance to see if they are equivalent.

  This differs from the java.lang.Object.equals() method in that the equals() method generally looks at both the object identity (location in memory) and the object state (data).

  Parameters:
    `ctx` - The object to compare with
  Returns:
    TRUE if this object is equivalent with the specified object that is, key fields match FALSE, otherwise

### getLogCorrelationIDString

    public String getLogCorrelationIDString()

  Get the ID associated with this object instance.

  Returns:
    A string that can be output to a log file as an identifier for this object instance. It is suitable for matching related log entries.

### getRootContext

    public ConfigurationContext getRootContext()

  Specified by:
    `getRootContext` in class `AbstractContext`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2004-2011 The Apache Software Foundation. All Rights Reserved.