In combination with CDI OWNER does the job really well.
Update
Inject Java Properties in Java EE Using CDI provides an introduction together with some sample code on github. As a next step you may delegate the properties part to OWNER.
Create an annotation type definition Config.java:
@Qualifier
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
public @interface Config {
}
Get the ConfigProducer.java in place:
@Produces
@Config
public Configuration produce(InjectionPoint ip) {
if (config == null) {
config = ConfigFactory.create(Configuration.class);
}
return config;
}
The producer must be instantiated by itself or another bean with @Startup @Singleton
annotations.
Setup your OWNER backed Configuration.java
@HotReload(type = HotReloadType.SYNC)
@LoadPolicy(LoadType.MERGE)
@Sources("file:${config.filepath}/config.properties")
public interface Configuration extends Config, Reloadable, Mutable, Accessible {
@Key("server.http.port")
int port();
@Key("server.host.name")
String hostname();
}
Inject and use the configuration in some bean:
@Stateless
public class SomeBean {
@Inject
@Config
private Configuration config;
}
Not to forget the path configuration in wildfly's standalone.xml:
<system-properties>
<property name="config.filepath" value="/your/path/"/>
</system-properties>