1. AOP 의존성 등록
<!-- https://mvnrepository.com/artifact/org.aspectj/aspectjweaver -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.9.4</version>
</dependency>
2. 타겟 객체 생성 (핵심 기능 구현한 빈)
3. aspect 객체 생성 (부가 기능 구현한 빈)
가. @Aspect 어노테이션 지정
나. pointcut 지정: 어떤 핵심기능의 메서드인지 알려주는 기능
Core Technologies
In the preceding scenario, using @Autowired works well and provides the desired modularity, but determining exactly where the autowired bean definitions are declared is still somewhat ambiguous. For example, as a developer looking at ServiceConfig, how do
docs.spring.io
@Pointcut("execution(public String sayEcho())")
public void xxx( ){
// 아무 구현 안함
}
다. advice 지정된 메서드
@Before("xxx( )")
public void method2( ) {
// 부가기능 구현
}
4. target과 aspect 빈 모두 xml에 등록
5. @Aspect 어노테이션 활성화
6. TestMain 작성
결과
advice + pointcut 같이 표현
'Framework > SPRING FRAMEWORK' 카테고리의 다른 글
AOP_부가기능의 실행시점(advice) - @AfterReturning (0) | 2023.08.31 |
---|---|
AOP_부가기능의 실행시점(advice) - @After (0) | 2023.08.31 |
AOP (0) | 2023.08.31 |
SpEL - Collection Projection (열 선택) (0) | 2023.08.30 |
SpEL - Collection selection (행 선택) (0) | 2023.08.30 |