Change config file name if webapp
This commit is contained in:
@ -84,7 +84,7 @@ public class I2PControlController implements RouterApp {
|
||||
_log = _appContext.logManager().getLog(I2PControlController.class);
|
||||
File pluginDir = new File(_context.getAppDir(), "plugins/I2PControl");
|
||||
_pluginDir = pluginDir.getAbsolutePath();
|
||||
_conf = new ConfigurationManager(_pluginDir);
|
||||
_conf = new ConfigurationManager(_appContext, pluginDir, true);
|
||||
_ksp = new KeyStoreProvider(_pluginDir);
|
||||
_secMan = new SecurityManager(_appContext, _ksp, _conf);
|
||||
_server = buildServer();
|
||||
@ -103,7 +103,7 @@ public class I2PControlController implements RouterApp {
|
||||
_mgr = null;
|
||||
_log = _appContext.logManager().getLog(I2PControlController.class);
|
||||
_pluginDir = pluginDir.getAbsolutePath();
|
||||
_conf = new ConfigurationManager(_pluginDir);
|
||||
_conf = new ConfigurationManager(_appContext, pluginDir, true);
|
||||
_ksp = new KeyStoreProvider(_pluginDir);
|
||||
_secMan = new SecurityManager(_appContext, _ksp, _conf);
|
||||
_server = buildServer();
|
||||
|
@ -68,8 +68,7 @@ public class JSONRPC2Servlet extends HttpServlet {
|
||||
throw new IllegalStateException();
|
||||
_context = (RouterContext) ctx;
|
||||
File appDir = ctx.getAppDir();
|
||||
String app = appDir.getAbsolutePath();
|
||||
_conf = new ConfigurationManager(app);
|
||||
_conf = new ConfigurationManager(ctx, appDir, false);
|
||||
// we don't really need a keystore
|
||||
File ksDir = new File(ctx.getConfigDir(), "keystore");
|
||||
KeyStoreProvider ksp = new KeyStoreProvider(ksDir.getAbsolutePath());
|
||||
|
@ -21,7 +21,8 @@ import java.util.Properties;
|
||||
*/
|
||||
public class ConfigurationManager {
|
||||
private final String CONFIG_FILE = "I2PControl.conf";
|
||||
private final String configLocation;
|
||||
private final String WEBAPP_CONFIG_FILE = "i2pcontrol.config";
|
||||
private final File configLocation;
|
||||
private final Log _log;
|
||||
private boolean _changed;
|
||||
|
||||
@ -34,12 +35,12 @@ public class ConfigurationManager {
|
||||
|
||||
|
||||
|
||||
public ConfigurationManager(String dir) {
|
||||
_log = I2PAppContext.getGlobalContext().logManager().getLog(ConfigurationManager.class);
|
||||
if (dir.endsWith("/")) {
|
||||
configLocation = dir + CONFIG_FILE;
|
||||
public ConfigurationManager(I2PAppContext ctx, File dir, boolean isPlugin) {
|
||||
_log = ctx.logManager().getLog(ConfigurationManager.class);
|
||||
if (isPlugin) {
|
||||
configLocation = new File(dir, CONFIG_FILE);
|
||||
} else {
|
||||
configLocation = dir + "/" + CONFIG_FILE;
|
||||
configLocation = new File(dir, WEBAPP_CONFIG_FILE);
|
||||
}
|
||||
readConfFile();
|
||||
}
|
||||
@ -61,13 +62,13 @@ public class ConfigurationManager {
|
||||
****/
|
||||
|
||||
/**
|
||||
* Reads configuration from file itoopie.conf, every line is parsed as key=value.
|
||||
* Reads configuration from file, every line is parsed as key=value.
|
||||
*/
|
||||
public synchronized void readConfFile() {
|
||||
try {
|
||||
Properties input = new Properties();
|
||||
// true: map to lower case
|
||||
DataHelper.loadProps(input, new File(configLocation), true);
|
||||
DataHelper.loadProps(input, configLocation, true);
|
||||
parseConfigStr(input);
|
||||
_changed = false;
|
||||
} catch (FileNotFoundException e) {
|
||||
@ -94,7 +95,7 @@ public class ConfigurationManager {
|
||||
tree.put(e.getKey(), e.getValue().toString());
|
||||
}
|
||||
try {
|
||||
DataHelper.storeProps(tree, new File(configLocation));
|
||||
DataHelper.storeProps(tree, configLocation);
|
||||
_changed = false;
|
||||
} catch (IOException e1) {
|
||||
_log.error("Couldn't open file, " + configLocation + " for writing config.");
|
||||
|
Reference in New Issue
Block a user