@Around는 org.aspectj.lang.ProcessingJoinPoint

@Befote는 org.aspectj.lang.JoinPoint

final Object thisObject = joinPoint.getTarget(); //class object

 

 

- pointcut 정의

www.egovframe.go.kr/wiki/doku.php?id=egovframework:rte:fdl:aop:aspectj

 

- args 이용

https://ehdvudee.tistory.com/22

 

- annotation 정보

https://stackoverflow.com/questions/21275819/how-to-get-a-methods-annotation-value-from-a-proceedingjoinpoint

 

- return type

https://stackoverflow.com/questions/28092800/when-using-spring-aoparound-how-can-i-get-return-type-of-the-pointcut-method

 

- parameter Name

https://stackoverflow.com/questions/25226441/java-aop-joinpoint-does-not-get-parameter-names

 

 

- parameter Value

https://stackoverflow.com/questions/45737080/spring-aop-get-method-parameter-value-based-on-parameter-name

 

- pointcut annotation으로 설정

https://stackoverflow.com/questions/46214537/how-can-spring-aop-matches-annotation-on-interface-method

 

https://www.baeldung.com/spring-aop-pointcut-tutorial


- class annotation 예제 (특정 annotation 있는 클래스의 메소드 aop)

stackoverflow.com/questions/2011089/aspectj-pointcut-for-all-methods-of-a-class-with-specific-annotation

 

@Around("execution(public * com.sample.*Mapper.*(..)) && within(@org.apache.ibatis.annotations.Mapper *)")

OR

@within(org.apache.ibatis.annotations.Mapper)

@Around("execution(public * com.sample..*Mapper.*(..)) && !@annotation(org.apache.ibatis.annotations.Mapper)")
OR
@Around("execution(public * com.sample..*Mapper.*(..)) && !@target(org.apache.ibatis.annotations.Mapper)")


 

- method annotation example

    @Pointcut("execution(@com.sample.common.annotation.ChangeDateFormat * *(..))")
    public void mapperTargetMethod(){
        //
    }
    @Around("mapperTargetMethod()")

 

    와 같은 표현은 아래와 같음

 

    @Around("execution(@com.sample.common.annotation.ChangeDateFormat * *(..))")

 

 

- parameter annotation example
    @Around("execution(* com.sample..dao..*Mapper.*(.., @com.sample.common.annotation.MultiLanguage (*), ..))")

 

- method의 annotation example

    @Arround("@annotation(org.springframework.web.bind.annotation.RequestMapping)")

- AfterThrowing

    @AfterThrowing(pointcut = "execution(public * com.sample..*Controller.*(..))", throwing = "rException")

    public void wrappingRestException(JoinPoint joinPoint, RuntimeException rException) {

        log.debug("error is {}", rException);

       throw new Exception(rException);

    }

https://www.egovframe.go.kr/wiki/doku.php?id=egovframework:rte:fdl:aop:aspectj

 

 

 

'spring-aop' 카테고리의 다른 글

aop transaction 설정  (0) 2023.11.14
AOP 트랜잭션 사용시 문제점 - self invocation  (0) 2020.08.22
@transaction + custom AOP  (0) 2019.10.28
aop 설정  (0) 2017.07.28
Posted by 張's blog
,