Search in sources :

Example 36 with State

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();
    }
}
Also used : State(com.arjuna.webservices11.wsat.State)

Example 37 with State

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();
    }
}
Also used : State(com.arjuna.webservices11.wsat.State)

Example 38 with State

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;
    }
}
Also used : StringWriter(java.io.StringWriter) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) State(com.arjuna.webservices11.wsba.State) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) QName(javax.xml.namespace.QName)

Example 39 with State

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;
    }
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) QName(javax.xml.namespace.QName) State(com.arjuna.webservices11.wsba.State) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) StreamSource(javax.xml.transform.stream.StreamSource) StringReader(java.io.StringReader) ParticipantCompletionCoordinatorEngine(com.arjuna.wst11.messaging.engines.ParticipantCompletionCoordinatorEngine)

Example 40 with State

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;
    }
}
Also used : StringWriter(java.io.StringWriter) InputObjectState(com.arjuna.ats.arjuna.state.InputObjectState) State(com.arjuna.webservices11.wsat.State) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) XMLStreamWriter(javax.xml.stream.XMLStreamWriter)

Aggregations

State (com.arjuna.webservices11.wsba.State)31 InstanceIdentifier (com.arjuna.webservices11.wsarj.InstanceIdentifier)12 MAP (org.jboss.ws.api.addressing.MAP)12 State (com.arjuna.webservices11.wsat.State)11 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)10 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)6 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)6 Test (org.junit.Test)6 SoapFault11 (com.arjuna.webservices11.SoapFault11)5 QName (javax.xml.namespace.QName)5 ConfirmCompletedParticipant (com.arjuna.wst11.ConfirmCompletedParticipant)3 StringReader (java.io.StringReader)3 StringWriter (java.io.StringWriter)3 XMLStreamReader (javax.xml.stream.XMLStreamReader)3 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)3 StreamSource (javax.xml.transform.stream.StreamSource)3 BAParticipantRecoveryRecord (org.jboss.jbossts.xts11.recovery.participant.ba.BAParticipantRecoveryRecord)3 FaultedException (com.arjuna.wst.FaultedException)2 CoordinatorCompletionCoordinatorDetails (com.arjuna.wst.tests.arq.TestCoordinatorCompletionCoordinatorProcessor.CoordinatorCompletionCoordinatorDetails)2 ParticipantCompletionCoordinatorDetails (com.arjuna.wst.tests.arq.TestParticipantCompletionCoordinatorProcessor.ParticipantCompletionCoordinatorDetails)2