All Downloads are FREE. Search and download functionalities are using the official Maven repository.

be.atbash.config.spi.AbstractConfigSource Maven / Gradle / Ivy

/*
 * Copyright 2017-2019 Rudy De Busscher
 *
 * 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 be.atbash.config.spi;

import org.eclipse.microprofile.config.spi.ConfigSource;

import java.util.Set;

/**
 *
 */

public abstract class AbstractConfigSource implements ConfigSource {

    /**
     * Gets all property names known to this config source, without evaluating the values.
     * 

* For backwards compatibility, there is a default implementation that just returns the keys of {@code getProperties()} * slower ConfigSource implementations should replace this with a more performant implementation * * @return the set of property keys that are known to this ConfigSource */ public Set getPropertyNames() { return getProperties().keySet(); } /** * Return the ordinal for this config source. If a property is specified in multiple config sources, the value * in the config source with the highest ordinal takes precedence. * For the config sources with the same ordinal value, the config source names will * be used for sorting according to string sorting criteria. * Note that this property only gets evaluated during ConfigSource discovery. *

* The default ordinals for the default config sources: *

    *
  1. System properties (default ordinal=400)
  2. *
  3. Environment properties (default ordinal=300)
  4. *
  5. /META-INF/microprofile-config.properties (default ordinal=100)
  6. *
*

*

* Any ConfigSource part of an application will typically use an ordinal between 0 and 200. * ConfigSource provided by the container or 'environment' typically use an ordinal higher than 200. * A framework which intends have values overwritten by the application will use ordinals between 0 and 100. * The property "config_ordinal" can be specified to override the default value. * * @return the ordinal value */ public int getOrdinal() { String configOrdinal = getValue(CONFIG_ORDINAL); if (configOrdinal != null) { try { return Integer.parseInt(configOrdinal); } catch (NumberFormatException ignored) { // Ignored } } return 100; // DEFAULT_VALUE } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy