Discuss / 手写Spring / 学艺不精,为什么已经拿到了代理类还要在调用proxyClass.getConstructor().newInstance()?

学艺不精,为什么已经拿到了代理类还要在调用proxyClass.getConstructor().newInstance()?

Topic source

#1 Created at ... [Delete] [Delete and Lock User]

廖老师,我有个疑问,createProxy()方法中,我们已经从around注解中拿到了代理类的名字,并通过createBeanAsEarlySingleton方法创建出了实例。为什么还要用proxyClass.getConstructor().newInstance()再返回一个代理类呢?

#2 Created at ... [Delete] [Delete and Lock User]

而且老师在打印日志时,打印的也是 Bean 'originBean' was replaced by post processor com.itranswarp.summer.aop.AroundProxyBeanPostProcessor. 希望得到廖大的解答

#3 Created at ... [Delete] [Delete and Lock User]

我大概明白了,从around注解中拿到的是拦截器的名字;拿到原始bean和拦截器后,通过bytebuddy才能动态生成代理类。


  • 1

Reply