Multi Process Configuration
I have a product built out of multiple processes. Each process uses inte开发者_JS百科rnally commons configuration.
Does anyone have an idea how to manage the config? I.e. we do not want to duplicate variables so each process will be able to read them.
Additionally, DB solution is no good, as we do not want to be dependent on DB for something like configuration.
Thanks
Yair
If the configuration is static the simplest solution is to use java.util.Properties. It uses a simple key/value format based on strings, and you can load it from any InputStream / Reader. You just may need to do extra processing for non-string values:
java.util.Properties p = new java.util.Properties();
p.load(new FileReader("myConfiguration.properties"));
int foo = Integer.parseInt(p.getProperty("foo"));
String bar = p.getProperty("bar");
A simple properties file:
foo=13
bar=baz
The javadocs for load(Reader) explains the properties file format.
精彩评论