Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package Configuration; import java.io.File; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.XMLConfiguration; /** * * @author estevo */ public class AlarmConfig { private static AlarmConfig instance = null; private Configuration config = null; public static AlarmConfig getInstance() { if (instance == null) { instance = new AlarmConfig(); } return instance; } public AlarmConfig() { try { File hmbCF = ConfigHelper.getConfigFile("AlarmConfig.xml"); config = new XMLConfiguration(hmbCF); } catch (Exception e) { System.out.println("Entra2"); Logger.getLogger("HMB").error("Could not find config file hmb.xml. Using default hardcoded values!!."); } } private String getConfigParam(String param) throws Exception { try { if (config != null) { return config.getString(param); } else { throw new Exception(); } } catch (Exception e) { Logger.getLogger("HMB").log(Level.WARN, "HMB Config File not found for parameter: " + param); throw e; } } public int getAlarmHighRepeat() { try { return Integer.valueOf(this.getConfigParam("alarm_high_repeat")); } catch (Exception e) { System.out.println("Entra"); return 4; } } public int getAlarmHighUnitTime() { try { return Integer.valueOf(this.getConfigParam("alarm_high_unitTime")); } catch (Exception e) { return 1; } } public String getalArmDeadlineEndPoint() { try { return this.getConfigParam("alarmDeadline_end_point"); } catch (Exception e) { return "http://localhost:8080/MongoAccessService/webresources/mongo/getAlarm"; } } public String getWorkflowInfoEndPoint() { try { return this.getConfigParam("retrieveWorkflowInfo_end_point"); } catch (Exception e) { return "http://localhost:8080/MongoAccessService/webresources/mongo/getWorkflowInfo"; } } public String getUserInfoEndPoint() { try { return this.getConfigParam("retrieveUserInfo_end_point"); } catch (Exception e) { return "http://localhost:8080/MongoAccessService/webresources/mongo/getUserInfo"; } } public Long getCachePersistanceTime() { try { return Long.valueOf(this.getConfigParam("cache_persistance_time_minutes")); } catch (Exception e) { return 10L; } } public Long getCacheSize() { try { return Long.valueOf(this.getConfigParam("cache_size")); } catch (Exception e) { return 10000L; } } public String getTwitterServiceEndPoint() { try { return this.getConfigParam("twitter_service_end_point"); } catch (Exception e) { return "http://localhost:8080/TwitterService/wbresources/twitter/updateStatus"; } } public String getMailServiceEndPoint() { try { return this.getConfigParam("mail_service_end_point"); } catch (Exception e) { return "http://localhost:8080/MailService/webresources/SendMail/send"; } } }