public class GetObectByName{
Object object=null;
static ApplicationContext applicationContext=null;
private static GetObectByName uniqueInstance = new GetObectByName();
private GetObectByName(){}
public static GetObectByName getInstance() {
if(uniqueInstance==null){
uniqueInstance = new GetObectByName();
}
return uniqueInstance;
}
public Object getObjectByName(String name){
object =applicationContext.getBean(name);
return object;
}
public void getObjectByName(ServletConfig config){
//服务启动过程中加载beanfactory
applicationContext =
WebApplicationContextUtils.getWebApplicationContext(config.getServletContext());
}
}
Object object=null;
static ApplicationContext applicationContext=null;
private static GetObectByName uniqueInstance = new GetObectByName();
private GetObectByName(){}
public static GetObectByName getInstance() {
if(uniqueInstance==null){
uniqueInstance = new GetObectByName();
}
return uniqueInstance;
}
public Object getObjectByName(String name){
object =applicationContext.getBean(name);
return object;
}
public void getObjectByName(ServletConfig config){
//服务启动过程中加载beanfactory
applicationContext =
WebApplicationContextUtils.getWebApplicationContext(config.getServletContext());
}
}
1512

被折叠的 条评论
为什么被折叠?



