use of com.arjuna.wst11.messaging.engines.CoordinatorEngine in project narayana by jbosstm.
the class ParticipantStub method restoreState.
public boolean restoreState(final InputObjectState ios) {
State state;
try {
final String id = ios.unpackString();
final boolean durable = ios.unpackBoolean();
final int stateTag = ios.unpackInt();
switch(stateTag) {
case 0:
state = State.STATE_ACTIVE;
break;
case 1:
state = State.STATE_PREPARING;
break;
case 2:
state = State.STATE_PREPARED_SUCCESS;
break;
case 3:
state = State.STATE_ABORTING;
break;
default:
state = State.STATE_COMMITTING;
break;
}
final String eprValue = ios.unpackString();
// this should successfully reverse the save process
final XMLStreamReader reader = SoapUtils.getXMLStreamReader(new StringReader(eprValue));
StreamHelper.checkNextStartTag(reader, QNAME_TWO_PC_PARTICIPANT);
String eprefText = reader.getElementText();
StreamSource source = new StreamSource(new StringReader(eprefText));
final W3CEndpointReference endpointReference = new W3CEndpointReference(source);
// if we already have a coordinator from a previous recovery scan or because
// we had a heuristic outcoe then reuse it with luck it will have been committed
// or aborted between the last scan and this one
// note that whatever happens it will not have been removed from the table
// because it is marked as recovered
coordinator = (CoordinatorEngine) CoordinatorProcessorImpl.getProcessor().getCoordinator(id);
if (coordinator == null) {
// no entry found so recreate one with the saved state
coordinator = new CoordinatorEngine(id, durable, endpointReference, true, state);
}
return true;
} catch (final Throwable th) {
WSTLogger.i18NLogger.error_wst11_stub_ParticipantStub_2(th);
return false;
}
}
Aggregations