浩晨众云网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
创新互联www.cdcxhl.cn八线动态BGP香港云服务器提供商,新人活动买多久送多久,划算不套路!
1.以ApplocationContext上下文单例模式装配bean为例,深入探讨bean的生命周期:
(1).生命周期图:
(2).具体事例:
person类实现BeanNameAware,BeanFactoryAware接口
public class Person implements BeanNameAware ,BeanFactoryAware{ private String name; public Person(){ System.out.println("调用构造器为属性值初始化"); } public String getName() { return name; } public void setName(String name) { this.name = name; } @Override public void setBeanName(String arg0) { // TODO Auto-generated method stub System.out.println("获取beanName id值"+" "+arg0); } @Override public void setBeanFactory(BeanFactory arg0) throws BeansException { // TODO Auto-generated method stub System.out.println("获取BeanFactory" +" "+arg0); } }