Search in sources :

Example 1 with CoordinatorCompletionParticipantEngine

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

the class BAParticipantRecoveryRecord method activate.

/**
 * create a participant engine to manage commit or rollback processing for the
 * participant and install it in the active participants table
 */
public void activate() {
    if (isParticipantCompletion) {
        ParticipantCompletionParticipantEngine engine = new ParticipantCompletionParticipantEngine(id, endpoint, participant, State.STATE_COMPLETED, true);
        ParticipantCompletionParticipantProcessor.getProcessor().activateParticipant(engine, getId());
        engine.recovery();
    } else {
        BusinessAgreementWithCoordinatorCompletionParticipant coordinatorCompletionParticipant = (BusinessAgreementWithCoordinatorCompletionParticipant) participant;
        CoordinatorCompletionParticipantEngine engine = new CoordinatorCompletionParticipantEngine(id, endpoint, coordinatorCompletionParticipant, State.STATE_COMPLETED, true);
        CoordinatorCompletionParticipantProcessor.getProcessor().activateParticipant(engine, getId());
        engine.recovery();
    }
}
Also used : BusinessAgreementWithCoordinatorCompletionParticipant(com.arjuna.wst.BusinessAgreementWithCoordinatorCompletionParticipant) ParticipantCompletionParticipantEngine(com.arjuna.wst11.messaging.engines.ParticipantCompletionParticipantEngine) CoordinatorCompletionParticipantEngine(com.arjuna.wst11.messaging.engines.CoordinatorCompletionParticipantEngine)

Example 2 with CoordinatorCompletionParticipantEngine

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

the class BAParticipantProcessor method cannotComplete.

/**
 * Execute the CannotComplete
 * @param map The current addressing context.
 *
 * @throws SoapFault11 for errors during processing
 */
public void cannotComplete(final CoordinationContextType coordinationContext, final MAP map) throws SoapFault11 {
    try {
        final CannotCompleteParticipant participant = new CannotCompleteParticipant();
        final CoordinatorCompletionParticipantEngine engine = BAInteropUtil.registerCoordinatorCompletion(coordinationContext, participant, new Uid().toString());
        participant.setEngine(engine);
        participant.initialiseTimeout();
    } catch (final Throwable th) {
        throw new SoapFault11(th);
    }
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) CannotCompleteParticipant(com.jboss.transaction.txinterop.webservices.bainterop.participant.CannotCompleteParticipant) CoordinatorCompletionParticipantEngine(com.arjuna.wst11.messaging.engines.CoordinatorCompletionParticipantEngine) SoapFault11(com.arjuna.webservices11.SoapFault11)

Example 3 with CoordinatorCompletionParticipantEngine

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

the class BAInteropUtil method registerCoordinatorCompletion.

/**
 * Register a coordinator completion participant in the specified coordination context.
 * @param context The coordination context.
 * @param participant The durable 2PC participant
 * @param id The participant id.
 * @return The participant engine.
 * @throws Exception for errors.
 */
public static CoordinatorCompletionParticipantEngine registerCoordinatorCompletion(final CoordinationContextType context, final BusinessAgreementWithCoordinatorCompletionParticipant participant, final String id) throws Exception {
    final W3CEndpointReference coordinator = RegistrationCoordinator.register(context, MessageId.getMessageId(), getCoordinatorCompletionParticipant(id), BusinessActivityConstants.WSBA_SUB_PROTOCOL_COORDINATOR_COMPLETION);
    final CoordinatorCompletionParticipantEngine engine = new CoordinatorCompletionParticipantEngine(id, coordinator, participant);
    CoordinatorCompletionParticipantProcessor.getProcessor().activateParticipant(engine, id);
    return engine;
}
Also used : CoordinatorCompletionParticipantEngine(com.arjuna.wst11.messaging.engines.CoordinatorCompletionParticipantEngine) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference)

Example 4 with CoordinatorCompletionParticipantEngine

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

the class ContextFactoryImple method create.

// TODO interposition
/*
     * If there is a context passed through to create then this newly created
     * coordinator should be interposed.
     */
