public static final String confDir = "conf" + File.separator;\r
\r
/**\r
- * Ways to fix path problem: 1) find a path to WEB-INF directory based on\r
- * the path to a known class. Then prepend this absolute path to the rest of\r
- * paths pros: no input from user cons: relocation of the source may cause\r
- * problems 2) Require users to add configuration directories to the class\r
- * path and then load entries from it. pros: cons: Many paths needs to be\r
- * added. Put significant burden on the user. Hard to tell web appl server\r
- * to add these entries to its class path. 3) Ask for project source\r
- * directory explicitly in the configuration. pros cons: similar to 1, but\r
- * this initial configuration file must reside in well known location! Why\r
- * ask users what can be found automatically? 4) Have everything in the\r
- * location already in class path for tomcat. cons: only classes and\r
- * lib/*.jar are added, eclipse will remove non classses from classes dir.\r
+ * Ways to fix path problem: \r
+ * 1) find a path to WEB-INF directory based on the path to a known class. \r
+ * Then prepend this absolute path to the rest of paths \r
+ * pros: no input from user \r
+ * cons: relocation of the source may cause problems \r
+ * \r
+ * 2) Require users to add configuration directories to the class\r
+ * path and then load entries from it. \r
+ * pros: \r
+ * cons: Many paths needs to be added. Put significant burden on the user. \r
+ * Hard to tell web appl server to add these entries to its class path. \r
+ * \r
+ * 3) Ask for project source directory explicitly in the configuration. \r
+ * pros:\r
+ * cons: similar to 1, but this initial configuration file must reside in \r
+ * well known location! Why ask users what can be found automatically?\r
+ * \r
+ * 4) Have everything in the location already in class path for tomcat. \r
+ * pros:\r
+ * cons: only classes and lib/*.jar are added, Eclipse will remove non \r
+ * classses from classes dir.\r
* \r
* Try 1 - succeed.\r
* \r
public static PropertyHelper getPropertyHelper() {\r
if (ph == null) {\r
try {\r
- File locEngineProp = getResourceFromClasspath(confDir\r
- + "Engine.local.properties");\r
- File clustEngineProp = getResourceFromClasspath(confDir\r
- + "Engine.cluster.properties");\r
- File execProp = getResourceFromClasspath(confDir\r
- + "Executable.properties");\r
- File gaProp = getResourceFromClasspath(confDir\r
- + "GA.properties");\r
- ph = new PropertyHelper(locEngineProp, clustEngineProp,\r
- execProp, gaProp);\r
+ File locEngineProp = getResourceFromClasspath(confDir + "Engine.local.properties");\r
+ File clustEngineProp = getResourceFromClasspath(confDir + "Engine.cluster.properties");\r
+ File execProp = getResourceFromClasspath(confDir + "Executable.properties");\r
+ File gaProp = getResourceFromClasspath(confDir + "GA.properties");\r
+ ph = new PropertyHelper(locEngineProp, clustEngineProp, execProp, gaProp);\r
} catch (IOException e) {\r
- log.warn(\r
- "Cannot read property files! Reason: "\r
- + e.getLocalizedMessage(), e.getCause());\r
+ log.warn("Cannot read property files! Reason: " + e.getLocalizedMessage(), e.getCause());\r
}\r
}\r
return ph;\r
String locPath = getLocalPath();\r
File prop = new File(locPath + resourceName);\r
if (!prop.exists()) {\r
- log.warn("Could not find a resource " + resourceName\r
- + " in the classpath!");\r
+ log.warn("Could not find a resource " + resourceName + " in the classpath!");\r
}\r
return prop;\r
}\r
\r
/**\r
* Method return the absolute path to the project root directory. It assumes\r
- * the following structure of the project project root conf settings\r
- * binaries WEB-INF classes compbio engine conf If the structure changes it\r
- * must be reflected in this method\r
+ * the following structure of the project:\r
+ * project-root: \r
+ * conf/settings\r
+ * binaries \r
+ * WEB-INF/classes/compbio/engine/conf/PropertyHelperManager.class\r
+ * If the structure changes it must be reflected in this method\r
* \r
* @return the local path\r
* @throws RuntimeException\r
f = f.getParentFile();\r
}\r
} catch (URISyntaxException e) {\r
- String message = "Could not find resources path! Problems locating PropertyHelperManager class! "\r
- + e.getLocalizedMessage();\r
+ String message = "Could not find resources path! Problems locating PropertyHelperManager class! " + e.getLocalizedMessage();\r
log.error(message, e.getCause());\r
throw new RuntimeException(message, e.getCause());\r
} catch (IllegalArgumentException e) {\r
f = f.getParentFile();\r
}\r
} catch (URISyntaxException e1) {\r
- log.error(\r
- "Could not find resources path! "\r
- + e1.getLocalizedMessage(), e1.getCause());\r
- throw new RuntimeException("Could not find resources path! ",\r
- e1.getCause());\r
+ log.error("Could not find resources path! " + e1.getLocalizedMessage(), e1.getCause());\r
+ throw new RuntimeException("Could not find resources path! ", e1.getCause());\r
}\r
}\r
log.debug("Project directory is: " + f.getAbsolutePath());\r
return f.getAbsolutePath() + File.separator;\r
}\r
-}\r
+\r
+ public static int getIntProperty(String propValue) {\r
+ if (!Util.isEmpty(propValue)) {\r
+ return Integer.parseInt(propValue.trim());\r
+ }\r
+ return -1;\r
+ }\r
+\r
+ public static boolean getBooleanProperty(String propValue) {\r
+ if (!Util.isEmpty(propValue)) {\r
+ propValue = propValue.trim();\r
+ return Boolean.parseBoolean(propValue);\r
+ }\r
+ return false;\r
+ }}\r