• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java BeanFactoryTransactionAttributeSourceAdvisor类的典型用法和代码示例

java 1次浏览

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

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

示例1: assertTxProxying

点赞 3

import org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor; //导入依赖的package包/类
private void assertTxProxying(AnnotationConfigApplicationContext ctx) {
	FooRepository repo = ctx.getBean(FooRepository.class);

	boolean isTxProxy = false;
	if (AopUtils.isAopProxy(repo)) {
		for (Advisor advisor : ((Advised)repo).getAdvisors()) {
			if (advisor instanceof BeanFactoryTransactionAttributeSourceAdvisor) {
				isTxProxy = true;
				break;
			}
		}
	}
	assertTrue("FooRepository is not a TX proxy", isTxProxy);

	// trigger a transaction
	repo.findAll();
}
 

开发者ID:langtianya,
项目名称:spring4-understanding,
代码行数:18,
代码来源:EnableTransactionManagementIntegrationTests.java

示例2: txProxiedTokenServices

点赞 3

import org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor; //导入依赖的package包/类
private DefaultTokenServices txProxiedTokenServices(DefaultTokenServices tokenServices, DataSource dataSource) {
    AnnotationTransactionAttributeSource attrSource = new AnnotationTransactionAttributeSource();
    DataSourceTransactionManager txManager = new DataSourceTransactionManager(dataSource);
    TransactionInterceptor txInterceptor = transactionInterceptor(attrSource, txManager);
    BeanFactoryTransactionAttributeSourceAdvisor txAdvisor = transactionAdvisor(attrSource, txInterceptor);
    ClassLoader classLoader = ClassUtils.getDefaultClassLoader();

    ProxyFactory proxyFactory = new ProxyFactory(tokenServices);
    proxyFactory.addAdvice(txInterceptor);
    proxyFactory.addAdvisor(txAdvisor);
    proxyFactory.setInterfaces(
        ClassUtils.getAllInterfacesForClass(
            new SingletonTargetSource(tokenServices).getTargetClass(), classLoader));

    return (DefaultTokenServices) proxyFactory.getProxy(classLoader);
}
 

开发者ID:petrbouda,
项目名称:joyrest,
代码行数:17,
代码来源:OAuth2Initializer.java

示例3: transactionAdvisor

点赞 2

