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