Eclipse MicroProfile Config 1.0 and WildFly implementation
Eclipse MicroProfile Config 1.0 has been released.
It is quite a milestone as it is the first specification released by the Eclipse MicroProfile project. It covers a simple need: unify the configuration of Java application from various sources with a simple API:
@Inject
@ConfigProperty(name = "app.timeout", defaultValue = "5000")
long timeout;
The developer no longer needs to check for configuration files, System properties, etc. He or she just specifies the name of the configuration property (and an optional default value). The Eclipse MicroProfile Config specification ensures that several sources will be queried in a consistent order to find the most relevant value for the property.
With Eclipse MicroProfile Config 1.0 API available, I have released wildfly-microprofile-config 1.0.1.
This project contains an implementation of the specification:
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-microprofile-config</artifactId>
<version>1.0.1</version>
</dependency>
This implementation passes the MicroProfile Config 1.0 TCK. It can be used by any CDI-aware container/server (i.e. that are able to load CDI extensions).
This project also contains a WildFly extension so that any application deployed in WildFly can use the MicroProfile Config API. The microprofile-config
subsystem can be used to configure various config sources such as directory-based for OpenShift/Kubernetes config maps (as described in a previous post) or the properties can be stored in the microprofile-config
subsystem itself):
<subsystem xmlns="urn:wildfly:microprofile-config:1.0">
<config-source name="appConfigSource">
<property name="app.timeout" value="2500" />
</config-source>
<config-source name="configSourceFromDir" dir="/etc/config/numbers-app" />
</subsystem>
Finally, a Fraction is available for WildFly Swarm so that any Swarm application can use the Config API as long as it depends on the appropriate Maven artifact:
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>microprofile-config</artifactId>
<version>1.0.1</version>
</dependency>
It is planned that this org.wildfly.swarm:microprofile-config
Fraction will eventually move to Swarm own Git repository so that it Swarm will be able to autodetect applications using the Config API and load the dependency automatically. But, for the time being, the dependency must be added explicitely.
If you have any issues or enhancements you want to propose for the WildFly MicroProfile Config implementation, do not hesitate to open issues or propose contributions for it.