@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 정보
- return type
- parameter Name
https://stackoverflow.com/questions/25226441/java-aop-joinpoint-does-not-get-parameter-names
- parameter Value
- pointcut annotation으로 설정
https://www.baeldung.com/spring-aop-pointcut-tutorial
- class annotation 예제 (특정 annotation 있는 클래스의 메소드 aop)
@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 |