开发者

Multi Process Configuration

开发者 https://www.devze.com 2022-12-24 02:08 出处:网络
I have a product built out of multiple processes. Each process uses inte开发者_JS百科rnally commons 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号