/**
 * Creates a coordination context.
 *
 * @param coordinationTypeURI the coordination type uri
 * @param expires the expire date/time for the returned context, can be null
 * @param currentContext the current context, can be null
 *
 * @return the created coordination context
 *
 * @throws com.arjuna.wsc.InvalidCreateParametersException if a parameter passed is invalid
 *         this activity identifier.
 */
public CoordinationContext create(final String coordinationTypeURI, final Long expires, final CoordinationContextType currentContext, final boolean isSecure) throws InvalidCreateParametersException {
    if (BusinessActivityConstants.WSBA_PROTOCOL_ATOMIC_OUTCOME.equals(coordinationTypeURI)) {
        try {
            if (currentContext == null) {
                _coordManager.suspend();
                final int timeout;
                if (expires == null) {
                    timeout = 0;
                } else {
                    final long longTimeout = expires.longValue();
                    timeout = (longTimeout > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) longTimeout);
                }
                _coordManager.begin(ArjunaContextImple.serviceType, timeout);
                final ArjunaContextImple arjunaContext = ArjunaContextImple.getContext();
                final ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
                final String registrationCoordinatorURI = serviceRegistry.getServiceURI(CoordinationConstants.REGISTRATION_SERVICE_NAME, isSecure);
                final CoordinationContext coordinationContext = new CoordinationContext();
                coordinationContext.setCoordinationType(coordinationTypeURI);
                CoordinationContextType.Identifier identifier = new CoordinationContextType.Identifier();
                identifier.setValue("urn:" + arjunaContext.getTransactionIdentifier());
                coordinationContext.setIdentifier(identifier);
                final int transactionExpires = arjunaContext.getTransactionExpires();
                if (transactionExpires > 0) {
                    Expires expiresInstance = new Expires();
                    expiresInstance.setValue(transactionExpires);
                    coordinationContext.setExpires(expiresInstance);
                }
                final W3CEndpointReference registrationCoordinator = getRegistrationCoordinator(registrationCoordinatorURI, arjunaContext);
                coordinationContext.setRegistrationService(registrationCoordinator);
                // why is this created early even though the enlistment for termination
                // is done late? well that's a good question. look at the corresponding registrar
                // code to see why
                // TODO sort this out
                String transactionIdentifier = arjunaContext.getTransactionIdentifier();
                BusinessActivityTerminator terminator = new BusinessActivityTerminatorImple();
                TerminationCoordinatorProcessor.getProcessor().activateParticipant(terminator, transactionIdentifier);
                _theRegistrar.associate();
                return coordinationContext;
            } else {
                // we need to create a subordinate transaction -- this transaction will not be associated
                // with an activity which identifes the parent transaction this means that we cannot use
                // the activity service to do things like enlist participants or deliver participant
                // initiated messages.
                SubordinateBACoordinator subTx = (SubordinateBACoordinator) createSubordinate();
                // now we register a coordinator completion participant on behalf of the subtransaction
                // with the registration service defined in the current context
                // there is no point registering a participant completion participant because we cannot
                // know when it is ok to forward a completed message -- even when all N registered PC
                // participants have notified completed another PC participant might enlist.
                String ccpid = subTx.getCoordinatorCompletionParticipantid();
                SubordinateCoordinatorCompletionParticipantStub ccp = new SubordinateCoordinatorCompletionParticipantStub(subTx);
                String messageId = MessageId.getMessageId();
                W3CEndpointReference participant = getParticipant(ccpid, isSecure);
                W3CEndpointReference coordinator = RegistrationCoordinator.register(currentContext, messageId, participant, BusinessActivityConstants.WSBA_SUB_PROTOCOL_COORDINATOR_COMPLETION);
                final CoordinatorCompletionParticipantEngine engine = new CoordinatorCompletionParticipantEngine(ccpid, coordinator, ccp);
                CoordinatorCompletionParticipantProcessor.getProcessor().activateParticipant(engine, ccpid);
                // we need to pass a manager to the stub in case it has to fail at completion
                BAParticipantManager manager = new BACoordinatorCompletionParticipantManagerStub(engine);
                ccp.setManager(manager);
                // 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(coordinationTypeURI);
                CoordinationContextType.Identifier identifier = new CoordinationContextType.Identifier();
                String txId = subTx.get_uid().stringForm();
                identifier.setValue("urn:" + txId);
                coordinationContext.setIdentifier(identifier);
                Expires expiresInstance = currentContext.getExpires();
                final long transactionExpires = (expiresInstance != null ? expiresInstance.getValue() : 0);
                if (transactionExpires > 0) {
                    expiresInstance = new Expires();
                    expiresInstance.setValue(transactionExpires);
                    coordinationContext.setExpires(expiresInstance);
                }
                W3CEndpointReference registrationCoordinator = getRegistrationCoordinator(registrationCoordinatorURI, txId);
                coordinationContext.setRegistrationService(registrationCoordinator);
                // now associate the tx id with the sub transaction
                _theRegistrar.associate(subTx);
                return coordinationContext;
            }
        } catch (com.arjuna.mw.wsas.exceptions.NoActivityException ex) {
            // TODO handle properly
            ex.printStackTrace();
        } catch (com.arjuna.mw.wsas.exceptions.SystemException ex) {
            // TODO handle properly
            ex.printStackTrace();
        } catch (com.arjuna.mw.wsas.exceptions.WrongStateException ex) {
            // TODO handle properly
            ex.printStackTrace();
        } catch (Exception ex) {
            // TODO handle properly
            ex.printStackTrace();
        }
    } else {
        wstxLogger.i18NLogger.warn_mwlabs_wst_ba_Context11FactoryImple_1(BusinessActivityConstants.WSBA_PROTOCOL_ATOMIC_OUTCOME, coordinationTypeURI);
        throw new InvalidCreateParametersException(wstxLogger.i18NLogger.get_mwlabs_wst_ba_Context11FactoryImple_3() + " < " + BusinessActivityConstants.WSBA_PROTOCOL_ATOMIC_OUTCOME + ", " + coordinationTypeURI + " >");
    }
    return null;
}
Also used : CoordinatorCompletionParticipantEngine(com.arjuna.wst11.messaging.engines.CoordinatorCompletionParticipantEngine) BACoordinatorCompletionParticipantManagerStub(com.arjuna.wst11.stub.BACoordinatorCompletionParticipantManagerStub) InvalidCreateParametersException(com.arjuna.wsc.InvalidCreateParametersException) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) 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) ArjunaContextImple(com.arjuna.mwlabs.wst11.ba.context.ArjunaContextImple) SubordinateBACoordinator(com.arjuna.mwlabs.wscf.model.sagas.arjunacore.subordinate.SubordinateBACoordinator) BusinessActivityTerminator(com.arjuna.wst11.BusinessActivityTerminator) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) ServiceRegistry(com.arjuna.webservices11.ServiceRegistry) Expires(org.oasis_open.docs.ws_tx.wscoor._2006._06.Expires) NoActivityException(com.arjuna.mw.wsas.exceptions.NoActivityException) BAParticipantManager(com.arjuna.wst11.BAParticipantManager) SubordinateCoordinatorCompletionParticipantStub(com.arjuna.wst11.stub.SubordinateCoordinatorCompletionParticipantStub)

