Java 类org.springframework.transaction.PlatformTransactionManager 实例源码

项目:EasyTransaction    文件:ParentTrxStatusUpdateFilter.java   
@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);
}
项目:bekit    文件:FlowTxParser.java   
/**
 * 解析流程事务
 *
 * @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;
}
项目:composed-task-runner    文件:ComposedTaskRunnerStepFactoryTests.java   
@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);
        }
    };
}
项目:alfresco-core    文件:SpringAwareUserTransaction.java   
/**
 * 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;
}
项目:EasyTransaction    文件:TestBusinessDataSourceSelector.java   
@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);
    }
}
项目:atsea-sample-shop-app    文件:JpaConfiguration.java   
@Bean
@Autowired
public PlatformTransactionManager transactionManager(EntityManagerFactory emf) {
    JpaTransactionManager txManager = new JpaTransactionManager();
    txManager.setEntityManagerFactory(emf);
    return txManager;
}
项目:jwala    文件:AemJpaConfiguration.java   
@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;
}
项目:bekit    文件:ServiceParser.java   
/**
 * 解析服务
 *
 * @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;
}
项目:OperatieBRP    文件:AbstractBaseReadonlyController.java   
/**
 * 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);
}
项目:tipi-engine    文件:ActivityRunnerContext.java   
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;
}
项目:Smart-Shopping    文件:JPAConfig.java   
@Bean
@Autowired
public PlatformTransactionManager transactionManager(EntityManagerFactory emf) throws NamingException {
    JpaTransactionManager jpaTransaction = new JpaTransactionManager();
    jpaTransaction.setEntityManagerFactory(emf);
    return jpaTransaction;
}
项目:alfresco-repository    文件:TransactionServiceImplTest.java   
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");
}
项目:alfresco-repository    文件:ExportDbTest.java   
@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");
}
项目:lams    文件:TransactionAspectSupport.java   
/**
 * 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;
}
项目:rjb-blog-multitenancy    文件:TransactionConfig.java   
@Bean
  public PlatformTransactionManager txManager() throws Exception {
HibernateTransactionManager returnVal = new HibernateTransactionManager(
        hibernateConfig.sessionFactory());
returnVal.setDataSource(dataSourceConfig.dataSource());
return returnVal;
  }
项目:cas-server-4.2.1    文件:JpaLockingStrategyTests.java   
@Before
public void setup() {
    final ClassPathXmlApplicationContext ctx = new
        ClassPathXmlApplicationContext("classpath:/jpaSpringContext.xml");
    this.factory = ctx.getBean("ticketEntityManagerFactory", EntityManagerFactory.class);
    this.txManager = ctx.getBean("ticketTransactionManager", PlatformTransactionManager.class);
    this.dataSource = ctx.getBean("dataSourceTicket", DataSource.class);
}
项目:repository-multi-tenancy    文件:DefualtHibernateDataBaseConfig.java   
@Bean
public PlatformTransactionManager transactionManager() {
    return new DataSourceTransactionManager(selectAnyDataSource);
}
项目:holon-datastore-jpa    文件:TestJpaDatastoreEclipselink.java   
@Bean
public PlatformTransactionManager transactionManager(EntityManagerFactory emf) {
    JpaTransactionManager jtm = new JpaTransactionManager(emf);
    jtm.setDataSource(dataSource());
    return jtm;
}
项目:springboot_cwenao    文件:MybatisConfig.java   
@Bean
public PlatformTransactionManager platformTransactionManager() {
    return new DataSourceTransactionManager(dataSource);
}
项目:fo-veilarbjobbsokerkompetanse    文件:DataSourceConfig.java   
@Bean(name = "transactionManager")
public PlatformTransactionManager transactionManager(DataSource ds) throws NamingException {
    return new DataSourceTransactionManager(ds);
}
项目:EasyTransaction    文件:SingleDataSourceSelector.java   
public SingleDataSourceSelector(DataSource dataSource, PlatformTransactionManager transactionManager) {
    super();
    this.dataSource = dataSource;
    this.transactionManager = transactionManager;
}
项目:EasyTransaction    文件:SingleDataSourceSelector.java   
@Override
public PlatformTransactionManager selectTransactionManager(String appId, String busCode, String trxId) {
    return transactionManager;
}
项目:EasyTransaction    文件:SingleDataSourceSelector.java   
@Override
public PlatformTransactionManager selectTransactionManager(String appId, String busCode, EasyTransRequest<?, ?> request) {
    return transactionManager;
}
项目:holon-datastore-jpa    文件:TestDatastoreMultiConditional.java   
@Bean
public PlatformTransactionManager transactionManager2(@Qualifier("two") EntityManagerFactory emf) {
    return new JpaTransactionManager(emf);
}
项目:keti    文件:EnvDataSourceConfig.java   
@Bean
public PlatformTransactionManager transactionManager(final EntityManagerFactory emf) {
    return this.acsConfigUtil.transactionManager(emf);
}
项目:springboot-multi-datasource    文件:TxConfig.java   
@Bean
public PlatformTransactionManager transactionManager(AbstractRoutingDataSource dataSource) throws Exception {
    return new DataSourceTransactionManager(dataSource);
}
项目:Spring-Security-Third-Edition    文件:DataSourceConfig.java   
@Bean
@Autowired
public PlatformTransactionManager transactionManager(final DataSource dataSource) {
    return new DataSourceTransactionManager(dataSource);
}
项目:jwala    文件:TestJpaConfiguration.java   
@Bean(name = "transactionManager")
public PlatformTransactionManager getTransactionManager() {
    final PlatformTransactionManager manager = new JpaTransactionManager(getEntityManagerFactory());
    return manager;
}
项目:spring-boot-starter-quartz    文件:QuartzSchedulerAutoConfiguration.java   
private PlatformTransactionManager getTransactionManager(ApplicationContext applicationContext) {
    return applicationContext.getBean(PlatformTransactionManager.class);
}
项目:Purchase-order-process-template    文件:Config.java   
@Bean
public PlatformTransactionManager transactionManager() {
    return new DataSourceTransactionManager(dataSource());
}
项目:cmc-claim-store    文件:DbConfiguration.java   
@Bean
public PlatformTransactionManager transactionManager(TransactionAwareDataSourceProxy dataSource) {
    return new DataSourceTransactionManager(dataSource);
}
项目:spring-cloud-samples    文件:JpaCommonConfig.java   
@Bean(name = "commonTransactionManager")
public PlatformTransactionManager transactionManager(LocalContainerEntityManagerFactoryBean localContainerEntityManagerFactoryBean) {
    JpaTransactionManager txManager = new JpaTransactionManager();
    txManager.setEntityManagerFactory(localContainerEntityManagerFactoryBean.getObject());
    return txManager;
}
项目:spring-cloud-samples    文件:JpaCommonConfig.java   
@Bean(name = "commonTransactionManager")
public PlatformTransactionManager transactionManager(LocalContainerEntityManagerFactoryBean localContainerEntityManagerFactoryBean) {
    JpaTransactionManager txManager = new JpaTransactionManager();
    txManager.setEntityManagerFactory(localContainerEntityManagerFactoryBean.getObject());
    return txManager;
}
项目:dev-courses    文件:Config.java   
@Bean
public PlatformTransactionManager transactionManager(EntityManagerFactory c) {
    JpaTransactionManager txManager = new JpaTransactionManager();
    txManager.setEntityManagerFactory(c);
    return txManager;
}
项目:springboot-start    文件:PrimaryConfig.java   
@Primary
@Bean(name = "primaryTransactionManager")
public PlatformTransactionManager primaryTransactionManager(@Qualifier("primaryEntityManager") EntityManagerFactory entityManagerFactory) {
    return new JpaTransactionManager(entityManagerFactory);
}
项目:holon-datastore-jpa    文件:ExampleJpaDatastoreSpring.java   
@Bean
public PlatformTransactionManager transactionManager(EntityManagerFactory emf) {
    return new JpaTransactionManager(emf);
}
项目:amv-access-api-poc    文件:JpaConfig.java   
@Bean
public PlatformTransactionManager transactionManager() {
    EntityManagerFactory entityManagerFactory = entityManagerFactory().getObject();
    JpaTransactionManager txManager = new JpaTransactionManager(entityManagerFactory);
    return txManager;
}
项目:holon-datastore-jdbc    文件:TestJdbcDatastoreDerby.java   
@Bean
public PlatformTransactionManager transactionManager() {
    return new DataSourceTransactionManager(dataSource());
}
项目:oasp-tutorial-sources    文件:BeansBatchConfig.java   
/**
 *
 * @param transactionManager the transactionManager to set
 */
@Inject
public void setTransactionManager(PlatformTransactionManager transactionManager) {

  this.transactionManager = transactionManager;
}
项目:cas-5.1.0    文件:CasSupportJdbcAuditConfiguration.java   
@Bean
public PlatformTransactionManager inspektrAuditTransactionManager() {
    return new DataSourceTransactionManager(inspektrAuditTrailDataSource());
}