반응형
  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
반응형
반응형
  1. <bean id="audienceAdvisor" class="org.springframework.aop.aspectj.AspectJExpressionPointcutAdvisor">
  2.     <prorperty name="advice" ref="audienceAdvice"></prorperty>
  3.     <prorperty name="expression" value="execution(* *.perform(..))"></prorperty>
  4. </bean>

excution(* *.perform(..))


excution  : method가 실행될때
*            : 모든 반환 값 타입에 대해
*.           : 모든 클래스의
perform   : perform() method
(..)         : 인자의 개수에 상관없이 


728x90
반응형

+ Recent posts