The approach I've used successfully in many projects is to have a generic mechanism for "settings loading" that comes before creating any modules, but contains a mechanism to bind the contents of properties files (layering them up from a variety of standard locations in the filesystem, or any source you care to provide - i.e. layer up /etc/foo.properties + ~/foo.properties + ./foo.properties - or URLs or wherever you want). I wound up creating a pretty minimal library for that - https://github.com/timboudreau/giulius and there's an example of a totally non-filesystem configuration source - https://github.com/timboudreau/giulius-settings-etcd )
Making this stuff lazy is an optimization, and trades time during startup for indeterminacy in runtime performance (you don't know what will trigger initialization), so it's worth being really sure that doing the loading upfront is prohibitively expensive. For my part, with regard to exceptions thrown during that process, I've settled on doing something somewhat naughty - http://timboudreau.com/blog/Unchecked_checked_exceptions/read - if the configuration is hosed during initialization, I want to the process to exit, not stagger around as a zombie. IMO, if something configuration-related can be catastrophically broken, it's preferable to pay in startup time to know that as early as possible (you could always keep your lazy singleton providers, but in production mode have a class bound as an eager singleton that requests all of them in its constructor). -Tim -- You received this message because you are subscribed to the Google Groups "google-guice" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/google-guice. To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/3c7a1215-c39e-495e-ac42-aa4b46687b6b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
