Java 类org.springframework.transaction.support.TransactionSynchronizationUtils 实例源码

项目:lams    文件:JtaAfterCompletionSynchronization.java   
@Override
public void afterCompletion(int status) {
    switch (status) {
        case Status.STATUS_COMMITTED:
            try {
                TransactionSynchronizationUtils.invokeAfterCommit(this.synchronizations);
            }
            finally {
                TransactionSynchronizationUtils.invokeAfterCompletion(
                        this.synchronizations, TransactionSynchronization.STATUS_COMMITTED);
            }
            break;
        case Status.STATUS_ROLLEDBACK:
            TransactionSynchronizationUtils.invokeAfterCompletion(
                    this.synchronizations, TransactionSynchronization.STATUS_ROLLED_BACK);
            break;
        default:
            TransactionSynchronizationUtils.invokeAfterCompletion(
                    this.synchronizations, TransactionSynchronization.STATUS_UNKNOWN);
    }
}
项目:spring4-understanding    文件:JtaAfterCompletionSynchronization.java   
@Override
public void afterCompletion(int status) {
    switch (status) {
        case Status.STATUS_COMMITTED:
            try {
                TransactionSynchronizationUtils.invokeAfterCommit(this.synchronizations);
            }
            finally {
                TransactionSynchronizationUtils.invokeAfterCompletion(
                        this.synchronizations, TransactionSynchronization.STATUS_COMMITTED);
            }
            break;
        case Status.STATUS_ROLLEDBACK:
            TransactionSynchronizationUtils.invokeAfterCompletion(
                    this.synchronizations, TransactionSynchronization.STATUS_ROLLED_BACK);
            break;
        default:
            TransactionSynchronizationUtils.invokeAfterCompletion(
                    this.synchronizations, TransactionSynchronization.STATUS_UNKNOWN);
    }
}
项目:spring4-understanding    文件:AbstractPollingMessageListenerContainer.java   
@Override
public void initialize() {
    // Set sessionTransacted=true in case of a non-JTA transaction manager.
    if (!this.sessionTransactedCalled &&
            this.transactionManager instanceof ResourceTransactionManager &&
            !TransactionSynchronizationUtils.sameResourceFactory(
                    (ResourceTransactionManager) this.transactionManager, getConnectionFactory())) {
        super.setSessionTransacted(true);
    }

    // Use bean name as default transaction name.
    if (this.transactionDefinition.getName() == null) {
        this.transactionDefinition.setName(getBeanName());
    }

    // Proceed with superclass initialization.
    super.initialize();
}
项目:class-guard    文件:JtaAfterCompletionSynchronization.java   
public void afterCompletion(int status) {
    switch (status) {
        case Status.STATUS_COMMITTED:
            try {
                TransactionSynchronizationUtils.invokeAfterCommit(this.synchronizations);
            }
            finally {
                TransactionSynchronizationUtils.invokeAfterCompletion(
                        this.synchronizations, TransactionSynchronization.STATUS_COMMITTED);
            }
            break;
        case Status.STATUS_ROLLEDBACK:
            TransactionSynchronizationUtils.invokeAfterCompletion(
                    this.synchronizations, TransactionSynchronization.STATUS_ROLLED_BACK);
            break;
        default:
            TransactionSynchronizationUtils.invokeAfterCompletion(
                    this.synchronizations, TransactionSynchronization.STATUS_UNKNOWN);
    }
}
项目:class-guard    文件:AbstractPollingMessageListenerContainer.java   
@Override
public void initialize() {
    // Set sessionTransacted=true in case of a non-JTA transaction manager.
    if (!this.sessionTransactedCalled &&
            this.transactionManager instanceof ResourceTransactionManager &&
            !TransactionSynchronizationUtils.sameResourceFactory(
                    (ResourceTransactionManager) this.transactionManager, getConnectionFactory())) {
        super.setSessionTransacted(true);
    }

    // Use bean name as default transaction name.
    if (this.transactionDefinition.getName() == null) {
        this.transactionDefinition.setName(getBeanName());
    }

    // Proceed with superclass initialization.
    super.initialize();
}
项目:easyooo-framework    文件:ChainedTransactionManager.java   
@Override
public void rollback(TransactionStatus status) throws TransactionException {
    if(logger.isWarnEnabled()){
        logger.warn("Rollback all connected transactions.");
    }
    try{
        TransactionSynchronizationUtils.triggerBeforeCompletion();
        Map<DataSource, ConnectionHolder> connSet = RoutingSynchronizationManager.getSynchronizations();
        Exception rollbackException = null;
        ConnectionHolder rollbackExceptionConnection = null;

        for (ConnectionHolder connection:connSet.values()) {
            try {
                connection.rollback();
                if (logger.isDebugEnabled()) {
                    logger.debug("Connection["+ connection +"] has been rolled back.");
                }
            } catch (Exception ex) {
                if (rollbackException == null) {
                    rollbackException = ex;
                    rollbackExceptionConnection = connection;
                } else {
                    logger.warn("Rollback exception (" + rollbackExceptionConnection + ") " + ex.getMessage(), ex);
                }
            }
        }

        if (rollbackException != null) {
            throw new UnexpectedRollbackException("Rollback exception, originated at ("+rollbackExceptionConnection+") "+
              rollbackException.getMessage(), rollbackException);
        }
    }finally{
        RoutingSynchronizationManager
                .invokeAfterCompletion(TransactionSynchronization.STATUS_ROLLED_BACK);
        RoutingSynchronizationManager.clearSynchronization();
    }
}
项目:spring-boot-starter-batch-web    文件:BatchMetricsImplTest.java   
@Test
public void incrementBy1Transactional() throws Exception {
    // Given
    TransactionSynchronizationManager.initSynchronization();
    // When
    batchMetrics.increment("counter.test", 1L);
    TransactionSynchronizationUtils.triggerAfterCompletion(TransactionSynchronization.STATUS_COMMITTED);
    // Then
    TransactionSynchronizationManager.clearSynchronization();
}
项目:spring-boot-starter-batch-web    文件:BatchMetricsImplTest.java   
@Test
public void decrementBy1Transactional() throws Exception {
    // Given
    TransactionSynchronizationManager.initSynchronization();
    // When
    batchMetrics.decrement("counter.test", 1L);
    TransactionSynchronizationUtils.triggerAfterCompletion(TransactionSynchronization.STATUS_COMMITTED);
    // Then
    TransactionSynchronizationManager.clearSynchronization();
}
项目:spring-boot-starter-batch-web    文件:BatchMetricsImplTest.java   
@Test
public void submitTransactional() throws Exception {
    // Given
    TransactionSynchronizationManager.initSynchronization();
    // When
    batchMetrics.submit("counter.test", 1L);
    TransactionSynchronizationUtils.triggerAfterCompletion(TransactionSynchronization.STATUS_COMMITTED);
    // Then
    TransactionSynchronizationManager.clearSynchronization();
}
项目:lams    文件:WebSphereUowTransactionManager.java   
@Override
public void flush() {
    TransactionSynchronizationUtils.triggerFlush();
}
项目:spring4-understanding    文件:WebSphereUowTransactionManager.java   
@Override
public void flush() {
    TransactionSynchronizationUtils.triggerFlush();
}
项目:opencucina    文件:TransactionHandlerImplTest.java   
/**
 *
 */
