Search in sources :

Example 6 with ActivityHierarchy

use of com.arjuna.mw.wsas.activity.ActivityHierarchy 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)

Example 7 with ActivityHierarchy

use of com.arjuna.mw.wsas.activity.ActivityHierarchy in project narayana by jbosstm.

the class RegistrarImple method associate.

public final void associate() throws Exception {
    // TODO colocation won't do suspend
    String txIdentifier = _coordManager.identifier().toString();
    ActivityHierarchy hier = _coordManager.suspend();
    _hierarchies.put(txIdentifier, hier);
}
Also used : ActivityHierarchy(com.arjuna.mw.wsas.activity.ActivityHierarchy)

Example 8 with ActivityHierarchy

use of com.arjuna.mw.wsas.activity.ActivityHierarchy 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.
 */
/*
	 * TODO
	 *
	 * See comment at head of class definition. We shouldn't have to rely on
	 * thread-to-activity association to register a participant. We currently do
	 * because the code is based on old WS-CAF models that are no longer
	 * applicable. This needs updating!
	 */
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 SubordinateATCoordinator)
        return registerWithSubordinate((SubordinateATCoordinator) 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 (AtomicTransactionConstants.WSAT_SUB_PROTOCOL_DURABLE_2PC.equals(protocolIdentifier)) {
        // enlist participant that wraps the requester URI.
        final String participantId = "D" + new Uid().stringForm();
        try {
            final Durable2PCStub participantStub = new Durable2PCStub(participantId, participantProtocolService);
            _coordManager.enlistParticipant(new DurableTwoPhaseCommitParticipant(participantStub, participantId));
            _coordManager.suspend();
            return getCoordinator(participantId, isSecure);
        } catch (Exception ex) {
            throw new InvalidStateException();
        }
    } else if (AtomicTransactionConstants.WSAT_SUB_PROTOCOL_VOLATILE_2PC.equals(protocolIdentifier)) {
        // enlist participant that wraps the requester URI.
        final String participantId = "V" + new Uid().stringForm();
        try {
            final Volatile2PCStub participantStub = new Volatile2PCStub(participantId, participantProtocolService);
            _coordManager.enlistSynchronization(new VolatileTwoPhaseCommitParticipant(participantStub));
            _coordManager.suspend();
            return getCoordinator(participantId, isSecure);
        } catch (Exception ex) {
            throw new InvalidStateException();
        }
    } else if (AtomicTransactionConstants.WSAT_SUB_PROTOCOL_COMPLETION.equals(protocolIdentifier)) {
        try {
            final CompletionCoordinatorParticipant participant = new CompletionCoordinatorImple(_coordManager, hier, true, participantProtocolService);
            CompletionCoordinatorProcessor.getProcessor().activateParticipant(participant, instanceIdentifier.getInstanceIdentifier());
            _coordManager.suspend();
            return getCompletionCoordinator(instanceIdentifier, isSecure);
        } catch (Exception ex) {
            ex.printStackTrace();
            throw new InvalidStateException(ex.toString());
        }
    } else if (AtomicTransactionConstants.WSAT_SUB_PROTOCOL_COMPLETION_RPC.equals(protocolIdentifier)) {
        try {
            final CompletionCoordinatorParticipant participant = new CompletionCoordinatorRPCImple(_coordManager, hier, true, participantProtocolService);
            CompletionCoordinatorRPCProcessor.getProcessor().activateParticipant(participant, instanceIdentifier.getInstanceIdentifier());
            _coordManager.suspend();
            return getCompletionCoordinatorRPC(instanceIdentifier, isSecure);
        } catch (Exception ex) {
            ex.printStackTrace();
            throw new InvalidStateException(ex.toString());
        }
    } else {
        wstxLogger.i18NLogger.warn_mwlabs_wst_at_Registrar11Imple_1(AtomicTransactionConstants.WSAT_PROTOCOL, protocolIdentifier);
        throw new InvalidProtocolException();
    }
}
Also used : DurableTwoPhaseCommitParticipant(com.arjuna.mwlabs.wst.at.participants.DurableTwoPhaseCommitParticipant) Volatile2PCStub(com.arjuna.wst11.stub.Volatile2PCStub) Durable2PCStub(com.arjuna.wst11.stub.Durable2PCStub) ActivityHierarchy(com.arjuna.mw.wsas.activity.ActivityHierarchy) ProtocolNotRegisteredException(com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) SubordinateATCoordinator(com.arjuna.mwlabs.wscf.model.twophase.arjunacore.subordinate.SubordinateATCoordinator) Uid(com.arjuna.ats.arjuna.common.Uid) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) CompletionCoordinatorRPCImple(com.arjuna.mwlabs.wst11.at.participants.CompletionCoordinatorRPCImple) VolatileTwoPhaseCommitParticipant(com.arjuna.mwlabs.wst.at.participants.VolatileTwoPhaseCommitParticipant) CompletionCoordinatorImple(com.arjuna.mwlabs.wst11.at.participants.CompletionCoordinatorImple) CompletionCoordinatorParticipant(com.arjuna.wst11.CompletionCoordinatorParticipant)

