MCPcopy Create free account
hub / github.com/OpenTSDB/asynchbase / Config

Class Config

src/Config.java:51–387  ·  view source on GitHub ↗

A configuration class that stores key/value pairs as strings similar to the System properties object. The class includes helper methods to parse the strings into numbers or booleans and it allows for loading a standard Java properties file from disk. The loadSystemAndDefaults will be called

Source from the content-addressed store, hash-verified

49 * @since 1.7.0
50 */
51public class Config {
52 private static final Logger LOG = LoggerFactory.getLogger(Config.class);
53
54 /** Flag to determine if we're running under Windows or not */
55 public static final boolean RUNNING_WINDOWS;
56 static {
57 // this should never be null, but who knows?
58 RUNNING_WINDOWS = System.getProperty("os.name") != null ? System
59 .getProperty("os.name").contains("Windows") : false;
60 }
61
62 /**
63 * The list of properties configured to their defaults or modified by users.
64 * We use a non-synchronized hash map for fast access as opposed to the
65 * HashTable backed properties objects.
66 */
67 protected final HashMap<String, String> properties = new HashMap<String, String>();
68
69 /** Holds default values for the config */
70 protected final HashMap<String, String> default_map = new HashMap<String, String>();
71
72 /** Tracks the location of the file that was actually loaded */
73 protected String config_location;
74
75 /**
76 * Constructor that initializes default configuration values from the
77 * System.properties map.
78 */
79 public Config() {
80 loadSystemAndDefaults();
81 }
82
83 /**
84 * Constructor that initializes default values and attempts to load the given
85 * properties file
86 * @param file Path to the file to load
87 * @throws IOException Thrown if unable to read or parse the file
88 */
89 public Config(final String file) throws IOException {
90 loadSystemAndDefaults();
91 loadConfig(file);
92 }
93
94 /**
95 * Constructor for subclasses who want a copy of the parent config but without
96 * the ability to modify the original values.
97 *
98 * This constructor will not re-read the file, but it will copy the location
99 * so if a child wants to reload the properties periodically, they may do so
100 * @param parent Parent configuration object to load from
101 */
102 public Config(final Config parent) {
103 properties.putAll(parent.properties);
104 config_location = parent.config_location;
105 loadSystemAndDefaults();
106 }
107
108 /**

Callers

nothing calls this directly

Calls 1

containsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…