sping
模拟实现:Bean对象获取
点击查看代码
public class MyBean{
id
clazz
}
public interface BeanFactory{
getBean(id)
}
ClassPathXmlApplication implement BeanFactory{
list<MyBean> beans;
map<String ,Object> maps;
public ClassPathXmlApplication(filePathName){
parseXml()
instanceBeans()
}
@Override
public Object getBean(id){
return maps.get(id)
}
}