그래서 LogTarget Annotation을 만들고, Pointcut을 "@target(LogTarget)"으로 지정했더니
Application Context에 있는 모든 Bean을 대상으로 Proxy를 생성하려고 하는 현상이 발생했습니다.
@Documented
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface LogTarget {
}
이상해서 간단한 Test를 생성해서 돌려보니 역시나 이상한 값이 나옵니다.
String expression = "@target(LogTarget)";
Class<?> targetClass = ApplicationContext.class;
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
pointcut.setExpression(expression);
System.out.println(AopUtils.canApply(pointcut, targetClass));
여러분이 다 아시는 ApplicationContext interface에는 LogTarget 이라는 Annotation이 붙어있
지 않은데도 AopUtils.canApply method는 true 를 return하고 있습니다.
Debugging 하면서 소스코드를 따라가다보니 AspectJ 에 문제가 있는 듯 하기도 한데, 혹시 이 문제 관련해서 뭔가 아
시는 분 계신가요?
사용하고 있는 버전은
Springframework : 3.0.5.RELEASE
AspectJ : 1.6.10
입니다.
앞전에 토스 읽기 모임에서 표시인터페이스 얘기를 했었는데,
역시 AOP 와 Annotation 함께 사용하면 막강하겠네요.