1. 程式人生 > >【知識庫】--spring ApplicationContext 功能的擴充套件起始點-prepareBeanFactory(241)

【知識庫】--spring ApplicationContext 功能的擴充套件起始點-prepareBeanFactory(241)

ApplicationContext擴充套件開始ing

 /**
     * Configure the factory's standard context characteristics,
     * such as the context's ClassLoader and post-processors.
     *
     * @param beanFactory the BeanFactory to configure
     */
    protected void prepareBeanFactory(ConfigurableListableBeanFactory beanFactory) {
         // Tell the internal bean factory to use the context's class loader etc.
         beanFactory.setBeanClassLoader(getClassLoader());
         //主要是在解析依賴注入bean的時候,以及在完成bean的初始化和屬性獲取後進行屬性填充的時候
         beanFactory.setBeanExpressionResolver(new StandardBeanExpressionResolver());
         //表示式語言處理器預設可以使用#{bean.xx}
         beanFactory.addPropertyEditorRegistrar(new ResourceEditorRegistrar(this, getEnvironment()));
         //bean屬性設定管理的工具 通用的屬性編輯器 如Class URL 等。自定義屬性編輯器:只需要實現 PropertyEditorRegistrar介面即可(最終會被AbstractBeanFactory持用) 或者 xml注入到CustomEditorConfigurer中的customEditors Map中。等待初始化beanWrapper時呼叫initBeanWrapper觸發。
                //Configure the bean factory with context callbacks.
		// Configure the bean factory with context callbacks.
		beanFactory.addBeanPostProcessor(new ApplicationContextAwareProcessor(this));
		beanFactory.ignoreDependencyInterface(ResourceLoaderAware.class);
		beanFactory.ignoreDependencyInterface(ApplicationEventPublisherAware.class);
		beanFactory.ignoreDependencyInterface(MessageSourceAware.class);
		beanFactory.ignoreDependencyInterface(ApplicationContextAware.class);
		beanFactory.ignoreDependencyInterface(EnvironmentAware.class);

		// BeanFactory interface not registered as resolvable type in a plain factory.
		// MessageSource registered (and found for autowiring) as a bean.
		beanFactory.registerResolvableDependency(BeanFactory.class, beanFactory);
		beanFactory.registerResolvableDependency(ResourceLoader.class, this);
		beanFactory.registerResolvableDependency(ApplicationEventPublisher.class, this);
		beanFactory.registerResolvableDependency(ApplicationContext.class, this);

		// Detect a LoadTimeWeaver and prepare for weaving, if found.
		if (beanFactory.containsBean(LOAD_TIME_WEAVER_BEAN_NAME)) {
			beanFactory.addBeanPostProcessor(new LoadTimeWeaverAwareProcessor(beanFactory));
			// Set a temporary ClassLoader for type matching.
			beanFactory.setTempClassLoader(new ContextTypeMatchClassLoader(beanFactory.getBeanClassLoader()));
		}

		// Register default environment beans.
		if (!beanFactory.containsLocalBean(ENVIRONMENT_BEAN_NAME)) {
			beanFactory.registerSingleton(ENVIRONMENT_BEAN_NAME, getEnvironment());
		}
		if (!beanFactory.containsLocalBean(SYSTEM_PROPERTIES_BEAN_NAME)) {
			beanFactory.registerSingleton(SYSTEM_PROPERTIES_BEAN_NAME, getEnvironment().getSystemProperties());
		}
		if (!beanFactory.containsLocalBean(SYSTEM_ENVIRONMENT_BEAN_NAME)) {
			beanFactory.registerSingleton(SYSTEM_ENVIRONMENT_BEAN_NAME, getEnvironment().getSystemEnvironment());
		}
}

相關推薦

知識庫--spring ApplicationContext 功能擴充套件起始-prepareBeanFactory241