Example 5 with CoordinatorCompletionParticipantEngine

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

the class BusinessActivityManagerImple method enlistForBusinessAgreementWithCoordinatorCompletion.

public com.arjuna.wst11.BAParticipantManager enlistForBusinessAgreementWithCoordinatorCompletion(BusinessAgreementWithCoordinatorCompletionParticipant bawcp, String id) throws WrongStateException, UnknownTransactionException, SystemException {
    final QName service = BusinessActivityConstants.COORDINATOR_COMPLETION_PARTICIPANT_SERVICE_QNAME;
    final QName endpoint = BusinessActivityConstants.COORDINATOR_COMPLETION_PARTICIPANT_PORT_QNAME;
    boolean isSecure = ((TxContextImple) currentTransaction()).isSecure();
    try {
        final ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
        final String address = serviceRegistry.getServiceURI(BusinessActivityConstants.COORDINATOR_COMPLETION_PARTICIPANT_SERVICE_NAME, isSecure);
        final W3CEndpointReference participant = getParticipant(service, endpoint, address, id);
        W3CEndpointReference baPMEndpoint = registerParticipant(participant, BusinessActivityConstants.WSBA_SUB_PROTOCOL_COORDINATOR_COMPLETION);
        final CoordinatorCompletionParticipantEngine engine = new CoordinatorCompletionParticipantEngine(id, baPMEndpoint, bawcp);
        CoordinatorCompletionParticipantProcessor.getProcessor().activateParticipant(engine, id);
        return new BACoordinatorCompletionParticipantManagerStub(engine);
    } catch (com.arjuna.wsc.InvalidProtocolException ex) {
        throw new SystemException(ex.toString());
    } catch (com.arjuna.wsc.InvalidStateException ex) {
        throw new WrongStateException();
    } catch (com.arjuna.wsc.CannotRegisterException ex) {
        ex.printStackTrace();
        throw new UnknownTransactionException();
    } catch (Throwable ex) {
        ex.printStackTrace();
        throw new SystemException(ex.toString());
    }
}
Also used : CoordinatorCompletionParticipantEngine(com.arjuna.wst11.messaging.engines.CoordinatorCompletionParticipantEngine) QName(javax.xml.namespace.QName) BACoordinatorCompletionParticipantManagerStub(com.arjuna.wst11.stub.BACoordinatorCompletionParticipantManagerStub) TxContextImple(com.arjuna.mwlabs.wst11.ba.context.TxContextImple) CannotRegisterException(com.arjuna.wsc.CannotRegisterException) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) ServiceRegistry(com.arjuna.webservices11.ServiceRegistry)