Example 9 with ActivityHierarchy

use of com.arjuna.mw.wsas.activity.ActivityHierarchy in project narayana by jbosstm.

the class RegistrarImple method associate.

public final void associate() throws Exception {
    // TODO colocation won't do suspend
    String txIdentifier = _coordManager.identifier().toString();
    ActivityHierarchy hier = _coordManager.suspend();
    _hierarchies.put(txIdentifier, hier);
}
Also used : ActivityHierarchy(com.arjuna.mw.wsas.activity.ActivityHierarchy)

Example 10 with ActivityHierarchy

use of com.arjuna.mw.wsas.activity.ActivityHierarchy in project narayana by jbosstm.

the class ArjunaContextImple method initialiseContext.

public void initialiseContext(Object param) {
    try {
        ATCoordinator currentCoordinator = (ATCoordinator) param;
        ActivityHierarchy hier = null;
        try {
            hier = UserActivityFactory.userActivity().currentActivity();
        } catch (SystemException ex) {
            ex.printStackTrace();
        }
        if ((currentCoordinator != null) && (hier != null)) {
            /*
				 * Do the manditory stuff first.
				 */
            ActionHierarchy txHier = currentCoordinator.getHierarchy();
            final int depth = txHier.depth();
            _identifierValues = new String[depth];
            _expiresValues = new int[depth];
            _identifierValues[0] = txHier.getDeepestActionUid().stringForm();
            _expiresValues[0] = hier.activity(hier.size() - 1).getTimeout();
            /*
				 * Now let's do the optional stuff.
				 */
            for (int count = 1, index = 0; count < depth; count++, index++) {
                _identifierValues[count] = txHier.getActionUid(index).stringForm();
                _expiresValues[count] = hier.activity(index).getTimeout();
            }
        }
    } catch (ClassCastException ex) {
        throw new IllegalArgumentException();
    }
}
Also used : SystemException(com.arjuna.mw.wsas.exceptions.SystemException) ATCoordinator(com.arjuna.mwlabs.wscf.model.twophase.arjunacore.ATCoordinator) ActionHierarchy(com.arjuna.ats.arjuna.coordinator.ActionHierarchy) ActivityHierarchy(com.arjuna.mw.wsas.activity.ActivityHierarchy)

Aggregations

ActivityHierarchy (com.arjuna.mw.wsas.activity.ActivityHierarchy)20 Test (org.junit.Test)12 SystemException (com.arjuna.mw.wsas.exceptions.SystemException)6 NoCoordinatorException (com.arjuna.mw.wscf.exceptions.NoCoordinatorException)4 UserActivity (com.arjuna.mw.wsas.UserActivity)3 NoActivityException (com.arjuna.mw.wsas.exceptions.NoActivityException)3 UserCoordinator (com.arjuna.mw.wscf.model.sagas.api.UserCoordinator)3 UserCoordinator (com.arjuna.mw.wscf.model.twophase.api.UserCoordinator)3 Uid (com.arjuna.ats.arjuna.common.Uid)2 ActionHierarchy (com.arjuna.ats.arjuna.coordinator.ActionHierarchy)2 ProtocolViolationException (com.arjuna.mw.wsas.exceptions.ProtocolViolationException)2 WrongStateException (com.arjuna.mw.wsas.exceptions.WrongStateException)2 ProtocolNotRegisteredException (com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException)2 CoordinatorManager (com.arjuna.mw.wscf.model.sagas.api.CoordinatorManager)2 ActivityHandleImple (com.arjuna.mwlabs.wsas.activity.ActivityHandleImple)2 SubordinateBACoordinator (com.arjuna.mwlabs.wscf.model.sagas.arjunacore.subordinate.SubordinateBACoordinator)2 SubordinateATCoordinator (com.arjuna.mwlabs.wscf.model.twophase.arjunacore.subordinate.SubordinateATCoordinator)2 GlobalId (com.arjuna.mw.wsas.common.GlobalId)1 DuplicateParticipantException (com.arjuna.mw.wscf.exceptions.DuplicateParticipantException)1 CoordinatorManager (com.arjuna.mw.wscf.model.twophase.api.CoordinatorManager)1