提交 18655e85 authored 作者: Thomas Mueller's avatar Thomas Mueller

H2 Console: command line settings are now longer stored.

上级 8ea55147
...@@ -113,7 +113,6 @@ public class WebServer implements Service { ...@@ -113,7 +113,6 @@ public class WebServer implements Service {
// } // }
// private URLClassLoader urlClassLoader; // private URLClassLoader urlClassLoader;
private String driverList;
private int port; private int port;
private boolean allowOthers; private boolean allowOthers;
private Set running = Collections.synchronizedSet(new HashSet()); private Set running = Collections.synchronizedSet(new HashSet());
...@@ -221,7 +220,6 @@ public class WebServer implements Service { ...@@ -221,7 +220,6 @@ public class WebServer implements Service {
public void init(String[] args) { public void init(String[] args) {
// TODO web: support using a different properties file // TODO web: support using a different properties file
Properties prop = loadProperties(); Properties prop = loadProperties();
driverList = prop.getProperty("drivers");
port = SortedProperties.getIntProperty(prop, "webPort", Constants.DEFAULT_HTTP_PORT); port = SortedProperties.getIntProperty(prop, "webPort", Constants.DEFAULT_HTTP_PORT);
ssl = SortedProperties.getBooleanProperty(prop, "webSSL", Constants.DEFAULT_HTTP_SSL); ssl = SortedProperties.getBooleanProperty(prop, "webSSL", Constants.DEFAULT_HTTP_SSL);
allowOthers = SortedProperties.getBooleanProperty(prop, "webAllowOthers", Constants.DEFAULT_HTTP_ALLOW_OTHERS); allowOthers = SortedProperties.getBooleanProperty(prop, "webAllowOthers", Constants.DEFAULT_HTTP_ALLOW_OTHERS);
...@@ -573,16 +571,18 @@ public class WebServer implements Service { ...@@ -573,16 +571,18 @@ public class WebServer implements Service {
/** /**
* Save the settings to the properties file. * Save the settings to the properties file.
*
* @param prop null or the properties webPort, webAllowOthers, and webSSL
*/ */
synchronized void saveSettings() { synchronized void saveSettings(Properties prop) {
try { try {
Properties prop = new SortedProperties(); if (prop == null) {
if (driverList != null) { Properties old = loadProperties();
prop.setProperty("drivers", driverList); prop = new SortedProperties();
prop.setProperty("webPort", old.getProperty("webPort"));
prop.setProperty("webAllowOthers", old.getProperty("webAllowOthers"));
prop.setProperty("webSSL", old.getProperty("webSSL"));
} }
prop.setProperty("webPort", String.valueOf(port));
prop.setProperty("webAllowOthers", String.valueOf(allowOthers));
prop.setProperty("webSSL", String.valueOf(ssl));
ArrayList settings = getSettings(); ArrayList settings = getSettings();
int len = settings.size(); int len = settings.size();
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
......
...@@ -73,6 +73,7 @@ import org.h2.util.NetUtils; ...@@ -73,6 +73,7 @@ import org.h2.util.NetUtils;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
import org.h2.util.ObjectUtils; import org.h2.util.ObjectUtils;
import org.h2.util.ScriptReader; import org.h2.util.ScriptReader;
import org.h2.util.SortedProperties;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
import org.h2.util.Tool; import org.h2.util.Tool;
...@@ -567,10 +568,17 @@ class WebThread extends Thread implements DatabaseEventListener { ...@@ -567,10 +568,17 @@ class WebThread extends Thread implements DatabaseEventListener {
private String adminSave() { private String adminSave() {
try { try {
server.setPort(MathUtils.decodeInt((String) attributes.get("port"))); Properties prop = new SortedProperties();
server.setAllowOthers(Boolean.valueOf((String) attributes.get("allowOthers")).booleanValue()); int port = MathUtils.decodeInt((String) attributes.get("port"));
server.setSSL(Boolean.valueOf((String) attributes.get("ssl")).booleanValue()); prop.setProperty("webPort", String.valueOf(port));
server.saveSettings(); server.setPort(port);
boolean allowOthers = Boolean.valueOf((String) attributes.get("allowOthers")).booleanValue();
prop.setProperty("webAllowOthers", String.valueOf(allowOthers));
server.setAllowOthers(allowOthers);
boolean ssl = Boolean.valueOf((String) attributes.get("ssl")).booleanValue();
prop.setProperty("webSSL", String.valueOf(ssl));
server.setSSL(ssl);
server.saveSettings(prop);
} catch (Exception e) { } catch (Exception e) {
trace(e.toString()); trace(e.toString());
} }
...@@ -2065,7 +2073,7 @@ class WebThread extends Thread implements DatabaseEventListener { ...@@ -2065,7 +2073,7 @@ class WebThread extends Thread implements DatabaseEventListener {
info.user = attributes.getProperty("user", ""); info.user = attributes.getProperty("user", "");
server.updateSetting(info); server.updateSetting(info);
attributes.put("setting", info.name); attributes.put("setting", info.name);
server.saveSettings(); server.saveSettings(null);
return "index.do"; return "index.do";
} }
...@@ -2102,7 +2110,7 @@ class WebThread extends Thread implements DatabaseEventListener { ...@@ -2102,7 +2110,7 @@ class WebThread extends Thread implements DatabaseEventListener {
if (settings.size() > 0) { if (settings.size() > 0) {
attributes.put("setting", settings.get(0)); attributes.put("setting", settings.get(0));
} }
server.saveSettings(); server.saveSettings(null);
return "index.do"; return "index.do";
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论