Spring 핵심원리 고급편 - Pointcut

목차

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface ClassAop {
}
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface MethodAop {
String value();
}
public interface MemberService {
String hello(String param);
}
@ClassAop
@Component
public class MemberServiceImpl implements MemberService {
@Override
@MethodAop("test")
public String hello(String param) {
return null;
}

public String internal(String param){
return "ok";
}
}

AspectJExpressionPointcut 이 포인트 컷 표현식을 처리해주는 클래스

@Slf4j
public class ExecutionTest {

AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
Method helloMethod;

@BeforeEach
public void init() throws NoSuchMethodException {
helloMethod = MemberServiceImpl.class.getMethod("hello", String.class);
}

@Test
void printMethod(){
log.info("helloMethod = {}", helloMethod);
}
}
Share