Exemple #1
0
public class Config {
  private static Logger logger = Logger.getLogger(Config.class);
  private static Configuration config = null;

  public Config() {
    loadConfig();
  }

  private static void loadConfig() {
    try {
      Configuration config = new PropertiesConfiguration("config.properties");
      setConfig(config);
    } catch (Exception e) {
      logger.fatal("unable to load config");
    }
  }

  public static Configuration getConfig() {
    if (Config.config == null) {
      Config.loadConfig();
    }

    return config;
  }

  public static void setConfig(Configuration config) {
    Config.config = config;
  }
}
Exemple #2
0
 private static void loadConfig() {
   try {
     Configuration config = new PropertiesConfiguration("config.properties");
     setConfig(config);
   } catch (Exception e) {
     logger.fatal("unable to load config");
   }
 }