diff options
author | James Moger <james.moger@gitblit.com> | 2011-06-18 09:39:01 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2011-06-18 09:39:01 -0400 |
commit | 0fe70c1cf434f492286e01e8528322134a10281a (patch) | |
tree | 9f5ddb41e837233146a9909b822bb37dfce2818d | |
parent | 767eb537d28dccf73c78796b7d6dd27fe7073d66 (diff) | |
download | gitblit-0fe70c1cf434f492286e01e8528322134a10281a.tar.gz gitblit-0fe70c1cf434f492286e01e8528322134a10281a.zip |
Override settings from command-line.
-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 |