码迷,mamicode.com
首页 > 其他好文 > 详细

PlatformTransactionManager

时间:2016-09-14 20:34:51      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:

@Bean
@Override
@ConditionalOnMissingBean
public PlatformTransactionManager annotationDrivenTransactionManager() {
return new DataSourceTransactionManager(dataSource);
}

@Bean
@ConditionalOnMissingBean
public PlatformTransactionManager transactionManager() {
return new DataSourceTransactionManager(dataSource);
}

@Bean
public TransactionInterceptor transactionInterceptor() {
Properties attributes = new Properties();
attributes.setProperty("get*", "PROPAGATION_REQUIRED");
attributes.setProperty("put*", "PROPAGATION_REQUIRED");
attributes.setProperty("post*", "PROPAGATION_REQUIRED");
attributes.setProperty("delete*", "PROPAGATION_REQUIRED");
TransactionInterceptor txAdvice = new TransactionInterceptor(annotationDrivenTransactionManager(), attributes);
return txAdvice;
}


@Bean
public AspectJExpressionPointcut aspectJExpressionPointcut(){
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
String transactionExecution = "execution(* " + getTransactionExecution() + "(..))";
if(transactionExecution==null)
transactionExecution = "execution(* com.service.impl.*.*.*(..)) || execution(* com.business.impl.*.*.*(..)) ";
pointcut.setExpression(transactionExecution);
return pointcut;
}

@Bean
public DefaultPointcutAdvisor defaultPointcutAdvisor(){
DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor();
advisor.setPointcut(aspectJExpressionPointcut());
advisor.setAdvice(transactionInterceptor());
return advisor;
}

 

PlatformTransactionManager

标签:

原文地址:http://www.cnblogs.com/softidea/p/5873317.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!