diff options
-rw-r--r-- | src/com/gitblit/GitBlitServer.java | 6 | ||||
-rw-r--r-- | src/com/gitblit/IStoredSettings.java | 22 |
2 files changed, 20 insertions, 8 deletions
diff --git a/src/com/gitblit/GitBlitServer.java b/src/com/gitblit/GitBlitServer.java index 678c9d43..80a46902 100644 --- a/src/com/gitblit/GitBlitServer.java +++ b/src/com/gitblit/GitBlitServer.java @@ -201,9 +201,9 @@ public class GitBlitServer { return;
}
- // Update settings
-// settings.put(Keys.realm.realmFile, params.realmFile);
-// settings.put(Keys.git.repositoriesFolder, params.repositoriesFolder);
+ // Override settings
+ settings.overrideSetting(Keys.realm.realmFile, params.realmFile);
+ settings.overrideSetting(Keys.git.repositoriesFolder, params.repositoriesFolder);
// Set the server's contexts
server.setHandler(rootContext);
diff --git a/src/com/gitblit/IStoredSettings.java b/src/com/gitblit/IStoredSettings.java index 403a0676..6fcb437e 100644 --- a/src/com/gitblit/IStoredSettings.java +++ b/src/com/gitblit/IStoredSettings.java @@ -27,16 +27,24 @@ import com.gitblit.utils.StringUtils; public abstract class IStoredSettings {
protected final Logger logger;
+
+ protected final Properties overrides = new Properties();
public IStoredSettings(Class<? extends IStoredSettings> clazz) {
logger = LoggerFactory.getLogger(clazz);
}
protected abstract Properties read();
+
+ private Properties getSettings() {
+ Properties props = read();
+ props.putAll(overrides);
+ return props;
+ }
public List<String> getAllKeys(String startingWith) {
List<String> keys = new ArrayList<String>();
- Properties props = read();
+ Properties props = getSettings();
if (StringUtils.isEmpty(startingWith)) {
keys.addAll(props.stringPropertyNames());
} else {
@@ -52,7 +60,7 @@ public abstract class IStoredSettings { }
public boolean getBoolean(String name, boolean defaultValue) {
- Properties props = read();
+ Properties props = getSettings();
if (props.containsKey(name)) {
String value = props.getProperty(name);
if (!StringUtils.isEmpty(value)) {
@@ -63,7 +71,7 @@ public abstract class IStoredSettings { }
public int getInteger(String name, int defaultValue) {
- Properties props = read();
+ Properties props = getSettings();
if (props.containsKey(name)) {
try {
String value = props.getProperty(name);
@@ -79,7 +87,7 @@ public abstract class IStoredSettings { }
public String getString(String name, String defaultValue) {
- Properties props = read();
+ Properties props = getSettings();
if (props.containsKey(name)) {
String value = props.getProperty(name);
if (value != null) {
@@ -95,11 +103,15 @@ public abstract class IStoredSettings { public List<String> getStrings(String name, String separator) {
List<String> strings = new ArrayList<String>();
- Properties props = read();
+ Properties props = getSettings();
if (props.containsKey(name)) {
String value = props.getProperty(name);
strings = StringUtils.getStringsFromValue(value, separator);
}
return strings;
}
+
+ public void overrideSetting(String key, String value) {
+ overrides.put(key, value);
+ }
}
\ No newline at end of file |