zoukankan      html  css  js  c++  java
  • Spring源码情操陶冶-AbstractApplicationContext#postProcessBeanFactory

    阅读源码有利于陶冶情操,承接前文Spring源码情操陶冶-AbstractApplicationContext#prepareBeanFactory
    约定:web.xml中配置的contextClassXmlWebApplicationContext

    瞧瞧官方注释

    /**
    	 * Modify the application context's internal bean factory after its standard
    	 * initialization. All bean definitions will have been loaded, but no beans
    	 * will have been instantiated yet. This allows for registering special
    	 * BeanPostProcessors etc in certain ApplicationContext implementations.
    	 * @param beanFactory the bean factory used by the application context
    	 */
    

    主要承接前文中的prepareBeanFactory()方法后,供子类在标准的基础上再添加自定义的属性性质,主要是注册BeanPostProcessors

    源码简析

    对应的父类AbstractRefreshableWebApplicationContext#postProcessBeanFactory代码清单如下

    	/**
    	 *注册request/session环境
    	 * Register request/session scopes, a {@link ServletContextAwareProcessor}, etc.
    	 */
    	@Override
    	protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
    		//注册ServletContextAwareProcessor
    		beanFactory.addBeanPostProcessor(new ServletContextAwareProcessor(this.servletContext, this.servletConfig));
    		beanFactory.ignoreDependencyInterface(ServletContextAware.class);
    		beanFactory.ignoreDependencyInterface(ServletConfigAware.class);
    		//注册web环境,包括request、session、golableSession、application
    		WebApplicationContextUtils.registerWebApplicationScopes(beanFactory, this.servletContext);
    		//注册servletContext、contextParamters、contextAttributes  、servletConfig单例bean
    		WebApplicationContextUtils.registerEnvironmentBeans(beanFactory, this.servletContext, this.servletConfig);
    	}
    

    具体的调用BeanFactoryPostProcessors可见下节

    下节预告

    Spring源码情操陶冶-AbstractApplicationContext#invokeBeanFactoryPostProcessors

  • 相关阅读:
    npm 常用命令
    vue router 配合transition 切换动画
    非指针 复制对象和数组的两种方法
    Date()对象的设置与解析
    js map()处理数组和对象数据
    鉴别JS数据类型的全套方法
    JS数组与对象的遍历方法大全
    js异步原理与 Promise
    HTTP请求封装:Ajax与RESTful API
    "unresolved reference 'appium' "问题解决
  • 原文地址:https://www.cnblogs.com/question-sky/p/6760811.html
Copyright © 2011-2022 走看看