]> source.dussan.org Git - gitblit.git/commitdiff
Override settings from command-line.
authorJames Moger <james.moger@gitblit.com>
Sat, 18 Jun 2011 13:39:01 +0000 (09:39 -0400)
committerJames Moger <james.moger@gitblit.com>
Sat, 18 Jun 2011 13:39:01 +0000 (09:39 -0400)
src/com/gitblit/GitBlitServer.java
src/com/gitblit/IStoredSettings.java

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