六:IOC中其他接口的使用
1. Beanpostprocessor:(後處理bean)在對象實例化後,進行方法調用前進行特殊處理
2. BeanFactoryPostProcessor:在實例化對象前,對配置文件進行特殊處理
3. PropertyeditorSupport :屬性編輯器類
可以根據定義的規則,將字符串類型自動編輯成一個對象類型來進行屬性注入。
4. PropertyPlaceholderConfigurer:
方便分散配置的一個類,可以讀取配置文件,以${key}獲得對應的value值
5. CustomEditorConfigurer:配置用戶自定義的屬性編輯器
例:
<bean
class="org.springframework.beans.factory.config
.PropertyPlaceholderConfigurer">
<property name="location">
<value>ioc//info.properties</value>
</property>
</bean>
<bean id="customEditorConfigurer"
class="org.springframework.beans.factory.config
.CustomEditorConfigurer">
<property name="customEditors">
<map>
<entry key="ioc9.Address">
<bean id="myEditor"class="ioc9.AddressEditor">
</bean>
</entry>
</map>
</property>
</bean>
七:Spring的事件處理機制:(監聽機制)
1. 自定義一個事件,需要實現接口ApplicationEvent
2. 定義一個監聽器,需要實現接口ApplicationListener
3. bean調用容器的方法,發佈事件,需要實接口ApplicationContextAware,來獲得對容器的引用