8000 GitHub - FrimaStudio/owner: Get rid of the boilerplate code in properties based configuration.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

FrimaStudio/owner

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OWNER

OWNER, an API to ease Java property files usage.

Build Status Build Status Coverage Status

Built with Maven Powered by Sonar

Build pre-requisites

  • Maven (tested with 3.1.1, older/newer versions should also work)

Generate Eclipse project

Run 'mvn -npr eclipse:eclipse'.

YAML

This fork was created to implement YAML loading/parsing into OWNER. To do so, we sadly had to let go of some features that we didn't need and didn't have time to port:

  • XML configurations are not supported anymore. '.properties' should still work but are not used outside of the unit tests.
  • Accessible interface does not have the 'store' method anymore since it's currently impossible to know which format the properties should be saved as. This sadly break a lot of unit tests that relied on properties being able to be saved at runtime :(
  • Documentation outdated in some places (Should not really impact users of the library though).

INTRODUCTION

The goal of OWNER API is to minimize the code required to handle application configuration through Java properties files.

Full documentation available on project website.

BASIC USAGE

The approach used by OWNER APIs, is to define a Java interface associated to a properties file.

Suppose your properties file is defined as ServerConfig.properties:

port=80
hostname=foobar.com
maxThreads=100

To access this property you need to define a convenient Java interface in ServerConfig.java:

public interface ServerConfig extends Config {
    int port();
    String hostname();
    int maxThreads();
}

We'll call this interface the Properties Mapping Interface or just Mapping Interface since its goal is to map Properties into a an easy to use piece of code.

Then, you can use it from inside your code:

public class MyApp {
    public static void main(String[] args) {
        ServerConfig cfg = ConfigFactory.create(ServerConfig.class);
        System.out.println("Server " + cfg.hostname() + ":" + cfg.port() +
                           " will run " + cfg.maxThreads());
    }
}

But this is just the tip of the iceberg.

Continue reading here: Basic usage.

DOCUMENTATION

Make sure to have a look at the documentation on project website to learn how flexible and powerful OWNER is, and why you may need it!

LICENSE

OWNER is released under the BSD license. See LICENSE file included for the details.

About

Get rid of the boilerplate code in properties based configuration.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 308A 84.9%
  • CSS 9.4%
  • HTML 5.6%
  • Shell 0.1%
0