Enabled saving of config files.

This commit is contained in:
dev
2011-07-05 14:10:19 +00:00
parent 24f8197964
commit dd5481f216
4 changed files with 17 additions and 9 deletions

View File

@ -78,9 +78,9 @@ public class Main {
//log.log(Log.ERROR, null, ex); //log.log(Log.ERROR, null, ex);
} }
_conf.parseConfigStr("server-name=127.0.0.1"); _conf.parseConfigStr("server.hostname=127.0.0.1");
_conf.parseConfigStr("server-port=5555"); _conf.parseConfigStr("server.port=5555");
_conf.parseConfigStr("server-target=jsonrpc"); _conf.parseConfigStr("server.target=jsonrpc");
@ -120,6 +120,12 @@ public class Main {
}); });
} }
@SuppressWarnings("static-access")
public static void beginShutdown(){
_conf.writeConfFile();
System.exit(0);
}
/** /**
* Avoids the app terminating because no Window is opened anymore. * Avoids the app terminating because no Window is opened anymore.
* More info: http://java.sun.com/javase/6/docs/api/java/awt/doc-files/AWTThreadIssues.html#Autoshutdown * More info: http://java.sun.com/javase/6/docs/api/java/awt/doc-files/AWTThreadIssues.html#Autoshutdown

View File

@ -129,7 +129,7 @@ public class TrayManager {
@Override @Override
protected Object doInBackground() throws Exception { protected Object doInBackground() throws Exception {
System.exit(0); Main.beginShutdown();
return null; return null;
} }
}.execute(); }.execute();

View File

@ -34,7 +34,9 @@ public class ConfigurationManager {
//Configurations with an Integer as value //Configurations with an Integer as value
private static Map<String, Integer> integerConfigurations = new HashMap<String, Integer>(); private static Map<String, Integer> integerConfigurations = new HashMap<String, Integer>();
private ConfigurationManager() {} private ConfigurationManager() {
readConfFile();
}
public synchronized static ConfigurationManager getInstance() { public synchronized static ConfigurationManager getInstance() {
if(instance == null) { if(instance == null) {
@ -69,7 +71,7 @@ public class ConfigurationManager {
} }
br.close(); br.close();
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
_log.error("Unable to find config file, " + DEFAULT_CONFIG_LOCATION); _log.info("Unable to find config file, " + DEFAULT_CONFIG_LOCATION);
} catch (IOException e) { } catch (IOException e) {
_log.error("Unable to read from config file, " + DEFAULT_CONFIG_LOCATION); _log.error("Unable to read from config file, " + DEFAULT_CONFIG_LOCATION);
} }

View File

@ -40,9 +40,9 @@ public class JSONInterface {
public static void setupSession() { public static void setupSession() {
URL srvURL = null; URL srvURL = null;
String srvHost = _conf.getConf("server-hostname", "localhost"); String srvHost = _conf.getConf("server.hostname", "localhost");
int srvPort = _conf.getConf("server-port", 7656); int srvPort = _conf.getConf("server.port", 7656);
String srvTarget = _conf.getConf("server-target", "jsonrpc"); String srvTarget = _conf.getConf("server.target", "jsonrpc");
try { try {
srvURL = new URL("https://" + srvHost + ":" + srvPort + "/" srvURL = new URL("https://" + srvHost + ":" + srvPort + "/"
+ srvTarget); + srvTarget);