import org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor; //导入依赖的package包/类
@Bean(name=TransactionManagementConfigUtils.TRANSACTION_ADVISOR_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public BeanFactoryTransactionAttributeSourceAdvisor transactionAdvisor() {
	BeanFactoryTransactionAttributeSourceAdvisor advisor = new BeanFactoryTransactionAttributeSourceAdvisor();
	advisor.setTransactionAttributeSource(transactionAttributeSource());
	advisor.setAdvice(transactionInterceptor());
	advisor.setOrder(this.enableTx.<Integer>getNumber("order"));
	return advisor;
}
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:10,
代码来源:ProxyTransactionManagementConfiguration.java

示例4: configureAutoProxyCreator

点赞 2

import org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor; //导入依赖的package包/类
public static void configureAutoProxyCreator(Element element, ParserContext parserContext) {
	AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(parserContext, element);

	String txAdvisorBeanName = TransactionManagementConfigUtils.TRANSACTION_ADVISOR_BEAN_NAME;
	if (!parserContext.getRegistry().containsBeanDefinition(txAdvisorBeanName)) {
		Object eleSource = parserContext.extractSource(element);

		// Create the TransactionAttributeSource definition.
		RootBeanDefinition sourceDef = new RootBeanDefinition(
				"org.springframework.transaction.annotation.AnnotationTransactionAttributeSource");
		sourceDef.setSource(eleSource);
		sourceDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
		String sourceName = parserContext.getReaderContext().registerWithGeneratedName(sourceDef);

		// Create the TransactionInterceptor definition.
		RootBeanDefinition interceptorDef = new RootBeanDefinition(TransactionInterceptor.class);
		interceptorDef.setSource(eleSource);
		interceptorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
		registerTransactionManager(element, interceptorDef);
		interceptorDef.getPropertyValues().add("transactionAttributeSource", new RuntimeBeanReference(sourceName));
		String interceptorName = parserContext.getReaderContext().registerWithGeneratedName(interceptorDef);

		// Create the TransactionAttributeSourceAdvisor definition.
		RootBeanDefinition advisorDef = new RootBeanDefinition(BeanFactoryTransactionAttributeSourceAdvisor.class);
		advisorDef.setSource(eleSource);
		advisorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
		advisorDef.getPropertyValues().add("transactionAttributeSource", new RuntimeBeanReference(sourceName));
		advisorDef.getPropertyValues().add("adviceBeanName", interceptorName);
		if (element.hasAttribute("order")) {
			advisorDef.getPropertyValues().add("order", element.getAttribute("order"));
		}
		parserContext.getRegistry().registerBeanDefinition(txAdvisorBeanName, advisorDef);

		CompositeComponentDefinition compositeDef = new CompositeComponentDefinition(element.getTagName(), eleSource);
		compositeDef.addNestedComponent(new BeanComponentDefinition(sourceDef, sourceName));
		compositeDef.addNestedComponent(new BeanComponentDefinition(interceptorDef, interceptorName));
		compositeDef.addNestedComponent(new BeanComponentDefinition(advisorDef, txAdvisorBeanName));
		parserContext.registerComponent(compositeDef);
	}
}
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:41,
代码来源:AnnotationDrivenBeanDefinitionParser.java

示例5: transactionAdvisor

点赞 2

import org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor; //导入依赖的package包/类
@Bean(name = TransactionManagementConfigUtils.TRANSACTION_ADVISOR_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public BeanFactoryTransactionAttributeSourceAdvisor transactionAdvisor() {
	BeanFactoryTransactionAttributeSourceAdvisor advisor = new BeanFactoryTransactionAttributeSourceAdvisor();
	advisor.setTransactionAttributeSource(transactionAttributeSource());
	advisor.setAdvice(transactionInterceptor());
	advisor.setOrder(this.enableTx.<Integer>getNumber("order"));
	return advisor;
}
 

开发者ID:langtianya,
项目名称:spring4-understanding,
代码行数:10,
代码来源:ProxyTransactionManagementConfiguration.java

示例6: transactionAdvisor

点赞 2

import org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor; //导入依赖的package包/类
private BeanFactoryTransactionAttributeSourceAdvisor transactionAdvisor(
    AnnotationTransactionAttributeSource source, TransactionInterceptor interceptor) {
    BeanFactoryTransactionAttributeSourceAdvisor advisor = new BeanFactoryTransactionAttributeSourceAdvisor();
    advisor.setTransactionAttributeSource(source);
    advisor.setAdvice(interceptor);
    return advisor;
}
 

开发者ID:petrbouda,
项目名称:joyrest,
代码行数:8,
代码来源:OAuth2Initializer.java

示例7: setBeanFactory

点赞 2

import org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor; //导入依赖的package包/类
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
	this.beanFactory = (ConfigurableListableBeanFactory) beanFactory;
	try{
		advisor = (BeanFactoryTransactionAttributeSourceAdvisor) this.beanFactory.getBean(TransactionManagementConfigUtils.TRANSACTION_ADVISOR_BEAN_NAME);
		BeanDefinition bd = this.beanFactory.getBeanDefinition(TransactionManagementConfigUtils.TRANSACTION_ADVISOR_BEAN_NAME);
		String adviceBeanName = (String) bd.getPropertyValues().getPropertyValue("adviceBeanName").getValue();
		this.transactionInterceptor = (TransactionInterceptor) beanFactory.getBean(adviceBeanName);
		
	}catch(Exception ex){
		//忽略这个异常,如果没有使用annotationDriver就将会出现的异常
	}
}
 

开发者ID:gsgsdtc,
项目名称:ldtm,
代码行数:14,
代码来源:AnnotationLdtmAttributeSource.java

示例8: configureAutoProxyCreator

点赞 2

import org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor; //导入依赖的package包/类
public static void configureAutoProxyCreator(Element element, ParserContext parserContext) {
	AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(parserContext, element);

	String txAdvisorBeanName = Constants.TRANSACTION_ADVISOR_BEAN_NAME;
	if (!parserContext.getRegistry().containsBeanDefinition(txAdvisorBeanName)) {
		LdtmSpringUtils.init(parserContext, element);
		
		Object eleSource = parserContext.extractSource(element);
		
		// Create the TransactionAttributeSource definition.
		RootBeanDefinition sourceDef = new RootBeanDefinition(AnnotationLdtmAttributeSource.class);
		sourceDef.setSource(eleSource);
		sourceDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
		String sourceName = parserContext.getReaderContext().registerWithGeneratedName(sourceDef);

		// Create the TransactionInterceptor definition.
		RootBeanDefinition interceptorDef = new RootBeanDefinition(TransactionInterceptor.class);
		interceptorDef.setSource(eleSource);
		interceptorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
		registerTransactionManager(element, interceptorDef);
		interceptorDef.getPropertyValues().add("transactionAttributeSource", new RuntimeBeanReference(sourceName));
		interceptorDef.getPropertyValues().add("ldtmTransactionHelper", new RuntimeBeanReference(Constants.TRANSACTION_HELPER_BEAN_NAME));
		String interceptorName = parserContext.getReaderContext().registerWithGeneratedName(interceptorDef);

		// Create the TransactionAttributeSourceAdvisor definition.
		RootBeanDefinition advisorDef = new RootBeanDefinition(BeanFactoryTransactionAttributeSourceAdvisor.class);
		advisorDef.setSource(eleSource);
		advisorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
		advisorDef.getPropertyValues().add("transactionAttributeSource", new RuntimeBeanReference(sourceName));
		advisorDef.getPropertyValues().add("adviceBeanName", interceptorName);
		advisorDef.getPropertyValues().add("order", Ordered.HIGHEST_PRECEDENCE);
		parserContext.getRegistry().registerBeanDefinition(txAdvisorBeanName, advisorDef);

		CompositeComponentDefinition compositeDef = new CompositeComponentDefinition(element.getTagName(), eleSource);
		compositeDef.addNestedComponent(new BeanComponentDefinition(sourceDef, sourceName));
		compositeDef.addNestedComponent(new BeanComponentDefinition(interceptorDef, interceptorName));
		compositeDef.addNestedComponent(new BeanComponentDefinition(advisorDef, txAdvisorBeanName));
		parserContext.registerComponent(compositeDef);
	}
}
 

开发者ID:gsgsdtc,
项目名称:ldtm,
代码行数:41,
代码来源:AnnotationDrivenBeanDefinitionParser.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)