@Test
void dynamicA() {
AInterface target = new AImpl();
TimeInvocationHandler handler = new TimeInvocationHandler(target); // 프록시를 호출하는 로직
// jdk에서 지원하는 프록시 생성기술(newProxyInstance를 하면 동적으로 생성된다.) 파라미터를 살펴보면. 1.프록시가 어디에 생성될지 지정 2.어떤 기반의 프록시를 만들지 지정 3.프록시가 사용할 로직
// 클래스로더를 지정해주는 이유는 자바는 클래스가 호출되면 클레스로더에 올라가게 되는데 그 위치를 지정해주기 위함이다.
AInterface proxy = (AInterface) Proxy.newProxyInstance(AInterface.class.getClassLoader(), new Class[]{AInterface.class}, handler);
proxy.call();
log.info("targetClass={}", target.getClass());
log.info("proxyClass={}", proxy.getClass());
}