锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产亚洲欧洲高清,久久久亚洲国产美女国产盗摄,狠狠躁18三区二区一区http://www.aygfsteel.com/yuyee/category/46859.htmlzh-cnMon, 06 Dec 2010 13:47:07 GMTMon, 06 Dec 2010 13:47:07 GMT60IOC鍒濆鍖栧拰浜掔浉寮曠敤瑙e喅http://www.aygfsteel.com/yuyee/archive/2010/11/10/337731.html緹旂緤緹旂緤Wed, 10 Nov 2010 08:27:00 GMThttp://www.aygfsteel.com/yuyee/archive/2010/11/10/337731.html闃呰鍏ㄦ枃

緹旂緤 2010-11-10 16:27 鍙戣〃璇勮
]]>
IOC鐩戠Beanhttp://www.aygfsteel.com/yuyee/archive/2010/11/03/337154.html緹旂緤緹旂緤Wed, 03 Nov 2010 09:04:00 GMThttp://www.aygfsteel.com/yuyee/archive/2010/11/03/337154.html

1.InitializingBean鎺ュ彛錛屽湪鍒濆鍖朆ean鏃跺鍣ㄤ細璋冪敤鍓嶈呯殑afterPropertiesSet()鏂規硶

2.DisposableBean鎺ュ彛錛屽湪鏋愭瀯Bean鏃跺鍣ㄤ細璋冪敤destroy()鏂規硶

3.BeanFactoryAware鎺ュ彛錛屽綋瀹冭BeanFactory鍒涘緩鍚庯紝瀹冧細鎷ユ湁涓涓寚鍚戝垱寤哄畠鐨凚eanFactory鐨勫紩鐢?/font>

4.BeanPostProcessor鎺ュ彛錛岃繖涓帴鍙d袱涓柟娉曪紝postProcessBeforeInitialization(Object bean, String beanName)鍜宲ostProcessAfterInitialization(Object bean, String beanName) 鍦ㄥ叾浠朆ean鏋勯犲墠鍚庢墽琛?/p>

5.BeanFactoryPostProcessor鎺ュ彛錛孲pring IoC瀹瑰櫒鍏佽BeanFactoryPostProcessor鍦ㄥ鍣ㄥ疄闄呭疄渚嬪寲浠諱綍鍏跺畠鐨刡ean涔嬪墠璇誨彇閰嶇疆鍏冩暟鎹紝騫舵湁鍙兘淇敼瀹?/p>

package com.google.springioctest;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;

public class A implements BeanPostProcessor, InitializingBean,
BeanFactoryAware, BeanFactoryPostProcessor,DisposableBean {

public A() {
System.out.println("Class A");
}
private void init(){
System.out.println("Class A init");
}

@Override
public void afterPropertiesSet() throws Exception {
// TODO Auto-generated method stub
System.out.println("Class A afterPropertiesSet()");

}

@Override
public void destroy() throws Exception {
System.out.println("Class A destroy()");

}

@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
// TODO Auto-generated method stub
System.out.println("Class A setBeanFactory()");
}

@Override
public Object postProcessAfterInitialization(Object bean, String beanName)
throws BeansException {
System.out.println("Class A postProcessAfterInitialization");
return null;
}

@Override
public Object postProcessBeforeInitialization(Object bean, String beanName)
throws BeansException {
// TODO Auto-generated method stub
System.out.println("Class A postProcessBeforeInitialization");
return null;
}


@Override
public void postProcessBeanFactory(
ConfigurableListableBeanFactory beanFactory) throws BeansException {
// TODO Auto-generated method stub
System.out.println("Class A postProcessBeanFactory");
}

}
鎵ц緇撴灉錛?/div>
Class A
Class A setBeanFactory()
Class A afterPropertiesSet()
Class A init
Class A postProcessBeanFactory
鍒涘緩涓涓狟綾伙紝鐢盇鏉ョ洃綆綾伙紝B瀹炵幇 InitializingBean,BeanFactoryAware,BeanFactoryPostProcessor
package com.google.springioctest;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;

public class B implements InitializingBean, BeanFactoryAware,
BeanFactoryPostProcessor {

public B() {
System.out.println("Class B");
}

public void init() {
System.out.println("Class B init");
}

@Override
public void afterPropertiesSet() throws Exception {
System.out.println("Class B afterPropertiesSet");

}

@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
System.out.println("Class B beanFactory");

}

