Search in sources :

Example 21 with SystemException

use of com.arjuna.mw.wsas.exceptions.SystemException in project narayana by jbosstm.

the class BACoordinator method changeParticipantStatus.

private final void changeParticipantStatus(String participantId, int status) throws InvalidParticipantException, SystemException {
    /*
		 * Transaction is active, so we can look at the pendingList only.
		 */
    // TODO allow transaction status to be changed during commit - exit
    // could come in late
    boolean found = false;
    if (pendingList != null) {
        RecordListIterator iter = new RecordListIterator(pendingList);
        AbstractRecord absRec = iter.iterate();
        try {
            while ((absRec != null) && !found) {
                if (absRec instanceof ParticipantRecord) {
                    ParticipantRecord pr = (ParticipantRecord) absRec;
                    Participant participant = (Participant) pr.value();
                    if (participantId.equals(participant.id())) {
                        found = true;
                        if (status == DELISTED) {
                            pr.delist(false);
                        } else if (status == FAILED) {
                            pr.delist(true);
                        } else {
                            pr.completed();
                        }
                    }
                }
                absRec = iter.iterate();
            }
        } catch (Exception ex) {
            throw new SystemException(ex.toString());
        }
    }
    if (!found)
        throw new InvalidParticipantException();
}
Also used : SystemException(com.arjuna.mw.wsas.exceptions.SystemException) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) DuplicateSynchronizationException(com.arjuna.mw.wscf.model.sagas.exceptions.DuplicateSynchronizationException) InvalidSynchronizationException(com.arjuna.mw.wscf.model.sagas.exceptions.InvalidSynchronizationException) WrongStateException(com.arjuna.mw.wsas.exceptions.WrongStateException) ProtocolViolationException(com.arjuna.mw.wsas.exceptions.ProtocolViolationException)

Example 22 with SystemException

use of com.arjuna.mw.wsas.exceptions.SystemException in project narayana by jbosstm.

the class ContextFactoryImple method createBridgedTransaction.

/**
 * create a bridged to subordinate WS-BA 1.1 transaction, associate it with the registrar and create and return
 * a coordination context for it. n.b. this is a private, behind-the-scenes method for use by the JTA-BA
 * transaction bridge code.
 * @param expires the timeout for the bridged to BA transaction
 * @param isSecure true if the registration cooridnator URL should use a secure address, otherwise false.
 * @return a coordination context for the bridged to transaction
 */
public BridgeTxData createBridgedTransaction(final Long expires, final boolean isSecure) {
    // we need to create a subordinate transaction and expose it to the bridge layer so it can
    // be driven to completion
    SubordinateBACoordinator subTx = null;
    try {
        subTx = (SubordinateBACoordinator) createSubordinate();
    } catch (NoActivityException e) {
        // will not happen
        return null;
    } catch (InvalidProtocolException e) {
        // will not happen
        return null;
    } catch (SystemException e) {
        // may happen
        return null;
    }
    // ok now create the context
    final ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
    final String registrationCoordinatorURI = serviceRegistry.getServiceURI(CoordinationConstants.REGISTRATION_SERVICE_NAME, isSecure);
    final CoordinationContext coordinationContext = new CoordinationContext();
    coordinationContext.setCoordinationType(BusinessActivityConstants.WSBA_PROTOCOL_ATOMIC_OUTCOME);
    CoordinationContextType.Identifier identifier = new CoordinationContextType.Identifier();
    String txId = subTx.get_uid().stringForm();
    identifier.setValue("urn:" + txId);
    coordinationContext.setIdentifier(identifier);
    if (expires != null && expires.longValue() > 0) {
        Expires expiresInstance = new Expires();
        expiresInstance.setValue(expires);
        coordinationContext.setExpires(expiresInstance);
    }
    W3CEndpointReference registrationCoordinator = getRegistrationCoordinator(registrationCoordinatorURI, txId);
    coordinationContext.setRegistrationService(registrationCoordinator);
    try {
        _theRegistrar.associate(subTx);
    } catch (Exception e) {
    // will not happen
    }
    BridgeTxData bridgeTxData = new BridgeTxData();
    bridgeTxData.context = coordinationContext;
    bridgeTxData.coordinator = subTx;
    bridgeTxData.identifier = txId;
    return bridgeTxData;
}
Also used : NoActivityException(com.arjuna.mw.wsas.exceptions.NoActivityException) InvalidProtocolException(com.arjuna.wsc.InvalidProtocolException) InvalidCreateParametersException(com.arjuna.wsc.InvalidCreateParametersException) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) NoActivityException(com.arjuna.mw.wsas.exceptions.NoActivityException) CoordinationContext(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext) SubordinateBACoordinator(com.arjuna.mwlabs.wscf.model.sagas.arjunacore.subordinate.SubordinateBACoordinator) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) InvalidProtocolException(com.arjuna.wsc.InvalidProtocolException) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) ServiceRegistry(com.arjuna.webservices11.ServiceRegistry) Expires(org.oasis_open.docs.ws_tx.wscoor._2006._06.Expires) CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType)

