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");
}
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();
}
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();
}
Aggregations