I have come to loathe .properties and .xml configuration files. (The use of them together is just inexcusable.) People tend to grab a properties or XML file when they need to parse something, and something is usually a configuration file of some stripe. This is convenient, as it happens that parsers for properties and XML files are readily available and built into Java, but both flunk on some aspects of usability:
- A configuration should be verifiable outside of the runtime container. I am deeply frustrated by compiling an application, building artifacts, and deploying those artifacts only to find out that a property was misnamed, a configuration file was not in the correct location, or a combination or parameters is unsupported.
- A configuration should be relatively easy to write. "Easy" in this context doesn't mean pretty colors and auto-completion, but it does mean that the configuration scheme should be human writable. (Human readable is a subordinate goal.) Overloading a markup language and thus forcing users to type everything twice doesn't count as "easy" and neither does overloading property naming for poor man's namespaces or hierarchy.
There are (at least) two viable alternatives:
- Use programmatic configuration. Build a reasonable, well-documented configuration API into your application and have users write to it.
- Invent a simple language and write a parser. It's not that difficult to pick up ANTLR or JavaCC and create a little language that meets your configuration requirements.
The use of a scripting language (like Beanshell or Groovy) can combine both approaches. (For example, Bob's approach for dynaop is a good example.)