@SuppressWarnings("rawtypes")
@Test
public void testRegisterTxHandler() {
    TransactionSynchronizationManager.initSynchronization();
    handler.registerTxHandler("entityType", 1L);
    TransactionSynchronizationUtils.triggerAfterCompletion(TransactionSynchronization.STATUS_COMMITTED);

    ArgumentCaptor<Message> mac = ArgumentCaptor.forClass(Message.class);

    verify(asyncChannel).send(mac.capture());

    Message<?> m = mac.getValue();

    assertTrue(m.getPayload() instanceof CommitSuccessEvent);

    CommitSuccessEvent cse = (CommitSuccessEvent) m.getPayload();

    Object id = ((Object[]) cse.getSource())[0];

    assertEquals(1L, id);
}
项目:class-guard    文件:WebSphereUowTransactionManager.java   
@Override
public void flush() {
    TransactionSynchronizationUtils.triggerFlush();
}
项目:easyooo-framework    文件:RoutingSynchronizationManager.java   
public static void invokeAfterCompletion(int completionStatus) {
    List<TransactionSynchronization> synchronizations = TransactionSynchronizationManager
            .getSynchronizations();
    TransactionSynchronizationUtils.invokeAfterCompletion(synchronizations, completionStatus);
}
项目:lams    文件:JtaTransactionObject.java   
/**
 * This implementation triggers flush callbacks,
 * assuming that they will flush all affected ORM sessions.
 * @see org.springframework.transaction.support.TransactionSynchronization#flush()
 */
@Override
public void flush() {
    TransactionSynchronizationUtils.triggerFlush();
}
项目:spring4-understanding    文件:JtaTransactionObject.java   
/**
 * This implementation triggers flush callbacks,
 * assuming that they will flush all affected ORM sessions.
 * @see org.springframework.transaction.support.TransactionSynchronization#flush()
 */
@Override
public void flush() {
    TransactionSynchronizationUtils.triggerFlush();
}
项目:class-guard    文件:JtaTransactionObject.java   
/**
 * This implementation triggers flush callbacks,
 * assuming that they will flush all affected ORM sessions.
 * @see org.springframework.transaction.support.TransactionSynchronization#flush()
 */
public void flush() {
    TransactionSynchronizationUtils.triggerFlush();
}