本文整理汇总了Java中org.springframework.aop.support.DefaultPointcutAdvisor.setAdvice方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultPointcutAdvisor.setAdvice方法的具体用法?Java DefaultPointcutAdvisor.setAdvice怎么用?Java DefaultPointcutAdvisor.setAdvice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.aop.support.DefaultPointcutAdvisor
的用法示例。
在下文中一共展示了DefaultPointcutAdvisor.setAdvice方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: defaultPointcutAdvisor
import org.springframework.aop.support.DefaultPointcutAdvisor; //导入方法依赖的package包/类
@Bean
public DefaultPointcutAdvisor defaultPointcutAdvisor(PlatformTransactionManager transactionManager) {
DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor();
advisor.setPointcut(aspectJExpressionPointcut());
advisor.setAdvice(transactionInterceptor(transactionManager));
return advisor;
}
示例2: druidAdvisor
import org.springframework.aop.support.DefaultPointcutAdvisor; //导入方法依赖的package包/类
@Bean
@Qualifier("druid-advisor")
public DefaultPointcutAdvisor druidAdvisor(){
DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor();
advisor.setPointcut(pointcut());
advisor.setAdvice(druidInterceptor());
return advisor;
}
示例3: logAdvisor
import org.springframework.aop.support.DefaultPointcutAdvisor; //导入方法依赖的package包/类
@Bean
@Qualifier("log-advisor")
public DefaultPointcutAdvisor logAdvisor(){
DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor();
advisor.setPointcut(pointcut());
advisor.setAdvice(logInterceptor());
return advisor;
}
示例4: exceptionAdvisor
import org.springframework.aop.support.DefaultPointcutAdvisor; //导入方法依赖的package包/类
@Bean
@Qualifier("exception-advisor")
public DefaultPointcutAdvisor exceptionAdvisor(){
DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor();
advisor.setPointcut(pointcut());
advisor.setAdvice(exceptionInterceptor());
return advisor;
}
示例5: getAdvisedProxy
import org.springframework.aop.support.DefaultPointcutAdvisor; //导入方法依赖的package包/类
private TestBean getAdvisedProxy(String pointcutExpression, CallCountingInterceptor interceptor) {
TestBean target = new TestBean();
Pointcut pointcut = getPointcut(pointcutExpression);
DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor();
advisor.setAdvice(interceptor);
advisor.setPointcut(pointcut);
ProxyFactory pf = new ProxyFactory();
pf.setTarget(target);
pf.addAdvisor(advisor);
return (TestBean) pf.getProxy();
}
示例6: createDbShardInterceptor
import org.springframework.aop.support.DefaultPointcutAdvisor; //导入方法依赖的package包/类
public static DefaultPointcutAdvisor createDbShardInterceptor(String springAop) {
DefaultPointcutAdvisor re = new DefaultPointcutAdvisor();
AspectJExpressionPointcut aspectJExpressionPointcut = new AspectJExpressionPointcut();
aspectJExpressionPointcut.setExpression(springAop);
re.setPointcut(aspectJExpressionPointcut);
re.setAdvice(new MethodInterceptor() {
public Object invoke(MethodInvocation methodInvocation) throws Throwable {
Object clz = methodInvocation.getThis();
DbRouter annotation = clz.getClass().getAnnotation(DbRouter.class);
if (annotation != null) {
DynamicDataSource.setDb(annotation.value());
Transfer.setForceUseTable(annotation.useTable());
} else {
DbRouter dbRouter = methodInvocation.getMethod().getAnnotation(DbRouter.class);
if (dbRouter != null) {
DynamicDataSource.setDb(dbRouter.value());
Transfer.setForceUseTable(dbRouter.useTable());
}
}
System.out.println("DB----> " + DynamicDataSource.getDb());
try {
return methodInvocation.proceed();
} finally {
DynamicDataSource.clearDb();
Transfer.clear();
}
}
});
return re;
}