http://git-wip-us.apache.org/repos/asf/incubator-tamaya-site/blob/8e3904a8/documentation-new/extensions/mod_functions.html ---------------------------------------------------------------------- diff --git a/documentation-new/extensions/mod_functions.html b/documentation-new/extensions/mod_functions.html new file mode 100644 index 0000000..c800cda --- /dev/null +++ b/documentation-new/extensions/mod_functions.html @@ -0,0 +1,373 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <meta charset="utf-8"/> + <title>Apache Tamaya - Extension: Functions</title> + <meta name="viewport" content="width=device-width, initial-scale=1.0"/> + <meta name="description" content=""/> + <meta name="author" content=""/> + <meta name="keywords" content=""/> + <meta name="generator" content="'JBake '+'${version}"/> + + <!-- Le styles --> + <link href="../../css/bootstrap.min.css" rel="stylesheet"/> + <link href="../../css/asciidoctor.css" rel="stylesheet"/> + <link href="../../css/base.css" rel="stylesheet"/> + <link href="../../css/prettify.css" rel="stylesheet"/> + + <!-- HTML5 shim, for IE6-8 support of HTML5 elements --> + <!--[if lt IE 9]> + <script src="../../js/html5shiv.min.js"></script> + <![endif]--> + + <!-- Fav and touch icons from ASF --> + <link rel="shortcut icon" href="../../favicon.ico"/> + <link rel="apple-touch-icon" sizes="57x57" href="../../favicons/apple-touch-icon-57x57.png"/> + <link rel="apple-touch-icon" sizes="60x60" href="../../favicons/apple-touch-icon-60x60.png"/> + <link rel="apple-touch-icon" sizes="72x72" href="../../favicons/apple-touch-icon-72x72.png"/> + <link rel="apple-touch-icon" sizes="76x76" href="../../favicons/apple-touch-icon-76x76.png"/> + <link rel="apple-touch-icon" sizes="114x114" href="../../favicons/apple-touch-icon-114x114.png"/> + <link rel="apple-touch-icon" sizes="120x120" href="../../favicons/apple-touch-icon-120x120.png"/> + <link rel="apple-touch-icon" sizes="144x144" href="../../favicons/apple-touch-icon-144x144.png"/> + <link rel="apple-touch-icon" sizes="152x152" href="../../favicons/apple-touch-icon-152x152.png"/> + <link rel="apple-touch-icon" sizes="180x180" href="../../favicons/apple-touch-icon-180x180.png"/> + <link rel="icon" type="image/png" href="../../favicons/favicon-32x32.png" sizes="32x32"/> + <link rel="icon" type="image/png" href="../../favicons/favicon-194x194.png" sizes="194x194"/> + <link rel="icon" type="image/png" href="../../favicons/favicon-96x96.png" sizes="96x96"/> + <link rel="icon" type="image/png" href="../../favicons/android-chrome-192x192.png" sizes="192x192"/> + <link rel="icon" type="image/png" href="../../favicons/favicon-16x16.png" sizes="16x16"/> + <link rel="manifest" href="../../favicons/manifest.json"/> + <link rel="shortcut icon" href="../../favicons/favicon.ico"/> + <meta name="msapplication-TileColor" content="#603cba"/> + <meta name="msapplication-TileImage" content="../../favicons/mstile-144x144.png"/> + <meta name="msapplication-config" content="../../favicons/browserconfig.xml"/> + <meta name="theme-color" content="#303284"/> + </head> + <body onload="prettyPrint()"> + <div id="wrap"> + <div> + + <!-- Fixed navbar --> + <div class="navbar navbar-default navbar-fixed-top" role="navigation"> + <div class="container"> + <div class="navbar-header"> + <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> + <span class="sr-only">Toggle navigation</span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </button> + <a class="navbar-brand" href="../../index.html">Apache Tamaya (incubating)</a> + </div> + <div class="navbar-collapse collapse"> + <ul class="nav navbar-nav"> + <li><a href="../../start.html">Tamaya in 5 minutes</a></li> + <li class="dropdown"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Documentation <b class="caret"></b></a> + <ul class="dropdown-menu"> + <li><a href="../../documentation/usecases.html">Use Cases and Requirements</a></li> + <li><a href="../../documentation/quickstart.html">Quickstart</a></li> + <li><a href="../../documentation/api.html">API</a></li> + <li><a href="../../documentation/core.html">Core</a></li> + <li><a href="../../documentation/extensions.html">Extension Guide</a></li> + <li class="divider"></li> + <li><a href="../../apidocs/stable/index.html">Javadoc 0.3-incubating (release/stable)</a></li> + <li><a href="../../apidocs/development/index.html">Javadoc 0.4-incubating-SNAPSHOT (development)</a></li> + </ul> + </li> + <li class="dropdown"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Development <b class="caret"></b></a> + <ul class="dropdown-menu"> + <li><a href="../../development/source.html">Sources</a></li> + <li><a href="../../development/community.html">Community</a></li> + <li><a href="../../development/team.html">Project Team</a></li> + <li><a target="_blank" href="https://builds.apache.org/view/S-Z/view/Tamaya/">CI / ASF Jenkins</a></li> + <li><a target="_blank" href="https://issues.apache.org/jira/browse/TAMAYA">Issues / ASF Jira</a></li> + <li><a href="../../devguide.html">Development Guide</a></li> + <li><a href="../../release-guide.html">Release Guide</a></li> + <li class="divider"></li> + <li><a href="../../development/possible-contributions.html">Possible Contributions</a></li> + </ul> + </li> + <li class="dropdown"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Releases <b class="caret"></b></a> + <ul class="dropdown-menu"> + <li><a href="../../download.html">Download</a></li> + <li><a href="../../history.html">Release History</a></li> + </ul> + </li> +<!-- Example: + <li class="dropdown"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a> + <ul class="dropdown-menu"> + <li><a href="#">Action</a></li> + <li><a href="#">Another action</a></li> + <li><a href="#">Something else here</a></li> + <li class="divider"></li> + <li class="dropdown-header">Nav header</li> + <li><a href="#">Separated link</a></li> + <li><a href="#">One more separated link</a></li> + </ul> + </li> +--> + <li><a href="../../sitemap.xml">Sitemap</a></li> + <li><a href="../../feed.xml">Subscribe</a></li> + </ul> + </div><!--/.nav-collapse --> + </div> + </div> + + </div> + <div class="container"> + + <div class="page-header"> + <h1>Apache Tamaya - Extension: Functions</h1> + </div> + + <p><em>2018-04-26</em></p> + + <p><div id="preamble"> +<div class="sectionbody"> +<!-- toc disabled --> +</div> +</div> +<div class="sect1"> +<h2 id="Functions">Tamaya Functions (Extension Module)</h2> +<div class="sectionbody"> +<div class="paragraph"> +<p>Tamaya <em>Functions</em> is an extension module. Refer to the <a href="../extensions.html">extensions documentation</a> for further details.</p> +</div> +<div class="sect2"> +<h3 id="_what_functionality_this_module_provides">What functionality this module provides ?</h3> +<div class="paragraph"> +<p>Tamaya <em>Functions</em> provides several functional extensions using the UnaryOperator<Config>,Function<Config, T> extension +points. Most functional extension are accessible from the ConfigurationFunctions singleton. Since the JSR API +does not provide any functional extension points it is recommended to adapt the Config instance into .FunctionalConfig. +Then, when importing the functional methods statically they can very easily applied, e.g.</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">import static org.apache.tamaya.functions.ConfigurationFunctions.*; + +FunctionalConfig fc = FunctionalConfig.of(ConfigProvider.getConfig()); +Set<String> sections = fc.with(areas("a", false).with(transitiveAreas());</code></pre> +</div> +</div> +<div class="paragraph"> +<p>The expression above returns all fully qualified section names that are child sections of the root section 'a'. +So given the entries a.b.entry1, a.b.entry2, a.a.entry3, a.b.c.entry4 the reult would be a, a.a, a.b, a.b.c.</p> +</div> +</div> +<div class="sect2"> +<h3 id="_compatibility">Compatibility</h3> +<div class="paragraph"> +<p>The module is based on Java 8, so it can be used with Java 8 and beyond.</p> +</div> +</div> +<div class="sect2"> +<h3 id="_installation">Installation</h3> +<div class="paragraph"> +<p>For using the functionality shown in this document you only must add the corresponding dependency to your module:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><dependency> + <groupId>org.apache.tamaya.ext</groupId> + <artifactId>tamaya-functions</artifactId> + <version>{tamaya_version}</version> +</dependency></code></pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_functionalconfig">FunctionalConfig</h3> +<div class="paragraph"> +<p>The FunctionalConfig actually adds the functional extension points with and query to .Config instance, which +allow to chain expressions as seen in the introductionary snippet:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public interface FunctionalConfig extends Config, ConfigContextSupplier { + + /** + * Enriches a {@link Config} instance with functional access points. + * @param config the config, not null + * @return a functional config instance. + */ + static FunctionalConfig of(Config config){ + ... + } + + default FunctionalConfig with(UnaryOperator<Config> operator); + default <T> T query(Function<Config, T> query); +}</code></pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_the_provided_functions">The Provided Functions</h3> +<div class="sect3"> +<h4 id="_functions_on_configurationfunctions">Functions on ConfigurationFunctions</h4> +<div class="paragraph"> +<p>The following sections explain the provided functions defined by ConfigurationFunctions singleton.</p> +</div> +<div class="ulist"> +<ul> +<li> +<p><strong>UnaryOperator<Config> filter(PropertyMatcher matcher)</strong> creates a UnaryOperator<Config> that creates a Configuration +containing only keys that are selected by the given <em>matcher predicate</em>. The PropertyMatcher hereby allows to evaluate not only +the <em>key</em>, but also the <em>value</em>.</p> +</li> +<li> +<p><strong>UnaryOperator<Config> map(KeyMapper keyMapper)</strong> creates a UnaryOperator<Config> that maps the keys as defined +by the given <em>keyMapper</em>.</p> +</li> +<li> +<p><strong>UnaryOperator<Config> section(String section)</strong> creates a UnaryOperator<Config> that creates a Configuration containing only +entries that are direct or indirect members of the given section.</p> +</li> +<li> +<p><strong>UnaryOperator<Config> section(String areaKey, boolean stripKeys)</strong> creates a UnaryOperator<Config> that creates a Configuration +containing only entries that are direct or indirect members of the given section. Hereby <em>stripKeys</em> allows to determine +if the returned entries should be relative to the search criteria {{stripKeys=true}} or absolute keys.</p> +</li> +<li> +<p><strong>isKeyInSection(String section, String sectionKey)</strong> allows to easily determine if a given <em>key</em> is a direct or indirect member +of a given section.</p> +</li> +<li> +<p><strong>boolean isKeyInSections(String key, String…​ sectionKeys)</strong> allows to easily determine if one key of given +<em>key</em> is a direct or indirect member of at least one of the given <em>sectionKeys</em>.</p> +</li> +<li> +<p><strong>Function<Config,Set<String>> sections()</strong> allows to query all the contained fully qualified section names (the ones that +also have parameters present).</p> +</li> +<li> +<p><strong>Function<Config,Set<String>> transitiveSections()</strong> allows to query all the contained fully qualified section names, +including the transitive closure of sections.</p> +</li> +<li> +<p><strong>Function<Config,Set<String>> sections(final Predicate<String> predicate)</strong> allows to query all the contained fully +qualified section names that are selected by the given <em>predicate</em>.</p> +</li> +<li> +<p><strong>Function<Config,Set<String>> sections(final Predicate<String> predicate)</strong> allows to query all the contained fully +qualified section names that are selected by the given <em>predicate</em>, including the transitive closure of sections +identified.</p> +</li> +<li> +<p><strong>UnaryOperator<Config> sectionsRecursive(String…​ sectionKeys)</strong> provides a UnaryOperator<Config> that filters all sections identified +by the given <em>sectionKeys</em> and its child sections.</p> +</li> +<li> +<p><strong>UnaryOperator<Config> sectionRecursive(final boolean stripKeys, final String…​ sectionKeys)</strong> provides a UnaryOperator<Config> +that filters all sections identified by the given <em>sectionKeys</em> and its child sections. <em>stripKeys</em> allows to +determine if the resulting configuration should be relative to the selected areas ({{stripKeys=true}}) or +absolute (filtering only).</p> +</li> +<li> +<p><strong>Function<Config,String> jsonInfo()</strong> returns a query that converts a Configuration into a JSON formatted String +representation.</p> +</li> +</ul> +</div> +</div> +<div class="sect3"> +<h4 id="_functions_on_configsourcefunctions">Functions on ConfigSourceFunctions</h4> +<div class="paragraph"> +<p>The following sections explain the provided functions defined by ConfigSourceFunctions singleton.</p> +</div> +<div class="ulist"> +<ul> +<li> +<p><strong>ConfigSource addMetaData(ConfigSource propertySource, Map<String,String> metaData)</strong> Creates a new ConfigSource +with the given metadata added.</p> +</li> +<li> +<p><strong>boolean isKeyInSection(String key, String sectionKey)</strong> Checks if the given <em>key</em> is a direct or indirect member of +one of the given <em>sectionKey</em>.</p> +</li> +<li> +<p><strong>boolean isKeyInSections(String key, String…​ sectionKeys)</strong> Checks if the given <em>key</em> is a direct or indirect member of +one of one of the given <em>sectionKeys</em>.</p> +</li> +<li> +<p><strong>Set<String> sections(Map<String, String> properties)</strong> Extracts the sections from the given properties.</p> +</li> +<li> +<p><strong>Set<String> transitiveSections(Map<String, String> properties)</strong> Extracts the transitive sections from the given +properties.</p> +</li> +<li> +<p><strong>Set<String> sections(Map<String, String> properties, final Predicate<String> predicate)</strong> Extracts the sections +from the given properties, also filtering with the given predicate.</p> +</li> +<li> +<p><strong>Set<String> transitiveSections(Map<String, String> properties, Predicate<String> predicate)</strong> Extracts the transitive +sections from the given properties, also filtering with the given predicate.</p> +</li> +<li> +<p><strong>Map<String,String> sectionsRecursive(Map<String, String> properties, String…​ sectionKeys)</strong> Creates w ConfigSource +only containing the sections that a direct or indirect children of the given <em>sectionKeys</em>.</p> +</li> +<li> +<p><strong>Map<String,String> sectionRecursive(Map<String, String> properties, boolean stripKeys, String…​ sectionKeys)</strong> Creates w ConfigSource +only containing the sections that a direct or indirect children of the given <em>sectionKeys</em>. With <em>stripKeys</em> one can +select of the returned values should be relative to its selection of be fully qualified.</p> +</li> +<li> +<p><strong>String stripSectionKeys(String key, String…​ sectionKeys)</strong> This function strips away the matching section key as given +in <em>sectionKeys</em> from a given <em>key</em>.</p> +</li> +</ul> +</div> +</div> +</div> +</div> +</div></p> + + <hr /> + </div> + </div> + <div> + <div id="push"></div> + + <div id="footer"> + <div class="container"> + <p class="muted credit">© 2014-<span>2018</span> Apache Software Foundation | Mixed with <a href="http://getbootstrap.com/">Bootstrap v3.1.1</a> + | Baked with <a href="http://jbake.org">JBake <span>v2.5.1</span></a> + at <span>2018-04-26</span> | + <a class="twitter-follow-button" data-show-count="false" href="https://twitter.com/tamayaconf">Follow @tamayaconf</a><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script> + </p> + <p> + <b>Disclaimer</b> + Apache Tamaya (incubating) is an effort undergoing + incubation at + The Apache Software Foundation (ASF), sponsored by + the name of Apache Incubator. Incubation is required of + all newly accepted projects until a further review indicates + that the infrastructure, communications, and decision making + process have stabilized in a manner consistent with other + successful ASF projects. While incubation status is not + necessarily a reflection of the completeness or stability of + the code, it does indicate that the project has yet to + be fully endorsed by the ASF. + Apache, Apache Tamaya, and the Apache Tamaya logo are registered trademarks or trademarks of The Apache Software Foundation in the U.S. and/or other countries.<br /> + <a href="https://incubator.apache.org/guides/website.html" style="border:0px;" target="_target"> + <img class="incubator-logo" src="../../logos/apache-incubator.png"/> + </a> + </p> + </div> + </div> + + <!-- Le javascript + ================================================== --> + <!-- Placed at the end of the document so the pages load faster --> + <script src="../../js/jquery-1.11.1.min.js"></script> + <script src="../../js/bootstrap.min.js"></script> + <script src="../../js/prettify.js"></script> + </div> + </body> +</html>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-site/blob/8e3904a8/documentation-new/extensions/mod_hazelcast.html ---------------------------------------------------------------------- diff --git a/documentation-new/extensions/mod_hazelcast.html b/documentation-new/extensions/mod_hazelcast.html new file mode 100644 index 0000000..785ad6e --- /dev/null +++ b/documentation-new/extensions/mod_hazelcast.html @@ -0,0 +1,306 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <meta charset="utf-8"/> + <title>Apache Tamaya - Extension: Integration with Hazelcast</title> + <meta name="viewport" content="width=device-width, initial-scale=1.0"/> + <meta name="description" content=""/> + <meta name="author" content=""/> + <meta name="keywords" content=""/> + <meta name="generator" content="'JBake '+'${version}"/> + + <!-- Le styles --> + <link href="../../css/bootstrap.min.css" rel="stylesheet"/> + <link href="../../css/asciidoctor.css" rel="stylesheet"/> + <link href="../../css/base.css" rel="stylesheet"/> + <link href="../../css/prettify.css" rel="stylesheet"/> + + <!-- HTML5 shim, for IE6-8 support of HTML5 elements --> + <!--[if lt IE 9]> + <script src="../../js/html5shiv.min.js"></script> + <![endif]--> + + <!-- Fav and touch icons from ASF --> + <link rel="shortcut icon" href="../../favicon.ico"/> + <link rel="apple-touch-icon" sizes="57x57" href="../../favicons/apple-touch-icon-57x57.png"/> + <link rel="apple-touch-icon" sizes="60x60" href="../../favicons/apple-touch-icon-60x60.png"/> + <link rel="apple-touch-icon" sizes="72x72" href="../../favicons/apple-touch-icon-72x72.png"/> + <link rel="apple-touch-icon" sizes="76x76" href="../../favicons/apple-touch-icon-76x76.png"/> + <link rel="apple-touch-icon" sizes="114x114" href="../../favicons/apple-touch-icon-114x114.png"/> + <link rel="apple-touch-icon" sizes="120x120" href="../../favicons/apple-touch-icon-120x120.png"/> + <link rel="apple-touch-icon" sizes="144x144" href="../../favicons/apple-touch-icon-144x144.png"/> + <link rel="apple-touch-icon" sizes="152x152" href="../../favicons/apple-touch-icon-152x152.png"/> + <link rel="apple-touch-icon" sizes="180x180" href="../../favicons/apple-touch-icon-180x180.png"/> + <link rel="icon" type="image/png" href="../../favicons/favicon-32x32.png" sizes="32x32"/> + <link rel="icon" type="image/png" href="../../favicons/favicon-194x194.png" sizes="194x194"/> + <link rel="icon" type="image/png" href="../../favicons/favicon-96x96.png" sizes="96x96"/> + <link rel="icon" type="image/png" href="../../favicons/android-chrome-192x192.png" sizes="192x192"/> + <link rel="icon" type="image/png" href="../../favicons/favicon-16x16.png" sizes="16x16"/> + <link rel="manifest" href="../../favicons/manifest.json"/> + <link rel="shortcut icon" href="../../favicons/favicon.ico"/> + <meta name="msapplication-TileColor" content="#603cba"/> + <meta name="msapplication-TileImage" content="../../favicons/mstile-144x144.png"/> + <meta name="msapplication-config" content="../../favicons/browserconfig.xml"/> + <meta name="theme-color" content="#303284"/> + </head> + <body onload="prettyPrint()"> + <div id="wrap"> + <div> + + <!-- Fixed navbar --> + <div class="navbar navbar-default navbar-fixed-top" role="navigation"> + <div class="container"> + <div class="navbar-header"> + <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> + <span class="sr-only">Toggle navigation</span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </button> + <a class="navbar-brand" href="../../index.html">Apache Tamaya (incubating)</a> + </div> + <div class="navbar-collapse collapse"> + <ul class="nav navbar-nav"> + <li><a href="../../start.html">Tamaya in 5 minutes</a></li> + <li class="dropdown"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Documentation <b class="caret"></b></a> + <ul class="dropdown-menu"> + <li><a href="../../documentation/usecases.html">Use Cases and Requirements</a></li> + <li><a href="../../documentation/quickstart.html">Quickstart</a></li> + <li><a href="../../documentation/api.html">API</a></li> + <li><a href="../../documentation/core.html">Core</a></li> + <li><a href="../../documentation/extensions.html">Extension Guide</a></li> + <li class="divider"></li> + <li><a href="../../apidocs/stable/index.html">Javadoc 0.3-incubating (release/stable)</a></li> + <li><a href="../../apidocs/development/index.html">Javadoc 0.4-incubating-SNAPSHOT (development)</a></li> + </ul> + </li> + <li class="dropdown"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Development <b class="caret"></b></a> + <ul class="dropdown-menu"> + <li><a href="../../development/source.html">Sources</a></li> + <li><a href="../../development/community.html">Community</a></li> + <li><a href="../../development/team.html">Project Team</a></li> + <li><a target="_blank" href="https://builds.apache.org/view/S-Z/view/Tamaya/">CI / ASF Jenkins</a></li> + <li><a target="_blank" href="https://issues.apache.org/jira/browse/TAMAYA">Issues / ASF Jira</a></li> + <li><a href="../../devguide.html">Development Guide</a></li> + <li><a href="../../release-guide.html">Release Guide</a></li> + <li class="divider"></li> + <li><a href="../../development/possible-contributions.html">Possible Contributions</a></li> + </ul> + </li> + <li class="dropdown"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Releases <b class="caret"></b></a> + <ul class="dropdown-menu"> + <li><a href="../../download.html">Download</a></li> + <li><a href="../../history.html">Release History</a></li> + </ul> + </li> +<!-- Example: + <li class="dropdown"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a> + <ul class="dropdown-menu"> + <li><a href="#">Action</a></li> + <li><a href="#">Another action</a></li> + <li><a href="#">Something else here</a></li> + <li class="divider"></li> + <li class="dropdown-header">Nav header</li> + <li><a href="#">Separated link</a></li> + <li><a href="#">One more separated link</a></li> + </ul> + </li> +--> + <li><a href="../../sitemap.xml">Sitemap</a></li> + <li><a href="../../feed.xml">Subscribe</a></li> + </ul> + </div><!--/.nav-collapse --> + </div> + </div> + + </div> + <div class="container"> + + <div class="page-header"> + <h1>Apache Tamaya - Extension: Integration with Hazelcast</h1> + </div> + + <p><em>2018-04-26</em></p> + + <p><div id="preamble"> +<div class="sectionbody"> +<!-- toc disabled --> +</div> +</div> +<div class="sect1"> +<h2 id="Consul">Integration with Hazelcast (Extension Module)</h2> +<div class="sectionbody"> +<div class="paragraph"> +<p>Tamaya <em>Hazelcast</em> is an extension module. Refer to the <a href="../extensions.html">extensions documentation</a> for further details.</p> +</div> +<div class="sect2"> +<h3 id="_what_functionality_this_module_provides">What functionality this module provides ?</h3> +<div class="paragraph"> +<p>Tamaya <em>Hazelcast</em> provides a property source which uses +<a href="http://www.hazelcast.org">Hazelcast</a> as configuration backend. Hereby the +module supports read-only integration (as a HazelcastConfigSource as well +as a writing configuration changes back (based on Tamaya’s MutableConfiguration API +defined by the <a href="mod_mutable_config.html">tamaya-mutable-config</a> extension module.</p> +</div> +</div> +<div class="sect2"> +<h3 id="_compatibility">Compatibility</h3> +<div class="paragraph"> +<p>The module is based on Java 8, so it will not run on Java 8 and beyond.</p> +</div> +</div> +<div class="sect2"> +<h3 id="_installation">Installation</h3> +<div class="paragraph"> +<p>To use <em>tamaya-hazelcast</em> you only must add the corresponding dependency to your module:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><dependency> + <groupId>org.apache.tamaya.ext</groupId> + <artifactId>tamaya-hazelcast</artifactId> + <version>{tamaya_version}</version> +</dependency></code></pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_the_extensions_provided">The Extensions Provided</h3> +<div class="paragraph"> +<p>Hazelcast integration comes basically with 2 artifacts:</p> +</div> +<div class="ulist"> +<ul> +<li> +<p>The org.apache.tamaya.hazelcast.HazelcastConfigSource is a ConfigSource. The property source is not automatically +registered. Either register it using the <em>ServiceLoader</em> yourself or implement +and register a corresponding <code>ConfigSourceProvider</code>.</p> +</li> +<li> +<p>If the tamaya-mutable-config module is loaded it is possible to write property values back into the consul cluster, +by accessing a MutableConfiguration using the URI config:hazelcast.</p> +</li> +</ul> +</div> +<div class="paragraph"> +<p>Access of consul key/value pairs is through the normal Tamaya API.</p> +</div> +</div> +<div class="sect2"> +<h3 id="_the_hazelcastconfigsource">The HazelcastConfigSource</h3> +<div class="paragraph"> +<p>The HazelcastConfigSource is not automatically registered and provides different options how to integrate +Tamaya with Hazelcast.</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">/** + * Creates a new instance, hereby using {@code "Hazelcast"} as property source name and + * a default hazelcast backend created by calling {@link Hazelcast#newHazelcastInstance()}. + */ +public HazelcastConfigSource(); + +/** + * Creates a new instance, hereby using {@code "Hazelcast"} as property source name and the + * given hazelcast instance. + * @param hazelcastInstance the hazelcast instance, not null. + */ +public HazelcastConfigSource(HazelcastInstance hazelcastInstance); + +/** + * Creates a new instance, hereby using the given property source name and + * a default hazelcast backend created by calling {@link Hazelcast#newHazelcastInstance()}. + * @param name the property source name, not null. + */ +public HazelcastConfigSource(String name); + +/** + * Creates a new instance, hereby using the given property source name and + * a creating a new hazelcast backend using the given Hazelcast {@link Config}. + * @param config the hazelcast config, not null. + * @param name the property source name, not null. + */ +public HazelcastConfigSource(String name, Config config); + +/** + * Creates a new instance, hereby using the given property source name and the + * hazelcast instance. + * @param name + * @param hazelcastInstance + */ +public HazelcastConfigSource(String name, HazelcastInstance hazelcastInstance);</code></pre> +</div> +</div> +<div class="paragraph"> +<p>To use hazelcast as a configuration backend, you simply create the corresponding Hazelcast instance +and use it to initialize the Tamaya property source. Given that a hazelcast backedn configuration +can be easily created asillustrated below:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">// define config settings +HazelcastInstance hazelcastInstance = Hazelcast.newInstance(hazelcastConfig); +HazelcastConfigSource cs = new HazelcastConfigSource(hazelcastInstance); +cs.setName("myHazelcast-config"); +cs.setOrdinal(2000); +// Build your own configuration +ConfigBuilder b = ConfigProviderResolver.getInstance().getBuilder(); +b.addDiscoveredConverters().addDefaultSources().addDiscoveredSources(); +// Add the hazelcast property source (as most significant) +b.awithSource(cs); +// build and use the configuration +Config config = b.build();</code></pre> +</div> +</div> +</div> +</div> +</div></p> + + <hr /> + </div> + </div> + <div> + <div id="push"></div> + + <div id="footer"> + <div class="container"> + <p class="muted credit">© 2014-<span>2018</span> Apache Software Foundation | Mixed with <a href="http://getbootstrap.com/">Bootstrap v3.1.1</a> + | Baked with <a href="http://jbake.org">JBake <span>v2.5.1</span></a> + at <span>2018-04-26</span> | + <a class="twitter-follow-button" data-show-count="false" href="https://twitter.com/tamayaconf">Follow @tamayaconf</a><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script> + </p> + <p> + <b>Disclaimer</b> + Apache Tamaya (incubating) is an effort undergoing + incubation at + The Apache Software Foundation (ASF), sponsored by + the name of Apache Incubator. Incubation is required of + all newly accepted projects until a further review indicates + that the infrastructure, communications, and decision making + process have stabilized in a manner consistent with other + successful ASF projects. While incubation status is not + necessarily a reflection of the completeness or stability of + the code, it does indicate that the project has yet to + be fully endorsed by the ASF. + Apache, Apache Tamaya, and the Apache Tamaya logo are registered trademarks or trademarks of The Apache Software Foundation in the U.S. and/or other countries.<br /> + <a href="https://incubator.apache.org/guides/website.html" style="border:0px;" target="_target"> + <img class="incubator-logo" src="../../logos/apache-incubator.png"/> + </a> + </p> + </div> + </div> + + <!-- Le javascript + ================================================== --> + <!-- Placed at the end of the document so the pages load faster --> + <script src="../../js/jquery-1.11.1.min.js"></script> + <script src="../../js/bootstrap.min.js"></script> + <script src="../../js/prettify.js"></script> + </div> + </body> +</html> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-site/blob/8e3904a8/documentation-new/extensions/mod_injection.html ---------------------------------------------------------------------- diff --git a/documentation-new/extensions/mod_injection.html b/documentation-new/extensions/mod_injection.html new file mode 100644 index 0000000..0575a0a --- /dev/null +++ b/documentation-new/extensions/mod_injection.html @@ -0,0 +1,756 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <meta charset="utf-8"/> + <title>Apache Tamaya - Extension: Injection</title> + <meta name="viewport" content="width=device-width, initial-scale=1.0"/> + <meta name="description" content=""/> + <meta name="author" content=""/> + <meta name="keywords" content=""/> + <meta name="generator" content="'JBake '+'${version}"/> + + <!-- Le styles --> + <link href="../../css/bootstrap.min.css" rel="stylesheet"/> + <link href="../../css/asciidoctor.css" rel="stylesheet"/> + <link href="../../css/base.css" rel="stylesheet"/> + <link href="../../css/prettify.css" rel="stylesheet"/> + + <!-- HTML5 shim, for IE6-8 support of HTML5 elements --> + <!--[if lt IE 9]> + <script src="../../js/html5shiv.min.js"></script> + <![endif]--> + + <!-- Fav and touch icons from ASF --> + <link rel="shortcut icon" href="../../favicon.ico"/> + <link rel="apple-touch-icon" sizes="57x57" href="../../favicons/apple-touch-icon-57x57.png"/> + <link rel="apple-touch-icon" sizes="60x60" href="../../favicons/apple-touch-icon-60x60.png"/> + <link rel="apple-touch-icon" sizes="72x72" href="../../favicons/apple-touch-icon-72x72.png"/> + <link rel="apple-touch-icon" sizes="76x76" href="../../favicons/apple-touch-icon-76x76.png"/> + <link rel="apple-touch-icon" sizes="114x114" href="../../favicons/apple-touch-icon-114x114.png"/> + <link rel="apple-touch-icon" sizes="120x120" href="../../favicons/apple-touch-icon-120x120.png"/> + <link rel="apple-touch-icon" sizes="144x144" href="../../favicons/apple-touch-icon-144x144.png"/> + <link rel="apple-touch-icon" sizes="152x152" href="../../favicons/apple-touch-icon-152x152.png"/> + <link rel="apple-touch-icon" sizes="180x180" href="../../favicons/apple-touch-icon-180x180.png"/> + <link rel="icon" type="image/png" href="../../favicons/favicon-32x32.png" sizes="32x32"/> + <link rel="icon" type="image/png" href="../../favicons/favicon-194x194.png" sizes="194x194"/> + <link rel="icon" type="image/png" href="../../favicons/favicon-96x96.png" sizes="96x96"/> + <link rel="icon" type="image/png" href="../../favicons/android-chrome-192x192.png" sizes="192x192"/> + <link rel="icon" type="image/png" href="../../favicons/favicon-16x16.png" sizes="16x16"/> + <link rel="manifest" href="../../favicons/manifest.json"/> + <link rel="shortcut icon" href="../../favicons/favicon.ico"/> + <meta name="msapplication-TileColor" content="#603cba"/> + <meta name="msapplication-TileImage" content="../../favicons/mstile-144x144.png"/> + <meta name="msapplication-config" content="../../favicons/browserconfig.xml"/> + <meta name="theme-color" content="#303284"/> + </head> + <body onload="prettyPrint()"> + <div id="wrap"> + <div> + + <!-- Fixed navbar --> + <div class="navbar navbar-default navbar-fixed-top" role="navigation"> + <div class="container"> + <div class="navbar-header"> + <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> + <span class="sr-only">Toggle navigation</span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </button> + <a class="navbar-brand" href="../../index.html">Apache Tamaya (incubating)</a> + </div> + <div class="navbar-collapse collapse"> + <ul class="nav navbar-nav"> + <li><a href="../../start.html">Tamaya in 5 minutes</a></li> + <li class="dropdown"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Documentation <b class="caret"></b></a> + <ul class="dropdown-menu"> + <li><a href="../../documentation/usecases.html">Use Cases and Requirements</a></li> + <li><a href="../../documentation/quickstart.html">Quickstart</a></li> + <li><a href="../../documentation/api.html">API</a></li> + <li><a href="../../documentation/core.html">Core</a></li> + <li><a href="../../documentation/extensions.html">Extension Guide</a></li> + <li class="divider"></li> + <li><a href="../../apidocs/stable/index.html">Javadoc 0.3-incubating (release/stable)</a></li> + <li><a href="../../apidocs/development/index.html">Javadoc 0.4-incubating-SNAPSHOT (development)</a></li> + </ul> + </li> + <li class="dropdown"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Development <b class="caret"></b></a> + <ul class="dropdown-menu"> + <li><a href="../../development/source.html">Sources</a></li> + <li><a href="../../development/community.html">Community</a></li> + <li><a href="../../development/team.html">Project Team</a></li> + <li><a target="_blank" href="https://builds.apache.org/view/S-Z/view/Tamaya/">CI / ASF Jenkins</a></li> + <li><a target="_blank" href="https://issues.apache.org/jira/browse/TAMAYA">Issues / ASF Jira</a></li> + <li><a href="../../devguide.html">Development Guide</a></li> + <li><a href="../../release-guide.html">Release Guide</a></li> + <li class="divider"></li> + <li><a href="../../development/possible-contributions.html">Possible Contributions</a></li> + </ul> + </li> + <li class="dropdown"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Releases <b class="caret"></b></a> + <ul class="dropdown-menu"> + <li><a href="../../download.html">Download</a></li> + <li><a href="../../history.html">Release History</a></li> + </ul> + </li> +<!-- Example: + <li class="dropdown"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a> + <ul class="dropdown-menu"> + <li><a href="#">Action</a></li> + <li><a href="#">Another action</a></li> + <li><a href="#">Something else here</a></li> + <li class="divider"></li> + <li class="dropdown-header">Nav header</li> + <li><a href="#">Separated link</a></li> + <li><a href="#">One more separated link</a></li> + </ul> + </li> +--> + <li><a href="../../sitemap.xml">Sitemap</a></li> + <li><a href="../../feed.xml">Subscribe</a></li> + </ul> + </div><!--/.nav-collapse --> + </div> + </div> + + </div> + <div class="container"> + + <div class="page-header"> + <h1>Apache Tamaya - Extension: Injection</h1> + </div> + + <p><em>2018-04-26</em></p> + + <p><div id="preamble"> +<div class="sectionbody"> +<!-- toc disabled --> +</div> +</div> +<div class="sect1"> +<h2 id="Injection">Tamaya Injection (Extension Module)</h2> +<div class="sectionbody"> +<div class="paragraph"> +<p>Tamaya <em>Injection</em> is an extension module. Refer to the <a href="../extensions.html">extensions documentation</a> for further details.</p> +</div> +<div class="sect2"> +<h3 id="_what_functionality_this_module_provides">What functionality this module provides ?</h3> +<div class="paragraph"> +<p>Tamaya <em>Injection</em> provides functionality for injecting configured values into beans, or creating configuration +template instances.</p> +</div> +<div class="paragraph"> +<p>Inversion of Control (aka IoC/Hollywood Principle) has proven to be very useful and effective in avoiding boilerplate +code. In Java there are different frameworks available that all provide IoC mechanisms. Unfortunately IoC is not a +built-in language feature. So for a portable solution that works also in Java SE Tamaya itself has to provide the +according injection services. This module adds this functionality to Tamaya.</p> +</div> +</div> +<div class="sect2"> +<h3 id="_compatibility">Compatibility</h3> +<div class="paragraph"> +<p>The module is based on Java 8, so it can be used with Java 8 and beyond.</p> +</div> +</div> +<div class="sect2"> +<h3 id="_installation">Installation</h3> +<div class="paragraph"> +<p>The basic injection API is defined by the configuration JSRÃs API. Nevertheless Tamaya’s adds some +useful extensions. These extensions are deployed as optional API artifact:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><dependency> + <groupId>org.apache.tamaya.ext</groupId> + <artifactId>tamaya-injection-api</artifactId> + <version>{tamaya_version}</version> +</dependency></code></pre> +</div> +</div> +<div class="paragraph"> +<p>To use injection with Java SE you must add the corresponding dependency to your module:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><dependency> + <groupId>org.apache.tamaya.ext</groupId> + <artifactId>tamaya-injection</artifactId> + <version>{tamaya_version}</version> +</dependency></code></pre> +</div> +</div> +<div class="paragraph"> +<p>Similarly there are other injection implementations available, targetig platforms such as</p> +</div> +<div class="ulist"> +<ul> +<li> +<p><a href="mod_spring.html">Spring, Spring Boot</a></p> +</li> +<li> +<p><a href="mod_CDI.html">Java EE/CDI</a></p> +</li> +</ul> +</div> +</div> +<div class="sect2"> +<h3 id="_core_concepts">Core Concepts</h3> +<div class="paragraph"> +<p>Basically you annotate fields or methods in your beans with @ConfigProperty to enable configuration injection. Tamaya +additionally defines further annotations that allo you to define additional aspects such as default values, custom +converters etc. The following example illustrates the basic functionality: +code snippet:</p> +</div> +<div class="listingblock"> +<div class="title">Annotated Example Class</div> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">package foo.bar; + +public class ConfiguredClass { + + // resolved by default, using property name, class and package name: foo.bar.ConfiguredClass.testProperty + private String testProperty; + + // Trying to resolve mutiple keys, with a default value, if none could be resolved + @ConfigProperty(key="a.b.c.key1", defaultValue="The current \\${JAVA_HOME} env property is ${env:JAVA_HOME}.") + @ConfigFaööbackKeys({"a.b.legacyKey",area1.key2"}) + String value1; + + // Typical case + @ConfigProperty(key="a.b.c.key2") + private int value2; + + // resolved by default as foo.bar.ConfiguredClass.accessUrl + // Using a (default) String -> URL converter + @ConfigProperty(defaultValue="http://127.0.0.1:8080/res/api/v1/info.json") + private URL accessUrl; + + // Config injection disabled for this property + @NoConfig + private Integer int1; + + // Overriding the String -> BigDecimal converter with a custom implementation. + @ConfigProperty(key="BD") + @WithConverter(MyBigDecimalRoundingAdapter.class) + private BigDecimal bigNumber; + + ... +}</code></pre> +</div> +</div> +<div class="paragraph"> +<p>When configuring data or configuration classes it is also possible to auto-inject the fields identified. For activating +this feature a class must be annotated with @ConfigAutoDetect:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">. An autoinjected bean class +-------------------------------------------- +package a.b;</code></pre> +</div> +</div> +<div class="paragraph"> +<p>@ConfigAutoDetect +public final class Tenant { + private int id; + private String name; + private String description; + @NoConfig // prevents auto detection for this field + private String id2;</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre> public int getId(){ + return id; + } + public String getName(){ + return name; + } + public String getDescription(){ + return description; + } +}</pre> +</div> +</div> +<div class="listingblock"> +<div class="content"> +<pre>These examples do not show all possibilities provided. Configuring instance of these +class using Tamaya is very simple: Just pass the instance to Tamaya to let +Tamaya inject the configuration: + +[source,java] +.Configuring the +ConfiguredClass+ Instance</pre> +</div> +</div> +<div class="paragraph"> +<p>ConfiguredClass classInstance = new ConfiguredClass(); +ConfigurationInjector.configure(configuredClass);</p> +</div> +<div class="paragraph"> +<p>Tenant tenant = new Tenant(); +ConfigurationInjector.configure(tenant);</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre>NOTE: Configuration injection works similarly, when used with other integration modules, e.g. when Tamaya is used +with CDI, Spring or within an OSGI container. For further details refer also to the corresponding integration module's +documentation. + + +==== The ConfigurationInjector + +The +ConfigurationInjector+ interface provides methods that allow any kind of instances to be configured +by passing the instances to +T ConfigurationInjector.getInstance().configure(T);+. The classes passed +hereby must not be annotated with +@ConfigProperty+ for being configurable. + + +==== Accessing Supplier instances + +In many cases you want to create a supplier that simply creates instances that are correctly configured as defined +by the current context. This can be done using +Suppliers+: + +[source, java]</pre> +</div> +</div> +<div class="paragraph"> +<p>Supplier<Tenant> configuredTenantSupplier = ConfigurationInjector.getInstance().getConfiguredSupplier( + new Supplier<Tenant>(){ + public Tenant get(){ + return new Tenant(); + } +});</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre>With Java 8 it's even more simple: + +[source, java]</pre> +</div> +</div> +<div class="paragraph"> +<p>Supplier<Tenant> configuredTenantSupplier = ConfigurationInjector.getInstance().getConfiguredSupplier( + Tenant::new);</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre>Hereby this annotation can be used in multiple ways and combined with other annotations such as ++@WithLoadPolicy+, +@WithConverter+. + + +==== Minimal Example + +To illustrate the mechanism below the most simple variant of a configured class is given: + +[source,java] +.Most simple configured class</pre> +</div> +</div> +<div class="paragraph"> +<p>pubic class ConfiguredItem{ + @Config + private String aValue; +}</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre>When this class is configured, e.g. by passing it to +ConfigurationInjector.getInstance().configure(Object)+, +the following is happening: + +* The current valid +Config+ is evaluated by calling +Config cfg = ConfigProvider.getConfig();+ +* The current property value (String) is evaluated by calling +cfg.getValue("aValue", Type.class);+ + for each possible key (mutliple keys are possible). +* if not successful, an error is thrown +* On success, since no type conversion is involved, the value is injected. + + +=== The Annotations in detail + +==== Using `@ConfigProperty` + +This is the main JSR annotation targeting a field in a class for configuration injection. + + +===== Evaluating of _configuration keys_ + +By default Tamaya tries to determine configuration for each property of an instance +passed, using the following resolution policy: + +* Given a class +a.b.MyClass+ and a field +myField+ it would try to look up the + following keys: + +[source, listing]</pre> +</div> +</div> +<div class="paragraph"> +<p>a.b.MyClass.myField +a.b.MyClass.my-field +MyClass.myField +MyClass.my-field +myField +my-field</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre>This behaviour can be adapted, e.g. by using the `@ConfigDefaultSections` annotation on the +declaring type:</pre> +</div> +</div> +<div class="paragraph"> +<p>@ConfigDefaultSections("a.b.c", "deprecated") +pubic class MyClass{ + @ConfigProperty + private String myField; +}</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre>This will result in a modified lookup chain as illustrated below: + +[source, listing]</pre> +</div> +</div> +<div class="paragraph"> +<p>a.b.c.myField +a.b.c.my-field +deprecated.myField +deprecated.my-field</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre>This helps to reduce redundancy when referring to you configuration keys. Additionally +it is also possible to define absolute key entries, e.g.</pre> +</div> +</div> +<div class="paragraph"> +<p>@ConfigDefaultSections("a.b.c") +pubic class MyClass{ + @ConfigProperty("myField" /* relative */) + @ConfigFallbackKeys("[absolute.key]") + private String myField; +}</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre>This will result in a lookup chain as illustrated below: + +[source, listing]</pre> +</div> +</div> +<div class="paragraph"> +<p>a.b.c.myField +absolute.key # default sections are ignored</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre>===== Using defaults + +In the next example we explicitly define the _default_ property value: +[source,java]</pre> +</div> +</div> +<div class="paragraph"> +<p>pubic class ConfiguredItem{</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre> @ConfigProperty(key="aValue", defaultValue="${env:java.version}") + @ConfigFallbackKeys({"a.b.value","a.b.deprecated.value"}) + private String aValue; +}</pre> +</div> +</div> +<div class="listingblock"> +<div class="content"> +<pre>==== Automatically inject all items using `@ConfigAutoInject` + +Using `@ConfigAutoDetect` allows you to automatically select all properties found for +configuration injection: + +[source,java]</pre> +</div> +</div> +<div class="paragraph"> +<p>@ConfigAutoDetect +pubic class ConfiguredItem{</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre>private transient int sum;</pre> +</div> +</div> +<div class="literalblock"> +<div class="content"> +<pre> private String a; + private String b; + Private String c; +}</pre> +</div> +</div> +<div class="listingblock"> +<div class="content"> +<pre>Adding the `@NoConfig` annotation prevents a field or method to be auto-detected from +configuration. This is especially useful, if a type is annotated as @ConfigAutoDetect with auto-confiuration +turned on as follows: + +[source,java]</pre> +</div> +</div> +<div class="paragraph"> +<p>@NoConfig +private transient int sum;</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre>In this case the fields +a,b,c+ are configured, whereas the field +sum+ is ignored regarding +configuration. + + +==== Adding custom property converters using `@WithConverter` + +The @WithConverter annotation allows you to define a class of type +Converter+, to be applied +on a property configured to convert the String value to the expected injected type. This can be used for +various use cases, e.g. adding custom formats, config models, decryption. + +[source,java]</pre> +</div> +</div> +<div class="paragraph"> +<p>pubic class ConfiguredItem{</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre>@WithConverter(MyPropertyConverter.class) +@ConfigProperty +private String a;</pre> +</div> +</div> +<div class="paragraph"> +<p>}</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre>==== Inject a `DynamicValue` + +Within this example we evaluate a dynamic value. This mechanism allows you to listen for configuration changes and to +commit new values exactly, when convenient for you. + +[source,java]</pre> +</div> +</div> +<div class="paragraph"> +<p>pubic class ConfiguredItem{</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre> @ConfigProperty(key="aValue", defaultValue="${env:java.version}") + private DynamicValue aValue; +}</pre> +</div> +</div> +<div class="listingblock"> +<div class="content"> +<pre>The +DynamicValue+ provides you the following functionality: + +[source,java]</pre> +</div> +</div> +<div class="paragraph"> +<p>public interface DynamicValue<T> {</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre>T get(); +T getNewValue(); +T evaluateValue(); +T commitAndGet(); +void commit(); +void discard(); +boolean updateValue();</pre> +</div> +</div> +<div class="literalblock"> +<div class="content"> +<pre>void setUpdatePolicy(UpdatePolicy updatePolicy); +UpdatePolicy getUpdatePolicy(); +void addListener(PropertyChangeListener l); +void removeListener(PropertyChangeListener l);</pre> +</div> +</div> +<div class="literalblock"> +<div class="content"> +<pre>boolean isPresent(); +T orElse(T other); +// Enabled with Java 8 +// T orElseGet(ConfiguredItemSupplier<? extends T> other); +// <X extends Throwable> T orElseThrow(ConfiguredItemSupplier<? extends X> exceptionSupplier) throws X;</pre> +</div> +</div> +<div class="paragraph"> +<p>}</p> +</div> +<div class="paragraph"> +<p>public enum UpdatePolicy{ + IMMEDIATE, + EXPLCIT, + NEVER, + LOG_AND_DISCARD +}</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre>//Summarizing +DynamicValue+ looks somehow similar to the new +Optional+ class added with Java 8. It provides +//a wrapper class around a configured instance. Additionally this class provides functionality that gives +//active control, to manage a configured value based on a ++LoadingPolicy+: +// +//* +IMMEDEATE+ means that when the configuration system detects a change on the underlying value, the new value +// is automatically applied without any further notice. +//* +EXPLICIT+ means that a new configuration value is signalled by setting the +newValue+ property. if +getNewValue()+ +// returns a non null value, the new value can be applied by calling +commit()+. You can always access the newest value, +// hereby implicitly applying it, by accessing it via +commitAndGet()+. Also it is possible ti ignore a change by calling +// +discard()+. +//* +NEVER+ means the configured value is evaluated once and never updated. All changes are silently discarded. +//* +LOG_AND_DISCARD+ similar to +NEVER+, but changes are logged before they are discarded. + +Summarizing a +DynamicValue+ allows you + +* to reload actively updates of configured values. +* update implicitly or explicitly all changes on the value. +* add listeners that observe changes of a certain value. + +Dynamic values also allow on-the-fly reevaluation of the value by calling +evaluateValue()+. Hereby the value of the +instance is not changed. + + +===== The LoadPolicy enum + +The +LoadPolicy+ enum defines different configuration loading behaviour +to be applied: + +[source,java]</pre> +</div> +</div> +<div class="paragraph"> +<p>@Deprecated +public enum LoadPolicy { + /<strong> + * The configuration keys is evaluated once, when the owning component is loaded/configured, but never updated later. + <strong>/ + INITIAL, + /</strong> + * The configuration keys is evaluated exactly once on its first access/use lazily, but never updated later. + * @see DynamicValue#get() + * @see DynamicValue#commitAndGet() + */ + LAZY, + /</strong>* + * The configuration value is evaluated every time it is accessed. + */ + ALWAYS +}</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre>This enum type currently is used only internally, so avoid using it as of +now in your code is recommended. + + +=== Configuration Events + +Similar to CDI Tamaya publishes Configuration events, when instances were configured. It depends on the effective +event backend in use, if and how events are published: + +* when you have the CDI extension active events are published using the default CDI event mechanism. +* in all other scenarios events are delegated to the +tamaya-events+ module, if available, +* if no event delegation is available no events are published. + +The event published is very simple: + +[source,java]</pre> +</div> +</div> +<div class="paragraph"> +<p>public interface ConfiguredType { + Class getType(); + String getName(); + Collection<ConfiguredField> getConfiguredFields(); + Collection<ConfiguredMethod> getConfiguredMethods(); + void configure(Object instance, Configuration config); +}</p> +</div> +<div class="paragraph"> +<p>public interface ConfiguredField { + Class<?> getType(); + Collection<String> getConfiguredKeys(); + String getName(); + String getSignature(); + Field getAnnotatedField(); + void configure(Object instance, Configuration config); +}</p> +</div> +<div class="paragraph"> +<p>public interface ConfiguredMethod { + Collection<String> getConfiguredKeys(); + Class<?>[] getParameterTypes(); + Method getAnnotatedMethod(); + String getName(); + String getSignature(); + void configure(Object instance, Configuration config); +}</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre></pre> +</div> +</div> +</div> +</div> +</div></p> + + <hr /> + </div> + </div> + <div> + <div id="push"></div> + + <div id="footer"> + <div class="container"> + <p class="muted credit">© 2014-<span>2018</span> Apache Software Foundation | Mixed with <a href="http://getbootstrap.com/">Bootstrap v3.1.1</a> + | Baked with <a href="http://jbake.org">JBake <span>v2.5.1</span></a> + at <span>2018-04-26</span> | + <a class="twitter-follow-button" data-show-count="false" href="https://twitter.com/tamayaconf">Follow @tamayaconf</a><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script> + </p> + <p> + <b>Disclaimer</b> + Apache Tamaya (incubating) is an effort undergoing + incubation at + The Apache Software Foundation (ASF), sponsored by + the name of Apache Incubator. Incubation is required of + all newly accepted projects until a further review indicates + that the infrastructure, communications, and decision making + process have stabilized in a manner consistent with other + successful ASF projects. While incubation status is not + necessarily a reflection of the completeness or stability of + the code, it does indicate that the project has yet to + be fully endorsed by the ASF. + Apache, Apache Tamaya, and the Apache Tamaya logo are registered trademarks or trademarks of The Apache Software Foundation in the U.S. and/or other countries.<br /> + <a href="https://incubator.apache.org/guides/website.html" style="border:0px;" target="_target"> + <img class="incubator-logo" src="../../logos/apache-incubator.png"/> + </a> + </p> + </div> + </div> + + <!-- Le javascript + ================================================== --> + <!-- Placed at the end of the document so the pages load faster --> + <script src="../../js/jquery-1.11.1.min.js"></script> + <script src="../../js/bootstrap.min.js"></script> + <script src="../../js/prettify.js"></script> + </div> + </body> +</html> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-site/blob/8e3904a8/documentation-new/extensions/mod_jndi.html ---------------------------------------------------------------------- diff --git a/documentation-new/extensions/mod_jndi.html b/documentation-new/extensions/mod_jndi.html new file mode 100644 index 0000000..9761249 --- /dev/null +++ b/documentation-new/extensions/mod_jndi.html @@ -0,0 +1,251 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <meta charset="utf-8"/> + <title>Apache Tamaya - Extension: Integration with JNDI</title> + <meta name="viewport" content="width=device-width, initial-scale=1.0"/> + <meta name="description" content=""/> + <meta name="author" content=""/> + <meta name="keywords" content=""/> + <meta name="generator" content="'JBake '+'${version}"/> + + <!-- Le styles --> + <link href="../../css/bootstrap.min.css" rel="stylesheet"/> + <link href="../../css/asciidoctor.css" rel="stylesheet"/> + <link href="../../css/base.css" rel="stylesheet"/> + <link href="../../css/prettify.css" rel="stylesheet"/> + + <!-- HTML5 shim, for IE6-8 support of HTML5 elements --> + <!--[if lt IE 9]> + <script src="../../js/html5shiv.min.js"></script> + <![endif]--> + + <!-- Fav and touch icons from ASF --> + <link rel="shortcut icon" href="../../favicon.ico"/> + <link rel="apple-touch-icon" sizes="57x57" href="../../favicons/apple-touch-icon-57x57.png"/> + <link rel="apple-touch-icon" sizes="60x60" href="../../favicons/apple-touch-icon-60x60.png"/> + <link rel="apple-touch-icon" sizes="72x72" href="../../favicons/apple-touch-icon-72x72.png"/> + <link rel="apple-touch-icon" sizes="76x76" href="../../favicons/apple-touch-icon-76x76.png"/> + <link rel="apple-touch-icon" sizes="114x114" href="../../favicons/apple-touch-icon-114x114.png"/> + <link rel="apple-touch-icon" sizes="120x120" href="../../favicons/apple-touch-icon-120x120.png"/> + <link rel="apple-touch-icon" sizes="144x144" href="../../favicons/apple-touch-icon-144x144.png"/> + <link rel="apple-touch-icon" sizes="152x152" href="../../favicons/apple-touch-icon-152x152.png"/> + <link rel="apple-touch-icon" sizes="180x180" href="../../favicons/apple-touch-icon-180x180.png"/> + <link rel="icon" type="image/png" href="../../favicons/favicon-32x32.png" sizes="32x32"/> + <link rel="icon" type="image/png" href="../../favicons/favicon-194x194.png" sizes="194x194"/> + <link rel="icon" type="image/png" href="../../favicons/favicon-96x96.png" sizes="96x96"/> + <link rel="icon" type="image/png" href="../../favicons/android-chrome-192x192.png" sizes="192x192"/> + <link rel="icon" type="image/png" href="../../favicons/favicon-16x16.png" sizes="16x16"/> + <link rel="manifest" href="../../favicons/manifest.json"/> + <link rel="shortcut icon" href="../../favicons/favicon.ico"/> + <meta name="msapplication-TileColor" content="#603cba"/> + <meta name="msapplication-TileImage" content="../../favicons/mstile-144x144.png"/> + <meta name="msapplication-config" content="../../favicons/browserconfig.xml"/> + <meta name="theme-color" content="#303284"/> + </head> + <body onload="prettyPrint()"> + <div id="wrap"> + <div> + + <!-- Fixed navbar --> + <div class="navbar navbar-default navbar-fixed-top" role="navigation"> + <div class="container"> + <div class="navbar-header"> + <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> + <span class="sr-only">Toggle navigation</span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </button> + <a class="navbar-brand" href="../../index.html">Apache Tamaya (incubating)</a> + </div> + <div class="navbar-collapse collapse"> + <ul class="nav navbar-nav"> + <li><a href="../../start.html">Tamaya in 5 minutes</a></li> + <li class="dropdown"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Documentation <b class="caret"></b></a> + <ul class="dropdown-menu"> + <li><a href="../../documentation/usecases.html">Use Cases and Requirements</a></li> + <li><a href="../../documentation/quickstart.html">Quickstart</a></li> + <li><a href="../../documentation/api.html">API</a></li> + <li><a href="../../documentation/core.html">Core</a></li> + <li><a href="../../documentation/extensions.html">Extension Guide</a></li> + <li class="divider"></li> + <li><a href="../../apidocs/stable/index.html">Javadoc 0.3-incubating (release/stable)</a></li> + <li><a href="../../apidocs/development/index.html">Javadoc 0.4-incubating-SNAPSHOT (development)</a></li> + </ul> + </li> + <li class="dropdown"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Development <b class="caret"></b></a> + <ul class="dropdown-menu"> + <li><a href="../../development/source.html">Sources</a></li> + <li><a href="../../development/community.html">Community</a></li> + <li><a href="../../development/team.html">Project Team</a></li> + <li><a target="_blank" href="https://builds.apache.org/view/S-Z/view/Tamaya/">CI / ASF Jenkins</a></li> + <li><a target="_blank" href="https://issues.apache.org/jira/browse/TAMAYA">Issues / ASF Jira</a></li> + <li><a href="../../devguide.html">Development Guide</a></li> + <li><a href="../../release-guide.html">Release Guide</a></li> + <li class="divider"></li> + <li><a href="../../development/possible-contributions.html">Possible Contributions</a></li> + </ul> + </li> + <li class="dropdown"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Releases <b class="caret"></b></a> + <ul class="dropdown-menu"> + <li><a href="../../download.html">Download</a></li> + <li><a href="../../history.html">Release History</a></li> + </ul> + </li> +<!-- Example: + <li class="dropdown"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a> + <ul class="dropdown-menu"> + <li><a href="#">Action</a></li> + <li><a href="#">Another action</a></li> + <li><a href="#">Something else here</a></li> + <li class="divider"></li> + <li class="dropdown-header">Nav header</li> + <li><a href="#">Separated link</a></li> + <li><a href="#">One more separated link</a></li> + </ul> + </li> +--> + <li><a href="../../sitemap.xml">Sitemap</a></li> + <li><a href="../../feed.xml">Subscribe</a></li> + </ul> + </div><!--/.nav-collapse --> + </div> + </div> + + </div> + <div class="container"> + + <div class="page-header"> + <h1>Apache Tamaya - Extension: Integration with JNDI</h1> + </div> + + <p><em>2018-04-26</em></p> + + <p><div id="preamble"> +<div class="sectionbody"> +<!-- toc disabled --> +</div> +</div> +<div class="sect1"> +<h2 id="JNDI">Integration with JNDI (Extension Module)</h2> +<div class="sectionbody"> +<div class="paragraph"> +<p>Tamaya <em>JNDI</em> is an extension module. Refer to the <a href="../extensions.html">extensions documentation</a> for further details.</p> +</div> +<div class="sect2"> +<h3 id="_what_functionality_this_module_provides">What functionality this module provides ?</h3> +<div class="paragraph"> +<p>Tamaya <em>JNDI</em> provides a simple ConfigySource that reads values from a +JNDI context.</p> +</div> +</div> +<div class="sect2"> +<h3 id="_compatibility">Compatibility</h3> +<div class="paragraph"> +<p>The module is based on Java 8, so it will not run on Java 8 and beyond.</p> +</div> +</div> +<div class="sect2"> +<h3 id="_installation">Installation</h3> +<div class="paragraph"> +<p>To use <em>jndi</em> as a configuration backend you only must add the corresponding dependency to +your module:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml"><dependency> + <groupId>org.apache.tamaya.ext</groupId> + <artifactId>tamaya-jndi</artifactId> + <version>{tamaya_version}</version> +</dependency></code></pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_the_functionality_provided">The Functionality Provided</h3> +<div class="paragraph"> +<p>Main artifact is the JNDIConfigSource class, which implements a +property source based on a JNDI context:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public class JNDIPropertySource extends BasePropertySource { + + public JNDIPropertySource(String name, Context context); + public JNDIPropertySource(String name) throws NamingException; + public JNDIPropertySource() throws NamingException; + + public void setScannable(boolean scannable); + + [...] +}</code></pre> +</div> +</div> +<div class="paragraph"> +<p>By default the property source is <em>non scannable</em>, so a call the <code>getProperties()</code> +will return an empty map instance. After calling <code>setScannable(true);</code> a call to +<code>getProperties()</code> will return a String representation of the JNDI tree. Hereby +leaves of the tree are converted using <code>String.valueOf(leaveObject)</code>.</p> +</div> +<div class="paragraph"> +<p>This module automatically registers an instance of JNDIConfigSource with a +default ordinal of 200.</p> +</div> +<div class="paragraph"> +<p>You can extend this class or manually instantiate it, e.g. as part of a +ConfigSourceProvider. If no <code>Context</code> is passed explicitly, a new +InitialContext is created, without any environment parameters set.</p> +</div> +</div> +</div> +</div></p> + + <hr /> + </div> + </div> + <div> + <div id="push"></div> + + <div id="footer"> + <div class="container"> + <p class="muted credit">© 2014-<span>2018</span> Apache Software Foundation | Mixed with <a href="http://getbootstrap.com/">Bootstrap v3.1.1</a> + | Baked with <a href="http://jbake.org">JBake <span>v2.5.1</span></a> + at <span>2018-04-26</span> | + <a class="twitter-follow-button" data-show-count="false" href="https://twitter.com/tamayaconf">Follow @tamayaconf</a><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script> + </p> + <p> + <b>Disclaimer</b> + Apache Tamaya (incubating) is an effort undergoing + incubation at + The Apache Software Foundation (ASF), sponsored by + the name of Apache Incubator. Incubation is required of + all newly accepted projects until a further review indicates + that the infrastructure, communications, and decision making + process have stabilized in a manner consistent with other + successful ASF projects. While incubation status is not + necessarily a reflection of the completeness or stability of + the code, it does indicate that the project has yet to + be fully endorsed by the ASF. + Apache, Apache Tamaya, and the Apache Tamaya logo are registered trademarks or trademarks of The Apache Software Foundation in the U.S. and/or other countries.<br /> + <a href="https://incubator.apache.org/guides/website.html" style="border:0px;" target="_target"> + <img class="incubator-logo" src="../../logos/apache-incubator.png"/> + </a> + </p> + </div> + </div> + + <!-- Le javascript + ================================================== --> + <!-- Placed at the end of the document so the pages load faster --> + <script src="../../js/jquery-1.11.1.min.js"></script> + <script src="../../js/bootstrap.min.js"></script> + <script src="../../js/prettify.js"></script> + </div> + </body> +</html>
