-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b69e07
commit c85bb8e
Showing
5 changed files
with
422 additions
and
1 deletion.
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
81 changes: 81 additions & 0 deletions
81
api/src/main/java/org/eclipse/microprofile/config/spi/ConfigContent.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,81 @@ | ||
/* | ||
* Copyright (c) 2020 Oracle and/or its affiliates. | ||
* | ||
* 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 java.util.Optional; | ||
|
||
/** | ||
* Config content as provided by a config source that can read all its data at once (an "eager" config source). | ||
* This interface provides necessary support for changes of the underlying source and for parsable content. | ||
* <p> | ||
* The data stamp can be any object (to be decided by the {@link ConfigSource}). | ||
*/ | ||
public interface ConfigContent { | ||
/** | ||
* Close the content, as it is no longer needed. | ||
*/ | ||
default void close() { | ||
} | ||
|
||
/** | ||
* A modification stamp of the content. | ||
* This can be used to check if a content of a config source has changed (to support | ||
* mutability without race conditions within a single source). | ||
* <p> | ||
* @return a stamp of the content | ||
*/ | ||
default Optional<Object> stamp() { | ||
return Optional.empty(); | ||
} | ||
|
||
/** | ||
* Config content that provides an {@link ConfigNode.ObjectNode} directly, with no need | ||
* for parsing. | ||
*/ | ||
interface NodeContent extends ConfigContent { | ||
/** | ||
* Data of this config source. | ||
* @return the data of the underlying source as an object node | ||
*/ | ||
ConfigNode.ObjectNode data(); | ||
} | ||
|
||
// I leave this here to show why it would make sense to have multiple types | ||
// interface ParsableContent extends ConfigContent { | ||
// /** | ||
// * Media type of the content. This method is only called if | ||
// * there is no parser configured. | ||
// * | ||
// * @return content media type if known, {@code empty} otherwise | ||
// */ | ||
// Optional<String> mediaType(); | ||
// | ||
// /** | ||
// * Data of this config source. | ||
// * | ||
// * @return the data of the underlying source to be parsed by a {@code ConfigParser} | ||
// */ | ||
// InputStream data(); | ||
// | ||
// /** | ||
// * Charset configured by the config source or {@code UTF-8} if none configured. | ||
// * | ||
// * @return charset to use when reading {@link #data()} if needed by the parser | ||
// */ | ||
// Charset charset(); | ||
// } | ||
} |
Oops, something went wrong.