48 lines
1.3 KiB
Java
48 lines
1.3 KiB
Java
package com.ycjy;
|
|
|
|
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;
|
|
|
|
public class LifecycleDemo implements BeanFactoryAware, InitializingBean, DisposableBean {
|
|
|
|
@Override
|
|
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
|
System.out.println("111" + beanFactory);
|
|
}
|
|
|
|
@Override
|
|
public void destroy() throws Exception {
|
|
System.out.println("--destroy捣毁, 销毁");
|
|
}
|
|
|
|
public void xiaohui() {
|
|
System.out.println("--xiaohui销毁");
|
|
}
|
|
|
|
private String p1;
|
|
private String p2;
|
|
|
|
public void setP1(String p1) {
|
|
System.out.println("装配属性p1");
|
|
this.p1 = p1;
|
|
}
|
|
|
|
public void setP2(String p2) {
|
|
System.out.println("装配属性p2");
|
|
this.p2 = p2;
|
|
}
|
|
|
|
@Override
|
|
public void afterPropertiesSet() throws Exception {
|
|
System.out.println("--afterPropertiesSet属性设置之后");
|
|
}
|
|
|
|
public void init() {
|
|
System.out.println("初始化init");
|
|
System.out.println("--p1 " + p1);
|
|
System.out.println("--p2 " + p2);
|
|
}
|
|
} |