http://git-wip-us.apache.org/repos/asf/incubator-tamaya-site/blob/8e3904a8/documentation-new/extensions/mod_events.html ---------------------------------------------------------------------- diff --git a/documentation-new/extensions/mod_events.html b/documentation-new/extensions/mod_events.html new file mode 100644 index 0000000..118906a --- /dev/null +++ b/documentation-new/extensions/mod_events.html @@ -0,0 +1,561 @@ +<!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: Events</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: Events</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="Events">Tamaya Events (Extension Module)</h2> +<div class="sectionbody"> +<div class="paragraph"> +<p>Tamaya <em>Events</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>Events</em> provides a mechanism to publish and subscribe to ConfigEvent<T> instances. +This module implements ConfigChange or ConfigSourceChange as possible payloads, but +the module itself is not constraint to this payload types. +These payload types describe detected changes of key/values of a Config or a ConfigSource. +The extension also provides a <em>Singleton accessor</em> which allows to register/unregister +listeners for changes and the period, when configuration should be scanned for +any changes.</p> +</div> +<div class="paragraph"> +<p>Summarizing with the events module you can easily observe configuration changes, record the +state of any configuration and compare configuration states to create and publish related +change events.</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>To benefit from configuration event 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-events</artifactId> + <version>{tamaya_version}</version> +</dependency></code></pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_core_architecture">Core Architecture</h3> +<div class="paragraph"> +<p>The core of the module are the ConfigEventListener and the ConfigEvent interfaces, +which defines an abstraction for event handling and observation:</p> +</div> +<div class="listingblock"> +<div class="title">ConfigEvent</div> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public interface ConfigEvent<T> { + + Class<T> getResourceType(); + T getResource(); + String getVersion(); + long getTimestamp(); +} + +@FunctionalInterface +public interface ConfigEventListener { + + void onConfigEvent(ConfigEvent<?> event); + +}</code></pre> +</div> +</div> +<div class="paragraph"> +<p>Hereby the payload <em>T</em> can be basically of an arbitrary type as long as +it implements the ConfigEvent interface. The next sections +give more details on the the event types provided by this extension +and their usage.</p> +</div> +<div class="paragraph"> +<p>Also the technology to be used for publishing these event types is adaptable. +In SE the module uses a simple in-memory implementation based on the +Google <em>Guava</em> library. But users can replace this mechanism as needed. For +more details refer to the SPI section later in this guide.</p> +</div> +</div> +<div class="sect2"> +<h3 id="_the_configeventmanager_singleton">The ConfigEventManager Singleton</h3> +<div class="paragraph"> +<p>Main entry point of the events module is the ConfigEventManager singleton class, which provides static accessor +methods to the extension’s functionality:</p> +</div> +<div class="ulist"> +<ul> +<li> +<p><em>Adding/removing</em> of ConfigChangeListener instances, either globally or per event type.</p> +</li> +<li> +<p><em>Firing configuration events</em> synchronously or asyncronously (mostly called by framework code).</p> +</li> +<li> +<p><em>Configuring the monitor</em> that periodically checks for changes on the global Configuration provided +by ConfigurationProvider.getConfiguration().</p> +</li> +</ul> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public final class ConfigEventManager { + + private ConfigEventManager() {} + + public static void addListener(ConfigEventListener l); + public static <T extends ConfigEvent> void addListener(ConfigEventListener l, Class<T> eventType); + public static void removeListener(ConfigEventListener l); + public static <T extends ConfigEvent> void removeListener(ConfigEventListener l, Class<T> eventType); + public static <T extends ConfigEvent> + Collection<? extends ConfigEventListener> getListeners(); + public static <T extends ConfigEvent> + Collection<? extends ConfigEventListener> getListeners(Class<T> type); + + public static <T> void fireEvent(ConfigEvent<?> event); + public static <T> void fireEventAsynch(ConfigEvent<?> event); + + public static void enableChangeMonitoring(boolean enable); + public static boolean isChangeMonitoring(); + public long getChangeMonitoringPeriod(); + public void setChangeMonitoringPeriod(long millis); + +}</code></pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_modelling_configuration_changes_as_events">Modelling configuration changes as events</h3> +<div class="paragraph"> +<p>This module provides a serializable and thread-safe abstraction modelling a +configuration change, which is anything of the following</p> +</div> +<div class="ulist"> +<ul> +<li> +<p>additional, <em>new</em> configuration entries</p> +</li> +<li> +<p><em>removed</em> configuration entries</p> +</li> +<li> +<p><em>changes</em> on existing entries</p> +</li> +</ul> +</div> +<div class="paragraph"> +<p>A collection of changes</p> +</div> +<div class="ulist"> +<ul> +<li> +<p>on a Config is modelled by the ConfigChange class</p> +</li> +<li> +<p>on a ConfigSource is modelled by the ConfigSourceChange class</p> +</li> +</ul> +</div> +<div class="sect3"> +<h4 id="_configuration_changes">Configuration Changes</h4> +<div class="paragraph"> +<p>A set of changes on a Config is described by a ConfigChange +as follows:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public final class ConfigChange implements ConfigEvent<Config>, Serializable{ + + public static ConfigChange emptyChangeSet(Config configuration); + + @Override + public Config getResource(); + @Override + public Class<Config> getResourceType(); + @Override + public String getVersion(); + @Override + public long getTimestamp(); + + // Event specific methods + + public Collection<PropertyChangeEvent> getChanges(); + public int getRemovedSize(); + public int getAddedSize(); + public int getUpdatedSize(); + + public boolean isKeyAffected(String key); + public boolean isRemoved(String key); + public boolean isAdded(String key); + public boolean isUpdated(String key); + public boolean containsKey(String key); + public boolean isEmpty(); +}</code></pre> +</div> +</div> +<div class="paragraph"> +<p>New instances of ConfignChange hereby can be created using a +fluent ConfigChangeBuilder:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">Config config = ...; +ConfigChange change = ConfigChangeBuilder.of(config) + .addChange("MyKey", "newValue") + .removeKeys("myRemovedKey").build();</code></pre> +</div> +</div> +<div class="paragraph"> +<p>Also it is possible to directly compare 2 instances of Config, +which results in a ConfigChange that +reflects the differences between the two configurations passed:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">Comparing 2 configurations +------------------------------------------------------- +Config config = ...; +Config changedConfig = ...; +ConfigChange change = ConfigChangeBuilder.of(config) + .addChanges(changedConfig).build(); +-------------------------------------------------------</code></pre> +</div> +</div> +<div class="paragraph"> +<p>So a ConfigChange describes all the changes detected on a Config. +This allows you to publish instances of this class as events to all registered +listeners (observer pattern). +For listening to ConfigChange events you must implement the +ConfigEventListener functional interface:</p> +</div> +<div class="listingblock"> +<div class="title">Implementing a ConfigChangeListener</div> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public final class MyConfigChangeListener implements ConfigEventListener<ConfigChange>{ + + private Config config = ConfigProvider.getConfig(); + + public void onConfigEvent(ConfigEvent<?> event){ + if(event.getResourceType()==Config.class){ + if(event.getConfiguration()==config){ + // do something + } + } + } + +}</code></pre> +</div> +</div> +<div class="paragraph"> +<p>You can <strong>register</strong> your implementation as illustrated below:</p> +</div> +<div class="olist arabic"> +<ol class="arabic"> +<li> +<p>Manually by calling ConfigEventManager.addListener(new MyConfigChangeListener())</p> +</li> +<li> +<p>Automatically by registering your listener using the ServiceLoader under +META-INF/services/org.apache.tamaya.events.ConfigEventListener</p> +</li> +</ol> +</div> +<div class="paragraph"> +<p>Registering programmatically also allows you to define additional constraint, +to filter out all kind of events you are not interested in.</p> +</div> +<div class="admonitionblock note"> +<table> +<tr> +<td class="icon"> +<div class="title">Note</div> +</td> +<td class="content"> +By default detection of configuration changes is not enabled. To enable it, call +ConfigEventManager.enableChangeMonitoring(true). +</td> +</tr> +</table> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_configsource_changes">ConfigSource Changes</h3> +<div class="paragraph"> +<p>Beside that a whole Config changes, also a ConfigSource can change, +e.g. by a configuration file edited on the fly. This is similarly to a +ConfigChange reflected by the classes ConfigSourceChange, +ConfigSourceChangeBuilder.</p> +</div> +<div class="sect3"> +<h4 id="_monitoring_of_configuration_changes">Monitoring of configuration changes</h4> +<div class="paragraph"> +<p>The ConfigEventManager supports <strong>active monitoring of the current configuration</strong> to trigger corresponding change +events to listeners registered. <strong>This feature is deactivated by default</strong>, but can be enabled by calling +ConfigEventManager.enableChangeMonitoring(true);. This feature avoids regularly polling your local Config for +any kind of changes. If a change has been encountered Tamaya identifies it and triggers corresponding +ConfigChange events automatically.</p> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_freezing_configs_and_configsources">Freezing Configs and ConfigSources</h3> +<div class="paragraph"> +<p>Config instances as well as ConfigSources are explicitly not required to be serializable. To enable easy +serialization of these types a Config's <strong>current state can be frozen</strong> (e.g. for later comparison with a newly +loaded version). Freezing hereby means</p> +</div> +<div class="ulist"> +<ul> +<li> +<p>all key/values are read-out by calling the getProperties() method.</p> +</li> +<li> +<p>a meta data entry is added of the form _frozenAt=223273777652325677, whichdefines the UTC timestamp in +milliseconds when this instance was frozen.</p> +</li> +<li> +<p>if not already defined an _id property will be added to the Config containing the +identifier of the configuration.</p> +</li> +</ul> +</div> +<div class="paragraph"> +<p>In code freezing is a no-brainer:</p> +</div> +<div class="listingblock"> +<div class="title">Freezing the current Config</div> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">Config config = ConfigProvider.getConfig(); +Config frozenConfig = FrozenConfig.of(config);</code></pre> +</div> +</div> +<div class="olist lowerroman"> +<ol class="lowerroman" type="i"> +<li> +<p>and similarly for a ConfigSource:</p> +</li> +</ol> +</div> +<div class="listingblock"> +<div class="title">Freezing a ConfigSource</div> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">ConfigSource configSource = ...; +ConfigSource frozenSource = FrozenConfigSource.of(configSource);</code></pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_spis">SPIs</h3> +<div class="paragraph"> +<p>This component also defines SPIs, which allows to adapt the implementation of the main ConfigEventManager +singleton. This enables, for example, using external eventing systems, such as CDI, instead of the default provided +simple SE based implementation. By default implementations must be registered using the current ServiceContext +active (by default using the Java ServiceLoader mechanism).</p> +</div> +<div class="listingblock"> +<div class="title">SPI: ConfigEventSpi</div> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public interface ConfigEventManagerSpi { + + <T> void addListener(ConfigEventListener l); + <T extends ConfigEvent> void addListener(ConfigEventListener l, Class<T> eventType); + void removeListener(ConfigEventListener l); + <T extends ConfigEvent> void removeListener(ConfigEventListener l, Class<T> eventType); + Collection<? extends ConfigEventListener> getListeners(); + Collection<? extends ConfigEventListener> getListeners(Class<? extends ConfigEvent> eventType); + + void fireEvent(ConfigEvent<?> event); + void fireEventAsynch(ConfigEvent<?> event); + + long getChangeMonitoringPeriod(); + void setChangeMonitoringPeriod(long millis); + boolean isChangeMonitorActive(); + void enableChangeMonitor(boolean enable); +}</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_features.html ---------------------------------------------------------------------- diff --git a/documentation-new/extensions/mod_features.html b/documentation-new/extensions/mod_features.html new file mode 100644 index 0000000..527da95 --- /dev/null +++ b/documentation-new/extensions/mod_features.html @@ -0,0 +1,305 @@ +<!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: Features Check</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: Features Check</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="Features">Tamaya Features Check (Extension Module)</h2> +<div class="sectionbody"> +<div class="paragraph"> +<p>Tamaya <em>Features</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>Features</em> provides a simple Features singleton that allows to check +which Tamaya Extensions are currently on the classpath.</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 Tamaya <em>Features</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-features</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 Features singleton, which provides various static methods +to check, which Tamaya extensions are currently loaded.</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public final class Features { + + private Features(){} + + public static boolean eventsAvailable(); + public static boolean formatsAvailable(); + public static boolean tamayaCoreAvailable(); + public static boolean injectionAvailable(); + public static boolean injectionCDIAvailable(); + public static boolean mutableConfigAvailable(); + public static boolean optionalAvailable(); + public static boolean resolverAvailable(); + public static boolean resourcesAvailable(); + public static boolean spiSupportAvailable(); + public static boolean filterSupportAvailable(); + public static boolean springAvailable(); + public static boolean jndiAvailable(); + + public static boolean extSpringCoreAvailable(); + public static boolean extJndiAvailable(); + public static boolean extOSGIAvailable(); + + public static boolean checkClassIsLoadable(String classname); +}</code></pre> +</div> +</div> +<div class="ulist"> +<ul> +<li> +<p>eventsAvailable(); checks for the <a href="mod_events.html"><em>tamaya_events</em></a> module.</p> +</li> +<li> +<p>formatsAvailable(); checks for the <a href="mod_formats.html"><em>tamaya_formats</em></a> module.</p> +</li> +<li> +<p>tamayaCoreAvailable(); checks if the <a href="core.html"><em>Tamaya core</em></a> implementation is loaded.</p> +</li> +<li> +<p>injectionAvailable(); checks for the <a href="mod_injection.html"><em>tamaya_injection</em></a> SE module.</p> +</li> +<li> +<p>injectionCDIAvailable(); checks for the <a href="mod_cdi.html"><em>tamaya CDI</em></a> modules.</p> +</li> +<li> +<p>mutableConfigAvailable(); checks for the <a href="mod_mutableconfig.html"><em>tamaya_mutableconfig</em></a> module.</p> +</li> +<li> +<p>optionalAvailable(); checks for the <a href="mod_optional.html"><em>tamaya_optional</em></a> module.</p> +</li> +<li> +<p>resolverAvailable(); checks for the <a href="mod_resolver.html"><em>tamaya_resolver</em></a> module.</p> +</li> +<li> +<p>resourcesAvailable(); checks for the <a href="mod_reources.html"><em>tamaya_resources</em></a> module.</p> +</li> +<li> +<p>spiSupportAvailable(); checks for the <a href="mod_spisupport.html"><em>tamaya_spisupport</em></a> module.</p> +</li> +<li> +<p>filterSupportAvailable(); checks for the <a href="mod_filter.html"><em>tamaya_filter</em></a> module.</p> +</li> +<li> +<p>springAvailable(); checks for the <a href="mod_spring.html"><em>tamaya_spring</em></a> module.</p> +</li> +<li> +<p>jndiAvailable(); checks for the <a href="mod_jndi.html"><em>tamaya_jndi</em></a> module.</p> +</li> +<li> +<p>extJndiAvailable(); checks if creation of a new <code>InitialContext</code> is successful.</p> +</li> +<li> +<p>extSpringCoreAvailable(); checks if Spring Core is on the classpath.</p> +</li> +<li> +<p>extOSGIAvailable(); checks the OSGI framework is on the classpath.</p> +</li> +<li> +<p>Finally checkClassIsLoaded(String) tries to load a class. If it fails, <code>false</code> is returned.</p> +</li> +</ul> +</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_filter.html ---------------------------------------------------------------------- diff --git a/documentation-new/extensions/mod_filter.html b/documentation-new/extensions/mod_filter.html new file mode 100644 index 0000000..c0dad8f --- /dev/null +++ b/documentation-new/extensions/mod_filter.html @@ -0,0 +1,302 @@ +<!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: User Filtering</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: User Filtering</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="Filter">User Filtering (Extension Module)</h2> +<div class="sectionbody"> +<div class="paragraph"> +<p>Tamaya <em>Filter</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>Filter</em> provides a simple singleton accessor that allows to explicitly add Filter instances +active on the current thread only. This can be very useful in many scenarios, especially within +Java EE web filters or similar. Additionally this module adds +standard filters that hide metadata entries when the full configuration map is accessed. When keys are accessed +explicitily no filtering is applied and everything is visible.</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 benefit from filter 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-filter</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>Tamaya Filter comes basically with 3 artifacts:</p> +</div> +<div class="ulist"> +<ul> +<li> +<p>The org.apache.tamaya.filter.ConfigurationFilter provides several static methods to register Filter +instances on the current thread:</p> +</li> +</ul> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public final class ConfigurationFilter implements Filter{ + + ... + + /** + * Seactivates metadata filtering also on global map access for this thread. + * @see #clearFilters() + * @param active true,to enable metadata filtering (default). + */ + public static void setFilterMetadata(boolean active); + + /** + * Access the filtering configuration that is used for filtering single property values accessed. + * @return the filtering config, never null. + */ + public static FilterContext getSingleFilterContext(); + + /** + * Access the filtering configuration that is used for filtering configuration properties accessed as full + * map. + * @return the filtering config, never null. + */ + public static FilterContext getMapFilters(); + + /** + * Removes all programmable filters active on the current thread. + */ + public static void clearFilters(); + + ... + +}</code></pre> +</div> +</div> +<div class="paragraph"> +<p>For using regular expression when filtering configuration keys a corresponding implementation of a PropertyFilter +is part of this module, So you can add a customized filter as follows:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">try { + ConfigurationFilter.getMapFilters().addFilter(new myFilter()); + + // do your code with filtering active +} +finally { + // cleanup + ConfigurationFilter.clearFilters(); +}</code></pre> +</div> +</div> +<div class="paragraph"> +<p>The FilterChain is a simple compound structure combining multiple filters into one new (chained) filter:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public final class FilterChain implements Filter { + + public void addFilter(Filter filter); + public void addFilter(int pos, Filter filter); + public Filter removeFilter(int pos); + public void clearFilters(); + public void setFilters(Filter... filters); + public void setFilters(Collection<Filter> filters); + public List<Filter> getFilters(); + +}</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_formats.html ---------------------------------------------------------------------- diff --git a/documentation-new/extensions/mod_formats.html b/documentation-new/extensions/mod_formats.html new file mode 100644 index 0000000..8598b45 --- /dev/null +++ b/documentation-new/extensions/mod_formats.html @@ -0,0 +1,595 @@ +<!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: Formats</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: Formats</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="Formats">Tamaya Formats (Extension Module)</h2> +<div class="sectionbody"> +<div class="paragraph"> +<p>Tamaya <em>Formats</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>Formats</em> provides an abstraction for configuration formats provding the following benefits:</p> +</div> +<div class="ulist"> +<ul> +<li> +<p>Parsing of resources in can be implemented separately from interpreting the different aspects/parts parsed. As an +example a file format can define different sections. Depending on the company specific semantics of the sections +a different set of ConfigSource instances must be created.</p> +</li> +<li> +<p>Similarly the configuration abstraction can also be used as an interface for integrating Tamaya with alternate +frameworks that provide logic for reading configuration files, such as Apache commons.configuration.</p> +</li> +</ul> +</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 use the formats module 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-formats</artifactId> + <version>{tamaya_version}</version> +</dependency></code></pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_basic_concept">Basic Concept</h3> +<div class="paragraph"> +<p>Formats should be reusable, meaning you should have to write a format parser only once and then be able to map the data read into whatever +data structure (in our cases: property sources). So it is useful to separate concerns into</p> +</div> +<div class="ulist"> +<ul> +<li> +<p>an arbitrary configuration format (textual or binary)</p> +</li> +<li> +<p>a parser (ConfigurationFormat) that transfers a given format into an intermediate +representation (ConfigurationData).</p> +</li> +<li> +<p>an optional customization, implemented by a <em>factory method pattern</em> to adapt the mapping of ConfigurationData read +to a collection of ConfigSources (they can have different ordinal semantics).</p> +</li> +</ul> +</div> +<div class="sect3"> +<h4 id="_configurationdata">ConfigurationData</h4> +<div class="paragraph"> +<p>Configuration formats can be very different. Some are simple key/value pairs, whereas other also consist of multiple sections (e.g. ini-files) or +hierarchical data (e.g. yaml, xml). This is solved in Tamaya by mapping the configuration read into a normalized intermediary format called +ConfigurationData:</p> +</div> +<div class="listingblock"> +<div class="title">ConfigurationData</div> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public final class ConfigurationData { + + public ConfigurationFormat getFormat(); + public String getResource(); + + public Set<String> getSectionNames(); + public Map<String,String> getSection(String name); + + public boolean hasDefaultProperties(); + public Map<String,String> getDefaultProperties(); + public Map<String,String> getCombinedProperties(); + + public boolean isEmpty(); +}</code></pre> +</div> +</div> +<div class="paragraph"> +<p>In detail the data read from a file is organized into <em>sections</em> as follows:</p> +</div> +<div class="ulist"> +<ul> +<li> +<p>with getResource() and getFormat() the underlying resource and the format that read this data can be accessed.</p> +</li> +<li> +<p>properties can be owned by</p> +<div class="ulist"> +<ul> +<li> +<p>named sections</p> +</li> +<li> +<p>an (unnamed) default section</p> +</li> +</ul> +</div> +</li> +<li> +<p>each section section contains a map of properties. Hereby the same key can be part of the default section and multiple +named sections, depending on the configuration format.</p> +</li> +<li> +<p>The method getSectionNames() returns a set of all section names.</p> +</li> +<li> +<p>With getSection(String name) a named section can be accessed.</p> +</li> +<li> +<p>With getDefaultSection() the 'default' section can be accessed. This is a convenience method.</p> +</li> +<li> +<p>With getCombinedProperties() a flattened entry map can be accessed built up (by default) out of</p> +<div class="ulist"> +<ul> +<li> +<p>all entries from the default section, without any changes.</p> +</li> +<li> +<p>all entries from named sections, where the key for each entry is prefix with the section name and a '::' separator.</p> +</li> +</ul> +</div> +</li> +<li> +<p>The configuration format used determines the mapping of configuration data read into this structure. The format +implementation can as well provide alternate implementations of how the data read should be mapped into the +combined properties map.</p> +</li> +</ul> +</div> +</div> +<div class="sect3"> +<h4 id="_configurationformat">ConfigurationFormat</h4> +<div class="paragraph"> +<p>A ConfigurationFormat is basically an abstraction that reads a configuration resource (modelled by an InputStream) and +creates a corresponding ConfigurationData instance.</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public interface ConfigurationFormat { + + String getName(); + boolean accepts(URL url); + ConfigurationData readConfiguration(String resource, InputStream inputStream); +}</code></pre> +</div> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_creating_a_default_configsource_for_a_configurationformat">Creating a default ConfigSource for a ConfigurationFormat</h3> +<div class="paragraph"> +<p>The module defines a singleton ConfigurationFormats which provides +an easy to use API for creating ConfigurationData and ConfigSources +using abstract ConfigurationFormat implementations:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public final class ConfigurationFormats { + + public static List<ConfigurationFormat> getFormats(); + public static List<ConfigurationFormat> getFormats(String... formatNames); + public static List<ConfigurationFormat> getFormats(final URL url); + + public static ConfigurationData readConfigurationData(final URL url) + throws IOException; + public static ConfigurationData readConfigurationData(URL url, ConfigurationFormat... formats) + throws IOException; + public static ConfigurationData readConfigurationData(URL url, Collection<ConfigurationFormat> formats) + throws IOException; + public static Collection<ConfigurationData> readConfigurationData(Collection<URL> urls, ConfigurationFormat... formats); + public static Collection<ConfigurationData> readConfigurationData(Collection<URL> urls, Collection<ConfigurationFormat> formats); + public static ConfigurationData readConfigurationData(String resource, InputStream inputStream, + ConfigurationFormat... formats) + throws IOException; + public static ConfigurationData readConfigurationData(String resource, InputStream inputStream, + Collection<ConfigurationFormat> formats) + throws IOException; + + public static ConfigSource createConfigSource(URL url, ConfigurationFormat... formats) + throws IOException; + public static ConfigSource createConfigSource(URL url, Collection<ConfigurationFormat> formats) + throws IOException; + public static ConfigSource createConfigSource(String resource, InputStream inputStream, + ConfigurationFormat... formats); + public static ConfigSource createConfigSource(String resource, InputStream inputStream, + Collection<ConfigurationFormat> formats); +}</code></pre> +</div> +</div> +<div class="ulist"> +<ul> +<li> +<p>getFormats() returns all registered formats.</p> +</li> +<li> +<p>getFormats(String...) allows to access all formats with a given name.</p> +</li> +<li> +<p>getFormats(URL url) allows to access all formats that declare that can optionally read an input from +a given <code>URL</code>.</p> +</li> +<li> +<p>readConfigurationData(...) reads data from an input and creates a corresponding ConfigurationData, +either trying all known formats that declare its compatibility with the given input or the formats +passed explicitly.</p> +</li> +<li> +<p>createConfigSource(...) allows to create a ConfigSource reading a given input and the formats +to be used or known. Hereby a default property mapping is applied.</p> +</li> +</ul> +</div> +<div class="paragraph"> +<p>So creating a ConfigSource from a resource is basically a one liner:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">URL url = ...; +ConfigSource configSource = ConfigurationFormats.createConfigSource(url); + +// constraining the formats to be used (assumption: json and yaml extensions are loaded) +ConfigSource configSource = ConfigurationFormats.createConfigSource( + url, + ConfigurationFormats.getFormats("json", "yaml"));</code></pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_customize_how_configurationdata_maps_to_configsource">Customize how ConfigurationData maps to ConfigSource</h3> +<div class="paragraph"> +<p>For for the conversion of ConfigurationData into a ConfigSource different approaches can be useful:</p> +</div> +<div class="olist arabic"> +<ol class="arabic"> +<li> +<p>The ConfigurationFormat that reads the data can provides all properties read either as sectioned properties +or/and as default properties. The most simple cases is, where all properties have been added as 'default' +properties. In this case the default properties can be used as the property sources properties without any change.</p> +</li> +<li> +<p>If the format did also add section based properties, the combined properties returned can be used, hereby +replacing the '::' separator with a '.' separator.</p> +</li> +<li> +<p>In all other cases a custom mapping is useful, which can be acomplished by using the MappedConfigurationDataConfigSource +and overriding the Map<String,String> populateData(ConfigurationData data) method.</p> +</li> +</ol> +</div> +<div class="paragraph"> +<p>In most cases the usage of a MappedConfigurationDataConfigSource, is a good choice to start. This class +provides a convenient default mapping and also allows to customized the mapping easily:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">ConfigurationData data = ...; +MappedConfigurationDataConfigSource ps = + new MappedConfigurationDataConfigSource(data){ + protected Map<String, String> populateData(ConfigurationData data) { + ... + } + };</code></pre> +</div> +</div> +<div class="paragraph"> +<p>Nevertheless, depending on the context, where a configuration source was read (classloader, time, source etc.) the +resulting properties can have different semnatics, especially different priorities. Also section +names may be mapped into different ordinals instead of using them as key prefixes (e.g. imagine configuration formats +with a 'default', 'main', and 'overrides' sections). For such more complex or custom cases no simple mapping +can be defined. Consequently the functionality mapping the normalized ConfigurationData read to the +appropriate collection of ConfigSource instances must be implemented.</p> +</div> +<div class="paragraph"> +<p>For this scenario the BaseFormatConfigSourceProvider can be used, defining the following mapping +function that mus be implemented:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-java" data-lang="java">/** + * Method to create a {@link org.apache.tamaya.spi.ConfigSource} based on the given entries read. + * + * @param data the configuration data, not null. + * @return the {@link org.apache.tamaya.spi.ConfigSource} instance ready to be registered. + */ +protected abstract Collection<ConfigSource> getConfigSources(ConfigurationData data);</code></pre> +</div> +</div> +<div class="paragraph"> +<p>When using Java 8 these mappings can be asily passed as parameters to the createConfigSource +methods.</p> +</div> +</div> +<div class="sect2"> +<h3 id="_predefined_formats">Predefined formats</h3> +<div class="paragraph"> +<p>The <em>formats</em> module ships with 3 predefined formats:</p> +</div> +<div class="ulist"> +<ul> +<li> +<p><code>.ini</code> files, commonly known from Microsoft based systems, registered as <code>ini</code>.</p> +</li> +<li> +<p><code>.properties</code> files, as defined by <code>java.util.Properties</code>, registered as <code>properties</code>.</p> +</li> +<li> +<p><code>.xml</code> properties files, as defined by <code>java.util.Properties</code>, registered as <code>xml-properties</code>.</p> +</li> +</ul> +</div> +<div class="sect3"> +<h4 id="_ini_config_file_mapping">ini Config File Mapping</h4> +<div class="paragraph"> +<p>This module implements the ini file format with the class +org.apache.tamaya.format.formats.IniConfigurationFormat.</p> +</div> +<div class="paragraph"> +<p>The default mapping is bext illustrated by a small example, so consider the +following <code>.ini</code> file:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-listing" data-lang="listing">a=valA +a.b=valB + +[section1] +aa=sectionValA +aa.b.c=SectionValC + +[section2] +a=val2Section2</code></pre> +</div> +</div> +<div class="paragraph"> +<p>This file content by default is mapped to the following Tamaya properties:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="prettyprint highlight"><code class="language-listing" data-lang="listing">a=valA +a.b=valB +section1::valA=sectionValA +section1::a.b.c=SectionValC +section2::a=val2Section2</code></pre> +</div> +</div> +<div class="paragraph"> +<p>Summarizing</p> +</div> +<div class="ulist"> +<ul> +<li> +<p>entries without a section are mapped to the <em>default</em> section.</p> +</li> +<li> +<p>entries with a section are mapped to a corresponding section, hereby everything between +the brackets is used as section name (trimmed).</p> +</li> +<li> +<p>section names are separated using a double colon (<code>::</code>).</p> +</li> +</ul> +</div> +<div class="paragraph"> +<p>ConfigurationData allows to access all the different parts:</p> +</div> +<div class="ulist"> +<ul> +<li> +<p>the <em>default</em> properties (a, a.b)</p> +</li> +<li> +<p>the section section1, with properties aa, aa.b.c</p> +</li> +<li> +<p>the section section2, with properties a</p> +</li> +</ul> +</div> +</div> +<div class="sect3"> +<h4 id="_xml_property_and_ordinary_property_files">XML Property and ordinary Property Files</h4> +<div class="paragraph"> +<p>This module also ships with ConfigurationFormat implementations that reuse the parsing +functionality provided with java.util.Properties:</p> +</div> +<div class="ulist"> +<ul> +<li> +<p><code>org.apache.tamaya.format.formats.PropertiesFormat</code> uses <code>Properties.read(InputStream)</code>.</p> +</li> +<li> +<p><code>org.apache.tamaya.format.formats.PropertiesXmlFormat</code> uses <code>Properties.readFromXml(InputStream)</code>.</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>
