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>

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