Java Properties reinvented

Recently i stumbled across the Owner Library( ). Using this small piece of technology, usage of Java property files can be reinvented! Now we can access properties using a refactoring safe interface the following way:

public interface ServerConfig extends Config {
    int port();

    String hostname();

    int maxThreads();

Properties props = new Properties(); // Load properties from a known source

ServerConfig cfg = ConfigFactory
    .create(ServerConfig.class, props);

System.out.println(cfg.hostname()); // And simply use them

This is a really nice way to deal with property files:-)

Loading comments...