blob: 4f17678e3b951c40ffdb98a9717b70b3cd15076f (
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 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 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;
}
/**
* @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;
}
}
|