반응형
  1. @Aspect   // aspect 선언
  2. public class Audience {
  3.     @Pointcut("execution(* *.perform(..))") // pointcut 정의
  4.     public void performance(){}
  5.    
  6.     @Before("performance()")
  7.     public void takeSeats(){
  8.    
  9.     }
  10.    
  11.     @AfterReturning("performance()")
  12.     public void applaud(){
  13.        
  14.     }
  15.    
  16.     @AfterThrowing("performance()")
  17.     public void demandRefund(){
  18.        
  19.     }
  20. }
@AspectJ 기반의 빈을 애스펙트로 변환하는 방법을 알고 있는 오토프록시 빈 선언
AnnotationAwareAspectJAutoProxyCreator  -> 이름이 길다 -_-;
대신
<aop:aspectj-autoproxy /> 
이거 한방이면 끝.

대신 이걸 사용하기 위해서는
xmlns:aop="http://www.springframework.org/schema/aop"
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"
이거 추가해야함!! 


728x90
반응형

+ Recent posts