oblac / jodd

Jodd! Lightweight. Java. Zero dependencies. Use what you like.

Home Page:https://jodd.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Load and merge multiple properties files

stodge opened this issue · comments

I've browsed the props documentation and Javadocs but I don't think this is supported. I'm looking to re-write my service's configuration loader and Jodd popped up onto my radar. One thing my current loader does is it loads multiple YAML files (I'm not tied to YAML) and merges them so that the data from all files can be accessed as one.

This might be a good addition to Jodd props. I suppose the API could be:

load(String[] filenames)

or load(File[] files)

Jodd would load them all - my current loader loads 5 or 6 files, each with 10 lines or less.

The API would still work as before, but you would be pulling data from the merged configuration:

    Props p = new Props();
    p.load(new File[] { new File("example.props"), new File("example2.props") } );
    ...
    String story = p.getValue("story");

Cheers

Wait a minute! Is this already supported? I need to try it out. The answer might be in the code example I posted above:

    Props p = new Props();
    p.load(new File("example.props"));
    p.load(new File("example2.props"));
    String story = p.getValue("story");

This is how it works?

Ok, I created a test app and this functionality already exists. I didn't realise (lack of caffeine) that the "..." in the documentation meant I could load multiple files. My bad.

Hey @stodge no worries, I should make that more clear :)

No worries - I wasn't thinking straight. Maybe the doc could show two files being loaded, just for idiots like me. :)