diff --git a/README.md b/README.md index 7e24da1..9726c34 100644 --- a/README.md +++ b/README.md @@ -1,98 +1,15 @@ -# property-inject [![Build Status](https://travis-ci.org/xlate/property-inject.svg?branch=master)](https://travis-ci.org/xlate/property-inject) [![Coverage Status](https://coveralls.io/repos/github/xlate/property-inject/badge.svg?branch=master)](https://coveralls.io/github/xlate/property-inject?branch=master) -Simple CDI extension to support injection of java.util.Properties values +# Property Inject [![Build Status](https://travis-ci.org/xlate/property-inject.svg?branch=master)](https://travis-ci.org/xlate/property-inject) [![Coverage Status](https://coveralls.io/repos/github/xlate/property-inject/badge.svg?branch=master)](https://coveralls.io/github/xlate/property-inject?branch=master) -## Maven Configuration +Simple CDI extension to support injection of java.util.Properties values. -```xml - - io.xlate - property-inject - 1.0.0 - -``` +Please see the [project wiki](https://github.com/xlate/property-inject/wiki) for +more information. -If you wish to use a SNAPSHOT version, add the Sonatype OSS repository to your Maven configuration. +### Licensing -```xml - - - oss-sonatype - oss-sonatype - https://oss.sonatype.org/content/repositories/snapshots/ - - true - - - -``` - -## Usage - -### 1) Simple - -```java -package com.example.injection; - -import javax.inject.Inject; -import io.xlate.inject.Property; - -public class Example { - @Inject - @Property(defaultValue = "theDefault") - private String simple; -} -``` -In this example, the extension searches for a system property passed to the Java process as package + class + field. - -``` --Dcom.example.injection.Example.simple=theValue -``` - -If not found in the system properties, searches for property key 'simple' in properties file -`/com/example/injection/Example.properties` on the class path. - -When neither a system property nor a matching properties file is found, the value will be set to "theDefault" as configured. If no defaultValue -is configured, the value will be `null`. - -### 2) Overridden system property name - -```java -package com.example.injection; - -import javax.inject.Inject; -import io.xlate.inject.Property; - -public class Example { - @Inject - @Property(systemProperty = "example.simple") - private String simple; -} -``` -In this example, the extension searches for a system property passed to the Java process as named by the systemProperty attribute of `@Property`. - -``` --Dexample.simple=theValue -``` - -As with the first example, if not found in the system properties, searches for property key 'simple' in properties file -`/com/example/injection/Example.properties` on the class path. - -When neither a system property nor a matching properties file is found, the value will be set to `null` since no defaultValue has been configured on the `@Property`. - -### 3) Providing a properties file - -```java -package com.example.injection; - -import javax.inject.Inject; -import io.xlate.inject.Property; - -public class Example { - @Inject - @Property(resourceName = "config/my-app.properties") - private String simple; -} -``` -In this example, the `resourceName` attribute of `@Property` specifies that a file named `config/my-app.properties` is available on the CLASSPATH. The properties will be loaded and the value of key `simple` injected to the field. Note that the properties will only be searched if no value is found for system property `com.example.injection.Example.simple`. - -If the properties file does not exist or there is no key `simple`, the value will be set to `null` since no defaultValue has been configured on the `@Property`. +Property Inject is available for use under the GNU Affero GPL license for open +source projects. Commercial license terms are also available (see COMM-LICENSE) +for individuals or companies wishing to develop software using the library but +do not wish to open source their own code. Please see the Property Inject +[product page](https://plasso.com/s/z9a9I2nkoD-xlateio-property-inject) for +pricing.