blob: b9edabe6c4ea191b7df8072d9598ae4c82c61550 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<title>ConfigSource</title>
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../../script.js"></script>
<link rel="shortcut icon" href="/img/microprofile-favicon.png">
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="ConfigSource";
}
}
catch(err) {
}
//-->
var methods = {"i0":6,"i1":18,"i2":18,"i3":6,"i4":6};
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],4:["t3","Abstract Methods"],16:["t5","Default Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/eclipse/microprofile/config/spi/ConfigProviderResolver.html" title="class in org.eclipse.microprofile.config.spi"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../../org/eclipse/microprofile/config/spi/ConfigSourceProvider.html" title="interface in org.eclipse.microprofile.config.spi"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/eclipse/microprofile/config/spi/ConfigSource.html" target="_top">Frames</a></li>
<li><a href="ConfigSource.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#field.summary">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#field.detail">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.eclipse.microprofile.config.spi</div>
<h2 title="Interface ConfigSource" class="title">Interface ConfigSource</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public interface <span class="typeNameLabel">ConfigSource</span></pre>
<div class="block">A <em>configuration source</em> which provides configuration values from a specific place. Some examples of
configuration sources may include:
<ul>
<li>a JNDI-backed naming service</li>
<li>a properties file</li>
<li>a database table</li>
</ul>
<p>
Implementations of this interface have the responsibility to get the value corresponding to a property name, and to
enumerate available property names.
<p>
A <em>configuration source</em> is always read-only; any potential updates of the backing configuration values must
be handled directly inside each configuration source instance.
<h2 id="default_config_sources">Default configuration sources</h2>
<p>
Some configuration sources are known as <em>default configuration sources</em>. These configuration sources are
normally available in all automatically-created configurations, and can be
<a href="../../../../../org/eclipse/microprofile/config/spi/ConfigBuilder.html#addDefaultSources--">manually added</a> to manually-created configurations as well. The default
configuration sources are:
<ol>
<li>System properties, with an <a href="../../../../../org/eclipse/microprofile/config/spi/ConfigSource.html#getOrdinal--">ordinal value</a> of
<code>400</code></li>
<li>Environment properties, with an ordinal value of <code>300</code></li>
<li>The <code>/META-INF/microprofile-config.properties</code> resource, with
an ordinal value of <code>100</code></li>
</ol>
<h3>Environment variable name mapping rules</h3>
<p>
Some operating systems allow only alphabetic characters or an underscore (<code>_</code>) in environment variable names.
Other characters such as <code>.</code>, <code>/</code>, etc. may be disallowed. In order to set a value for a config property
that has a name containing such disallowed characters from an environment variable, the following rules are used.
<p>
Three environment variables are searched for a given property name (e.g. "<code>com.ACME.size</code>"):
<ol>
<li>The exact name (i.e. "<code>com.ACME.size</code>")</li>
<li>The name, with each character that is neither alphanumeric nor _ replaced with _ (i.e.
"<code>com_ACME_size</code>")</li>
<li>The name, with each character that is neither alphanumeric nor _ replaced with _ and then converted to upper case
(i.e. "<code>COM_ACME_SIZE</code>")</li>
</ol>
<p>
The first of these environment variables that is found for a given name is returned.
<h3 id="discovery">Configuration source discovery</h3>
<p>
Discovered configuration sources are loaded via the <code>ServiceLoader</code> mechanism and and can be
registered by providing a resource named <code>META-INF/services/org.eclipse.microprofile.config.spi.ConfigSource</code>,
which contains the fully qualified <code>ConfigSource</code> implementation class name as its content.
<p>
Configuration sources may also be added by defining <a href="../../../../../org/eclipse/microprofile/config/spi/ConfigSourceProvider.html" title="interface in org.eclipse.microprofile.config.spi"><code>ConfigSourceProvider</code></a>
classes which are discoverable in this manner.
<h3>Closing configuration sources</h3>
<p>
If a configuration source implements the <code>AutoCloseable</code> interface, then its close method will be called when the underlying configuration is released.</div>
<dl>
<dt><span class="simpleTagLabel">Examples (en):</span></dt>
<dd><a href="../../../../../../../../tomee-9.0/examples/mp-config-source-database.html">mp-config-source-database</a></dd>
<dt><span class="simpleTagLabel">Examples (es):</span></dt>
<dd><a href="../../../../../../../../tomee-9.0/es/examples/mp-config-source-database.html">mp-config-source-database</a></dd>
<dt><span class="simpleTagLabel">Examples (pt):</span></dt>
<dd><a href="../../../../../../../../tomee-9.0/pt/examples/mp-config-source-database.html">mp-config-source-database</a></dd>
</dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- =========== FIELD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="field.summary">
<!-- -->
</a>
<h3>Field Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Field Summary table, listing fields, and an explanation">
<caption><span>Fields</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Field and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static java.lang.String</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/eclipse/microprofile/config/spi/ConfigSource.html#CONFIG_ORDINAL">CONFIG_ORDINAL</a></span></code>
<div class="block">The name of the configuration ordinal property, "<code>config_ordinal</code>".</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/eclipse/microprofile/config/spi/ConfigSource.html#DEFAULT_ORDINAL">DEFAULT_ORDINAL</a></span></code>
<div class="block">The default configuration ordinal value, <code>100</code>.</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method.summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t3" class="tableTab"><span><a href="javascript:show(4);">Abstract Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t5" class="tableTab"><span><a href="javascript:show(16);">Default Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr id="i0" class="altColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/eclipse/microprofile/config/spi/ConfigSource.html#getName--">getName</a></span>()</code>
<div class="block">The name of the configuration source.</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>default int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/eclipse/microprofile/config/spi/ConfigSource.html#getOrdinal--">getOrdinal</a></span>()</code>
<div class="block">Return the ordinal priority value of this configuration source.</div>
</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>default java.util.Map&lt;java.lang.String,java.lang.String&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/eclipse/microprofile/config/spi/ConfigSource.html#getProperties--">getProperties</a></span>()</code>
<div class="block">Return the properties in this configuration source as a map.</div>
</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code>java.util.Set&lt;java.lang.String&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/eclipse/microprofile/config/spi/ConfigSource.html#getPropertyNames--">getPropertyNames</a></span>()</code>
<div class="block">Gets all property names known to this configuration source, potentially without evaluating the values.</div>
</td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/eclipse/microprofile/config/spi/ConfigSource.html#getValue-java.lang.String-">getValue</a></span>(java.lang.String&nbsp;propertyName)</code>
<div class="block">Return the value for the specified property in this configuration source.</div>
</td>
</tr>
</table>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ FIELD DETAIL =========== -->
<ul class="blockList">
<li class="blockList"><a name="field.detail">
<!-- -->
</a>
<h3>Field Detail</h3>
<a name="CONFIG_ORDINAL">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>CONFIG_ORDINAL</h4>
<pre>static final&nbsp;java.lang.String CONFIG_ORDINAL</pre>
<div class="block">The name of the configuration ordinal property, "<code>config_ordinal</code>".</div>
<dl>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../../../constant-values.html#org.eclipse.microprofile.config.spi.ConfigSource.CONFIG_ORDINAL">Constant Field Values</a></dd>
</dl>
</li>
</ul>
<a name="DEFAULT_ORDINAL">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>DEFAULT_ORDINAL</h4>
<pre>static final&nbsp;int DEFAULT_ORDINAL</pre>
<div class="block">The default configuration ordinal value, <code>100</code>.</div>
<dl>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../../../constant-values.html#org.eclipse.microprofile.config.spi.ConfigSource.DEFAULT_ORDINAL">Constant Field Values</a></dd>
</dl>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="getProperties--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getProperties</h4>
<pre>default&nbsp;java.util.Map&lt;java.lang.String,java.lang.String&gt;&nbsp;getProperties()</pre>
<div class="block">Return the properties in this configuration source as a map.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a map containing properties of this configuration source</dd>
</dl>
</li>
</ul>
<a name="getPropertyNames--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getPropertyNames</h4>
<pre>java.util.Set&lt;java.lang.String&gt;&nbsp;getPropertyNames()</pre>
<div class="block">Gets all property names known to this configuration source, potentially without evaluating the values. The
returned property names may be a subset of the names of the total set of retrievable properties in this config
source.
<p>
The returned set is not required to allow concurrent or multi-threaded iteration; however, if the same set is
returned by multiple calls to this method, then the implementation must support concurrent and multi-threaded
iteration of that set.
<p>
The set of keys returned <em>may</em> be a point-in-time snapshot, or <em>may</em> change over time (even during
active iteration) to reflect dynamic changes to the available set of keys.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a set of property names that are known to this configuration source</dd>
</dl>
</li>
</ul>
<a name="getOrdinal--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getOrdinal</h4>
<pre>default&nbsp;int&nbsp;getOrdinal()</pre>
<div class="block">Return the ordinal priority value of this configuration source.
<p>
If a property is specified in multiple config sources, the value in the config source with the highest ordinal
takes precedence. For configuration sources with the same ordinal value, the configuration source name will be
used for sorting according to string sorting criteria.
<p>
Note that this method is only evaluated during the construction of the configuration, and does not affect the
ordering of configuration sources within a configuration after that time.
<p>
The ordinal values for the default configuration sources can be found
<a href="#default_config_sources">above</a>.
<p>
Any configuration source which is a part of an application will typically use an ordinal between 0 and 200.
Configuration sources provided by the container or 'environment' typically use an ordinal higher than 200. A
framework which intends have values overridden by the application will use ordinals between 0 and 100.
<p>
The default implementation of this method looks for a configuration property named "<a href="../../../../../org/eclipse/microprofile/config/spi/ConfigSource.html#CONFIG_ORDINAL"><code>config_ordinal</code></a>" to determine the ordinal value for this configuration source. If the property is not found, then
the <a href="../../../../../org/eclipse/microprofile/config/spi/ConfigSource.html#DEFAULT_ORDINAL">default ordinal value</a> is used.
<p>
This method may be overridden by configuration source implementations to provide a different behavior.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the ordinal value</dd>
</dl>
</li>
</ul>
<a name="getValue-java.lang.String-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getValue</h4>
<pre>java.lang.String&nbsp;getValue(java.lang.String&nbsp;propertyName)</pre>
<div class="block">Return the value for the specified property in this configuration source.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>propertyName</code> - the property name</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the property value, or <code>null</code> if the property is not present</dd>
</dl>
</li>
</ul>
<a name="getName--">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>getName</h4>
<pre>java.lang.String&nbsp;getName()</pre>
<div class="block">The name of the configuration source. The name might be used for logging or for analysis of configured values,
and also may be used in <a href="../../../../../org/eclipse/microprofile/config/spi/ConfigSource.html#getOrdinal--">ordering decisions</a>.
<p>
An example of a configuration source name is "<code>property-file mylocation/myprops.properties</code>".</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the name of the configuration source</dd>
</dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/eclipse/microprofile/config/spi/ConfigProviderResolver.html" title="class in org.eclipse.microprofile.config.spi"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../../org/eclipse/microprofile/config/spi/ConfigSourceProvider.html" title="interface in org.eclipse.microprofile.config.spi"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/eclipse/microprofile/config/spi/ConfigSource.html" target="_top">Frames</a></li>
<li><a href="ConfigSource.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#field.summary">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#field.detail">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>