use of com.arjuna.webservices11.wsba.State in project narayana by jbosstm.
the class ParticipantEngine method rollbackDecision.
/**
* Handle the rollback decision event.
*
* Active -> Aborting (send aborted)
* Preparing -> Aborting (send aborted)
*/
private void rollbackDecision() {
final State current;
synchronized (this) {
current = state;
if ((current == State.STATE_PREPARING) || (current == State.STATE_ACTIVE)) {
state = State.STATE_ABORTING;
}
}
if ((current == State.STATE_PREPARING) || (current == State.STATE_ACTIVE)) {
sendAborted();
forget();
}
}
use of com.arjuna.webservices11.wsba.State in project narayana by jbosstm.
the class ParticipantEngine method readOnlyDecision.
/**
* Handle the readOnly decision event.
*
* Active -> None (send ReadOnly)
* Preparing -> None (send ReadOnly)
*/
private void readOnlyDecision() {
final State current;
synchronized (this) {
current = state;
if ((current == State.STATE_ACTIVE) || (current == State.STATE_PREPARING)) {
state = null;
}
}
if ((current == State.STATE_ACTIVE) || (current == State.STATE_PREPARING)) {
sendReadOnly();
forget();
}
}
use of com.arjuna.webservices11.wsba.State in project narayana by jbosstm.
the class BusinessAgreementWithParticipantCompletionStub method saveState.
public boolean saveState(final OutputObjectState oos) {
try {
oos.packString(participant.getId());
// n.b. just use toString() for the endpoint -- it uses the writeTo() method which calls a suitable marshaller
final StringWriter sw = new StringWriter();
final XMLStreamWriter writer = SoapUtils.getXMLStreamWriter(sw);
StreamHelper.writeStartElement(writer, QNAME_BAPCWS_PARTICIPANT);
String eprefText = participant.getParticipant().toString();
writer.writeCData(eprefText);
StreamHelper.writeEndElement(writer, null, null);
writer.close();
oos.packString(sw.toString());
final State state = participant.getStatus();
final QName stateName = state.getValue();
final String ns = stateName.getNamespaceURI();
final String localPart = stateName.getLocalPart();
final String prefix = stateName.getPrefix();
oos.packString(ns != null ? ns : "");
oos.packString(localPart != null ? localPart : "");
oos.packString(prefix != null ? prefix : "");
return true;
} catch (final Throwable th) {
WSTLogger.i18NLogger.error_wst11_stub_BusinessAgreementWithParticipantCompletionStub_2(th);
return false;
}
}
use of com.arjuna.webservices11.wsba.State in project narayana by jbosstm.
the class BusinessAgreementWithParticipantCompletionStub method restoreState.
public boolean restoreState(final InputObjectState ios) {
try {
final String id = ios.unpackString();
final String eprValue = ios.unpackString();
// this should successfully reverse the save process
final XMLStreamReader reader = SoapUtils.getXMLStreamReader(new StringReader(eprValue));
StreamHelper.checkNextStartTag(reader, QNAME_BAPCWS_PARTICIPANT);
String eprefText = reader.getElementText();
StreamSource source = new StreamSource(new StringReader(eprefText));
final W3CEndpointReference endpointReference = new W3CEndpointReference(source);
String ns = ios.unpackString();
final String localPart = ios.unpackString();
String prefix = ios.unpackString();
if ("".equals(ns)) {
ns = null;
}
if ("".equals(prefix)) {
prefix = null;
}
QName statename = new QName(ns, localPart, prefix);
State state = State.toState11(statename);
// if we already have an engine from a previous recovery scan or because
// we had a heuristic outcome 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
participant = (ParticipantCompletionCoordinatorEngine) ParticipantCompletionCoordinatorProcessor.getProcessor().getCoordinator(id);
if (participant == null) {
participant = new ParticipantCompletionCoordinatorEngine(id, endpointReference, state, true);
}
return true;
} catch (final Throwable th) {
WSTLogger.i18NLogger.error_wst11_stub_BusinessAgreementWithParticipantCompletionStub_3(th);
return false;
}
}
use of com.arjuna.webservices11.wsba.State in project narayana by jbosstm.
the class ParticipantStub method saveState.
public boolean saveState(final OutputObjectState oos) {
try {
oos.packString(coordinator.getId());
oos.packBoolean(coordinator.isDurable());
State state = coordinator.getState();
// participants in the heuristic list may get saved in any state
if (state == State.STATE_ACTIVE) {
oos.packInt(0);
} else if (state == State.STATE_PREPARING) {
oos.packInt(1);
} else if (state == State.STATE_PREPARED || state == State.STATE_PREPARED_SUCCESS) {
oos.packInt(2);
} else if (state == State.STATE_ABORTING) {
oos.packInt(3);
} else {
// COMMITTING or none
oos.packInt(4);
}
// n.b. just use toString() for the endpoint -- it uses the writeTo() method which calls a suitable marshaller
final StringWriter sw = new StringWriter();
final XMLStreamWriter writer = SoapUtils.getXMLStreamWriter(sw);
StreamHelper.writeStartElement(writer, QNAME_TWO_PC_PARTICIPANT);
String eprefText = coordinator.getParticipant().toString();
writer.writeCData(eprefText);
StreamHelper.writeEndElement(writer, null, null);
writer.close();
sw.close();
String tmp = writer.toString();
String swString = sw.toString();
oos.packString(swString);
return true;
} catch (final Throwable th) {
WSTLogger.i18NLogger.error_wst11_stub_ParticipantStub_1(th);
return false;
}
}
Aggregations