?? factory.java
字號:
package com.laozizhu.search;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* Spring的通用工廠類。
*
* @author 老紫竹(laozizhu.com)
*/
public class Factory {
private static BeanFactory beanFactory;
static {
init();
}
public static void init() {
try {
beanFactory = new ClassPathXmlApplicationContext(new String[] { "applicationContext.xml" });
} catch (Exception ex) {
ex.printStackTrace();
}
}
public static Object getBean(String beanName) {
if (beanName == null) {
return null;
}
try {
Object obj = beanFactory.getBean(beanName);
if (obj == null) {
System.err.println("Lookup Object[" + beanName + "] Error!");
}
return obj;
} catch (Exception ex) {
ex.printStackTrace();
return null;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -