http://git-wip-us.apache.org/repos/asf/incubator-tamaya-site/blob/cb3c154a/documentation/extensions/mod_mutable_config.html ---------------------------------------------------------------------- diff --git a/documentation/extensions/mod_mutable_config.html b/documentation/extensions/mod_mutable_config.html new file mode 100644 index 0000000..1ba79cf --- /dev/null +++ b/documentation/extensions/mod_mutable_config.html @@ -0,0 +1,505 @@ +<!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&#8201;&#8212;&#8201;Extension: Mutable Configuration</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="../../">Apache Tamaya (incubating)</a> + </div> + <div class="navbar-collapse collapse"> + <ul class="nav navbar-nav"> + <li><a href="../../index.html">Home</a></li> + <li><a href="../../about.html">About</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/index.html">Javadoc ${tamaya_version} (external)</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="../../devguide.html">Development Guide</a></li> + <li><a href="../../release-guide.html">Release Guide</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&#8201;&#8212;&#8201;Extension: Mutable Configuration</h1> + </div> + + <p><em>2016-12-19</em></p> + + <p><div id="preamble"> +<div class="sectionbody"> +<!-- toc disabled --> +</div> +</div> +<div class="sect1"> +<h2 id="Core">Tamaya Mutable Configuration (Extension Module)</h2> +<div class="sectionbody"> +<div class="sect2"> +<h3 id="_overview">Overview</h3> +<div class="paragraph"> +<p>Tamaya Configuration by default is read-only, which covers must of the use cases. But there are many legit scenarios +where configuration should be written back to some backend systems or the local file system. This module adds this +functionality.</p> +</div> +</div> +<div class="sect2"> +<h3 id="_compatibility">Compatibility</h3> +<div class="paragraph"> +<p>The module is based on Java 7, so it can be used with Java 7 and beyond.</p> +</div> +</div> +<div class="sect2"> +<h3 id="_installation">Installation</h3> +<div class="paragraph"> +<p>To benefit from configuration mutability support 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-mutable-config</artifactId> + <version>{tamaya_version}</version> +</dependency></code></pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_core_architecture">Core Architecture</h3> +<div class="sect3"> +<h4 id="_accessing_mutableconfiguration">Accessing MutableConfiguration</h4> +<div class="paragraph"> +<p>The core of the module is the MutableConfigurationProvider singleton, which provides access to MutableConfiguration +instance, which extends Configuration. This interface adds additional methods to add/update or remove property values. +Hereby changes applied are managed in a transaction like context, called ConfigChangeContext. Each context defines +a UUID that identifes a change. +Backends for writing changes applied are of type MutablePropertySource, similarly extending the PropertySource +SPI with methods for writing changes back. Registrations and ordering policies are like with ordinary property sources, +with one important difference. Mutable property source can be targeted by write operations.</p> +</div> +<div class="paragraph"> +<p>The example below shows how a MutableConfiguration can be obtained the simplest way:</p> +</div> +<div class="listingblock"> +<div class="title">Accessing and changing configuration</div> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">MutableConfiguration config = MutableConfigurationProvider + .createMutableConfiguration(); +config.put("newKey", "newValue") + .put("anotherKey", "updatedValue") + .remove("valueNotValid") + .store();</code></pre> +</div> +</div> +<div class="paragraph"> +<p>In the above scenario we use the overall system’s configuration as the backend to be used. +We can also pass any Configuration to render it into a mutable instance, e.g.</p> +</div> +<div class="listingblock"> +<div class="title">Explicitly passing the backing configuration</div> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">Configuration config = ...; +MutableConfiguration config = MutableConfigurationProvider + .createMutableConfiguration(config);</code></pre> +</div> +</div> +<div class="admonitionblock note"> +<table> +<tr> +<td class="icon"> +<div class="title">Note</div> +</td> +<td class="content"> +If a configuration does not contain any MutablePropertySource instances, + a MutableConfiguration built from it will not be able to accept any changes. +</td> +</tr> +</table> +</div> +<div class="paragraph"> +<p>Following you see the options how to create a MutableConfiguration using the +MutableConfigurationProvider singleton:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public final class MutableConfigurationProvider { + + private MutableConfigurationProvider(){} + + public static MutableConfiguration createMutableConfiguration(); + public static MutableConfiguration createMutableConfiguration( + ChangePropagationPolicy changePropgationPolicy); + public static MutableConfiguration createMutableConfiguration(Configuration configuration); + public static MutableConfiguration createMutableConfiguration( + Configuration configuration, + ChangePropagationPolicy changePropgationPolicy); + + [...] +}</code></pre> +</div> +</div> +<div class="paragraph"> +<p>Hereby MutableConfiguration is defined as follows:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public interface MutableConfiguration extends Configuration { + + void store(); + + ConfigChangeRequest getConfigChangeRequest(); + ChangePropagationPolicy getChangePropagationPolicy(); + + MutableConfiguration put(String key, String value); + MutableConfiguration putAll(Map<String, String> properties); + MutableConfiguration remove(Collection<String> keys); + MutableConfiguration remove(String... keys); + +}</code></pre> +</div> +</div> +</div> +<div class="sect3"> +<h4 id="_targeting_the_right_mutablepropertysources">Targeting the right MutablePropertySources</h4> +<div class="paragraph"> +<p>A Configuration may have multiple MutablePropertySource instances present. These are members of Tamaya’s oredered list of +PropertySources to evaluate the configuration. Nevertheless writing back changes requires additional aspects to +be considered: +* Should changes being written back to all mutable property sources? Or should a key that could be added or removed + on a more significant instance not be written/removed on less significant property source instances? +* Should a change be applied only to a specific mutable property source, regardless its position in the + processing chain?</p> +</div> +<div class="paragraph"> +<p>Therefore a ChangePropagationPolicy can be set on a MutableConfiguration instance, which allows to control +this aspect:</p> +</div> +<div class="listingblock"> +<div class="title">Explicitly passing the backing configuration</div> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public interface ChangePropagationPolicy { + /** + * Method being called when a multiple key/value pairs are added or updated. + * @param propertySources the property sources, including readable property sources of the current configuration, + * never null. + * @param configChange the configuration change, not null. + */ + void applyChange(ConfigChangeRequest configChange, Collection<PropertySource> propertySources); +}</code></pre> +</div> +</div> +<div class="paragraph"> +<p>By default, changes are applied to all registered MutablePropertySources similarly.</p> +</div> +<div class="paragraph"> +<p>Also the MutableConfigurationProvider provides access to the most commonly used change propagation policies:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public final class MutableConfigurationProvider { + + [...] + + public static ChangePropagationPolicy getApplyAllChangePolicy(); + public static ChangePropagationPolicy getApplyMostSignificantOnlyChangePolicy(); + public static ChangePropagationPolicy getApplySelectiveChangePolicy(String... propertySourceNames); + public static ChangePropagationPolicy getApplyNonePolicy(); +}</code></pre> +</div> +</div> +</div> +<div class="sect3"> +<h4 id="_some_aspects_to_consider">Some Aspects to consider</h4> +<div class="paragraph"> +<p>Due to Tamaya’s design the effective effect of your changes to the overall configuration, cannot +be sometimes a bit tricky to be predicted, since it depends on several aspects:</p> +</div> +<div class="olist arabic"> +<ol class="arabic"> +<li> +<p>is the corresponding configuration resource configured as part of the current system’s configuration?</p> +</li> +<li> +<p>what is the PropertySource's priority within the configuration context? Is it overriding or overridden +by other sources?</p> +</li> +<li> +<p>is the change directly visible to the configuration system? E.g. injected values are normally not updated, +whereas injecting a DynamicValue<T> instance allows to detect and react single value changes. Also the +PropertySources implementation must be able to detect any configuration changes and adapt its values returned +accordingly. Finally values also can be marked as immutable or being cached.</p> +</li> +<li> +<p>Is configuration cached, or written/collected directly on access?</p> +</li> +<li> +<p>can the changes applied be committed at all?</p> +</li> +</ol> +</div> +<div class="paragraph"> +<p>So it is part of your application configuration design to clearly define, which property sources may be read-only, which +may be mutable, how overriding should work and to which backends finally any changes should be written back. Nevertheless +changing or adding value is very easy:</p> +</div> +<div class="listingblock"> +<div class="title">Changing a configuration</div> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">MutableConfiguration config = MutableConfigurationProvider.createMutableConfiguration(); +config.put("newKey", "newValue"); +config.remove("mycluster.myapp.myKey"); +config.store();</code></pre> +</div> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_configuration_changes">Configuration Changes</h3> +<div class="paragraph"> +<p>This module does not handle detection of changes to the overall system’s Configuration. This can be done in +several ways, e.g. by:</p> +</div> +<div class="ulist"> +<ul> +<li> +<p>using the <em>tamaya-events</em> extension, which can be used to observe the system’s configuration and +publishing events when things have been changed.</p> +</li> +<li> +<p>The SPI implementing the MutableConfigurationBackendSpi may inform/update any affected PropertySource, +PropertySourceProvider instances about the changes applied.</p> +</li> +</ul> +</div> +</div> +<div class="sect2"> +<h3 id="_supported_backends">Supported Backends</h3> +<div class="paragraph"> +<p>Multiple backends are supported. E.g. the <em>etcd</em> integration module of Tamaya also registers +corresponding SPI implementations/backends. By default this module comes with +the following MutablePropertySource implementations:</p> +</div> +<div class="ulist"> +<ul> +<li> +<p>MutablePropertySource resources, targeting local .properties files, using the java.util.Properties +format.</p> +</li> +<li> +<p>MutableXmlPropertySource resources, targeting local .xml property files, using the java.util.Properties +XML format.</p> +</li> +</ul> +</div> +<div class="sect3"> +<h4 id="_refreshable_property_sources">Refreshable Property Sources</h4> +<div class="paragraph"> +<p>Somehow similar to configuration changes applied explicitly is the case, where values of underlying +configuration backends change and must be reflected in the new configuration tree. Examples are:</p> +</div> +<div class="ulist"> +<ul> +<li> +<p>Configuration files being edited, added or removed.</p> +</li> +<li> +<p>Changes on remote servers like etcd, consul</p> +</li> +<li> +<p>etc.</p> +</li> +</ul> +</div> +<div class="paragraph"> +<p>For having a common API for refreshable items a Refreshable interface is defined:</p> +</div> +<div class="listingblock"> +<div class="title">Refreshable interface</div> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">/** + * Interface to be implemented by items that can be refreshed. By default + * these are property sources, but more types may be supported at a later + * point in time. + */ +public interface Refreshable { + + /** + * Refreshes the item by reloading its internal state. + */ + void refresh(); + +}</code></pre> +</div> +</div> +</div> +<div class="sect3"> +<h4 id="_refreshable_property_sources_2">Refreshable Property Sources</h4> + +</div> +</div> +<div class="sect2"> +<h3 id="_spis">SPIs</h3> +<div class="paragraph"> +<p>The module defines MutableConfigurationProviderSpi, that is used as a delegate by the MutableConfigurationProvider +singleton accessor:</p> +</div> +<div class="listingblock"> +<div class="title">SPI: MutableConfigurationProviderSpi</div> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public interface MutableConfigurationProviderSpi { + /** + * Creates a new {@link MutableConfiguration} with {@code autoCommit = false} as default. + * + * @param configuration the configuration, not null. + * @param propagationPolicy policy that defines how changes are published to the property + * sources. + * @return a new mutable configuration instance. + */ + MutableConfiguration createMutableConfiguration(Configuration configuration, + ChangePropagationPolicy propagationPolicy); +}</code></pre> +</div> +</div> +<div class="paragraph"> +<p>Implementations are registered with the current ServiceContext (using by default the + java.util.ServiceLoader service).</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-2016 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.0</span></a> + at <span>2016-12-19</span> + </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.<br /> + <a href="http://incubator.apache.org/guides/website.html" style="border:0px;" target="_target"><img class="incubator-logo" src="../../logos/egg-logo2.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/cb3c154a/documentation/extensions/mod_optional.html ---------------------------------------------------------------------- diff --git a/documentation/extensions/mod_optional.html b/documentation/extensions/mod_optional.html new file mode 100644 index 0000000..511b256 --- /dev/null +++ b/documentation/extensions/mod_optional.html @@ -0,0 +1,225 @@ +<!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&#8201;&#8212;&#8201;Extension: Optional Tamaya Configuration</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="../../">Apache Tamaya (incubating)</a> + </div> + <div class="navbar-collapse collapse"> + <ul class="nav navbar-nav"> + <li><a href="../../index.html">Home</a></li> + <li><a href="../../about.html">About</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/index.html">Javadoc ${tamaya_version} (external)</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="../../devguide.html">Development Guide</a></li> + <li><a href="../../release-guide.html">Release Guide</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&#8201;&#8212;&#8201;Extension: Optional Tamaya Configuration</h1> + </div> + + <p><em>2016-12-19</em></p> + + <p><div id="preamble"> +<div class="sectionbody"> +<!-- toc disabled --> +</div> +</div> +<div class="sect1"> +<h2 id="Optional">Tamaya Optional Configuration (Extension Module)</h2> +<div class="sectionbody"> +<div class="sect2"> +<h3 id="_overview">Overview</h3> +<div class="paragraph"> +<p>The Tamaya optional module provides contains three types only. It is for projects that want to benefit from Tamaya +configuration optionally only. E.g. doing an OSS project you can declare to support configuration with Tamaya as +an optional extension. This module can be added as a hard dependency to your code, hereby adding only three artofacts. +It automatically checks the availability of Tamaya on the classpath and only if available tries to access it for +configuration evaluation. Additionally an EvaluationPolicy lets you define the precedence of configured values +(yours, or Tamaya ones if present).</p> +</div> +</div> +<div class="sect2"> +<h3 id="_compatibility">Compatibility</h3> +<div class="paragraph"> +<p>The module is based on Java 7, so it will not run on Java 7 and beyond.</p> +</div> +</div> +<div class="sect2"> +<h3 id="_installation">Installation</h3> +<div class="paragraph"> +<p>To benefit from configuration builder support 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-optional</artifactId> + <version>{tamaya_version}</version> +</dependency></code></pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_reading_configuration_using_the_tamaya_optional_module">Reading configuration using the Tamaya Optional Module</h3> +<div class="paragraph"> +<p>The optional module allows reading configuration with a small subset of functionality only. For extended of full +featured config please consider using the Apache Tamaya as a full configuration backend.</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">BigDecimal interestRate = + OptionalConfiguration.of( + EvaluationPolicy.TAMAYA_OVERRIDES_OTHER, + (k) -> MyConfigMechanism.get(k) // String get(String key); + ) + .get("com.mycomp.ratecalculator.rate", BigDecimal.class)) + .orElse(BigDecimal.of(0.05d));</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-2016 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.0</span></a> + at <span>2016-12-19</span> + </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.<br /> + <a href="http://incubator.apache.org/guides/website.html" style="border:0px;" target="_target"><img class="incubator-logo" src="../../logos/egg-logo2.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/cb3c154a/documentation/extensions/mod_osgi.html ---------------------------------------------------------------------- diff --git a/documentation/extensions/mod_osgi.html b/documentation/extensions/mod_osgi.html new file mode 100644 index 0000000..3c9301e --- /dev/null +++ b/documentation/extensions/mod_osgi.html @@ -0,0 +1,315 @@ +<!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&#8201;&#8212;&#8201;Extensions: OSGI Integrations</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="../../">Apache Tamaya (incubating)</a> + </div> + <div class="navbar-collapse collapse"> + <ul class="nav navbar-nav"> + <li><a href="../../index.html">Home</a></li> + <li><a href="../../about.html">About</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/index.html">Javadoc ${tamaya_version} (external)</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="../../devguide.html">Development Guide</a></li> + <li><a href="../../release-guide.html">Release Guide</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&#8201;&#8212;&#8201;Extensions: OSGI Integrations</h1> + </div> + + <p><em>2016-12-19</em></p> + + <p><div id="preamble"> +<div class="sectionbody"> +<!-- toc disabled --> +</div> +</div> +<div class="sect1"> +<h2 id="Optional">Tamaya OSGI Support</h2> +<div class="sectionbody"> +<div class="sect2"> +<h3 id="_overview">Overview</h3> +<div class="paragraph"> +<p>Tamaya provides also support for integration with OSGI. Hereby several options are available how Tamaya can be used in +an OSGI context:</p> +</div> +<div class="olist arabic"> +<ol class="arabic"> +<li> +<p>All Tamaya modules, its API and core library are actually valid OSGI bundles. So adding them into your OSGI modules +and using Tamaya is basically directly supported. Nevertheless OSGI works rather differently from a class- and +resource loading perspective. As long as you rely on Tamaya’s mechanisms for resource loading things should work +out of the box. In the back Tamaya’s core module actually comes with implicit OSGI support, which is automatically +activated, if Tamaya is running in an OSGI context. This support actually</p> +<div class="ulist"> +<ul> +<li> +<p>Listens on deployed bundles and actively reads all resources configured as java.util.ServiceLoader services and +registers them as OSGI services. Hereby integration is complete meaning you can also register Tamaya services +as normal OSGI services, e.g. your own PropertySource instances.</p> +</li> +<li> +<p>Uses the OSGI bundle to resolve for resources, because accessing them from the classloader directly +typically fails in an OSGI context.</p> +</li> +</ul> +</div> +</li> +<li> +<p>Adding Tamaya’s OSGI integration module replaces the existing OSGI ConfigAdmin service with an istance based on +Tamaya. Hereby several aspects can be configured using system properties:</p> +<div class="ulist"> +<ul> +<li> +<p>org.tamaya.integration.osgi.cm.ranking (int) allows to configure the OSGI service ranking used by the Tamaya +BundleActivator to register Tamaya’s ConfigAdmin service. In OSGI higher ranking precede lower rankings. By default +Tamaya’s OSGI extending service registration mechanism is reusing any annotated @Priority priority values as +corresponsing rankings.</p> +</li> +<li> +<p>org.tamaya.integration.osgi.cm.override (boolean) allows to configure if Tamaya is overriding any existing +values from the default ConfigAdmin instance, or only extending them. In other words this setting allows you to +define, which configuration subsystem has precedence for evaluating the final values, either Tamaya based +configuration (default) or the configuration mechanisms provided by default from your OSGI container (when this flag +is set to false).</p> +</li> +<li> +<p>org.tamaya.integration.osgi.cm.inject allows you to deactivate injection of configuration values into your +OSGI services (by default injection is enabled). In all cases accessing the OSGI ConfigAdmin service to +read your configuration is working as usual. But Tamaya adds additional injection functionality, which allows +to inject typed configuration as described by the Tamaya injection api.</p> +</li> +</ul> +</div> +</li> +</ol> +</div> +<div class="paragraph"> +<p>It is also possible to combine things, e.g. when you only define a low ranking for Tamaya’s configuration service and +the same time allow injection to be active, you will have Tamaya’s injection support based on your default +OSGI configuration.</p> +</div> +</div> +<div class="sect2"> +<h3 id="_compatibility">Compatibility</h3> +<div class="paragraph"> +<p>All module described are based on Java 7, so it will run on Java 7 and beyond. +The modules are built against OSGI Compendium version 5.0.</p> +</div> +</div> +<div class="sect2"> +<h3 id="_installation">Installation</h3> +<div class="paragraph"> +<p>To benefit from Tamaya in an OSGI context you must deploy at least the following modules to your OSGI runtime +environment:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-listing" data-lang="listing"># API and core +org.apache.tamaya:tamaya-api:{tamaya_version} +org.apache.tamaya:tamaya-core:{tamaya_version} +org.apache.geronimo.specs:geronimo-annotation_1.2_spec:1.0-alpha-1 +# injection API. SE injection module and dependencies +org.apache.tamaya.ext:tamaya-injection-api:{tamaya_version} +org.apache.tamaya.ext:tamaya-injection:{tamaya_version} +org.apache.geronimo.specs:geronimo-atinject_1.0_spec:1.0 +org.apache.geronimo.specs:geronimo-el_2.2_spec:1.0.4 +org.apache.geronimo.specs:geronimo-interceptor_1.1_spec:1.0 +org.apache.geronimo.specs:geronimo-jcdi_1.1_spec:1.0 +# OSGI integration and dependencies +org.apache.tamaya.ext:tamaya-osgi:{tamaya_version} +org.apache.tamaya.ext:tamaya-functions:{tamaya_version}</code></pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_usage">Usage</h3> +<div class="paragraph"> +<p>As an example, what is possible you can implement an OSGI service as a normal POJO and publish it as an OSGI service. +Given that configuration can be injected very easily:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public class HelloServiceImpl implements HelloService{ + + @Config("example.message") + @ConfigDefault("A Tamaya default.") + private String message; + + @Override + public String sayHello() { + System.err.println("HELLO: " + message); + return message; + } +}</code></pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_spi">SPI</h3> +<div class="paragraph"> +<p>By default the OSGI pid or factory pid is mapped to a corresponding root section in Tamaya’s configuration. We are +well aware that this might not always be the desired approach. Therefore there as an SPI service provided that allows +to determine this mapping:</p> +</div> +<div class="listingblock"> +<div class="title">OSGIConfigRootMapper</div> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public interface OSGIConfigRootMapper { + + String getTamayaConfigRoot(String pid, String factoryPid); +}</code></pre> +</div> +</div> +<div class="paragraph"> +<p>Registering your own implementation as an OSGI service allows you to redefine the key mapping. +By default a configuration mapping for pid/factoryPid==myBundle is mapped to [bundle:myBundle]. +This mapping is used as a prefix when collecting the corresponding entries for the OSGI configuration.</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-2016 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.0</span></a> + at <span>2016-12-19</span> + </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.<br /> + <a href="http://incubator.apache.org/guides/website.html" style="border:0px;" target="_target"><img class="incubator-logo" src="../../logos/egg-logo2.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/cb3c154a/documentation/extensions/mod_remote.html ---------------------------------------------------------------------- diff --git a/documentation/extensions/mod_remote.html b/documentation/extensions/mod_remote.html new file mode 100644 index 0000000..177daac --- /dev/null +++ b/documentation/extensions/mod_remote.html @@ -0,0 +1,288 @@ +<!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&#8201;&#8212;&#8201;Extension: Remote Configuration</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="../../">Apache Tamaya (incubating)</a> + </div> + <div class="navbar-collapse collapse"> + <ul class="nav navbar-nav"> + <li><a href="../../index.html">Home</a></li> + <li><a href="../../about.html">About</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/index.html">Javadoc ${tamaya_version} (external)</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="../../devguide.html">Development Guide</a></li> + <li><a href="../../release-guide.html">Release Guide</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&#8201;&#8212;&#8201;Extension: Remote Configuration</h1> + </div> + + <p><em>2016-12-19</em></p> + + <p><div id="preamble"> +<div class="sectionbody"> +<!-- toc disabled --> +</div> +</div> +<div class="sect1"> +<h2 id="Remote">Tamaya Remote Configuration (Extension Module)</h2> +<div class="sectionbody"> +<div class="sect2"> +<h3 id="_overview">Overview</h3> +<div class="paragraph"> +<p>The Tamaya remote module provides support for reading configuration from remote resources. It provides +especially out-of-the-box support for reading scoped configuration from a configuration server as +provided with the <em>Tamaya server module</em> .</p> +</div> +</div> +<div class="sect2"> +<h3 id="_compatibility">Compatibility</h3> +<div class="paragraph"> +<p>The module is based on Java 7, so it will not run on Java 7 and beyond.</p> +</div> +</div> +<div class="sect2"> +<h3 id="_installation">Installation</h3> +<div class="paragraph"> +<p>To benefit from configuration builder support 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-remote</artifactId> + <version>{tamaya_version}</version> +</dependency></code></pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_reading_remote_configuration_from_a_tamaya_configuration_server">Reading Remote configuration from a Tamaya Configuration Server</h3> +<div class="paragraph"> +<p>The remote module allows reading JSON formatted configuration as provided by the <em>Tamaya server extension</em> . The JSON +format used looks as follows:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-json" data-lang="json">{ + "java.vendor.url": "http://java.oracle.com/", + "java.vendor.url.bug": "http://bugreport.sun.com/bugreport/", + "java.vm.info": "mixed mode", + "java.vm.name": "Java HotSpot(TM) 64-Bit Server VM", + "java.vm.specification.name": "Java Virtual Machine Specification", + "java.vm.specification.vendor": "Oracle Corporation", + "java.vm.specification.version": "1.8", + "java.vm.vendor": "Oracle Corporation", + "java.vm.version": "25.45-b02", + "sun.arch.data.model": "64", + "sun.boot.class.path": "C:\apps\jdk18\jre\lib\resources.jar;C:\apps\jdk18\jre\lib\rt.jar;C:\apps\jdk18\jre\lib\sunrsasign.jar;C:\apps\jdk18\jre\lib\jsse.jar;C:\apps\jdk18\jre\lib\jce.jar;C:\apps\jdk18\jre\lib\charsets.jar;C:\apps\jdk18\jre\lib\jfr.jar;C:\apps\jdk18\jre\classes", + "sun.boot.library.path": "C:\apps\jdk18\jre\bin", + "sun.cpu.endian": "little", + "sun.cpu.isalist": "amd64", + "sun.desktop": "windows", + "sun.io.unicode.encoding": "UnicodeLittle", + "sun.java.command": "com.intellij.rt.execution.application.AppMain org.apache.tamaya.examples.remote.server.Start", + "sun.java.launcher": "SUN_STANDARD", + "sun.jnu.encoding": "Cp1252", + "sun.management.compiler": "HotSpot 64-Bit Tiered Compilers", + "sun.os.patch.level": "", + "{meta}class": "org.apache.tamaya.functions.FilteredConfiguration", + "{meta}info.filter": "java.v,sun", + "{meta}info.format": "application/json", + "{meta}info.timestamp": "1441463200571", + "{meta}timestamp": "1441463200571", + "{meta}type": "Configuration" +}</code></pre> +</div> +</div> +<div class="paragraph"> +<p>Basically there are no constraints about they keys provided. By default Tamaya uses keys prefixed with +{xxx} to identify meta-data entries, but this is not a required precondition.</p> +</div> +<div class="paragraph"> +<p>Finally such a remote configuration can be easily integrated by inheriting from the provided base +class. Hereby a default ordinal must be defined and the protected Collection<URL> getAccessURLs() +method must be implemented to define the URL from where the configuration should be accessible. Hereby +multiple URLs can be provided, which are accesed in order as provided by the collection’s iterator. The +first URL that is successfully accessed determines the configuration read and imported into the +PropertySource.</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public class RemotePropertySource extends BaseRemotePropertySource{ + /** Current remote property source default ordinal. */ + private static final int REMOTE_ORDINAL = 15000; + + @Override + public int getDefaultOrdinal(){ + return REMOTE_ORDINAL; + } + + @Override + protected Collection<URL> getAccessURLs() { + try { + String configServerUrl = System.getenv("CONFIG_SERVER"); + if(configServerUrl==null){ + configServerUrl = System.getProperty("configServer"); + } + if(configServerUrl==null){ + configServerUrl = "http://localhost:8888/config?scope=CLIENT&scopeId={clientId}&format=application/json"; + } + System.out.println("Reading config from " + configServerUrl.replace("{clientId}", Client.getClientId())); + return Arrays.asList(new URL[]{new URL(configServerUrl.replace("{clientId}", Client.getClientId()))}); + } catch (MalformedURLException e) { + Logger.getLogger(getClass().getName()).log(Level.WARNING, "Failed to configure remote config location,", e); + return Collections.emptySet(); + } + } + +}</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-2016 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.0</span></a> + at <span>2016-12-19</span> + </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.<br /> + <a href="http://incubator.apache.org/guides/website.html" style="border:0px;" target="_target"><img class="incubator-logo" src="../../logos/egg-logo2.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/cb3c154a/documentation/extensions/mod_resolver.html ---------------------------------------------------------------------- diff --git a/documentation/extensions/mod_resolver.html b/documentation/extensions/mod_resolver.html new file mode 100644 index 0000000..0e8159d --- /dev/null +++ b/documentation/extensions/mod_resolver.html @@ -0,0 +1,313 @@ +<!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&#8201;&#8212;&#8201;Extension: Resolver</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="../../">Apache Tamaya (incubating)</a> + </div> + <div class="navbar-collapse collapse"> + <ul class="nav navbar-nav"> + <li><a href="../../index.html">Home</a></li> + <li><a href="../../about.html">About</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/index.html">Javadoc ${tamaya_version} (external)</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="../../devguide.html">Development Guide</a></li> + <li><a href="../../release-guide.html">Release Guide</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&#8201;&#8212;&#8201;Extension: Resolver</h1> + </div> + + <p><em>2016-12-19</em></p> + + <p><div class="sect1"> +<h2 id="Core">Tamaya Resolver (Extension Module)</h2> +<div class="sectionbody"> +<div class="sect2"> +<h3 id="_overview">Overview</h3> +<div class="paragraph"> +<p>Tamaya Resolver is an extension module. Refer to the +<a href="modules.html">extensions documentation</a> +for further details about modules.</p> +</div> +<div class="paragraph"> +<p>Tamaya Resolver provides a dynamic resolution mechanism, which allows to use UNIX-styled (${...} placeholder +expressions in your configuration values. The resolver hereby supports transitive resolution and also prevents +cycles to loop endlessly.</p> +</div> +</div> +<div class="sect2"> +<h3 id="_compatibility">Compatibility</h3> +<div class="paragraph"> +<p>The module is based on Java 7, so it can be used with Java 7 and beyond.</p> +</div> +</div> +<div class="sect2"> +<h3 id="_installation">Installation</h3> +<div class="paragraph"> +<p>To benefit from dynamic value resolution 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-resolver</artifactId> + <version>0.3-SNAPSHOT</version> +</dependency></code></pre> +</div> +</div> +<div class="paragraph"> +<p>The module automatically registers an according PropertyFilter that is automatically called, whenever a value +is accessed.</p> +</div> +</div> +<div class="sect2"> +<h3 id="_available_resolvers">Available Resolvers</h3> +<div class="paragraph"> +<p>Currently the module defined the following resolvers:</p> +</div> +<table class="tableblock frame-all grid-all spread"> +<caption class="title">Table 1. Available Resolvers</caption> +<colgroup> +<col style="width: 25%;"> +<col style="width: 50%;"> +<col style="width: 25%;"> +</colgroup> +<tbody> +<tr> +<td class="tableblock halign-left valign-top"><p class="tableblock"><em>Expression</em></p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock"><em>Description</em></p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock"><em>Example</em></p></td> +</tr> +<tr> +<td class="tableblock halign-left valign-top"><p class="tableblock">conf:<configKey></p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">Reads another configKey and replaces the expression with the value found.</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">conf-ref=${conf:anotherConf.entryKey}</p></td> +</tr> +<tr> +<td class="tableblock halign-left valign-top"><p class="tableblock">resource:<resourceRef></p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">Reads a resource from the current classpath and replaces the expression with the given text content.</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">cp-ref=${resource:Testresource.txt}</p></td> +</tr> +<tr> +<td class="tableblock halign-left valign-top"><p class="tableblock">file:<fileRef></p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">Reads a resource from the current classpath and replaces the expression with the given text content.</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">file-ref=${file:c:\myFile.txt}</p></td> +</tr> +<tr> +<td class="tableblock halign-left valign-top"><p class="tableblock">url:<url></p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">Reads an URL and replaces the expression with the given text content.</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">url-ref=${url:http://www.google.com}</p></td> +</tr> +</tbody> +</table> +</div> +<div class="sect2"> +<h3 id="_spi_implementing_your_own_resolvers">SPI: Implementing your own Resolvers</h3> +<div class="paragraph"> +<p>The module also provides an easy but powerful SPI for adding your own resolver implementations. Basically the +first and most important thing to do is implementing the ExpressionResolver interface:</p> +</div> +<div class="listingblock"> +<div class="title">Implementing a Custom Resolver</div> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public class PwdDecrypter implements ExpressionResolver { + + @Override + public String getResolverPrefix() { + return "decrypt:"; + } + + @Override + public String evaluate(String expression) { + return decrypt(expression); + } + + private String decrypt(String s) { + ... + } +}</code></pre> +</div> +</div> +<div class="paragraph"> +<p>Basically that is all you must do, after having registered the class with the ServiceLoader it will be found +and loaded by the implementation. With that all expressions that start with the given prefix are passed to the +resolver, so all the following expressions will be sent to the implementation:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-listing" data-lang="listing">blabla ${decrypt:myname} +blabla ${decrypt:myname} foo blabla ${decrypt:myname}</code></pre> +</div> +</div> +<div class="paragraph"> +<p>Hereby evaluation is repeated until no further change of values could be detetced. In case of a endless loop +the evaluation is broken after a (configurable) number of cycles.</p> +</div> +<div class="paragraph"> +<p>Under the hood instances of ExpressionResolver are managed by an implementation of the ExpressionEvaluator +interface:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public interface ExpressionEvaluator { + /** + * Evaluates the current expression. + * @param key the key, not null. + * @param value the value to be filtered/evaluated. + * @return the filtered/evaluated value, including null. + */ + String evaluateExpression(String key, String value); +}</code></pre> +</div> +</div> +<div class="paragraph"> +<p>Implementing and registering this interface gives you full control, but in most cases yhou should be fine with +the default implementation in place.</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-2016 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.0</span></a> + at <span>2016-12-19</span> + </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.<br /> + <a href="http://incubator.apache.org/guides/website.html" style="border:0px;" target="_target"><img class="incubator-logo" src="../../logos/egg-logo2.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>