Search in sources :

Example 1 with CoordinatorEngine

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

Aggregations

InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)1 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)1 State (com.arjuna.webservices11.wsat.State)1 CoordinatorEngine (com.arjuna.wst11.messaging.engines.CoordinatorEngine)1 StringReader (java.io.StringReader)1 XMLStreamReader (javax.xml.stream.XMLStreamReader)1 StreamSource (javax.xml.transform.stream.StreamSource)1 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)1