Просмотр исходного кода

Add compatibility with re-maven era convention of log4php filepaths.

tags/before_postback_reorg
ymlam 6 лет назад
Родитель
Сommit
396dca45be
1 измененных файлов: 26 добавлений и 2 удалений
  1. +26
    -2
      src/main/java/altk/comm/engine/CommEngine.java

+ 26
- 2
src/main/java/altk/comm/engine/CommEngine.java Просмотреть файл

@@ -100,6 +100,28 @@ public abstract class CommEngine extends HttpServlet
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.
*/
@@ -131,8 +153,10 @@ public abstract class CommEngine extends HttpServlet
String key = (String)e.nextElement();
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);


Загрузка…
Отмена
Сохранить