@Override
public void postProcessBeanFactory(
ConfigurableListableBeanFactory beanFactory) throws BeansException {
// TODO Auto-generated method stub
System.out.println("Class B postProcessBeanFactory");
}

}
鎵ц緇撴灉錛?/div>
Class A
Class A setBeanFactory()
Class A afterPropertiesSet()
Class A init
Class B
Class B beanFactory
Class B afterPropertiesSet
Class B init
Class A postProcessBeanFactory
Class B postProcessBeanFactory

鍙互鐪嬪嚭A騫舵病鏈夌洃綆綾伙紝涔熷氨鏄病璋冪敤BeanPostProcessor榪欎釜鎺ュ彛鐨?涓柟娉?/div>
鍐嶆潵鍘繪帀B涓婄殑BeanFactoryPostProcessor鎺ュ彛
package com.google.springioctest;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;

public class B implements InitializingBean,
BeanFactoryAware{

public B() {
System.out.println("Class B");
}

public void init() {
System.out.println("Class B init");
}

@Override
public void afterPropertiesSet() throws Exception {
System.out.println("Class B afterPropertiesSet");

}

@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
System.out.println("Class B beanFactory");

}

public void postProcessBeanFactory(
ConfigurableListableBeanFactory beanFactory) throws BeansException {
// TODO Auto-generated method stub
System.out.println("Class B postProcessBeanFactory");
}


}
鎵ц杈撳嚭錛欳lass A
Class A setBeanFactory()
Class A afterPropertiesSet()
Class A init
Class A postProcessBeanFactory
2010-11-3 21:33:31 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
淇℃伅: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@8916a2: defining beans [A,B]; root of factory hierarchy
Class B
Class B beanFactory
Class A postProcessBeforeInitialization
2010-11-3 21:33:31 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
淇℃伅: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@8916a2: defining beans [A,B]; root of factory hierarchy
Class A destroy()
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'B' defined in class path resource [icoContext.xml]: Invocation of init method failed; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.google.springioctest.Test.main(Test.java:8)
Caused by: java.lang.NullPointerException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1393)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1375)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
... 15 more
鎶涘紓甯鎬簡銆傘傘傘傘?/div>
鍘熷洜鏄疉綾婚噷鐨刾ostProcessBeforeInitialization錛宲ostProcessAfterInitialization2涓柟娉曟病鏈夎繑鍥瀊ean,淇敼涓?/div>
鎵ц杈撳嚭錛?/div>
Class A
Class A setBeanFactory()
Class A afterPropertiesSet()
Class A init
Class A postProcessBeanFactory
2010-11-3 21:37:10 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
淇℃伅: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1193779: defining beans [A,B]; root of factory hierarchy
Class B
Class B beanFactory
Class A postProcessBeforeInitialization
Class B afterPropertiesSet
Class B init
Class A postProcessAfterInitialization
鍦˙綾昏鍒濆鍖栦箣鍚庯紝涔熷氨鏄皟鐢╝fterPropertiesSet涔嬪墠閭f鏃墮棿錛屽睘鎬у垵濮嬪寲瀹屾垚鍚庯紝榪涜浜嗗洖璋冿紝鎺у埗B綾?/div>

娉ㄦ剰:鍦ㄥ啓琚洃鎺х殑Bean鐨勬椂鍊欙紝涓嶈兘瀹炵幇BeanFactoryPostProcessor榪欎釜鎺ュ彛,娌$湅婧愮爜錛屽叾瀹炰篃涓嶇煡閬撴槸浠涔堝師鍥狅紝鍝堝搱錛屽彧鑳界‖璁頒簡



緹旂緤 2010-11-03 17:04 鍙戣〃璇勮
]]> 主站蜘蛛池模板: 宁河县| 绥德县| 安岳县| 瑞昌市| 唐海县| 会昌县| 阿勒泰市| 洛南县| 海门市| 高青县| 兴宁市| 醴陵市| 措勤县| 彭州市| 桂东县| 九江县| 友谊县| 裕民县| 东兴市| 瑞金市| 新巴尔虎左旗| 治县。| 连城县| 华阴市| 祁阳县| 呼玛县| 富平县| 乐陵市| 奎屯市| 阜宁县| 子洲县| 台州市| 江油市| 民勤县| 洪洞县| 阿拉善左旗| 龙门县| 那坡县| 琼结县| 从江县| 马关县|