ApplicationContext擴充套件開始ing /** * Configure the factory's standard context characteristics, * such as the context's ClassLoa

知識庫--spring aop 動態代理--inner private protected 方法失效212

私有方法或者保護的方法無效! AspectJ pointcut for annotated PRIVATE methods Due to the proxy-based nature of Spring's AOP framework, protected methods

如何為Apache JMeter開發插件

選擇 ref 測試結果 沒有 通過 pri for entry state 本文轉載於http://blog.csdn.net/column/details/12925.html,作者:xreztento 作者寫的很精華,我打算在此系列操作一遍後,加多點截圖,便於更多人更快

bash: ssh: command not found解決方法linux

inux 配置 pan html clas client oop post bash 原文轉自:http://www.cnblogs.com/ahauzyy/archive/2013/04/25/3043699.html 今天在搭建hadoop的開發環境中,用的是ce

轉載Apache Spark Jobs 性能調優

放棄 instance bar 並行處理 defaults 執行 .exe nag 原則 調試資源分配 Spark 的用戶郵件郵件列表中經常會出現 “我有一個500個節點的集群,為什麽但是我的應用一次只有兩個 task 在執行”,鑒於 Spark 控制資源使用的參數的數

轉載Apache Spark Jobs 性能調優

功能 dso brush 數據結構 nsf 必須 char dal 開始 當你開始編寫 Apache Spark 代碼或者瀏覽公開的 API 的時候,你會遇到各種各樣術語,比如 transformation,action,RDD 等等。 了解到這些是編寫 Spark 代碼

模板前向星 SPFA求最短

代碼 poj ostream name 兩個 col spfa ron esp 之前一個改自別人的模板竟然在一道題上TLE了,而代碼也實在醜陋,網上找得到的模板也大多跑得慢(vector存圖)或代碼醜陋、殘疾(無初始化函數的模板能叫模板嗎?),索性自己重新寫了一個。 題是P

轉載TCP粘包問題分析和解決

刪除 而且 實例 報文 底層 nagle 存在 ngxin 想想 TCP通信粘包問題分析和解決(全) 在socket網絡程序中,TCP和UDP分別是面向連接和非面向連接的。因此TCP的socket編程,收發兩端(客戶端和服務器端)都要有成對的socket,因此,發送端為了將

javajava學習之路-01-Linux基礎

x文件 字母 at命令 超過 用戶登錄 創建刪除 軟連接 nbsp tail linux學習方法: 你的程序要在服務器(linux)上執行,服務器沒有桌面系統,學習linux就是學習命令。 一、Linux介紹 1、芬蘭大學生,名字叫Linux,因為個人興趣,編寫了一個類Un

整理分塊在數論中的運用初稿(各位幫幫忙填下坑,裏面列的好多都不會)

body element set max main lucas定理 們的 prev 成了 之前已經做過幾個分塊的水題,導致nmphy居然口出狂言:“高中學過,簡單”。(現在nmphy收回他的話,並且跪著寫下這篇總結) 前言: 由於數

Linux基礎每日一命之awk命令

設置變量 兩個 oob 每日 gin water 不能 -o source awk 是一個強大的文本分析工具 語法:awk [選項參數] ‘script‘ var=value file(s)或awk [選項參數] -f scriptfile var=value file(s

CodeforcesCF 2 B The least round waydp

clu 更新 .org ORC 我們 std 預處理 blank putc 題目 傳送門:QWQ 分析 求結尾0的數量QwQ。 10只能是$ 2 \times 5 $,我們預處理出每個數因子中2和5的數量。 我們接著dp出從左上到右下的經過的最少的

CodeforcesCF 5 C Longest Regular Bracket Sequencedp

ont ref urn 左右 namespace 連續 %d pan tro 題目 傳送門:QWQ 分析 洛谷題解裏有一位大佬講的很好。 就是先用棧預處理出可以匹配的左右括號在數組中設為1 其他為0 最後求一下最長連續1的數量。 代碼

轉載linux內核調度算法3--多核系統的負載均衡

調度 -- 頻繁 target tel 內核調度 intel 當前 .cn 多核CPU現在很常見,那麽問題來了,一個程序在運行時,只在一個CPU核上運行?還是交替在多個CPU核上運行呢?LINUX內核是如何在多核間調度進程的呢?又是內核又是CPU核,兩個核有點繞,下面稱CP

函式和常用模組day05:不同目錄間進行模組呼叫

本節內容 1、背景 2、函式功能解釋 3、絕對路徑和相對路徑 4、不同目錄間進行模組呼叫 一、背景   之前寫了軟體開發目錄規範這篇部落格,相信很多人都已經知道,我們在寫程式時需要遵循一定的規範,不然,就算很簡答的邏輯程式的程式碼,讀起來會很費勁,佔用了我們大量的時間,但是,我們一旦用了這樣的規範

面向物件day07:類的例項化過程剖析

本節內容 1、概述 2、類的語法 3、總結 一、概述    之前我們說關於python中的類,都一臉懵逼,都想說,類這麼牛逼到底是什麼,什麼才是類?下面我們就來講講,什麼是類?它具有哪些特性。 二、類的語法 2.1 語法

溫故知新——BABYLON.js學習之路·前輩經驗

前言:在上一篇隨筆BABYLON.js學習之路·前輩經驗(一)中回顧了組內同事們長時間在Babylon開發實踐中的總結出的學習之路和經驗,這一篇主要對開發中常見的一些功能點做一個梳理,這裡只作為溫故知新。   一、相機    

LeetCode730. Count Different Palindromic Subsequences 解題報告Python

作者: 負雪明燭 id: fuxuemingzhu 個人部落格: http://fuxuemingzhu.cn/ 目錄 題目描述 題目大意 解題方法 記憶化搜尋 動態規劃 日期

LeetCode938. Range Sum of BST 解題報告Python

作者: 負雪明燭 id: fuxuemingzhu 個人部落格: http://fuxuemingzhu.cn/ 目錄 題目描述 題目大意 解題方法 遞迴 日期 題目

LeetCode933. Number of Recent Calls 解題報告Python

作者: 負雪明燭 id: fuxuemingzhu 個人部落格: http://fuxuemingzhu.cn/ 目錄 題目描述 題目大意 解題方法 二分查詢 佇列 相似題目