5.4.2 Aspect 선언하기 by ys

@AspectJ 지원이 활성화되면 @AspectJ 애스펙트 ( @Aspect주석 이있는 클래스)로 애플리케이션 컨텍스트에 정의 된 모든 Bean 이 Spring에 의해 자동으로 감지되고 Spring AOP를 구성하는 데 사용됩니다. 다음 두 예제는 매우 유용하지 않은 측면에 필요한 최소 정의를 보여줍니다.

첫 번째 예제는 @Aspect어노테이션 이있는 Bean 클래스를 가리키는 애플리케이션 컨텍스트의 일반 Bean 정의를 보여줍니다 .

<bean id="myAspect" class="org.xyz.NotVeryUsefulAspect">
    <!-- configure properties of the aspect here -->
</bean>

두 예제 중 두 번째 예제 NotVeryUsefulAspect는 주석으로 org.aspectj.lang.annotation.Aspect주석 이 달린 클래스 정의를 보여줍니다 .

package org.xyz;
import org.aspectj.lang.annotation.Aspect;

@Aspect
public class NotVeryUsefulAspect {

}

Aspects (어노테이션 된 클래스 @Aspect)는 다른 클래스와 같은 메소드 및 필드를 가질 수 있습니다. 또한 pointcut, advice 및 introduction (inter-type) 선언을 포함 할 수 있습니다.

Last updated