Search in sources :

Example 41 with CoordinationContext

use of org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext in project narayana by jbosstm.

the class TransactionManagerImple method registerParticipant.

final W3CEndpointReference registerParticipant(final W3CEndpointReference participant, final String protocol) throws InvalidProtocolException, InvalidStateException, CannotRegisterException, SystemException {
    TxContextImple currentTx = null;
    try {
        currentTx = (TxContextImple) _ctxManager.suspend();
        if (currentTx == null)
            throw new CannotRegisterException();
        final CoordinationContextType coordinationContext = currentTx.context().getCoordinationContext();
        final String messageId = MessageId.getMessageId();
        return com.arjuna.wsc11.RegistrationCoordinator.register(coordinationContext, messageId, participant, protocol);
    } catch (final SoapFault sf) {
        throw new SystemException(sf.getMessage());
    } catch (final CannotRegisterException cre) {
        throw cre;
    } catch (final InvalidStateException ise) {
        throw ise;
    } catch (final InvalidProtocolException ipe) {
        throw ipe;
    } catch (final Exception ex) {
        throw new SystemException(ex.toString());
    } finally {
        try {
            if (currentTx != null)
                _ctxManager.resume(currentTx);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
Also used : SoapFault(com.arjuna.webservices.SoapFault) TxContextImple(com.arjuna.mwlabs.wst11.at.context.TxContextImple) CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType)

Example 42 with CoordinationContext

use of org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext in project narayana by jbosstm.

the class UserTransactionImple method startTransaction.

protected final Context startTransaction(int timeout, TxContextImple current) throws com.arjuna.wsc.InvalidCreateParametersException, SystemException {
    try {
        // TODO: tricks for per app _activationCoordinatorService config, perhaps:
        // InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("/foo.properties");
        final Long expires = (timeout > 0 ? new Long(timeout) : null);
        final String messageId = MessageId.getMessageId();
        final CoordinationContext currentContext = (current != null ? getContext(current) : null);
        final CoordinationContextType coordinationContext = ActivationCoordinator.createCoordinationContext(_activationCoordinatorService, messageId, AtomicTransactionConstants.WSAT_PROTOCOL, expires, currentContext);
        if (coordinationContext == null) {
            throw new SystemException(wstxLogger.i18NLogger.get_mwlabs_wst_at_remote_UserTransaction11Imple__2());
        }
        return new ContextImple(coordinationContext);
    } catch (final InvalidCreateParametersException icpe) {
        throw icpe;
    } catch (final SoapFault sf) {
        throw new SystemException(sf.getMessage());
    } catch (final Exception ex) {
        throw new SystemException(ex.toString());
    }
}
Also used : SoapFault(com.arjuna.webservices.SoapFault) ContextImple(com.arjuna.mwlabs.wst11.at.ContextImple) TxContextImple(com.arjuna.mwlabs.wst11.at.context.TxContextImple) SystemException(com.arjuna.wst.SystemException) CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType) InvalidCreateParametersException(com.arjuna.wsc.InvalidCreateParametersException) UnknownTransactionException(com.arjuna.wst.UnknownTransactionException) WrongStateException(com.arjuna.wst.WrongStateException) SystemException(com.arjuna.wst.SystemException) InvalidCreateParametersException(com.arjuna.wsc.InvalidCreateParametersException) TransactionRolledBackException(com.arjuna.wst.TransactionRolledBackException) CoordinationContext(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext)

Example 43 with CoordinationContext

use of org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext in project narayana by jbosstm.

the class UserTransactionImple method getContext.

/**
 * fetch the coordination context type stashed in the current AT context implememtation
 * and use it to construct an instance of the coordination context extension type we need to
 * send down the wire to the activation coordinator
 * @param current the current AT context implememtation
 * @return an instance of the coordination context extension type
 */
private CoordinationContext getContext(TxContextImple current) {
    CoordinationContextType contextType = getContextType(current);
    CoordinationContext context = new CoordinationContext();
    context.setCoordinationType(contextType.getCoordinationType());
    context.setExpires(contextType.getExpires());
    context.setIdentifier(contextType.getIdentifier());
    context.setRegistrationService(contextType.getRegistrationService());
    return context;
}
Also used : CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType) CoordinationContext(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext)

Example 44 with CoordinationContext

use of org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext in project narayana by jbosstm.

the class SubordinateImporter method importContext.

