summaryrefslogtreecommitdiffstats
path: root/logserver/src/main/java/com/yahoo/plugin/SystemPropertyConfig.java
diff options
context:
space:
mode:
Diffstat (limited to 'logserver/src/main/java/com/yahoo/plugin/SystemPropertyConfig.java')
-rw-r--r--logserver/src/main/java/com/yahoo/plugin/SystemPropertyConfig.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/logserver/src/main/java/com/yahoo/plugin/SystemPropertyConfig.java b/logserver/src/main/java/com/yahoo/plugin/SystemPropertyConfig.java
new file mode 100644
index 00000000000..763dc2d1f3e
--- /dev/null
+++ b/logserver/src/main/java/com/yahoo/plugin/SystemPropertyConfig.java
@@ -0,0 +1,35 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.plugin;
+
+/**
+ * This class implements plugin config through system properties.
+ * Each plugin typically has its own system property prefix, such as
+ * "logserver.archiver.". A request for the config key "foo" will
+ * then return the contents of the "logserver.archiver.foo" system
+ * property.
+ *
+ * @author <a href="mailto:stig@yahoo-inc.com">Stig Bakken</a>
+ */
+public class SystemPropertyConfig extends Config
+{
+ private final String prefix;
+
+ /**
+ * @param prefix Prefix string prepended to config keys
+ * as they are looked up as system properties.
+ */
+ public SystemPropertyConfig(String prefix) {
+ this.prefix = prefix;
+ }
+
+ /**
+ * @return a config value for the specified key
+ */
+ public String get(String key, String defaultValue) {
+ return System.getProperty(prefix + key, defaultValue);
+ }
+
+ public String toString () {
+ return "Prefix=" + prefix;
+ }
+}