Spring AOP - execution

salgu·2022년 4월 12일
0

Spring

목록 보기
6/21

execution

  • execution(접근제어자? 반환타입 선언타입?메서드이름(파라미터) 예외?)
  • 메소드 실행 joinpoint를 매칭합니다.
  • ?는 생략할 수 있습니다.
  • "*" 패턴을 지정할 수 있습니다.

가정 정확한 pointcut

public java.lang.String hello.aop.member.MemberServiceImpl.hello(java.lang.String)

위의 해당하는 메소드 정확한 execution 표현식으로는 아래처럼 표현할 수 있습니다.

pointcut.setExpression("execution(public String hello.aop.member.MemberServiceImpl.hello(String))");

assertThat(pointcut.matches(helloMethod, MemberServiceImpl.class)).isTrue();

match 조건

  • 접근제어자?: public
  • 반환타입: String
  • 선언타입?: hello.aop.member.MemberServiceImpl
  • 메서드이름: hello
  • 파라미터: (String)
  • 예외?: 생략

가장 많이 생략한 pointcut

pointcut.setExpression("execution(* *(..))");

assertThat(pointcut.matches(helloMethod, MemberServiceImpl.class)).isTrue();

match 조건

  • 접근제어자?: 생략
  • 반환타입: *
  • 선언타입?: 생략
  • 메서드이름: *
  • 파라미터: (..)
  • 예외?: 없음

패키지에서 . , .. 의 차이를 이해해야 한다.

  • . : 정확하게 해당 위치의 패키지
  • .. : 해당 위치의 패키지와 그 하위 패키지도 포함
profile
https://github.com/leeeesanggyu, leeeesanggyu@gmail.com

0개의 댓글