I would like to write (in Java) something like the following:
public class A implements MagicallyConfigurable { @configuration_source_type{"xml"} @configuration_dir{"some/rel/path/"} int length = 4 ; char c = '*' ; @do_not_configure String title; A(String title) { this.title = title; } void goForIt() { System.out.println(title); for(int i=0; i < length; i++) { System.out.print(c); } } }
and so that it works as expected. That is, the only thing I would need to initialize the fields based on the configuration is to add some annotations, implement the interface, and possibly make one function call (but hopefully without it).
I'm sure this is theoretically feasible, the question is whether there is an existing library / framework / add -on / thingie that allows this. (Maybe Apache commons.configuration somehow? Didn't work with it before.)
source share