码上敲享录 > Spring框架常见问题详解分享 > spring的@Pointcut注解匹配多个表达式

spring的@Pointcut注解匹配多个表达式

上一章章节目录下一章 2018-11-17已有9758人阅读 评论(0)

spring的@Pointcut注解匹配多个表达式


解决方法:

假如我想匹配spring的JdbcTemplate所有增删改查操作,也就是说JdbcTemplate的所有操作都会执行doBeforeForJdbc这个方法。

import org.aspectj.lang.JoinPoint;

import org.aspectj.lang.ProceedingJoinPoint;

import org.aspectj.lang.annotation.AfterReturning;

import org.aspectj.lang.annotation.Around;

import org.aspectj.lang.annotation.Aspect;

import org.aspectj.lang.annotation.Before;

import org.aspectj.lang.annotation.Pointcut;

import org.springframework.aop.ProxyMethodInvocation;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Component;


@Aspect

@Component

public class AspectComponent {    

 @Pointcut("execution(* org.springframework.jdbc.core..JdbcTemplate.query*(..)) || execution(* org.springframework.jdbc.core..JdbcTemplate.update*

(..)) || execution(* org.springframework.jdbc.core..JdbcTemplate.batchUpdate*(..)) || execution(*


org.springframework.jdbc.core..JdbcTemplate.execute*(..))")

   public void jdbcTplProc() {

   }


   @BeforejdbcTplProc()")

   public void doBeforeForJdbc(JoinPoint joinPoint) {

       log.debug("拦截JdbcTemplate的方法");

   }


}


本文链接:http://www.yayihouse.com/yayishuwu/chapter/1686

向大家推荐《Activiti工作流实战教程》:https://xiaozhuanlan.com/activiti
0

有建议,请留言!

  • *您的姓名:

  • *所在城市:

  • *您的联系电话:

    *您的QQ:

  • 咨询问题:

  • 提 交