Search in sources :

Example 1 with ParticipantCompletionCoordinatorEngine

use of com.arjuna.wst11.messaging.engines.ParticipantCompletionCoordinatorEngine 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 2 with ParticipantCompletionCoordinatorEngine

use of com.arjuna.wst11.messaging.engines.ParticipantCompletionCoordinatorEngine in project narayana by jbosstm.

the class RegistrarImple method registerWithSubordinate.

private final W3CEndpointReference registerWithSubordinate(final SubordinateBACoordinator theTx, final W3CEndpointReference participantProtocolService, final String protocolIdentifier, final boolean isSecure) throws AlreadyRegisteredException, InvalidProtocolException, InvalidStateException, NoActivityException {
    if (BusinessActivityConstants.WSBA_SUB_PROTOCOL_PARTICIPANT_COMPLETION.equals(protocolIdentifier)) {
        // enlist participant that wraps the requester URI.
        final String id = "PCP" + new Uid().stringForm();
        try {
            // we use a manager which goes direct to the tx rather than via the activity service
            BAParticipantManager manager = new SubordinateBAParticipantManagerImple(theTx, id);
            final ParticipantCompletionCoordinatorEngine engine = new ParticipantCompletionCoordinatorEngine(id, participantProtocolService);
            BusinessAgreementWithParticipantCompletionImple participant = new BusinessAgreementWithParticipantCompletionImple(manager, new BusinessAgreementWithParticipantCompletionStub(engine), id);
            engine.setCoordinator(participant.participantManager());
            theTx.enlistParticipant(participant);
            final ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
            return getParticipantManager(BusinessActivityConstants.PARTICIPANT_COMPLETION_COORDINATOR_SERVICE_QNAME, BusinessActivityConstants.PARTICIPANT_COMPLETION_COORDINATOR_PORT_QNAME, serviceRegistry.getServiceURI(BusinessActivityConstants.PARTICIPANT_COMPLETION_COORDINATOR_SERVICE_NAME, isSecure), id);
        } catch (DuplicateParticipantException dpe) {
            throw new AlreadyRegisteredException();
        } catch (Exception ex) {
            throw new InvalidStateException();
        }
    } else if (BusinessActivityConstants.WSBA_SUB_PROTOCOL_COORDINATOR_COMPLETION.equals(protocolIdentifier)) {
        // enlist participant that wraps the requester URI.
        final String id = "CCP" + new Uid().stringForm();
        try {
            BAParticipantManager manager = new SubordinateBAParticipantManagerImple(theTx, id);
            final CoordinatorCompletionCoordinatorEngine engine = new CoordinatorCompletionCoordinatorEngine(id, participantProtocolService);
            BusinessAgreementWithCoordinatorCompletionImple participant = new BusinessAgreementWithCoordinatorCompletionImple(manager, new BusinessAgreementWithCoordinatorCompletionStub(engine), id);
            engine.setCoordinator(participant.participantManager());
            theTx.enlistParticipant(participant);
            final ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
            return getParticipantManager(BusinessActivityConstants.COORDINATOR_COMPLETION_COORDINATOR_SERVICE_QNAME, BusinessActivityConstants.COORDINATOR_COMPLETION_COORDINATOR_PORT_QNAME, serviceRegistry.getServiceURI(BusinessActivityConstants.COORDINATOR_COMPLETION_COORDINATOR_SERVICE_NAME, isSecure), id);
        } catch (Exception ex) {
            throw new InvalidStateException();
        }
    } else if (com.arjuna.webservices.wsarjtx.ArjunaTXConstants.WSARJTX_PROTOCOL_TERMINATION.equals(protocolIdentifier)) {
        throw new InvalidStateException();
    } else {
        wstxLogger.i18NLogger.warn_mwlabs_wst_ba_Registrar11Imple_1(BusinessActivityConstants.WSBA_PROTOCOL_ATOMIC_OUTCOME, protocolIdentifier);
        throw new InvalidProtocolException();
    }
}
Also used : CoordinatorCompletionCoordinatorEngine(com.arjuna.wst11.messaging.engines.CoordinatorCompletionCoordinatorEngine) BusinessAgreementWithCoordinatorCompletionImple(com.arjuna.mwlabs.wst11.ba.participants.BusinessAgreementWithCoordinatorCompletionImple) BusinessAgreementWithParticipantCompletionStub(com.arjuna.wst11.stub.BusinessAgreementWithParticipantCompletionStub) ProtocolNotRegisteredException(com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException) DuplicateParticipantException(com.arjuna.mw.wscf.exceptions.DuplicateParticipantException) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) Uid(com.arjuna.ats.arjuna.common.Uid) SubordinateBAParticipantManagerImple(com.arjuna.mwlabs.wst11.ba.remote.SubordinateBAParticipantManagerImple) DuplicateParticipantException(com.arjuna.mw.wscf.exceptions.DuplicateParticipantException) ServiceRegistry(com.arjuna.webservices11.ServiceRegistry) BusinessAgreementWithCoordinatorCompletionStub(com.arjuna.wst11.stub.BusinessAgreementWithCoordinatorCompletionStub) BAParticipantManager(com.arjuna.wst11.BAParticipantManager) ParticipantCompletionCoordinatorEngine(com.arjuna.wst11.messaging.engines.ParticipantCompletionCoordinatorEngine) BusinessAgreementWithParticipantCompletionImple(com.arjuna.mwlabs.wst11.ba.participants.BusinessAgreementWithParticipantCompletionImple)

