| 1 | OWNER |
| 2 | ===== |
| 3 | |
| 4 | OWNER, an API to ease Java property files usage. |
| 5 | |
| 6 | [](https://travis-ci.org/lviggiano/owner) |
| 7 | [](https://coveralls.io/r/lviggiano/owner) |
| 8 | [](https://www.meterian.com/report/gh/lviggiano/owner) |
| 9 | [](https://www.meterian.com/report/gh/lviggiano/owner) |
| 10 | [](http://maven.apache.org) |
| 11 | |
| 12 | DONATIONS |
| 13 | --------- |
| 14 | |
| 15 | Your support, is the acknowledgment of the value of this work and helps it running and improving. |
| 16 | Donations are welcome. |
| 17 | |
| 18 |  |
| 19 | bitcoin:1DARNDYjjKhNF8j2DFwT3zrtUsMQvV2am1 |
| 20 | |
| 21 | [](https://www.paypal.me/lviggiano) |
| 22 | |
| 23 | Thank you! |
| 24 | |
| 25 | |
| 26 | INTRODUCTION |
| 27 | ------------ |
| 28 | |
| 29 | The goal of OWNER API is to minimize the code required to handle |
| 30 | application configuration through Java properties files. |
| 31 | |
| 32 | Full documentation available on [project website][website]. |
| 33 | |
| 34 | BASIC USAGE |
| 35 | ----------- |
| 36 | |
| 37 | The approach used by OWNER APIs, is to define a Java interface |
| 38 | associated to a properties file. |
| 39 | |
| 40 | Suppose your properties file is defined |
| 41 | as `ServerConfig.properties`: |
| 42 | |
| 43 | ```properties |
| 44 | port=80 |
| 45 | hostname=foobar.com |
| 46 | maxThreads=100 |
| 47 | ``` |
| 48 | |
| 49 | To access this property you need to define a convenient Java |
| 50 | interface in `ServerConfig.java`: |
| 51 | |
| 52 | ```java |
| 53 | public interface ServerConfig extends Config { |
| 54 | int port(); |
| 55 | String hostname(); |
| 56 | int maxThreads(); |
| 57 | } |
| 58 | ``` |
| 59 | |
| 60 | We'll call this interface the *Properties Mapping Interface* or |
| 61 | just *Mapping Interface* since its goal is to map Properties into |
| 62 | a an easy to use piece of code. |
| 63 | |
| 64 | Then, you can use it from inside your code: |
| 65 | |
| 66 | ```java |
| 67 | public class MyApp { |
| 68 | public static void main(String[] args) { |
| 69 | ServerConfig cfg = ConfigFactory.create(ServerConfig.class); |
| 70 | System.out.println("Server " + cfg.hostname() + ":" + cfg.port() + |
| 71 | " will run " + cfg.maxThreads()); |
| 72 | } |
| 73 | } |
| 74 | ``` |
| 75 | |
| 76 | But this is just the tip of the iceberg. |
| 77 | |
| 78 | Continue reading here: [Basic usage](http://owner.aeonbits.org/docs/usage/). |
| 79 | |
| 80 | DOWNLOAD |
| 81 | -------- |
| 82 | |
| 83 | Public Releases can be downloaded from [GitHub Releases](https://github.com/lviggiano/owner/releases) page or |
| 84 | [Maven Central Repository](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.aeonbits.owner%22%20AND%20a%3A%22owner%22). |
| 85 | |
| 86 | |
| 87 | DOCUMENTATION |
| 88 | ------------- |
| 89 | |
| 90 | Make sure to have a look at the documentation on [project website][website] |
| 91 | to learn how flexible and powerful OWNER is, and why you may need it! |
| 92 | |
| 93 | Chinese documentation is provided by [Yunfeng Cheng](https://github.com/cyfonly) via a GitHub independent project at |
| 94 | [this address][chinese-docs]. |
| 95 | |
| 96 | [website]: http://owner.aeonbits.org |
| 97 | [chinese-docs]: https://github.com/cyfonly/owner-doc |
| 98 | |
| 99 | |
| 100 | LICENSE |
| 101 | ------- |
| 102 | |
| 103 | OWNER is released under the BSD license. |
| 104 | See [LICENSE][] file included for the details. |
| 105 | |
| 106 | [LICENSE]: https://raw.github.com/lviggiano/owner/master/LICENSE |