aboutsummaryrefslogtreecommitdiffstats
path: root/logserver/src/main/java/com/yahoo/plugin/SystemPropertyConfig.java
blob: 01b4b584ddcd0a12467df61028e2fad39ce43536 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright Yahoo. 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 Stig Bakken
 */
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;
    }

    /** Returns 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;
    }

}