Example 3 with ParticipantCompletionCoordinatorEngine

use of com.arjuna.wst11.messaging.engines.ParticipantCompletionCoordinatorEngine in project narayana by jbosstm.

the class RegistrarImple method register.

/**
 * Registers the interest of participant in a particular protocol.
 *
 * @param participantProtocolService
 *            the address of the participant protocol service
 * @param protocolIdentifier
 *            the protocol identifier
 *
 * @return the PortReference of the coordinator protocol service
 *
 * @throws com.arjuna.wsc.AlreadyRegisteredException
 *             if the participant is already registered for this
 *             coordination protocol under this activity identifier
 * @throws com.arjuna.wsc.InvalidProtocolException
 *             if the coordination protocol is not supported
 * @throws com.arjuna.wsc.InvalidStateException
 *             if the state of the coordinator no longer allows registration
 *             for this coordination protocol
 * @throws com.arjuna.wsc.NoActivityException
 *             if the activity does not exist.
 */
public W3CEndpointReference register(final W3CEndpointReference participantProtocolService, final String protocolIdentifier, final InstanceIdentifier instanceIdentifier, final boolean isSecure) throws AlreadyRegisteredException, InvalidProtocolException, InvalidStateException, NoActivityException {
    Object tx = _hierarchies.get(instanceIdentifier.getInstanceIdentifier());
    if (tx instanceof SubordinateBACoordinator)
        return registerWithSubordinate((SubordinateBACoordinator) tx, participantProtocolService, protocolIdentifier, isSecure);
    ActivityHierarchy hier = (ActivityHierarchy) tx;
    if (hier == null)
        throw new NoActivityException();
    try {
        _coordManager.resume(hier);
    } catch (com.arjuna.mw.wsas.exceptions.InvalidActivityException ex) {
        throw new NoActivityException();
    } catch (SystemException ex) {
        throw new InvalidProtocolException();
    }
    if (BusinessActivityConstants.WSBA_SUB_PROTOCOL_PARTICIPANT_COMPLETION.equals(protocolIdentifier)) {
        // enlist participant that wraps the requester URI.
        final String id = new Uid().stringForm();
        try {
            final ParticipantCompletionCoordinatorEngine engine = new ParticipantCompletionCoordinatorEngine(id, participantProtocolService);
            BusinessAgreementWithParticipantCompletionImple participant = new BusinessAgreementWithParticipantCompletionImple(new BusinessAgreementWithParticipantCompletionStub(engine), id);
            engine.setCoordinator(participant.participantManager());
            _coordManager.enlistParticipant(participant);
            _coordManager.suspend();
            final ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
            return getParticipantManager(BusinessActivityConstants.PARTICIPANT_COMPLETION_COORDINATOR_SERVICE_QNAME, BusinessActivityConstants.PARTICIPANT_COMPLETION_COORDINATOR_PORT_QNAME, serviceRegistry.getServiceURI(BusinessActivityConstants.PARTICIPANT_COMPLETION_COORDINATOR_SERVICE_NAME, isSecure), id);
        } catch (Exception ex) {
            throw new InvalidStateException();
        }
    } else if (BusinessActivityConstants.WSBA_SUB_PROTOCOL_COORDINATOR_COMPLETION.equals(protocolIdentifier)) {
        final String id = new Uid().stringForm();
        try {
            final CoordinatorCompletionCoordinatorEngine engine = new CoordinatorCompletionCoordinatorEngine(id, participantProtocolService);
            BusinessAgreementWithCoordinatorCompletionImple participant = new BusinessAgreementWithCoordinatorCompletionImple(new BusinessAgreementWithCoordinatorCompletionStub(engine), id);
            engine.setCoordinator(participant.participantManager());
            _coordManager.enlistParticipant(participant);
            _coordManager.suspend();
            final ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
            return getParticipantManager(BusinessActivityConstants.COORDINATOR_COMPLETION_COORDINATOR_SERVICE_QNAME, BusinessActivityConstants.COORDINATOR_COMPLETION_COORDINATOR_PORT_QNAME, serviceRegistry.getServiceURI(BusinessActivityConstants.COORDINATOR_COMPLETION_COORDINATOR_SERVICE_NAME, isSecure), id);
        } catch (Exception ex) {
            throw new InvalidStateException();
        }
    } else if (com.arjuna.webservices.wsarjtx.ArjunaTXConstants.WSARJTX_PROTOCOL_TERMINATION.equals(protocolIdentifier)) {
        /*
                     * update the server side terminator with the participant end point
                     */
        BusinessActivityTerminatorImple terminator;
        terminator = (BusinessActivityTerminatorImple) TerminationCoordinatorProcessor.getProcessor().getParticipant(instanceIdentifier);
        terminator.setEndpoint(participantProtocolService);
        try {
            _coordManager.suspend();
            final ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
            return getParticipantManager(ArjunaTX11Constants.TERMINATION_COORDINATOR_SERVICE_QNAME, ArjunaTX11Constants.TERMINATION_COORDINATOR_PORT_QNAME, serviceRegistry.getServiceURI(ArjunaTX11Constants.TERMINATION_COORDINATOR_SERVICE_NAME, isSecure), instanceIdentifier.getInstanceIdentifier());
        } catch (Exception ex) {
            throw new InvalidStateException();
        }
    } else if (com.arjuna.webservices.wsarjtx.ArjunaTXConstants.WSARJTX_PROTOCOL_TERMINATION_RPC.equals(protocolIdentifier)) {
        try {
            _coordManager.suspend();
            final ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
            return getParticipantManager(ArjunaTX11Constants.TERMINATION_COORDINATOR_RPC_SERVICE_QNAME, ArjunaTX11Constants.TERMINATION_COORDINATOR_RPC_PORT_QNAME, serviceRegistry.getServiceURI(ArjunaTX11Constants.TERMINATION_COORDINATOR_RPC_SERVICE_NAME, isSecure), instanceIdentifier.getInstanceIdentifier());
        } catch (Exception ex) {
            throw new InvalidStateException();
        }
    } else {
        wstxLogger.i18NLogger.warn_mwlabs_wst_ba_Registrar11Imple_1(BusinessActivityConstants.WSBA_PROTOCOL_ATOMIC_OUTCOME, protocolIdentifier);
        throw new InvalidProtocolException();
    }
}
Also used : CoordinatorCompletionCoordinatorEngine(com.arjuna.wst11.messaging.engines.CoordinatorCompletionCoordinatorEngine) BusinessAgreementWithCoordinatorCompletionImple(com.arjuna.mwlabs.wst11.ba.participants.BusinessAgreementWithCoordinatorCompletionImple) ActivityHierarchy(com.arjuna.mw.wsas.activity.ActivityHierarchy) BusinessAgreementWithParticipantCompletionStub(com.arjuna.wst11.stub.BusinessAgreementWithParticipantCompletionStub) ProtocolNotRegisteredException(com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException) DuplicateParticipantException(com.arjuna.mw.wscf.exceptions.DuplicateParticipantException) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) SubordinateBACoordinator(com.arjuna.mwlabs.wscf.model.sagas.arjunacore.subordinate.SubordinateBACoordinator) Uid(com.arjuna.ats.arjuna.common.Uid) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) ServiceRegistry(com.arjuna.webservices11.ServiceRegistry) BusinessAgreementWithCoordinatorCompletionStub(com.arjuna.wst11.stub.BusinessAgreementWithCoordinatorCompletionStub) ParticipantCompletionCoordinatorEngine(com.arjuna.wst11.messaging.engines.ParticipantCompletionCoordinatorEngine) BusinessAgreementWithParticipantCompletionImple(com.arjuna.mwlabs.wst11.ba.participants.BusinessAgreementWithParticipantCompletionImple)

