Spring後置處理器


<bean id="newperson"class="cm.xls.czq.spring.NewPerson" init-method="init"destroy-method="destory">

init-method="init" 初始化的方法

destroy-method="destory"銷燬前的方法

 

後置處理器是可以配置在初始化前後的方法:

1.        繼承BeanPostProcessor接口

初始化前

public ObjectpostProcessAfterInitialization(Object bean, String beanName) throws BeansException;

初始化後

public Object postProcessBeforeInitialization(Object bean, String beanName)

 

         在bean.xml在新建一個bean

<bean class="cm.xls.czq.spring.MyBeanPostProcessor"></bean>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章