@Override public <T> T execute(TransactionCallback<T> action) throws TransactionException { return action.doInTransaction(null); }
@Override public <T> T execute(TransactionDefinition definition, TransactionCallback<T> callback) throws TransactionException { this.definition = definition; this.status = new SimpleTransactionStatus(); return callback.doInTransaction(this.status); }
@Override @Nullable public <T> T execute(TransactionCallback<T> action) throws TransactionException { Assert.state(this.transactionManager != null, "No PlatformTransactionManager set"); if (this.transactionManager instanceof CallbackPreferringPlatformTransactionManager) { return ((CallbackPreferringPlatformTransactionManager) this.transactionManager).execute(this, action); } else { TransactionStatus status = this.transactionManager.getTransaction(this); T result; try { result = action.doInTransaction(status); } catch (RuntimeException | Error ex) { // Transactional code threw application exception -> rollback rollbackOnException(status, ex); throw ex; } catch (Throwable ex) { // Transactional code threw unexpected exception -> rollback rollbackOnException(status, ex); throw new UndeclaredThrowableException(ex, "TransactionCallback threw undeclared checked exception"); } this.transactionManager.commit(status); return result; } }
public <T> T execute(final org.springframework.transaction.support.TransactionCallback<T> action) { return transactionTemplate.execute(status -> { txnCtx().transactionPushed(); try { return action.doInTransaction(status); } finally { txnCtx().transactionPopped(); } }); }
@Override @Nullable public <T> T execute(TransactionCallback<T> action) throws TransactionException { Assert.state(this.transactionManager != null, "No PlatformTransactionManager set"); if (this.transactionManager instanceof CallbackPreferringPlatformTransactionManager) { return ((CallbackPreferringPlatformTransactionManager) this.transactionManager).execute(this, action); } else { TransactionStatus status = this.transactionManager.getTransaction(this); T result; try { result = action.doInTransaction(status); } catch (RuntimeException | Error ex) { // Transactional code threw application exception -> rollback rollbackOnException(status, ex); throw ex; } catch (Throwable ex) { // Transactional code threw unexpected exception -> rollback rollbackOnException(status, ex); throw new UndeclaredThrowableException(ex, "TransactionCallback threw undeclared checked exception"); } this.transactionManager.commit(status); return result; } }
this.newTransaction, this.newSynchronization, this.debug, null); try { this.result = this.callback.doInTransaction(status); triggerBeforeCommit(status);
this.newTransaction, this.newSynchronization, this.debug, null); try { this.result = this.callback.doInTransaction(status); triggerBeforeCommit(status);
@Override public Object execute(TransactionCallback action) throws TransactionException { Object o = null; try { o = action.doInTransaction(null); synchronizationManager.executeAfterCompletion(TransactionSynchronization.STATUS_COMMITTED); synchronizationManager.executeAfterCommit(); } catch (RuntimeException e) { synchronizationManager.executeAfterCompletion(TransactionSynchronization.STATUS_ROLLED_BACK); throw e; } catch (Error e) { synchronizationManager.executeAfterCompletion(TransactionSynchronization.STATUS_ROLLED_BACK); throw e; } finally { synchronizationManager.clearSynchronizations(); } return o; } }
nextResponseBundle = callback.doInTransaction(null); } else { nextResponseBundle = txTemplate.execute(callback);
BUNDLE nextResponseBundle = callback.doInTransaction(null);
@Override public T doInTransaction(TransactionStatus status) { joinTransaction(status); return action.doInTransaction(status); } };
public <T> T execute(final TransactionCallback<T> action) throws TransactionException { final TransactionStatus status = getTransactionManager().getTransaction(this); final T result = action.doInTransaction(status); getTransactionManager().commit(status); return result; } }
@Override @Nullable public <T> T execute(TransactionCallback<T> action) throws TransactionException { Assert.state(this.transactionManager != null, "No PlatformTransactionManager set"); if (this.transactionManager instanceof CallbackPreferringPlatformTransactionManager) { return ((CallbackPreferringPlatformTransactionManager) this.transactionManager).execute(this, action); } else { TransactionStatus status = this.transactionManager.getTransaction(this); T result; try { result = action.doInTransaction(status); } catch (RuntimeException | Error ex) { // Transactional code threw application exception -> rollback rollbackOnException(status, ex); throw ex; } catch (Throwable ex) { // Transactional code threw unexpected exception -> rollback rollbackOnException(status, ex); throw new UndeclaredThrowableException(ex, "TransactionCallback threw undeclared checked exception"); } this.transactionManager.commit(status); return result; } }
@Override @Nullable public <T> T execute(TransactionCallback<T> action) throws TransactionException { Assert.state(this.transactionManager != null, "No PlatformTransactionManager set"); if (this.transactionManager instanceof CallbackPreferringPlatformTransactionManager) { return ((CallbackPreferringPlatformTransactionManager) this.transactionManager).execute(this, action); } else { TransactionStatus status = this.transactionManager.getTransaction(this); T result; try { result = action.doInTransaction(status); } catch (RuntimeException | Error ex) { // Transactional code threw application exception -> rollback rollbackOnException(status, ex); throw ex; } catch (Throwable ex) { // Transactional code threw unexpected exception -> rollback rollbackOnException(status, ex); throw new UndeclaredThrowableException(ex, "TransactionCallback threw undeclared checked exception"); } this.transactionManager.commit(status); return result; } }
public <T> T execute(final TransactionCallback<T> action) throws TransactionException { final TransactionStatus status = getTransactionManager().getTransaction(this); final T result = action.doInTransaction(status); getTransactionManager().commit(status); return result; } }
@Before public void setUp() { final EventTypeOptionsValidator eventTypeOptionsValidator = new EventTypeOptionsValidator(TOPIC_RETENTION_MIN_MS, TOPIC_RETENTION_MAX_MS); eventTypeService = new EventTypeService(eventTypeRepository, timelineService, partitionResolver, enrichment, subscriptionDbRepository, schemaEvolutionService, partitionsCalculator, featureToggleService, authorizationValidator, timelineSync, transactionTemplate, nakadiSettings, nakadiKpiPublisher, KPI_ET_LOG_EVENT_TYPE, nakadiAuditLogPublisher, eventTypeOptionsValidator, adminService); when(transactionTemplate.execute(any())).thenAnswer(invocation -> { final TransactionCallback callback = (TransactionCallback) invocation.getArguments()[0]; return callback.doInTransaction(null); }); }
/** * Execute the action specified by the given callback object within a transaction. * <p>Allows for returning a result object created within the transaction, i.e. * a domain object or a collection of domain objects. A RuntimeException thrown * by the callback is treated as application exception that enforces a rollback. * An exception gets propagated to the caller of the template. * @param action callback object that specifies the transactional action * @return a result object returned by the callback, or <code>null</code> * @throws TransactionException in case of initialization, rollback, or system errors */ public Object execute(TransactionCallback action) throws TransactionException { TransactionStatus status = this.transactionManager.getTransaction(this); Object result = null; try { result = action.doInTransaction(status); } catch (RuntimeException ex) { // transactional code threw application exception -> rollback rollbackOnException(status, ex); throw ex; } catch (Error err) { // transactional code threw error -> rollback rollbackOnException(status, err); throw err; } this.transactionManager.commit(status); return result; }
this.newTransaction, this.newSynchronization, this.debug, null); try { this.result = this.callback.doInTransaction(status); triggerBeforeCommit(status);
this.newTransaction, this.newSynchronization, this.debug, null); try { this.result = this.callback.doInTransaction(status); triggerBeforeCommit(status);
when(transactionTemplate.execute(any())).thenAnswer(invocation -> { final TransactionCallback callback = (TransactionCallback) invocation.getArguments()[0]; return callback.doInTransaction(null); });