Aggregations

ParticipantCompletionCoordinatorEngine (com.arjuna.wst11.messaging.engines.ParticipantCompletionCoordinatorEngine)3 Uid (com.arjuna.ats.arjuna.common.Uid)2 SystemException (com.arjuna.mw.wsas.exceptions.SystemException)2 DuplicateParticipantException (com.arjuna.mw.wscf.exceptions.DuplicateParticipantException)2 ProtocolNotRegisteredException (com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException)2 BusinessAgreementWithCoordinatorCompletionImple (com.arjuna.mwlabs.wst11.ba.participants.BusinessAgreementWithCoordinatorCompletionImple)2 BusinessAgreementWithParticipantCompletionImple (com.arjuna.mwlabs.wst11.ba.participants.BusinessAgreementWithParticipantCompletionImple)2 ServiceRegistry (com.arjuna.webservices11.ServiceRegistry)2 CoordinatorCompletionCoordinatorEngine (com.arjuna.wst11.messaging.engines.CoordinatorCompletionCoordinatorEngine)2 BusinessAgreementWithCoordinatorCompletionStub (com.arjuna.wst11.stub.BusinessAgreementWithCoordinatorCompletionStub)2 BusinessAgreementWithParticipantCompletionStub (com.arjuna.wst11.stub.BusinessAgreementWithParticipantCompletionStub)2 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)1 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)1 ActivityHierarchy (com.arjuna.mw.wsas.activity.ActivityHierarchy)1 SubordinateBACoordinator (com.arjuna.mwlabs.wscf.model.sagas.arjunacore.subordinate.SubordinateBACoordinator)1 SubordinateBAParticipantManagerImple (com.arjuna.mwlabs.wst11.ba.remote.SubordinateBAParticipantManagerImple)1 State (com.arjuna.webservices11.wsba.State)1 BAParticipantManager (com.arjuna.wst11.BAParticipantManager)1 StringReader (java.io.StringReader)1 QName (javax.xml.namespace.QName)1