blob: d95f8aadff22934be051b6b7adde2fce150088fb [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>ConfigProvider</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="ConfigProvider";
}
}
catch(err) {
}
//-->
var methods = {"i0":9,"i1":9};
var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],8:["t4","Concrete 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/Config.html" title="interface in org.eclipse.microprofile.config"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li>Next&nbsp;Class</li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/eclipse/microprofile/config/ConfigProvider.html" target="_top">Frames</a></li>
<li><a href="ConfigProvider.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="Class ConfigProvider" class="title">Class ConfigProvider</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li>org.eclipse.microprofile.config.ConfigProvider</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public final class <span class="typeNameLabel">ConfigProvider</span>
extends java.lang.Object</pre>
<div class="block"><p>
This is the central class to access a <a href="../../../../org/eclipse/microprofile/config/Config.html" title="interface in org.eclipse.microprofile.config"><code>Config</code></a>.
A <a href="../../../../org/eclipse/microprofile/config/Config.html" title="interface in org.eclipse.microprofile.config"><code>Config</code></a> provides access to application Configuration.
That might be auto-discovered <code>Config</code> or even manually created one.
<p>
The default usage is to use <a href="../../../../org/eclipse/microprofile/config/ConfigProvider.html#getConfig--"><code>getConfig()</code></a> to automatically pick up the
'Configuration' for the Thread Context ClassLoader (See
<code>Thread.getContextClassLoader()</code>).
<p>
A 'Configuration' consists of the information collected from the registered <a href="../../../../org/eclipse/microprofile/config/spi/ConfigSource.html" title="interface in org.eclipse.microprofile.config.spi"><code>ConfigSources</code></a>.
These <a href="../../../../org/eclipse/microprofile/config/spi/ConfigSource.html" title="interface in org.eclipse.microprofile.config.spi"><code>ConfigSources</code></a> get sorted according to
their <em>ordinal</em> defined via <a href="../../../../org/eclipse/microprofile/config/spi/ConfigSource.html#getOrdinal--"><code>ConfigSource.getOrdinal()</code></a>.
Thus it is possible to overwrite configuration by providing in a ConfigSource with higher importance from outside.
<p>
It is also possible to register custom <a href="../../../../org/eclipse/microprofile/config/spi/ConfigSource.html" title="interface in org.eclipse.microprofile.config.spi"><code>ConfigSources</code></a> to flexibly
extend the configuration mechanism. An example would be to pick up
configuration values from a database table.
Example usage:
<pre>
String restUrl = ConfigProvider.getConfig().getValue(&quot;myproject.some.remote.service.url&quot;, String.class);
Integer port = ConfigProvider.getConfig().getValue(&quot;myproject.some.remote.service.port&quot;, Integer.class);
</pre>
For more advanced use cases like e.g. registering a manually created <a href="../../../../org/eclipse/microprofile/config/Config.html" title="interface in org.eclipse.microprofile.config"><code>Config</code></a> please see
<a href="../../../../org/eclipse/microprofile/config/spi/ConfigProviderResolver.html#registerConfig-org.eclipse.microprofile.config.Config-java.lang.ClassLoader-"><code>ConfigProviderResolver.registerConfig(Config, ClassLoader)</code></a> and <a href="../../../../org/eclipse/microprofile/config/spi/ConfigProviderResolver.html#getBuilder--"><code>ConfigProviderResolver.getBuilder()</code></a>.</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="t1" class="tableTab"><span><a href="javascript:show(1);">Static Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete 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>static <a href="../../../../org/eclipse/microprofile/config/Config.html" title="interface in org.eclipse.microprofile.config">Config</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/eclipse/microprofile/config/ConfigProvider.html#getConfig--">getConfig</a></span>()</code>
<div class="block">Provide a <a href="../../../../org/eclipse/microprofile/config/Config.html" title="interface in org.eclipse.microprofile.config"><code>Config</code></a> based on all <a href="../../../../org/eclipse/microprofile/config/spi/ConfigSource.html" title="interface in org.eclipse.microprofile.config.spi"><code>ConfigSources</code></a> of the
current Thread Context ClassLoader (TCCL)</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>static <a href="../../../../org/eclipse/microprofile/config/Config.html" title="interface in org.eclipse.microprofile.config">Config</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/eclipse/microprofile/config/ConfigProvider.html#getConfig-java.lang.ClassLoader-">getConfig</a></span>(java.lang.ClassLoader&nbsp;cl)</code>
<div class="block">Provide a <a href="../../../../org/eclipse/microprofile/config/Config.html" title="interface in org.eclipse.microprofile.config"><code>Config</code></a> based on all <a href="../../../../org/eclipse/microprofile/config/spi/ConfigSource.html" title="interface in org.eclipse.microprofile.config.spi"><code>ConfigSources</code></a> of the
specified ClassLoader</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.Object</h3>
<code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li>
</ul>
</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="getConfig--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getConfig</h4>
<pre>public static&nbsp;<a href="../../../../org/eclipse/microprofile/config/Config.html" title="interface in org.eclipse.microprofile.config">Config</a>&nbsp;getConfig()</pre>
<div class="block">Provide a <a href="../../../../org/eclipse/microprofile/config/Config.html" title="interface in org.eclipse.microprofile.config"><code>Config</code></a> based on all <a href="../../../../org/eclipse/microprofile/config/spi/ConfigSource.html" title="interface in org.eclipse.microprofile.config.spi"><code>ConfigSources</code></a> of the
current Thread Context ClassLoader (TCCL)
<p>
<p>
The <a href="../../../../org/eclipse/microprofile/config/Config.html" title="interface in org.eclipse.microprofile.config"><code>Config</code></a> will be stored for future retrieval.
<p>
There is exactly a single Config instance per ClassLoader</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the config object for the thread context classloader</dd>
</dl>
</li>
</ul>
<a name="getConfig-java.lang.ClassLoader-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>getConfig</h4>
<pre>public static&nbsp;<a href="../../../../org/eclipse/microprofile/config/Config.html" title="interface in org.eclipse.microprofile.config">Config</a>&nbsp;getConfig(java.lang.ClassLoader&nbsp;cl)</pre>
<div class="block">Provide a <a href="../../../../org/eclipse/microprofile/config/Config.html" title="interface in org.eclipse.microprofile.config"><code>Config</code></a> based on all <a href="../../../../org/eclipse/microprofile/config/spi/ConfigSource.html" title="interface in org.eclipse.microprofile.config.spi"><code>ConfigSources</code></a> of the
specified ClassLoader
<p>
There is exactly a single Config instance per ClassLoader</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>cl</code> - the specified classloader</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the config for the specified classloader</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/Config.html" title="interface in org.eclipse.microprofile.config"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li>Next&nbsp;Class</li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/eclipse/microprofile/config/ConfigProvider.html" target="_top">Frames</a></li>
<li><a href="ConfigProvider.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>