blob: 67f429e79894e7d86e3383fb1bd4e027c7e4ac51 [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>Config</title>
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Config";
}
}
catch(err) {
}
//-->
var methods = {"i0":6,"i1":6,"i2":6,"i3":6};
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],4:["t3","Abstract 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>Prev&nbsp;Class</li>
<li><a href="../../../../org/eclipse/microprofile/config/ConfigProvider.html" title="class in org.eclipse.microprofile.config"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/eclipse/microprofile/config/Config.html" target="_top">Frames</a></li>
<li><a href="Config.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>Field&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>Field&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</div>
<h2 title="Interface Config" class="title">Interface Config</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public interface <span class="typeNameLabel">Config</span></pre>
<div class="block"><p>
Resolves the property value by searching through all configured
<a href="../../../../org/eclipse/microprofile/config/spi/ConfigSource.html" title="interface in org.eclipse.microprofile.config.spi"><code>ConfigSources</code></a>. If the same property is specified in multiple
<a href="../../../../org/eclipse/microprofile/config/spi/ConfigSource.html" title="interface in org.eclipse.microprofile.config.spi"><code>ConfigSources</code></a>, the value in the <a href="../../../../org/eclipse/microprofile/config/spi/ConfigSource.html" title="interface in org.eclipse.microprofile.config.spi"><code>ConfigSource</code></a> with the highest
ordinal will be used.
<p>If multiple <a href="../../../../org/eclipse/microprofile/config/spi/ConfigSource.html" title="interface in org.eclipse.microprofile.config.spi"><code>ConfigSources</code></a> are specified with
the same ordinal, the <a href="../../../../org/eclipse/microprofile/config/spi/ConfigSource.html#getName--"><code>ConfigSource.getName()</code></a> will be used for sorting.
<p>
The config objects produced via the injection model <pre>@Inject Config</pre> are guaranteed to be serializable, while
the programmatically created ones are not required to be serializable.
<p>
If one or more converters are registered for a class of a requested value then one of the registered converters
which has the highest priority is used to convert the string value retrieved from config sources.
The highest priority means the highest priority number.
For more information about converters, see <a href="../../../../org/eclipse/microprofile/config/spi/Converter.html" title="interface in org.eclipse.microprofile.config.spi"><code>Converter</code></a>
<h3>Usage</h3>
For accessing the config you can use the <a href="../../../../org/eclipse/microprofile/config/ConfigProvider.html" title="class in org.eclipse.microprofile.config"><code>ConfigProvider</code></a>:
<pre>
public void doSomething(
Config cfg = ConfigProvider.getConfig();
String archiveUrl = cfg.getString("my.project.archive.endpoint", String.class);
Integer archivePort = cfg.getValue("my.project.archive.port", Integer.class);
</pre>
<p>It is also possible to inject the Config if a DI container is available:
<pre>
public class MyService {
&#064;Inject
private Config config;
}
</pre>
<p>See <a href="../../../../org/eclipse/microprofile/config/Config.html#getValue-java.lang.String-java.lang.Class-"><code>getValue(String, Class)</code></a> and <a href="../../../../org/eclipse/microprofile/config/Config.html#getOptionalValue-java.lang.String-java.lang.Class-"><code>getOptionalValue(String, Class)</code></a> for accessing a configured value.
<p>Configured values can also be accessed via injection.
See <a href="../../../../org/eclipse/microprofile/config/inject/ConfigProperty.html" title="annotation in org.eclipse.microprofile.config.inject"><code>ConfigProperty</code></a> for more information.</div>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ========== 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></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.Iterable&lt;<a href="../../../../org/eclipse/microprofile/config/spi/ConfigSource.html" title="interface in org.eclipse.microprofile.config.spi">ConfigSource</a>&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/eclipse/microprofile/config/Config.html#getConfigSources--">getConfigSources</a></span>()</code>&nbsp;</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>&lt;T&gt;&nbsp;java.util.Optional&lt;T&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/eclipse/microprofile/config/Config.html#getOptionalValue-java.lang.String-java.lang.Class-">getOptionalValue</a></span>(java.lang.String&nbsp;propertyName,
java.lang.Class&lt;T&gt;&nbsp;propertyType)</code>
<div class="block">Return the resolved property value with the specified type for the
specified property name from the underlying <a href="../../../../org/eclipse/microprofile/config/spi/ConfigSource.html" title="interface in org.eclipse.microprofile.config.spi"><code>ConfigSources</code></a>.</div>
</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>java.lang.Iterable&lt;java.lang.String&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/eclipse/microprofile/config/Config.html#getPropertyNames--">getPropertyNames</a></span>()</code>
<div class="block">Return a collection of property names.</div>
</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code>&lt;T&gt;&nbsp;T</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/eclipse/microprofile/config/Config.html#getValue-java.lang.String-java.lang.Class-">getValue</a></span>(java.lang.String&nbsp;propertyName,
java.lang.Class&lt;T&gt;&nbsp;propertyType)</code>
<div class="block">Return the resolved property value with the specified type for the
specified property name from the underlying <a href="../../../../org/eclipse/microprofile/config/spi/ConfigSource.html" title="interface in org.eclipse.microprofile.config.spi"><code>ConfigSources</code></a>.</div>
</td>
</tr>
</table>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="getValue-java.lang.String-java.lang.Class-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getValue</h4>
<pre>&lt;T&gt;&nbsp;T&nbsp;getValue(java.lang.String&nbsp;propertyName,
java.lang.Class&lt;T&gt;&nbsp;propertyType)</pre>
<div class="block">Return the resolved property value with the specified type for the
specified property name from the underlying <a href="../../../../org/eclipse/microprofile/config/spi/ConfigSource.html" title="interface in org.eclipse.microprofile.config.spi"><code>ConfigSources</code></a>.
If this method gets used very often then consider to locally store the configured value.</div>
<dl>
<dt><span class="paramLabel">Type Parameters:</span></dt>
<dd><code>T</code> - The property type</dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>propertyName</code> - The configuration propertyName.</dd>
<dd><code>propertyType</code> - The type into which the resolve property value should get converted</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the resolved property value as an object of the requested type.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if the property cannot be converted to the specified type.</dd>
<dd><code>java.util.NoSuchElementException</code> - if the property isn't present in the configuration.</dd>
</dl>
</li>
</ul>
<a name="getOptionalValue-java.lang.String-java.lang.Class-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getOptionalValue</h4>
<pre>&lt;T&gt;&nbsp;java.util.Optional&lt;T&gt;&nbsp;getOptionalValue(java.lang.String&nbsp;propertyName,
java.lang.Class&lt;T&gt;&nbsp;propertyType)</pre>
<div class="block">Return the resolved property value with the specified type for the
specified property name from the underlying <a href="../../../../org/eclipse/microprofile/config/spi/ConfigSource.html" title="interface in org.eclipse.microprofile.config.spi"><code>ConfigSources</code></a>.
If this method is used very often then consider to locally store the configured value.</div>
<dl>
<dt><span class="paramLabel">Type Parameters:</span></dt>
<dd><code>T</code> - The property type</dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>propertyName</code> - The configuration propertyName.</dd>
<dd><code>propertyType</code> - The type into which the resolve property value should be converted</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>The resolved property value as an Optional of the requested type.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if the property cannot be converted to the specified type.</dd>
</dl>
</li>
</ul>
<a name="getPropertyNames--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getPropertyNames</h4>
<pre>java.lang.Iterable&lt;java.lang.String&gt;&nbsp;getPropertyNames()</pre>
<div class="block">Return a collection of property names.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the names of all configured keys of the underlying configuration.</dd>
</dl>
</li>
</ul>
<a name="getConfigSources--">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>getConfigSources</h4>
<pre>java.lang.Iterable&lt;<a href="../../../../org/eclipse/microprofile/config/spi/ConfigSource.html" title="interface in org.eclipse.microprofile.config.spi">ConfigSource</a>&gt;&nbsp;getConfigSources()</pre>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>all currently registered <a href="../../../../org/eclipse/microprofile/config/spi/ConfigSource.html" title="interface in org.eclipse.microprofile.config.spi"><code>configsources</code></a> sorted with descending ordinal and ConfigSource name</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>Prev&nbsp;Class</li>
<li><a href="../../../../org/eclipse/microprofile/config/ConfigProvider.html" title="class in org.eclipse.microprofile.config"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/eclipse/microprofile/config/Config.html" target="_top">Frames</a></li>
<li><a href="Config.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>Field&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>Field&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>