as rolz asked for useful ideas, here is one. i use it since my first viewer prototype and find very convenient
if you use xml for static configurations (ie. not changed during program run) this is a simple receipt to make it robust and light-weight
* use
jibx to convert your xml file to a tree of java objects. this eliminates those regular xml parsing issues which are both painful and error-prone
* serialize your object tree to a file
* re-compile the classes that make the object tree (as jibx uses bytecode enhancement, after using it your classes gets fatter and you need jibx runtime in your classpath to use them)
* now you can de-serialize that file in your program and use it without jibx runtime
* dont forget to manually assign a serial version id to your serializable classes -as below- otherwise above will fail
another advantage of this method is, since jibx uses reflection, you can make your configuration classes very small: with no setters-getters and almost all fields final
the result is, you get rid of xml parsing code and have a pure type-safe configuration in very little space
public class SomeConfigurationClass implements java.io.Serializable {
private static final long serialVersionUID = 999; // 'manually' assign serial version id
public final String aStringValue = null;
public final SomeOtherConfClass aComplexConfValue = null;
// no need even for a constructor
//..
}
r a f t
cheers :wink: