Package 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
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:
-
Field Summary
Fields inherited from class org.apache.axis2.context.AbstractContext
COPY_PROPERTIES, lastTouchedTime, parent, properties -
Constructor Summary
ConstructorsConstructorDescriptionSimple constructor (needed for deserialization, shouldn't be used otherwise!)OperationContext(AxisOperation axisOperation, ServiceContext serviceContext) Constructs a new OperationContext. -
Method Summary
Modifier and TypeMethodDescriptionvoidThis method checks to see if additional work needs to be done in order to complete the object reconstitution.voidaddMessageContext(MessageContext msgContext) When a new message is added to theMEPContextthe logic should be included remove the MEPContext from the table in theEngineContext.voidcleanup()Removes the pointers to thisOperationContextin theConfigurationContext's OperationContextMap so that thisOperationContextwill eventually get garbage collected along with theMessageContext's it contains.Returns the EngineContext in which the parent ServiceContext lives.Get the ID associated with this object instance.getMessageContext(String messageLabel) Get the message context identified by a given label.Get the name associated with the operation.Returns the ServiceContext in which this OperationContext lives.Get the name associated with the service group.Get the name associated with the service.booleanChecks 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.booleanCompares key parts of the state from the current instance of this class with the specified instance to see if they are equivalent.voidIsolate the specified message context object to prepare for serialization.voidreadExternal(ObjectInput inObject) Restore the contents of the object that was previously saved.voidremoveMessageContext(String label) Remove the indicated message context.voidRestore the specified MessageContext object in the table used to hold the message contexts associated with this operation.voidsetComplete(boolean complete) voidvoidSave 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
-
Constructor Details
-
OperationContext
public OperationContext()Simple constructor (needed for deserialization, shouldn't be used otherwise!) -
OperationContext
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 Details
-
addMessageContext
When a new message is added to theMEPContextthe logic should be included remove the MEPContext from the table in theEngineContext. 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 thisOperationContextin theConfigurationContext's OperationContextMap so that thisOperationContextwill eventually get garbage collected along with theMessageContext'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
- Returns:
- Returns the axisOperation.
-
getConfigurationContext
Returns the EngineContext in which the parent ServiceContext lives.- Returns:
- Returns parent ServiceContext's parent EngineContext.
-
getMessageContext
Get the message context identified by a given label.- Parameters:
messageLabel- The label of the message context to retrieve. This should be one of theMESSAGE_LABEL_xxxconstants defined inWSDLConstants.- Returns:
- the message context for the given label, or
nullif no message context was found - Throws:
AxisFault- never
-
removeMessageContext
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
-
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
-
writeExternal
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:
writeExternalin interfaceExternalizable- Parameters:
out- The stream to write the object contents to- Throws:
IOException
-
readExternal
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:
readExternalin interfaceExternalizable- Parameters:
in- The stream to read the object contents from- Throws:
IOExceptionClassNotFoundException
-
activate
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
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
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
Get the name associated with the operation.- Returns:
- The name String
-
getServiceName
Get the name associated with the service.- Returns:
- The name String
-
getServiceGroupName
Get the name associated with the service group.- Returns:
- The name String
-
isEquivalent
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
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
- Specified by:
getRootContextin classAbstractContext
-