📄 springbeanfactory.java
字号:
package com.set.appframe.business;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.set.appframe.exception.SystemException;
public class SpringBeanFactory {
protected static AbstractApplicationContext ctx = null;
private static SpringBeanFactory instance = null;
private SpringBeanFactory() {
init();
}
private void init() {
if (null == ctx) {
String paths[] = { "classpath*:applicationContext-*.xml" };
ctx = new ClassPathXmlApplicationContext(paths);
}
}
public static SpringBeanFactory getInstance() {
if (null == instance) {
instance = new SpringBeanFactory();
}
return instance;
}
public Object getBean(String name) throws SystemException {
Object bean = null;
try {
bean = ctx.getBean(name);
} catch (Exception ex) {
throw new SystemException("error.springconfig");
}
return bean;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -