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


Java PlatformTransactionManager类代码示例

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


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

示例1: invoke

import org.springframework.transaction.PlatformTransactionManager; //导入依赖的package包/类
@Override
public EasyTransResult invoke(EasyTransFilterChain filterChain, Map<String, Object> header,
		EasyTransRequest<?, ?> request) {

	Integer pTrxStatus = MetaDataFilter.getMetaData(EasytransConstant.CallHeadKeys.PARENT_TRANSACTION_STATUS);
	if(!pTrxStatus.equals(com.yiqiniu.easytrans.datasource.TransStatusLogger.TransactionStatus.UNKNOWN)){
		// start transaction to update 
		PlatformTransactionManager transactionManager = getTransactionManager(filterChain, request);
		TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager,
				new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRED));
		TransactionId pTrxId = MetaDataFilter.getMetaData(EasytransConstant.CallHeadKeys.PARENT_TRX_ID_KEY);
		transactionTemplate.execute(new TransactionCallback<Object>() {
			@Override
			public Object doInTransaction(TransactionStatus status) {
				TransactionId trxId = pTrxId;
				transStatusLogger.updateExecuteFlagForSlaveTrx(trxId, request, pTrxStatus);
				return null;
			}
		});
		boolean commited = pTrxStatus.equals(com.yiqiniu.easytrans.datasource.TransStatusLogger.TransactionStatus.COMMITTED);
		//may be concurrent,but it's ok
		easyTransSynchronizer.cascadeExecuteCachedTransaction(pTrxId, commited);
	}
	
	return filterChain.invokeFilterChain(header, request);
}
 
开发者ID:QNJR-GROUP,项目名称:EasyTransaction,代码行数:27,代码来源:ParentTrxStatusUpdateFilter.java

示例2: transactionManager

import org.springframework.transaction.PlatformTransactionManager; //导入依赖的package包/类
@Bean
@Autowired
public PlatformTransactionManager transactionManager(EntityManagerFactory emf) {
	JpaTransactionManager txManager = new JpaTransactionManager();
	txManager.setEntityManagerFactory(emf);
	return txManager;
}
 
开发者ID:dockersamples,项目名称:atsea-sample-shop-app,代码行数:8,代码来源:JpaConfiguration.java

示例3: parseFlowTx

import org.springframework.transaction.PlatformTransactionManager; //导入依赖的package包/类
/**
 * 解析流程事务
 *
 * @param flowTx             流程事务
 * @param transactionManager 事务管理器
 * @return 流程事务执行器
 */
public static FlowTxExecutor parseFlowTx(Object flowTx, PlatformTransactionManager transactionManager) {
    // 获取目标class(应对AOP代理情况)
    Class<?> flowTxClass = AopUtils.getTargetClass(flowTx);
    logger.debug("解析流程事务:{}", ClassUtils.getQualifiedName(flowTxClass));
    FlowTx flowTxAnnotation = flowTxClass.getAnnotation(FlowTx.class);
    // 创建流程事务执行器
    FlowTxExecutor flowTxExecutor = new FlowTxExecutor(flowTxAnnotation.flow(), flowTx, transactionManager);
    for (Method method : flowTxClass.getDeclaredMethods()) {
        for (Class clazz : FlowTxExecutor.FLOW_TX_OPERATE_ANNOTATIONS) {
            if (method.isAnnotationPresent(clazz)) {
                // 设置流程事务操作执行器
                flowTxExecutor.setOperateExecutor(clazz, parseFlowTxOperate(method));
                break;
            }
        }
    }
    flowTxExecutor.validate();

    return flowTxExecutor;
}
 
开发者ID:zhongxunking,项目名称:bekit,代码行数:28,代码来源:FlowTxParser.java

示例4: taskConfigurer

import org.springframework.transaction.PlatformTransactionManager; //导入依赖的package包/类
@Bean
public TaskConfigurer taskConfigurer() {
	return new TaskConfigurer() {
		@Override
		public TaskRepository getTaskRepository() {
			return null;
		}

		@Override
		public PlatformTransactionManager getTransactionManager() {
			return null;
		}

		@Override
		public TaskExplorer getTaskExplorer() {
			return mock(TaskExplorer.class);
		}

		@Override
		public DataSource getTaskDataSource() {
			return mock(DataSource.class);
		}
	};
}
 
开发者ID:spring-cloud-task-app-starters,项目名称:composed-task-runner,代码行数:25,代码来源:ComposedTaskRunnerStepFactoryTests.java

示例5: SpringAwareUserTransaction

import org.springframework.transaction.PlatformTransactionManager; //导入依赖的package包/类
/**
 * Creates a user transaction that defaults to {@link TransactionDefinition#PROPAGATION_REQUIRED}.
 * 
 * @param transactionManager the transaction manager to use
 * @param readOnly true to force a read-only transaction
 * @param isolationLevel one of the
 *      {@link TransactionDefinition#ISOLATION_DEFAULT TransactionDefinition.ISOLATION_XXX}
 *      constants
 * @param propagationBehaviour one of the
 *      {@link TransactionDefinition#PROPAGATION_MANDATORY TransactionDefinition.PROPAGATION__XXX}
 *      constants
 * @param timeout the transaction timeout in seconds.
 * 
 * @see TransactionDefinition#getTimeout()
 */
public SpringAwareUserTransaction(
        PlatformTransactionManager transactionManager,
        boolean readOnly,
        int isolationLevel,
        int propagationBehaviour,
        int timeout)
{
    super();
    setTransactionManager(transactionManager);
    setTransactionAttributeSource(this);
    this.readOnly = readOnly;
    this.isolationLevel = isolationLevel;
    this.propagationBehaviour = propagationBehaviour;
    this.timeout = timeout;
}
 
开发者ID:Alfresco,项目名称:alfresco-core,代码行数:31,代码来源:SpringAwareUserTransaction.java

示例6: selectTransactionManager

import org.springframework.transaction.PlatformTransactionManager; //导入依赖的package包/类
@Override
public PlatformTransactionManager selectTransactionManager(String appId, String busCode, EasyTransRequest<?, ?> request) {
	if(appId != null){
		busCode = busCode.replace("Cascade", "");
		return ctx.getBean(busCode+"TransactionManager", PlatformTransactionManager.class);
	}else{
		return ctx.getBean("wholeTransactionManager", PlatformTransactionManager.class);
	}
}
 
开发者ID:QNJR-GROUP,项目名称:EasyTransaction,代码行数:10,代码来源:TestBusinessDataSourceSelector.java

示例7: getPlatformTransactionManager

import org.springframework.transaction.PlatformTransactionManager; //导入依赖的package包/类
@Bean
public PlatformTransactionManager getPlatformTransactionManager(final EntityManagerFactory emf) {
    final JpaTransactionManager transactionManager = new JpaTransactionManager();
    transactionManager.setDefaultTimeout(ApplicationProperties.getAsInteger(JWALA_JTA_TRANSACTION_TIMEOUT, 30));
    transactionManager.setEntityManagerFactory(emf);
    return transactionManager;
}
 
开发者ID:cerner,项目名称:jwala,代码行数:8,代码来源:AemJpaConfiguration.java

示例8: parseService

import org.springframework.transaction.PlatformTransactionManager; //导入依赖的package包/类
/**
 * 解析服务
 *
 * @param service            服务
 * @param transactionManager 事务管理器
 * @return 服务执行器
 */
public static ServiceExecutor parseService(Object service, PlatformTransactionManager transactionManager) {
    // 获取目标class(应对AOP代理情况)
    Class<?> serviceClass = AopUtils.getTargetClass(service);
    logger.debug("解析服务:{}", ClassUtils.getQualifiedName(serviceClass));
    Service serviceAnnotation = serviceClass.getAnnotation(Service.class);
    // 获取服务名称
    String serviceName = serviceAnnotation.name();
    if (StringUtils.isEmpty(serviceName)) {
        serviceName = ClassUtils.getShortNameAsProperty(serviceClass);
    }
    // 创建服务执行器
    ServiceExecutor serviceExecutor = new ServiceExecutor(serviceName, serviceAnnotation.enableTx(), service);
    if (serviceAnnotation.enableTx()) {
        if (transactionManager == null) {
            throw new IllegalArgumentException("服务" + serviceAnnotation.name() + "的enableTx属性为开启状态,但不存在事务管理器(PlatformTransactionManager),请检查是否有配置spring事务管理器");
        }
        serviceExecutor.setTxExecutor(new TxExecutor(transactionManager));
    }
    for (Method method : serviceClass.getDeclaredMethods()) {
        for (Class clazz : ServiceExecutor.SERVICE_PHASE_ANNOTATIONS) {
            if (method.isAnnotationPresent(clazz)) {
                // 设置服务阶段执行器
                serviceExecutor.setPhaseExecutor(clazz, parseServicePhase(method));
                break;
            }
        }
    }
    serviceExecutor.validate();

    return serviceExecutor;
}
 
开发者ID:zhongxunking,项目名称:bekit,代码行数:39,代码来源:ServiceParser.java

示例9: setTransactionManagerReadonly

import org.springframework.transaction.PlatformTransactionManager; //导入依赖的package包/类
/**
 * Zet de transaction manager.
 *
 * @param transactionManager transaction manager
 */
