Search in sources :

Example 1 with TXFrameworkException

use of org.jboss.narayana.txframework.api.exception.TXFrameworkException in project narayana by jbosstm.

the class HandlerFactory method getCurrentTXID.

private static String getCurrentTXID() throws TXFrameworkException {
    String txid;
    // Try WS-AT
    txid = UserTransactionFactory.userTransaction().transactionIdentifier();
    if (!txid.equals("Unknown")) {
        return txid;
    }
    // Try WS-BA
    try {
        BusinessActivityManager businessActivityManager = BusinessActivityManagerFactory.businessActivityManager();
        if (businessActivityManager.currentTransaction() != null) {
            txid = businessActivityManager.currentTransaction().toString();
            if (!txid.equals("Unknown")) {
                return txid;
            }
        }
    } catch (SystemException e) {
        throw new TXFrameworkException("Error when looking up Business Activity", e);
    }
    // Try REST-AT
    HttpServletRequest req = ResteasyProviderFactory.getContextData(HttpServletRequest.class);
    String enlistUrl = req.getHeader("enlistURL");
    if (enlistUrl != null) {
        String[] parts = enlistUrl.split("/");
        return parts[parts.length - 1];
    }
    throw new TXFrameworkException("No Transaction detected");
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) SystemException(com.arjuna.wst.SystemException) TXFrameworkException(org.jboss.narayana.txframework.api.exception.TXFrameworkException) BusinessActivityManager(com.arjuna.mw.wst11.BusinessActivityManager)

Example 2 with TXFrameworkException

use of org.jboss.narayana.txframework.api.exception.TXFrameworkException in project narayana by jbosstm.

the class WSBAHandler method notifyFailure.

@Override
public void notifyFailure() throws TXFrameworkException {
    try {
        participantManager.cannotComplete();
    } catch (WrongStateException e) {
        throw new TXFrameworkException("Error notifying cannotComplete on participant manager.", e);
    } catch (UnknownTransactionException e) {
        throw new TXFrameworkException("Error notifying cannotComplete on participant manager.", e);
    } catch (SystemException e) {
        throw new TXFrameworkException("Error notifying cannotComplete on participant manager.", e);
    }
    Participant.suspend();
    WSBATxControlImpl.suspend();
}
Also used : TXFrameworkException(org.jboss.narayana.txframework.api.exception.TXFrameworkException) UnknownTransactionException(com.arjuna.wst.UnknownTransactionException) SystemException(com.arjuna.wst.SystemException) WrongStateException(com.arjuna.wst.WrongStateException)

Example 3 with TXFrameworkException

use of org.jboss.narayana.txframework.api.exception.TXFrameworkException in project narayana by jbosstm.

the class WSBAHandler method notifySuccess.

@Override
public void notifySuccess() throws TXFrameworkException {
    // todo: find a better way of getting the current status of the TX
    if (shouldComplete(serviceInvocationMeta.getServiceMethod()) && !((WSBATxControlImpl) wsbaTxControl).isCannotComplete()) {
        try {
            participantManager.completed();
        } catch (WrongStateException e) {
            throw new TXFrameworkException("Error notifying completion on participant manager.", e);
        } catch (UnknownTransactionException e) {
            throw new TXFrameworkException("Error notifying completion on participant manager.", e);
        } catch (SystemException e) {
            throw new TXFrameworkException("Error notifying completion on participant manager.", e);
        }
    }
    Participant.suspend();
    WSBATxControlImpl.suspend();
}
Also used : TXFrameworkException(org.jboss.narayana.txframework.api.exception.TXFrameworkException) UnknownTransactionException(com.arjuna.wst.UnknownTransactionException) SystemException(com.arjuna.wst.SystemException) WrongStateException(com.arjuna.wst.WrongStateException)

Aggregations

SystemException (com.arjuna.wst.SystemException)3 TXFrameworkException (org.jboss.narayana.txframework.api.exception.TXFrameworkException)3 UnknownTransactionException (com.arjuna.wst.UnknownTransactionException)2 WrongStateException (com.arjuna.wst.WrongStateException)2 BusinessActivityManager (com.arjuna.mw.wst11.BusinessActivityManager)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1