| @@ -100,6 +100,28 @@ public abstract class CommEngine extends HttpServlet | |||||
| myException = null; | myException = null; | ||||
| } | } | ||||
| /** | |||||
| * Relocates a filepath relative to runtime directory if filepath is not absolute. | |||||
| * @param filepath | |||||
| * @return | |||||
| */ | |||||
| public String relocateToRuntimeDir(String filepath) | |||||
| { | |||||
| if (filepath.startsWith("/")) return filepath; // no change to absolute path | |||||
| String relocated = filepath; | |||||
| // The next 2 lines take care of pre-git era meaning convention of filepath in properties. | |||||
| // Then, the runtime is relative to the current working directory of tomcat. | |||||
| // Now they are relative to the runtimDirPath obtained from the tomcat tomcat context. | |||||
| // These 2 lines an be deleted when all CommEngines in production are in the git era. | |||||
| String unwanted_prefix = engineName + "/"; | |||||
| if (filepath.startsWith(unwanted_prefix)) relocated = filepath.substring(unwanted_prefix.length()); | |||||
| relocated = runtimeDirPath + "/" + relocated; | |||||
| return relocated; | |||||
| } | |||||
| /** | /** | ||||
| * Invoked by servlet container during initialization of servlet. | * Invoked by servlet container during initialization of servlet. | ||||
| */ | */ | ||||
| @@ -131,8 +153,10 @@ public abstract class CommEngine extends HttpServlet | |||||
| String key = (String)e.nextElement(); | String key = (String)e.nextElement(); | ||||
| if (key.toLowerCase().endsWith(".file")) | if (key.toLowerCase().endsWith(".file")) | ||||
| { | { | ||||
| prop.setProperty(key, runtimeDirPath + "/" + prop.getProperty(key)); | |||||
| System.out.println(key + "=" + prop.getProperty(key)); | |||||
| String filepath = prop.getProperty(key); | |||||
| String relocate = relocateToRuntimeDir(filepath); | |||||
| prop.setProperty(key, relocate); | |||||
| System.out.println(key + "=" + relocate); | |||||
| } | } | ||||
| } | } | ||||
| PropertyConfigurator.configure(prop); | PropertyConfigurator.configure(prop); | ||||