Spring---AspectJ與Spring
阿新 • • 發佈:2022-03-22
/** * 【代理物件建立】 * * org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#initializeBean * * -> * * org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#applyBeanPostProcessorsAfterInitialization * * -> * * org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator#postProcessAfterInitialization{ * * public Object postProcessAfterInitialization(@Nullable Object bean, String beanName) { * ... * return wrapIfNecessary(bean, beanName, cacheKey); * ... * } * * protected Object wrapIfNecessary(Object bean, String beanName, Object cacheKey) { * ... * Object proxy = createProxy(bean.getClass(), beanName, specificInterceptors, new SingletonTargetSource(bean)); * ... * } * * protected Object createProxy(Class<?> beanClass, @Nullable String beanName, @Nullable Object[] specificInterceptors, TargetSource targetSource) { * ... * ProxyFactory proxyFactory = new ProxyFactory(); * ... * return proxyFactory.getProxy(getProxyClassLoader()); * } * } * * * BeanPostProcessor :org.springframework.scheduling.annotation.AsyncAnnotationBeanPostProcessor * * * */