| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| <!-- NewPage --> |
| <html lang="en"> |
| <head> |
| <title>org.eclipse.microprofile.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="org.eclipse.microprofile.config"; |
| } |
| } |
| catch(err) { |
| } |
| //--> |
| </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 class="navBarCell1Rev">Package</li> |
| <li>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/auth/package-summary.html">Prev Package</a></li> |
| <li><a href="../../../../org/eclipse/microprofile/config/inject/package-summary.html">Next Package</a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../index.html?org/eclipse/microprofile/config/package-summary.html" target="_top">Frames</a></li> |
| <li><a href="package-summary.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_top"> |
| <li><a href="../../../../allclasses-noframe.html">All 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> |
| <a name="skip.navbar.top"> |
| <!-- --> |
| </a></div> |
| <!-- ========= END OF TOP NAVBAR ========= --> |
| <div class="header"> |
| <h1 title="Package" class="title">Package org.eclipse.microprofile.config</h1> |
| <div class="docSummary"> |
| <div class="block">Configuration for Java Microprofile</div> |
| </div> |
| <p>See: <a href="#package.description">Description</a></p> |
| </div> |
| <div class="contentContainer"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Interface Summary table, listing interfaces, and an explanation"> |
| <caption><span>Interface Summary</span><span class="tabEnd"> </span></caption> |
| <tr> |
| <th class="colFirst" scope="col">Interface</th> |
| <th class="colLast" scope="col">Description</th> |
| </tr> |
| <tbody> |
| <tr class="altColor"> |
| <td class="colFirst"><a href="../../../../org/eclipse/microprofile/config/Config.html" title="interface in org.eclipse.microprofile.config">Config</a></td> |
| <td class="colLast"> |
| <div class="block"> |
| 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>.</div> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </li> |
| <li class="blockList"> |
| <table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Class Summary table, listing classes, and an explanation"> |
| <caption><span>Class Summary</span><span class="tabEnd"> </span></caption> |
| <tr> |
| <th class="colFirst" scope="col">Class</th> |
| <th class="colLast" scope="col">Description</th> |
| </tr> |
| <tbody> |
| <tr class="altColor"> |
| <td class="colFirst"><a href="../../../../org/eclipse/microprofile/config/ConfigProvider.html" title="class in org.eclipse.microprofile.config">ConfigProvider</a></td> |
| <td class="colLast"> |
| <div class="block"> |
| 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>.</div> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </li> |
| </ul> |
| <a name="package.description"> |
| <!-- --> |
| </a> |
| <h2 title="Package org.eclipse.microprofile.config Description">Package org.eclipse.microprofile.config Description</h2> |
| <div class="block"><p>Configuration for Java Microprofile |
| |
| <h2>Rational</h2> |
| |
| <p>For many project artifacts (e.g. WAR, EAR) it should be possible to build them only once |
| and then install them at different customers, stages, etc. |
| They need to target those different execution environments without the necessity of any repackaging. |
| In other words: depending on the situation they need different configuration. |
| |
| <p>This is easily achievable by having a set of default configuration values inside the project artifact. |
| But be able to overwrite those default values from external. |
| |
| <h2>How it works</h2> |
| |
| <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 <code>ConfigSources</code> get sorted according to their <i>ordinal</i>. |
| That way it is possible to overwrite configuration with lower importance from outside. |
| |
| <p>By default there are 3 ConfigSources: |
| |
| <ul> |
| <li><code>System.getenv()</code> (ordinal=400)</li> |
| <li><code>System.getProperties()</code> (ordinal=300)</li> |
| <li>all <code>META-INF/microprofile-config.properties</code> files on the ClassPath. |
| (ordinal=100, separately configurable via a config_ordinal property inside each file)</li> |
| </ul> |
| |
| <p>That means that one can put the default configuration in a <code>META-INF/microprofile-config.properties</code> anywhere on the classpath. |
| and the Operations team can later simply e.g set a system property to change this default configuration. |
| |
| <p>It is of course also possible to register own <a href="../../../../org/eclipse/microprofile/config/spi/ConfigSource.html" title="interface in org.eclipse.microprofile.config.spi"><code>ConfigSources</code></a>. |
| A <code>ConfigSource</code> could e.g. read configuration values from a database table, a remote server, etc |
| |
| <h2>Accessing and Using the Configuration</h2> |
| |
| <p> The configuration of an application is represented by an instance of <a href="../../../../org/eclipse/microprofile/config/Config.html" title="interface in org.eclipse.microprofile.config"><code>Config</code></a>. |
| The <a href="../../../../org/eclipse/microprofile/config/Config.html" title="interface in org.eclipse.microprofile.config"><code>Config</code></a> can be accessed via the <a href="../../../../org/eclipse/microprofile/config/ConfigProvider.html" title="class in org.eclipse.microprofile.config"><code>ConfigProvider</code></a>. |
| |
| <pre> |
| Config config = ConfigProvider.getConfig(); |
| String restUrl = config.getValue("myproject.some.endpoint.url", String.class); |
| </pre> |
| |
| <p> Of course we also support injection via a JSR-330 DI container: |
| <pre> |
| @Inject |
| @ConfigProperty(name="myproject.some.endpoint.url"); |
| private String restUrl; |
| </pre></div> |
| </div> |
| <!-- ======= 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 class="navBarCell1Rev">Package</li> |
| <li>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/auth/package-summary.html">Prev Package</a></li> |
| <li><a href="../../../../org/eclipse/microprofile/config/inject/package-summary.html">Next Package</a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../index.html?org/eclipse/microprofile/config/package-summary.html" target="_top">Frames</a></li> |
| <li><a href="package-summary.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_bottom"> |
| <li><a href="../../../../allclasses-noframe.html">All 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> |
| <a name="skip.navbar.bottom"> |
| <!-- --> |
| </a></div> |
| <!-- ======== END OF BOTTOM NAVBAR ======= --> |
| </body> |
| </html> |