package com.yunchow.util;
/**
* read the jdbc connection information
* @author yunchow
* @version 1.2 09/8/17
*/
final class ConfigBean extends java.util.Properties {
private static final long serialVersionUID = 1L;
private static ConfigBean instance;
private static final byte[] lock = new byte[0];
private static String fileName;
private ConfigBean() {
try {
load(ConfigBean.class.getClassLoader().getResourceAsStream(fileName));
} catch(Exception ex) {
throw new ExceptionInInitializerError(ex);
}
}
/** 设置配置文件的名字 */
public static void setConfigFile(String file) {
fileName = file;
}
/** 根据传过来的文件名, 得到一个配置文件的实例 */
public static ConfigBean getInstance(String file) {
fileName = file;
return getInstance();
}
/** 得到一个配置文件的实例 */
public static ConfigBean getInstance() {
if(instance == null) {
synchronized(lock) {
if(instance == null) {
instance = new ConfigBean();
}
}
}
// System.out.println("Jdbc config bean ->" + instance);
return instance;
}
}