當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。