while (i.hasNext()) {
Object obj = i.next();
String objClass = obj.getClass().getName();
// start the meta data entry for this object
MetaDataEntry mdEntry = new MetaDataEntry();
mdEntry.setClassName(objClass);
// get the correct object-specific name
String qnameAsString;
if (obj instanceof Phase) {
Phase phaseObj = (Phase) obj;
qnameAsString = phaseObj.getName();
// add the list of handlers to the meta data
setupPhaseList(phaseObj, mdEntry);
} else if (obj instanceof Handler) {
Handler handlerObj = (Handler) obj;
qnameAsString = handlerObj.getName();
} else {
// TODO: will there be any other kinds of objects in the execution Chain?
qnameAsString = "NULL";
}
mdEntry.setQName(qnameAsString);
// update the index for the entry in the chain
if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
log.trace(logCorrelationIDString +
":writeExternal(): ***BEFORE OBJ WRITE*** executionChain entry class [" +
objClass + "] qname [" + qnameAsString + "]");
}
ObjectStateUtils.writeObject(out, mdEntry, logCorrelationIDString +
".executionChain:entry class [" + objClass + "] qname [" + qnameAsString +
"]");
// update the index so that the index
// now indicates the next entry that
// will be attempted
nextIndex++;
if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
log.trace(logCorrelationIDString +
":writeExternal(): ***AFTER OBJ WRITE*** executionChain entry class [" +
objClass + "] qname [" + qnameAsString + "]");
}
} // end while entries in execution chain
// done with the entries in the execution chain
// add the end-of-list marker
MetaDataEntry lastEntry = new MetaDataEntry();
lastEntry.setClassName(MetaDataEntry.END_OF_LIST);
ObjectStateUtils.writeObject(out, lastEntry,
logCorrelationIDString + ".executionChain: last entry ");
nextIndex++;
// nextIndex also gives us the number of entries
// that were actually saved as opposed to the
// number of entries in the executionChain
out.writeInt(nextIndex);
} else {
// general case: handle "null" or "empty"
out.writeUTF(execChainDesc);
out.writeBoolean(ObjectStateUtils.EMPTY_OBJECT);
if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
log.trace(logCorrelationIDString + ":writeExternal(): executionChain is NULL");
}
}
//---------------------------------------------------------
// LinkedList executedPhases
//---------------------------------------------------------
// The strategy is to save some metadata about each
// member of the list and the order of the list.
// Then when the message context is re-constituted,
// try to match up with phases and handlers on the
// engine.
//
// Non-null list:
// UTF - description string
// boolean - active flag
// int - expected number of entries in the list
// objects - MetaDataEntry object per list entry
// last entry will be empty MetaDataEntry
// with MetaDataEntry.LAST_ENTRY marker
// int - adjusted number of entries in the list
// includes the last empty entry
//
// Empty list:
// UTF - description string
// boolean - empty flag
//---------------------------------------------------------
String execListDesc = logCorrelationIDString + ".executedPhases";
int execListSize = 0;
if (executedPhases != null) {
execListSize = executedPhases.size();
}
if (execListSize > 0) {
// start writing data to the output stream
out.writeUTF(execListDesc);
out.writeBoolean(ObjectStateUtils.ACTIVE_OBJECT);
out.writeInt(execListSize);
// put the metadata on each member of the list into a buffer
int execNextIndex = 0;
Iterator iterator = executedPhases.iterator();
while (iterator.hasNext()) {
Object obj = iterator.next();
String objClass = obj.getClass().getName();
// start the meta data entry for this object
MetaDataEntry mdEntry = new MetaDataEntry();
mdEntry.setClassName(objClass);
// get the correct object-specific name
String qnameAsString;
if (obj instanceof Phase) {
Phase inPhaseObj = (Phase) obj;
qnameAsString = inPhaseObj.getName();
// add the list of handlers to the meta data
setupPhaseList(inPhaseObj, mdEntry);
} else if (obj instanceof Handler) {
Handler inHandlerObj = (Handler) obj;
qnameAsString = inHandlerObj.getName();
} else {
// TODO: will there be any other kinds of objects in the list
qnameAsString = "NULL";
}
mdEntry.setQName(qnameAsString);
if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
log.trace(logCorrelationIDString +
":writeExternal(): ***BEFORE Executed List OBJ WRITE*** executedPhases entry class [" +
objClass + "] qname [" + qnameAsString + "]");
}
ObjectStateUtils.writeObject(out, mdEntry, logCorrelationIDString +
".executedPhases:entry class [" + objClass + "] qname [" +
qnameAsString + "]");
// update the index so that the index
// now indicates the next entry that
// will be attempted
execNextIndex++;
if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
log.trace(logCorrelationIDString + ":writeExternal(): " +
"***AFTER Executed List OBJ WRITE*** " +
"executedPhases entry class [" + objClass + "] " +
"qname [" + qnameAsString + "]");
}
} // end while entries in execution chain
// done with the entries in the execution chain
// add the end-of-list marker
MetaDataEntry lastEntry = new MetaDataEntry();
lastEntry.setClassName(MetaDataEntry.END_OF_LIST);
ObjectStateUtils.writeObject(out, lastEntry, logCorrelationIDString +
".executedPhases: last entry ");
execNextIndex++;
// execNextIndex also gives us the number of entries
// that were actually saved as opposed to the
// number of entries in the executedPhases
out.writeInt(execNextIndex);
} else {
// general case: handle "null" or "empty"
out.writeUTF(execListDesc);
out.writeBoolean(ObjectStateUtils.EMPTY_OBJECT);
if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
log.trace(
logCorrelationIDString + ":writeExternal(): executedPhases is NULL");
}
}
//---------------------------------------------------------
// options
//---------------------------------------------------------
// before saving the Options, make sure there is a message ID
String tmpID = getMessageID();
if (tmpID == null) {
// get an id to use when restoring this object
tmpID = UUIDGenerator.getUUID();
setMessageID(tmpID);
}
if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
log.trace(logCorrelationIDString + ":writeExternal(): message ID [" + tmpID + "]");
}
ObjectStateUtils.writeObject(out, options, logCorrelationIDString + ".options for [" +
options.getLogCorrelationIDString() + "]");
//---------------------------------------------------------
// operation
//---------------------------------------------------------
// axis operation
//---------------------------------------------------------
String axisOpMarker = logCorrelationIDString + ".axisOperation";
ObjectStateUtils.writeString(out, axisOpMarker, axisOpMarker);
if (axisOperation == null) {
out.writeBoolean(ObjectStateUtils.EMPTY_OBJECT);
} else {
// TODO: may need to include the meta data for the axis service that is
// the parent of the axis operation
out.writeBoolean(ObjectStateUtils.ACTIVE_OBJECT);
// make sure the axis operation has a name associated with it
QName aoTmpQName = axisOperation.getName();
if (aoTmpQName == null) {
aoTmpQName = new QName(ObjectStateUtils.EMPTY_MARKER);
axisOperation.setName(aoTmpQName);
}
metaAxisOperation = new MetaDataEntry(axisOperation.getClass().getName(),
axisOperation.getName().toString());
ObjectStateUtils.writeObject(out, metaAxisOperation,
logCorrelationIDString + ".metaAxisOperation");
}
//---------------------------------------------------------
// operation context
//---------------------------------------------------------
// The OperationContext has pointers to MessageContext objects.
// In order to avoid having multiple copies of the object graph
// being saved at different points in the serialization,
// it is important to isolate this message context object.
String oc_desc = logCorrelationIDString + ".operationContext";
if (operationContext != null) {
operationContext.isolateMessageContext(this);
oc_desc = oc_desc + " for [" + operationContext.getLogCorrelationIDString() + "]";
}
// NOTE: expect this to be the parent of the message context
ObjectStateUtils.writeObject(out, operationContext, oc_desc);
//---------------------------------------------------------
// service
//---------------------------------------------------------
// axis service
//-------------------------
// this is expected to be the parent of the axis operation object
String axisServMarker = logCorrelationIDString + ".axisService";
ObjectStateUtils.writeString(out, axisServMarker, axisServMarker);
if (axisService == null) {
out.writeBoolean(ObjectStateUtils.EMPTY_OBJECT);
} else {
out.writeBoolean(ObjectStateUtils.ACTIVE_OBJECT);
metaAxisService =
new MetaDataEntry(axisService.getClass().getName(), axisService.getName());
ObjectStateUtils
.writeObject(out, metaAxisService, logCorrelationIDString + ".metaAxisService");
}
//-------------------------
// serviceContextID string
//-------------------------
ObjectStateUtils
.writeString(out, serviceContextID, logCorrelationIDString + ".serviceContextID");
//-------------------------
// serviceContext
//-------------------------
// is this the same as the parent of the OperationContext?
boolean isParent = false;
if (operationContext != null) {
ServiceContext opctxParent = operationContext.getServiceContext();
if (serviceContext != null) {
if (serviceContext.equals(opctxParent)) {
// the ServiceContext is the parent of the OperationContext
isParent = true;
}
}
}
String servCtxMarker = logCorrelationIDString + ".serviceContext";
ObjectStateUtils.writeString(out, servCtxMarker, servCtxMarker);
if (serviceContext == null) {
out.writeBoolean(ObjectStateUtils.EMPTY_OBJECT);
} else {
out.writeBoolean(ObjectStateUtils.ACTIVE_OBJECT);
out.writeBoolean(isParent);
// only write out the object if it is not the parent
if (!isParent) {
ObjectStateUtils.writeObject(out, serviceContext,
logCorrelationIDString + ".serviceContext");
}
}
//---------------------------------------------------------
// axisServiceGroup
//---------------------------------------------------------
String axisServGrpMarker = logCorrelationIDString + ".axisServiceGroup";
ObjectStateUtils.writeString(out, axisServGrpMarker, axisServGrpMarker);
if (axisServiceGroup == null) {
out.writeBoolean(ObjectStateUtils.EMPTY_OBJECT);
} else {
out.writeBoolean(ObjectStateUtils.ACTIVE_OBJECT);
metaAxisServiceGroup = new MetaDataEntry(axisServiceGroup.getClass().getName(),
axisServiceGroup.getServiceGroupName());
ObjectStateUtils.writeObject(out, metaAxisServiceGroup,
logCorrelationIDString + ".metaAxisServiceGroup");
}
//-----------------------------
// serviceGroupContextId string
//-----------------------------
ObjectStateUtils.writeString(out, serviceGroupContextId,
logCorrelationIDString + ".serviceGroupContextId");
//-------------------------
// serviceGroupContext
//-------------------------
// is this the same as the parent of the ServiceContext?
isParent = false;
if (serviceContext != null) {
ServiceGroupContext srvgrpctxParent = (ServiceGroupContext) serviceContext.getParent();
if (serviceGroupContext != null) {
if (serviceGroupContext.equals(srvgrpctxParent)) {
// the ServiceGroupContext is the parent of the ServiceContext
isParent = true;
}
}
}
String servGrpCtxMarker = logCorrelationIDString + ".serviceGroupContext";
ObjectStateUtils.writeString(out, servGrpCtxMarker, servGrpCtxMarker);
if (serviceGroupContext == null) {
out.writeBoolean(ObjectStateUtils.EMPTY_OBJECT);
} else {
out.writeBoolean(ObjectStateUtils.ACTIVE_OBJECT);
out.writeBoolean(isParent);
// only write out the object if it is not the parent
if (!isParent) {
ObjectStateUtils.writeObject(out, serviceGroupContext,
logCorrelationIDString + ".serviceGroupContext");
}
}
//---------------------------------------------------------
// axis message
//---------------------------------------------------------
String axisMsgMarker = logCorrelationIDString + ".axisMessage";
ObjectStateUtils.writeString(out, axisMsgMarker, axisMsgMarker);
if (axisMessage == null) {
out.writeBoolean(ObjectStateUtils.EMPTY_OBJECT);
} else {
// This AxisMessage is expected to belong to the AxisOperation
// that has already been recorded for this MessageContext.
// If an AxisMessage associated with this Messagecontext is
// associated with a different AxisOperation, then more
// meta information would need to be saved
out.writeBoolean(ObjectStateUtils.ACTIVE_OBJECT);
// make sure the axis message has a name associated with it
String amTmpName = axisMessage.getName();
if (amTmpName == null) {
amTmpName = ObjectStateUtils.EMPTY_MARKER;
axisMessage.setName(amTmpName);
}
// get the element name if there is one
QName amTmpElementQName = axisMessage.getElementQName();
String amTmpElemQNameString = null;
if (amTmpElementQName != null) {
amTmpElemQNameString = amTmpElementQName.toString();
}
metaAxisMessage = new MetaDataEntry(axisMessage.getClass().getName(),
axisMessage.getName(), amTmpElemQNameString);
ObjectStateUtils
.writeObject(out, metaAxisMessage, logCorrelationIDString + ".metaAxisMessage");
}
//---------------------------------------------------------
// configuration context
//---------------------------------------------------------
// NOTE: Currently, there does not seem to be any
// runtime data important to this message context
// in the configuration context.
// if so, then need to save that runtime data and reconcile
// it with the configuration context on the system when
// this message context object is restored
//---------------------------------------------------------
// session context
//---------------------------------------------------------
ObjectStateUtils
.writeObject(out, sessionContext, logCorrelationIDString + ".sessionContext");
//---------------------------------------------------------
// transport
//---------------------------------------------------------
//------------------------------
// incomingTransportName string
//------------------------------
ObjectStateUtils.writeString(out, incomingTransportName,
logCorrelationIDString + ".incomingTransportName");
// TransportInDescription transportIn
if (transportIn != null) {
metaTransportIn = new MetaDataEntry(null, transportIn.getName());
} else {
metaTransportIn = null;
}
ObjectStateUtils.writeObject(out, metaTransportIn, logCorrelationIDString + ".transportIn");
// TransportOutDescription transportOut
if (transportOut != null) {
metaTransportOut = new MetaDataEntry(null, transportOut.getName());
} else {
metaTransportOut = null;
}
ObjectStateUtils
.writeObject(out, metaTransportOut, logCorrelationIDString + ".transportOut");