当前位置: 首页>>代码示例>>Java>>正文


Java DefaultPointcutAdvisor.setAdvice方法代码示例

本文整理汇总了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;
}
 
开发者ID:helloworldtang,项目名称:springboot-multi-datasource,代码行数:8,代码来源:TxConfig.java

示例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;
}
 
开发者ID:finefuture,项目名称:data-migration,代码行数:9,代码来源:AopConfiguration.java

示例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;
}
 
开发者ID:finefuture,项目名称:data-migration,代码行数:9,代码来源:AopConfiguration.java

示例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;
}
 
开发者ID:finefuture,项目名称:data-migration,代码行数:9,代码来源:AopConfiguration.java

示例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();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:AspectJExpressionPointcutTests.java

示例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;
}
 
开发者ID:maniaclee,项目名称:shardy,代码行数:32,代码来源:DbShardFactory.java


注:本文中的org.springframework.aop.support.DefaultPointcutAdvisor.setAdvice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。