@Inject
public final void setTransactionManagerReadonly(final PlatformTransactionManager transactionManager) {
    final DefaultTransactionDefinition transactionDefinition = new DefaultTransactionDefinition();
    transactionDefinition.setReadOnly(true);
    transactionTemplate = new TransactionTemplate(transactionManager, transactionDefinition);
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:12,代码来源:AbstractBaseReadonlyController.java

示例10: ActivityRunnerContext

import org.springframework.transaction.PlatformTransactionManager; //导入依赖的package包/类
public ActivityRunnerContext(ActivityRepository persist, CommandHelperService commandHelperService, CommandService commandService, TopProcessGroupManager groupManager, PlatformTransactionManager txManager, TopProcessGroupLauncher launcher) {
	this.activityRepository = persist;
	this.commandHelperService = commandHelperService;
	this.commandService = commandService;
	this.groupManager = groupManager;
	this.txManager = txManager;
	this.launcher = launcher;
}
 
开发者ID:shared-vd,项目名称:tipi-engine,代码行数:9,代码来源:ActivityRunnerContext.java

示例11: transactionManager

import org.springframework.transaction.PlatformTransactionManager; //导入依赖的package包/类
@Bean
@Autowired
public PlatformTransactionManager transactionManager(EntityManagerFactory emf) throws NamingException {
	JpaTransactionManager jpaTransaction = new JpaTransactionManager();
	jpaTransaction.setEntityManagerFactory(emf);
	return jpaTransaction;
}
 
开发者ID:Azanx,项目名称:Smart-Shopping,代码行数:8,代码来源:JPAConfig.java

示例12: setUp

import org.springframework.transaction.PlatformTransactionManager; //导入依赖的package包/类
public void setUp() throws Exception
{
    transactionManager = (PlatformTransactionManager) ctx.getBean("transactionManager");
    transactionService = new TransactionServiceImpl();
    transactionService.setTransactionManager(transactionManager);   
    transactionService.setAllowWrite(true, vetoName);
    
    nodeService = (NodeService) ctx.getBean("dbNodeService");
    authenticationService = (MutableAuthenticationService) ctx.getBean("AuthenticationService");
    personService = (PersonService) ctx.getBean("PersonService");
    
    dialect = (Dialect) ctx.getBean("dialect");
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:14,代码来源:TransactionServiceImplTest.java

示例13: setUp

import org.springframework.transaction.PlatformTransactionManager; //导入依赖的package包/类
@Before
public void setUp() throws Exception
{
    ctx = ApplicationContextHelper.getApplicationContext();
    dataSource = (DataSource) ctx.getBean("dataSource");
    tx = (PlatformTransactionManager) ctx.getBean("transactionManager"); 
    jdbcTemplate = new SimpleJdbcTemplate(dataSource);
    exporter = new ExportDb(ctx);
    exporter.setNamePrefix("export_test_");
    dialect = (Dialect) ctx.getBean("dialect");
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:12,代码来源:ExportDbTest.java

示例14: prepareTransactionInfo

import org.springframework.transaction.PlatformTransactionManager; //导入依赖的package包/类
/**
 * Prepare a TransactionInfo for the given attribute and status object.
 * @param txAttr the TransactionAttribute (may be {@code null})
 * @param joinpointIdentification the fully qualified method name
 * (used for monitoring and logging purposes)
 * @param status the TransactionStatus for the current transaction
 * @return the prepared TransactionInfo object
 */
protected TransactionInfo prepareTransactionInfo(PlatformTransactionManager tm,
		TransactionAttribute txAttr, String joinpointIdentification, TransactionStatus status) {

	TransactionInfo txInfo = new TransactionInfo(tm, txAttr, joinpointIdentification);
	if (txAttr != null) {
		// We need a transaction for this method
		if (logger.isTraceEnabled()) {
			logger.trace("Getting transaction for [" + txInfo.getJoinpointIdentification() + "]");
		}
		// The transaction manager will flag an error if an incompatible tx already exists
		txInfo.newTransactionStatus(status);
	}
	else {
		// The TransactionInfo.hasTransaction() method will return
		// false. We created it only to preserve the integrity of
		// the ThreadLocal stack maintained in this class.
		if (logger.isTraceEnabled())
			logger.trace("Don't need to create transaction for [" + joinpointIdentification +
					"]: This method isn't transactional.");
	}

	// We always bind the TransactionInfo to the thread, even if we didn't create
	// a new transaction here. This guarantees that the TransactionInfo stack
	// will be managed correctly even if no transaction was created by this aspect.
	txInfo.bindToThread();
	return txInfo;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:36,代码来源:TransactionAspectSupport.java

示例15: txManager

import org.springframework.transaction.PlatformTransactionManager; //导入依赖的package包/类
@Bean
  public PlatformTransactionManager txManager() throws Exception {
HibernateTransactionManager returnVal = new HibernateTransactionManager(
		hibernateConfig.sessionFactory());
returnVal.setDataSource(dataSourceConfig.dataSource());
return returnVal;
  }
 
开发者ID:RJBTechnology,项目名称:rjb-blog-multitenancy,代码行数:8,代码来源:TransactionConfig.java


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