Example 23 with SystemException

use of com.arjuna.mw.wsas.exceptions.SystemException in project narayana by jbosstm.

the class ContextFactoryImple method createSubordinate.

public final Object createSubordinate() throws NoActivityException, InvalidProtocolException, SystemException {
    try {
        CoordinatorServiceImple coordManager = (CoordinatorServiceImple) _coordManager;
        BACoordinator subordinateTransaction = coordManager.createSubordinate();
        /*
             * Now add the registrar for this specific coordinator to the
             * mapper.
             */
        subordinateTransaction.enlistSynchronization(new CleanupSynchronization(subordinateTransaction.get_uid().stringForm(), _theRegistrar));
        _theRegistrar.associate(subordinateTransaction);
        return subordinateTransaction;
    } catch (Exception ex) {
        throw new SystemException(ex.toString());
    }
}
Also used : CleanupSynchronization(com.arjuna.mwlabs.wst11.ba.participants.CleanupSynchronization) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) CoordinatorServiceImple(com.arjuna.mwlabs.wscf.model.sagas.arjunacore.CoordinatorServiceImple) BACoordinator(com.arjuna.mwlabs.wscf.model.sagas.arjunacore.BACoordinator) SubordinateBACoordinator(com.arjuna.mwlabs.wscf.model.sagas.arjunacore.subordinate.SubordinateBACoordinator) InvalidProtocolException(com.arjuna.wsc.InvalidProtocolException) InvalidCreateParametersException(com.arjuna.wsc.InvalidCreateParametersException) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) NoActivityException(com.arjuna.mw.wsas.exceptions.NoActivityException)

Example 24 with SystemException

use of com.arjuna.mw.wsas.exceptions.SystemException 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 25 with SystemException

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

Aggregations

SystemException (com.arjuna.mw.wsas.exceptions.SystemException)32 NoActivityException (com.arjuna.mw.wsas.exceptions.NoActivityException)16 WrongStateException (com.arjuna.mw.wsas.exceptions.WrongStateException)16 ProtocolViolationException (com.arjuna.mw.wsas.exceptions.ProtocolViolationException)15 SubordinateATCoordinator (com.arjuna.mwlabs.wscf.model.twophase.arjunacore.subordinate.SubordinateATCoordinator)7 ActivityHierarchy (com.arjuna.mw.wsas.activity.ActivityHierarchy)6 HLS (com.arjuna.mw.wsas.activity.HLS)6 ProtocolNotRegisteredException (com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException)6 SubordinateBACoordinator (com.arjuna.mwlabs.wscf.model.sagas.arjunacore.subordinate.SubordinateBACoordinator)6 InvalidActivityException (com.arjuna.mw.wsas.exceptions.InvalidActivityException)5 InvalidTimeoutException (com.arjuna.mw.wsas.exceptions.InvalidTimeoutException)5 NoPermissionException (com.arjuna.mw.wsas.exceptions.NoPermissionException)5 ActivityImple (com.arjuna.mwlabs.wsas.activity.ActivityImple)5 InvalidCreateParametersException (com.arjuna.wsc.InvalidCreateParametersException)5 InvalidProtocolException (com.arjuna.wsc.InvalidProtocolException)5 SOAPContext (com.arjuna.mw.wsas.context.soap.SOAPContext)4 ActiveChildException (com.arjuna.mw.wsas.exceptions.ActiveChildException)4 ServiceRegistry (com.arjuna.webservices11.ServiceRegistry)4 EmptyStackException (java.util.EmptyStackException)4 Outcome (com.arjuna.mw.wsas.activity.Outcome)3