Re: the best way to store program setup
Please do not top-post. Use trim-and-inline posting.
I think, this [to store program configuration settings] can be achieved with serializati on -
all you need, is to identify the application state data to persist, and make it as a
separate class(set of classes). After that you can use plenty of a
tools/libs/facilities to serialize data to a stream, and read it from
A few of the most common techniques: JAXB (as you mentioned), XML-RPC (as used
in SOAP messages), java.io.Serializable, Serializable over RMI, the Java API
Properties and ResourceBundles mechanisms, other text files like CSV, and
roll-yer-own. Probably the most successful approaches use either properties
files or deployment descriptors, as with Apache Tomcat or Apache Web Server.
I'd avoid java.io.Serializable for configuration or simple data transfer. Its
purpose is to serialize object graphs. Many data transfer matters, and likely
all configuration matters, are much simpler than that.
XML descriptor files seem to be the industry's consensus in modern times on
how to configure things. Consider Tomcat's server.xml and web.xml
descriptors, for example.
XML is nice because, as you stated, it is "completely transparent and
editable", indeed, generally human-readable. XML configuration files make for
explicable documentation of deployment scenarios. That you can drop such a
document into a deployment and have its system behave accordingly is an
amazing synergy of operational and documentary purpose.
I wouldn't limit oneself to "one descriptor file - one class". Split up
descriptors according to the needs of the operations personnel, not the
developers. Ops won't care about what class is doing what, unless your code
breaks the system. They will care about, "Where are the database parameters?"
"Where are the memory parameters?" "Where are the driver parameters?"
We need to show operations more respect. Design for the folks in the trenches.