Aggregations

CoordinatorCompletionParticipantEngine (com.arjuna.wst11.messaging.engines.CoordinatorCompletionParticipantEngine)7 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)3 Uid (com.arjuna.ats.arjuna.common.Uid)2 ServiceRegistry (com.arjuna.webservices11.ServiceRegistry)2 SoapFault11 (com.arjuna.webservices11.SoapFault11)2 ParticipantCompletionParticipantEngine (com.arjuna.wst11.messaging.engines.ParticipantCompletionParticipantEngine)2 BACoordinatorCompletionParticipantManagerStub (com.arjuna.wst11.stub.BACoordinatorCompletionParticipantManagerStub)2 NoActivityException (com.arjuna.mw.wsas.exceptions.NoActivityException)1 SystemException (com.arjuna.mw.wsas.exceptions.SystemException)1 SubordinateBACoordinator (com.arjuna.mwlabs.wscf.model.sagas.arjunacore.subordinate.SubordinateBACoordinator)1 ArjunaContextImple (com.arjuna.mwlabs.wst11.ba.context.ArjunaContextImple)1 TxContextImple (com.arjuna.mwlabs.wst11.ba.context.TxContextImple)1 InstanceIdentifier (com.arjuna.webservices11.wsarj.InstanceIdentifier)1 TerminationCoordinatorProcessor (com.arjuna.webservices11.wsarjtx.processors.TerminationCoordinatorProcessor)1 CompletionCoordinatorProcessor (com.arjuna.webservices11.wsat.processors.CompletionCoordinatorProcessor)1 ParticipantProcessor (com.arjuna.webservices11.wsat.processors.ParticipantProcessor)1 CoordinatorCompletionParticipantProcessor (com.arjuna.webservices11.wsba.processors.CoordinatorCompletionParticipantProcessor)1 ParticipantCompletionParticipantProcessor (com.arjuna.webservices11.wsba.processors.ParticipantCompletionParticipantProcessor)1 CannotRegisterException (com.arjuna.wsc.CannotRegisterException)1 InvalidCreateParametersException (com.arjuna.wsc.InvalidCreateParametersException)1