public static TxContext importContext(CoordinationContextType cc) {
    // get the subordinate transaction manager to install any existing
    // subordinate tx for this one or create and install a new one.
    final String identifier = cc.getIdentifier().getValue();
    TxContext subordinateTxContext = subordinateContextMap.get(identifier);
    if (subordinateTxContext == null) {
        // create a context for a local coordinator
        CoordinationContext context = null;
        try {
            context = baContextFactory.create(BusinessActivityConstants.WSBA_PROTOCOL_ATOMIC_OUTCOME, 0L, cc, false);
        } catch (InvalidCreateParametersException e) {
        // should not happen
        }
        subordinateTxContext = new TxContextImple(context);
        subordinateContextMap.put(identifier, subordinateTxContext);
        // register a cleanup callback with the subordinate transactionso that the entry gets removed
        // when the transcation commits or rolls back
        // remove "urn:" prefix
        String subordinateId = context.getIdentifier().getValue().substring(4);
        SubordinateBACoordinator.SubordinateCallback callback = new SubordinateBACoordinator.SubordinateCallback() {

            public String parentId = identifier;

            public void run() {
                subordinateContextMap.remove(parentId);
            }
        };
        SubordinateBACoordinator.addCallback(subordinateId, callback);
    }
    return subordinateTxContext;
}
Also used : SubordinateBACoordinator(com.arjuna.mwlabs.wscf.model.sagas.arjunacore.subordinate.SubordinateBACoordinator) TxContext(com.arjuna.mw.wst.TxContext) TxContextImple(com.arjuna.mwlabs.wst11.ba.context.TxContextImple) InvalidCreateParametersException(com.arjuna.wsc.InvalidCreateParametersException) CoordinationContext(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext)

Example 45 with CoordinationContext

use of org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext in project narayana by jbosstm.

the class BusinessActivityManagerImple method registerParticipant.

private final W3CEndpointReference registerParticipant(final W3CEndpointReference participant, final String protocol) throws com.arjuna.wsc.InvalidProtocolException, com.arjuna.wsc.InvalidStateException, com.arjuna.wsc.CannotRegisterException, SystemException {
    TxContextImple currentTx = null;
    try {
        currentTx = (TxContextImple) _ctxManager.currentTransaction();
        if (currentTx == null)
            throw new com.arjuna.wsc.NoActivityException();
        final CoordinationContextType coordinationContext = currentTx.context().getCoordinationContext();
        final String messageId = MessageId.getMessageId();
        return RegistrationCoordinator.register(coordinationContext, messageId, participant, protocol);
    } catch (final SoapFault sf) {
        throw new SystemException(sf.getMessage());
    } catch (CannotRegisterException ex) {
        throw ex;
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new SystemException(ex.toString());
    } finally {
        try {
            if (currentTx != null)
                _ctxManager.resume(currentTx);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
Also used : SoapFault(com.arjuna.webservices.SoapFault) TxContextImple(com.arjuna.mwlabs.wst11.ba.context.TxContextImple) CoordinationContextType(org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType) CannotRegisterException(com.arjuna.wsc.CannotRegisterException) CannotRegisterException(com.arjuna.wsc.CannotRegisterException)

Aggregations

CoordinationContextType (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType)69 MAP (org.jboss.ws.api.addressing.MAP)43 SoapFault11 (com.arjuna.webservices11.SoapFault11)39 Action (javax.xml.ws.Action)38 RequestWrapper (javax.xml.ws.RequestWrapper)38 MessageContext (javax.xml.ws.handler.MessageContext)38 CoordinationContext (org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext)24 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)14 InvalidCreateParametersException (com.arjuna.wsc.InvalidCreateParametersException)12 CreateCoordinationContextType (org.oasis_open.docs.ws_tx.wscoor._2006._06.CreateCoordinationContextType)9 Expires (org.oasis_open.docs.ws_tx.wscoor._2006._06.Expires)9 Test (org.junit.Test)7 SoapFault (com.arjuna.webservices.SoapFault)6 InvalidProtocolException (com.arjuna.wsc.InvalidProtocolException)6 SystemException (com.arjuna.wst.SystemException)6 TxContextImple (com.arjuna.mwlabs.wst11.at.context.TxContextImple)5 ServiceRegistry (com.arjuna.webservices11.ServiceRegistry)5 SOAPEnvelope (javax.xml.soap.SOAPEnvelope)5 SOAPHeaderElement (javax.xml.soap.SOAPHeaderElement)5 ProtocolException (javax.xml.ws.ProtocolException)5