SpringBeanFactory
SpringBeanFactory
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.support.GenericApplicationContext;
public class SpringBeanFactory {
private static GenericApplicationContext context;
static {
if (context == null) {
context = new GenericApplicationContext();
new XmlBeanDefinitionReader(context)
.loadBeanDefinitions(new String[] { "applicationContext*.xml" });
context.refresh();
}
}
private SpringBeanFactory() {
}
public static final Object getBean(String beanName) {
return context.getBean(beanName);
}
}
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.support.GenericApplicationContext;
public class SpringBeanFactory {
private static GenericApplicationContext context;
static {
if (context == null) {
context = new GenericApplicationContext();
new XmlBeanDefinitionReader(context)
.loadBeanDefinitions(new String[] { "applicationContext*.xml" });
context.refresh();
}
}
private SpringBeanFactory() {
}
public static final Object getBean(String beanName) {
return context.getBean(beanName);
}
}