ConfigJSR
ConfigJSR copied to clipboard
JSR382
// // Copyright (c) 2016-2019 Contributors to the Eclipse Foundation // // See the NOTICE file(s) distributed with this work for additional // information regarding copyright ownership. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // image:https://badges.gitter.im/eclipse/ConfigJSR.svg[link="https://gitter.im/eclipse/ConfigJSR"]
image:https://api.travis-ci.org/eclipse/ConfigJSR.svg?branch=master[link="https://travis-ci.org/eclipse/ConfigJSR"]
= JSR-382 - Configuration API for Java, v1.0 Specification Leads: Emily Jiang, Mark Struberg
This is the official Source Repository of this very JSR.
== Status
Configuration API for Java JSR Draft - Work In Progress!
== How to Contribute?
=== JCP page
https://jcp.org/en/jsr/detail?id=382
https://twitter.com/ConfigJSR
=== Source Repository
The source code is available under the Apache License, v2.0 and hosted at https://github.com/eclipse/ConfigJSR
=== Mailing Lists
The Expert Group list is only used for announcements and voting.
All the normal interaction is going on on the general discussion list
To subscribe to a list just send a mail to configjsr-discuss-join (at) eclipse.org
=== EG Meeting minutes
https://docs.google.com/document/d/1ixB3_Lu4Os__mw4_W5zlKspUE-lL3_h0asflewErlFY/edit?usp=sharing
== Rationale
The majority of applications need to be configured based on a running environment. It must be possible to modify configuration data from outside an application so that the application itself does not need to be repackaged.
The configuration data can come from different locations and in different formats (e.g. system properties, system environment variables, .properties, .xml, datasource). We call these config locations ConfigSources. If the same property is defined in multiple ConfigSources, we apply a policy to specify which one of the values will effectively be used.
Under some circumstances, some data sources may change dynamically. The changed values should be fed into the client without the need for restarting the application. This requirement is particularly important for microservices running in a cloud environment. The JavaConfig approach allows to pick up configured values immediately after they got changed.
== Influences and History
There are a number of Config projects which directly influenced this proposal and acted as basis for this API, such as:
- DeltaSpike Config (http://deltaspike.apache.org/documentation/configuration.html)
- Extracted parts of DeltaSpike Config (https://github.com/struberg/javaConfig/)
- Apache Tamaya (https://tamaya.incubator.apache.org/)
The approach of those got merged together into MicroProfile Config (https://github.com/eclipse/microprofile-config). This now serves as a starting point for this very JSR.
== Implementations
JavaConfig does not contain an implementation itself but only provides the specified API and, a TCK and documentation.
== Design
The current configuration of an application can be accessed via ConfigProvider#getConfig()
.
A Config
consists of the information collected from the registered javax.config.spi.ConfigSource
s.
These ConfigSource
s get sorted according to their ordinal.
That way it is possible to overwrite configuration with lower importance from outside.
By default there are 3 default ConfigSources:
-
System.getProperties()
(ordinal=400) -
System.getenv()
(ordinal=300) - all
META-INF/javaconfig.properties
files on the ClassPath. (default ordinal=100, separately configurable via a config_ordinal property inside each file)
Therefore, the default values can be specified in the above files packaged with the application and the value can be overwritten later for each deployment. A higher ordinal number takes precedence over a lower number.
== Custom ConfigSources
It is possible to write and register a custom ConfigSources
.
An example would be a ConfigSource which gets the configured values from a shared database table in a cluster.
== Building
The whole JavaConfig project can be built via Apache Maven
$> mvn clean install