当前位置: 首页>>代码示例>>Java>>正文


Java TransactionSynchronizationUtils类代码示例

本文整理汇总了Java中org.springframework.transaction.support.TransactionSynchronizationUtils的典型用法代码示例。如果您正苦于以下问题:Java TransactionSynchronizationUtils类的具体用法?Java TransactionSynchronizationUtils怎么用?Java TransactionSynchronizationUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TransactionSynchronizationUtils类属于org.springframework.transaction.support包,在下文中一共展示了TransactionSynchronizationUtils类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: afterCompletion

import org.springframework.transaction.support.TransactionSynchronizationUtils; //导入依赖的package包/类
@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);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:JtaAfterCompletionSynchronization.java

示例2: initialize

import org.springframework.transaction.support.TransactionSynchronizationUtils; //导入依赖的package包/类
@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();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:AbstractPollingMessageListenerContainer.java

示例3: afterCompletion

import org.springframework.transaction.support.TransactionSynchronizationUtils; //导入依赖的package包/类
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);
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:21,代码来源:JtaAfterCompletionSynchronization.java

示例4: rollback

import org.springframework.transaction.support.TransactionSynchronizationUtils; //导入依赖的package包/类
@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();
	}
}
 
开发者ID:leopardoooo,项目名称:easyooo-framework,代码行数:38,代码来源:ChainedTransactionManager.java

示例5: incrementBy1Transactional

import org.springframework.transaction.support.TransactionSynchronizationUtils; //导入依赖的package包/类
@Test
public void incrementBy1Transactional() throws Exception {
	// Given
	TransactionSynchronizationManager.initSynchronization();
	// When
	batchMetrics.increment("counter.test", 1L);
	TransactionSynchronizationUtils.triggerAfterCompletion(TransactionSynchronization.STATUS_COMMITTED);
	// Then
	TransactionSynchronizationManager.clearSynchronization();
}
 
开发者ID:codecentric,项目名称:spring-boot-starter-batch-web,代码行数:11,代码来源:BatchMetricsImplTest.java

示例6: decrementBy1Transactional

import org.springframework.transaction.support.TransactionSynchronizationUtils; //导入依赖的package包/类
@Test
public void decrementBy1Transactional() throws Exception {
	// Given
	TransactionSynchronizationManager.initSynchronization();
	// When
	batchMetrics.decrement("counter.test", 1L);
	TransactionSynchronizationUtils.triggerAfterCompletion(TransactionSynchronization.STATUS_COMMITTED);
	// Then
	TransactionSynchronizationManager.clearSynchronization();
}
 
开发者ID:codecentric,项目名称:spring-boot-starter-batch-web,代码行数:11,代码来源:BatchMetricsImplTest.java

示例7: submitTransactional

import org.springframework.transaction.support.TransactionSynchronizationUtils; //导入依赖的package包/类
@Test
public void submitTransactional() throws Exception {
	// Given
	TransactionSynchronizationManager.initSynchronization();
	// When
	batchMetrics.submit("counter.test", 1L);
	TransactionSynchronizationUtils.triggerAfterCompletion(TransactionSynchronization.STATUS_COMMITTED);
	// Then
	TransactionSynchronizationManager.clearSynchronization();
}
 
开发者ID:codecentric,项目名称:spring-boot-starter-batch-web,代码行数:11,代码来源:BatchMetricsImplTest.java

示例8: flush

import org.springframework.transaction.support.TransactionSynchronizationUtils; //导入依赖的package包/类
@Override
public void flush() {
	TransactionSynchronizationUtils.triggerFlush();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:WebSphereUowTransactionManager.java

示例9: testRegisterTxHandler

import org.springframework.transaction.support.TransactionSynchronizationUtils; //导入依赖的package包/类
/**
 *
 */
@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);
}
 
开发者ID:cucina,项目名称:opencucina,代码行数:25,代码来源:TransactionHandlerImplTest.java

示例10: invokeAfterCompletion

import org.springframework.transaction.support.TransactionSynchronizationUtils; //导入依赖的package包/类
public static void invokeAfterCompletion(int completionStatus) {
	List<TransactionSynchronization> synchronizations = TransactionSynchronizationManager
			.getSynchronizations();
	TransactionSynchronizationUtils.invokeAfterCompletion(synchronizations, completionStatus);
}
 
开发者ID:leopardoooo,项目名称:easyooo-framework,代码行数:6,代码来源:RoutingSynchronizationManager.java

示例11: flush

import org.springframework.transaction.support.TransactionSynchronizationUtils; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:JtaTransactionObject.java

示例12: flush

import org.springframework.transaction.support.TransactionSynchronizationUtils; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:9,代码来源:JtaTransactionObject.java


注:本文中的org.springframework.transaction.support.TransactionSynchronizationUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。