AlphaResponse preIntercept(int timeout) { try { return sender .send(new SagaStartedEvent(omegaContext.globalTxId(), omegaContext.localTxId(), timeout)); } catch (OmegaException e) { throw new TransactionalException(e.getMessage(), e.getCause()); } }
@Override public Response toResponse(TransactionalException exception) { if (exception.getCause() instanceof InvalidTransactionException) { return Response.status(412).entity(INVALID_TRANSACTIONA_MESSAGE).build(); } else if (exception.getCause() instanceof TransactionRequiredException) { return Response.status(412).entity(TRANSACTIONA_REQUIRED_MESSAGE).build(); } throw exception; } }
public AlphaResponse preIntercept(String parentTxId, String methodName, int timeout) { try { return tccMessageSender.tccTransactionStart(new TccStartedEvent(omegaContext.globalTxId(), omegaContext.localTxId())); } catch (OmegaException e) { throw new TransactionalException(e.getMessage(), e.getCause()); } }
@Override public <T> T doInTransaction(Callable<T> callable) { try { return impl.doInTransaction(callable); } catch (TransactionalException e) { // unwrap since not usable, cause more interesting // (validationException, etc.) Throwable cause = e.getCause(); if (cause instanceof RuntimeException) { throw (RuntimeException) cause; } throw e; } } }
@Override protected State start() { try { if (transactionManager.getTransaction() != null) { throw new TransactionalException("@Transactional(NEVER) but a transaction is running", new IllegalStateException()); } return STATE; } catch (final SystemException e) { throw new TransactionalException(e.getMessage(), e); } }
@Override public Response toResponse(final TransactionalException ejbException) { final Throwable cause = ejbException.getCause(); if (cause != null) { final Class causeClass = cause.getClass(); final ExceptionMapper exceptionMapper = providers.getExceptionMapper(causeClass); if (exceptionMapper == null) { return defaultResponse(cause); } return exceptionMapper.toResponse(cause); } return defaultResponse(ejbException); }
@Override protected void commit(final State state) { if (state.old != state.current) { try { state.current.commit(); } catch (final HeuristicMixedException | HeuristicRollbackException | RollbackException | SystemException e) { throw new TransactionalException(e.getMessage(), e); } } } }
@Override protected void commit(final State state) { if (state.old != null) { try { transactionManager.resume(state.old); } catch (final InvalidTransactionException | SystemException e) { throw new TransactionalException(e.getMessage(), e); } } }
@Override protected State start() { try { final Transaction transaction = transactionManager.getTransaction(); final Transaction current; if (transaction == null) { transactionManager.begin(); current = transactionManager.getTransaction(); } else { current = transaction; } return new State(transaction, current); } catch (final SystemException | NotSupportedException se) { throw new TransactionalException(se.getMessage(), se); } }
@Override protected State start() { try { final Transaction transaction = transactionManager.suspend(); transactionManager.begin(); return new State(transaction, transactionManager.getTransaction()); } catch (final SystemException | NotSupportedException se) { throw new TransactionalException(se.getMessage(), se); } }
@Override protected void commit(final State state) { try { if (state.old != state.current) { try { state.current.commit(); } catch (final HeuristicMixedException | HeuristicRollbackException | RollbackException | SystemException e) { throw new TransactionalException(e.getMessage(), e); } } } finally { if (state.old != null) { try { transactionManager.resume(state.old); } catch (final InvalidTransactionException | SystemException e) { throw new TransactionalException(e.getMessage(), e); } } } } }
@Override protected State start() { try { final Transaction transaction = transactionManager.getTransaction(); return new State(transaction, transaction); } catch (final SystemException e) { throw new TransactionalException(e.getMessage(), e); } }
@Override protected State start() { try { final Transaction tx = transactionManager.getTransaction(); return new State(tx, null); } catch (final SystemException e) { throw new TransactionalException(e.getMessage(), e); } }
@Override protected State start() { final Transaction transaction; try { transaction = transactionManager.getTransaction(); } catch (final SystemException e) { throw new TransactionalException(e.getMessage(), e); } return new State(transaction, transaction); }
@AroundInvoke public Object intercept(final InvocationContext ic) throws Exception { try { return super.intercept(ic); } catch (final RemoteException re) { throw new TransactionalException(re.getMessage(), new InvalidTransactionException(re.getMessage())); } }
@Override protected Object doIntercept(TransactionManager tm, Transaction tx, InvocationContext ic) throws Exception { if (tx == null) { throw new TransactionalException(jtaLogger.i18NLogger.get_tx_required(), new TransactionRequiredException()); } return invokeInCallerTx(ic, tx); } }
@Override protected Object doIntercept(TransactionManager tm, Transaction tx, InvocationContext ic) throws Exception { if (tx == null) { throw new TransactionalException(jtaLogger.i18NLogger.get_tx_required(), new TransactionRequiredException()); } return invokeInCallerTx(ic, tx); } }
@Override protected Object doIntercept(TransactionManager tm, Transaction tx, InvocationContext ic) throws Exception { if (tx != null) { throw new TransactionalException(jtaLogger.i18NLogger.get_tx_required(), new InvalidTransactionException()); } return invokeInNoTx(ic); } }
@Override protected Object doIntercept(TransactionManager tm, Transaction tx, InvocationContext ic) throws Exception { if (tx == null) { throw new TransactionalException(jtaLogger.i18NLogger.get_tx_required(), new TransactionRequiredException()); } return invokeInCallerTx(ic, tx); } }
@Override protected Object doIntercept(TransactionManager tm, Transaction tx, InvocationContext ic) throws Exception { if (tx == null) { throw new TransactionalException(jtaLogger.i18NLogger.get_tx_required(), new TransactionRequiredException()); } return invokeInCallerTx(ic, tx); } }