어드바이스 동작시점
애스팩트(결합,위빙)설정할때 함께 설정함
before : 비즈니스 메서드 수행전 =>일반 로그,반환이 있는거랑 엮는다 보통 select
after : finally, 비즈니스 메서드 수행후 예외가 발생하던 말던 수행
after-returning : 비즈니스 메서드 return 반환 후 => 예외가 발생하지 않고 리턴 되었을때
after-throwing : catch,비즈니스 메서드 예외 발생시
around : 비즈니스 메서드 수행 전후로 접근가능
핵심로직의 성능 평가
before
<aop:pointcut id="bPointcut" expression="execution(* com.spring.biz..*Impl.select*(..))" />
<aop:aspect ref="logAdvice">
<aop:before pointcut-ref="bPointcut" method="printLog" />
</aop:aspect>

after-returning
<aop:pointcut id="bPointcut" expression="execution(* com.spring.biz..*Impl.select*(..))" />
<aop:aspect ref="ara">
<aop:after-returning pointcut-ref="bPointcut" method="afterReturningPrintLog" />
</aop:aspect>

after-throwing
<aop:pointcut id="aPointcut" expression="execution(* com.spring.biz..*Impl.*(..))" />
<aop:aspect ref="ata">
<aop:after-throwing pointcut-ref="aPointcut" method="printException" />
</aop:aspect>

around
<aop:pointcut id="aPointcut" expression="execution(* com.spring.biz..*Impl.*(..))" />
<aop:aspect ref="aa">
<aop:around pointcut-ref="aPointcut" method="aroundPringtLog" />
</aop:aspect>

aop를 잘 사용하면 로그를 직접 작성하지 않고 사용할수 있다
'Spring' 카테고리의 다른 글
| DAO var.1 -> DAO var.2 설정 (0) | 2024.03.14 |
|---|---|
| @어노테이션을 이용한 AOP (1) | 2024.03.12 |
| AOP 정리 (0) | 2024.03.10 |
| Spring 어노테이션을 이용한 연습 (0) | 2024.03.09 |
| 어노테이션으로 의존성 주입 (0) | 2024.03.07 |