forked from eclipse/microprofile-config
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes eclipse#62 move seldom used parts away from ConfigProvider
A power-user can use the ConfigProviderResolver directly to access the ConfigBuilder. That way the casual user doesn't get hit with all the complexity he doesn't need most times. Signed-off-by: Mark Struberg <[email protected]>
- Loading branch information
Showing
3 changed files
with
104 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
api/src/main/java/org/eclipse/microprofile/config/spi/ConfigBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
******************************************************************************* | ||
* Copyright (c) 2016-2017 Mark Struberg and others | ||
* | ||
* 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. | ||
* | ||
*******************************************************************************/ | ||
package org.eclipse.microprofile.config.spi; | ||
|
||
import org.eclipse.microprofile.config.Config; | ||
|
||
/** | ||
* Builder for manually creating an instance of a {@code Config}. | ||
* | ||
* @see ConfigProviderResolver#getBuilder() | ||
* | ||
* @author <a href="mailto:[email protected]">Mark Struberg</a> | ||
* @author <a href="mailto:[email protected]">Romain Manni-Bucau</a> | ||
* @author <a href="mailto:[email protected]">Emily Jiang</a> | ||
*/ | ||
public interface ConfigBuilder { | ||
/** | ||
* Add the default config sources appearing on the builder's classpath | ||
* including: | ||
* <ol> | ||
* <li>System properties</li> | ||
* <li>Environment properties</li> | ||
* <li>/META-INF/microprofile-config.properties</li> | ||
* </ol> | ||
* | ||
* @return the ConfigBuilder with the default config sources | ||
*/ | ||
ConfigBuilder addDefaultSources(); | ||
|
||
/** | ||
* Return the ConfigBuilder for a given classloader | ||
* | ||
* @param loader | ||
* @return the ConfigureBuilder for the given classloader | ||
*/ | ||
ConfigBuilder forClassLoader(ClassLoader loader); | ||
|
||
/** | ||
* Add the specified {@link ConfigSource}. | ||
* | ||
* @param sources | ||
* @return the ConfigBuilder with the configured sources | ||
*/ | ||
ConfigBuilder withSources(ConfigSource... sources); | ||
|
||
/** | ||
* Add the specified {@link Converter} | ||
* | ||
* @param converters | ||
* @return the ConfigBuilder with the added converters | ||
*/ | ||
ConfigBuilder withConverters(Converter<?>... converters); | ||
|
||
/** | ||
* Build the {@link Config} object. | ||
* | ||
* @return the Config object | ||
*/ | ||
Config build(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters