http://git-wip-us.apache.org/repos/asf/incubator-tamaya-site/blob/97bc8884/extensions/mod_model.html ---------------------------------------------------------------------- diff --git a/extensions/mod_model.html b/extensions/mod_model.html deleted file mode 100644 index 26bf90b..0000000 --- a/extensions/mod_model.html +++ /dev/null @@ -1,769 +0,0 @@ -<!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: Model Documentation and Validation</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="../quickstart.html">Quickstart</a></li> - <li><a href="../index.html">Documentation</a></li> - <li><a href="..//apidocs/index.html">API</a></li> - <li><a href="../index.html">Development</a></li> - <li><a href="../index.html">Releases</a></li> - <li><a href="../about.html">About</a></li> - <li><a href="../sitemap.xml">Sitemap</a></li> - <li><a href="../feed.xml">Subscribe</a></li> -<!-- - <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> ---> - </ul> - </div><!--/.nav-collapse --> - </div> - </div> - - </div> - <div class="container"> - - <div class="page-header"> - <h1>Apache Tamaya&#8201;&#8212;&#8201;Extension: Model Documentation and Validation</h1> - </div> - - <p><em>2016-10-31</em></p> - - <p><div id="preamble"> -<div class="sectionbody"> -<!-- toc disabled --> -</div> -</div> -<div class="sect1"> -<h2 id="ExtModel">Tamaya Model Documentation and Validation (Extension Module)</h2> -<div class="sectionbody"> -<div class="sect2"> -<h3 id="_overview">Overview</h3> -<div class="paragraph"> -<p>The Tamaya model module provides support for documenting configuration and validating configuration read and processed -against this model. Documentation and config models can be provided in different ways:</p> -</div> -<div class="ulist"> -<ul> -<li> -<p>as separate meta-model documents</p> -</li> -<li> -<p>by providers that check classes/packages for configuration annotations (planned)</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 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-model</artifactId> - <version>{tamayaVersion}</version> -</dependency></code></pre> -</div> -</div> -</div> -<div class="sect2"> -<h3 id="_describing_the_configuration_meta_model">Describing the Configuration Meta-Model</h3> -<div class="paragraph"> -<p>Basically configuration is modelled using key, value-pairs. Looking at a keys -a.b.c.param1 and a.b.c.param2 the following concepts can be used to defined/describe -configuration:</p> -</div> -<div class="olist arabic"> -<ol class="arabic"> -<li> -<p>the <em>configuration section:</em> In our case this equals to a.b.c, which itself also includes the -transitive entries a.b and a.</p> -</li> -<li> -<p>the <em>configuration parameter:</em> Basically parameters are adressed using their fully qualified names, -which equals to the containing section name and the relative parameter name, separated by the dor separator. -In the above example a.b.c.param1 and a.b.c.param2 are the fully qualified parameter names.</p> -</li> -</ol> -</div> -<div class="paragraph"> -<p>Now with only these 2 concepts a simple configuration meta-model can be defined as</p> -</div> -<div class="ulist"> -<ul> -<li> -<p>a meta-model’s name, used just for grouping different meta-models and entries to better separate -descriptions, e.g. in a management console or generated configuration documentation site.</p> -</li> -<li> -<p>a set of sections.</p> -</li> -<li> -<p>a set of parameters.</p> -</li> -<li> -<p>Both, sections (.model.target=Section) as well as parameter models (.model.target=Parameter)</p> -<div class="ulist"> -<ul> -<li> -<p>can be modelled by a meta-data entry, by default _my.config.key.model.</p> -</li> -<li> -<p>may be required, or optional (.model.required=true|false)</p> -</li> -<li> -<p>may have an optional description</p> -</li> -</ul> -</div> -</li> -<li> -<p>Parameters additionally have</p> -<div class="ulist"> -<ul> -<li> -<p>a <em>type</em> (.model.type=Classname), described by the fully qualified class name, into which any configured (String) -value must be convertable into. If no type is configured java.ui.lang.String is assumed as default.</p> -</li> -<li> -<p>an optional regular expression that can be used to validate the String values returned from a -configuration (.model.expression=regexpression).</p> -</li> -</ul> -</div> -</li> -</ul> -</div> -<div class="paragraph"> -<p>Given these concepts a configuration can be fully described. Entries that are not contained in one of the given -sections (or its children), or parameters not described or marked as valid (e.g. for dynamic configModels of -a section), are called <em>undefined</em>. Undefined parameters should be grouped with its parent section. Each section, as -well as all parent sections, including transitive) of any parametet read, should similarly marked as undefined, if and -only if</p> -</div> -<div class="olist arabic"> -<ol class="arabic"> -<li> -<p>the section itself is (directly) <em>undefined</em></p> -</li> -<li> -<p>the section is not a <em>super section</em> of a defined section.</p> -</li> -</ol> -</div> -<div class="paragraph"> -<p>As en example the section definition of a.b.c also implicitly includes the sections a.b and a to be defined -sections, despite the fact that section properties, such as description and custom configModels are not inherited to -its parent, or child section.</p> -</div> -</div> -<div class="sect2"> -<h3 id="_defining_meta_configuration_model">Defining Meta-Configuration Model</h3> -<div class="paragraph"> -<p>The configuration meta-model is defined by simple configuration meta-data entries. The section for all model -configuration by default is called model, which results in entries such as _my.config.key.model.target=Section. -Within this section fully qualified configuration keys defines -which part of the configuration is targeted by certain entries.</p> -</div> -<div class="sect3"> -<h4 id="_defining_sections">Defining Sections</h4> -<div class="paragraph"> -<p>First we start to define some configuration sections, the example below starts with the most important -variants supported:</p> -</div> -<div class="listingblock"> -<div class="content"> -<pre class="prettyprint highlight"><code class="language-listing" data-lang="listing"># Metamodel information -_model.provider=ConfigModel Extension - -# org.mycompany.root (optional section) -_org.mycompany.root.model.target=Section -_org.mycompany.root.model.description=Root section defining my company configuration. - -# org.mycompany.security (required section) -_org.mycompany.security.model.target=Section -_org.mycompany.security.model.required=true -_org.mycompany.security.model.description=Security related settings.\ - refer for further details to XXX. - -# minmal section -_minimal.model.target=Section - -# custom validated section -_validated.model.target=Section -_validated.model.validator=org.apache.tamaya.model.TestValidator</code></pre> -</div> -</div> -<div class="paragraph"> -<p>Above org.mycompany.root transitively defines 3 sections:</p> -</div> -<div class="ulist"> -<ul> -<li> -<p>org</p> -</li> -<li> -<p>org.mycompany</p> -</li> -<li> -<p>org.mycompany.root</p> -</li> -</ul> -</div> -<div class="paragraph"> -<p>All sections are optional. Additionally the model above also defines a required section org.mycompany.security. -Required sections are checked so the section is not empty. It is not checked for any specific parameter hereby, -only the existance of any child parameter is validated.</p> -</div> -<div class="paragraph"> -<p>The <em>class</em> attribute has to be defined for any section definition, because if not set a model entry is, by default, -defined to be a parameter configModel entry. Given above the entry for the section minimal shows such a minimal -entry.</p> -</div> -<div class="paragraph"> -<p>validated defines a section, which is validated through a customizable validator. Hereby an ordered list of validators -can be provided, separated by commas.</p> -</div> -</div> -<div class="sect3"> -<h4 id="_defining_parameters">Defining Parameters</h4> -<div class="paragraph"> -<p>Similarly parameters also can be defined:</p> -</div> -<div class="listingblock"> -<div class="content"> -<pre class="prettyprint highlight"><code class="language-listing" data-lang="listing"># org.mycompany.root.name (required parameter) -_org.mycompany.root.name.model.target=Parameter -_org.mycompany.root.name.model.required=true -_org.mycompany.root.name.model.description=The company's name, also used in the application's main header. - -# org.mycompany.security (required parameters) -_org.mycompany.security.uid.model.required=true -_org.mycompany.security.uid.model.description=The user id. -_org.mycompany.security.realm.model.required=true -_org.mycompany.security.realm.model.validator=org.apache.tamaya.model.RealmValidator -_org.mycompany.security.realm.model.description=The security realm required. -_org.mycompany.security.tokenid.model.description=The token id, if the token service is used (optional). - -# A minmal parameter -_minimalClass.model.target=Class</code></pre> -</div> -</div> -<div class="paragraph"> -<p>Similarly as when defining section also parameter entries define transitively its containing sections. E.g. -the entry above for org.mycompany.security.realm also defines the following sections (as optional).</p> -</div> -<div class="ulist"> -<ul> -<li> -<p>org</p> -</li> -<li> -<p>org.mycompany</p> -</li> -<li> -<p>org.mycompany.security</p> -</li> -</ul> -</div> -<div class="paragraph"> -<p>Additional entries for section, e.g. configModels to be done, can be added as described in the previous section, -but are optional.</p> -</div> -<div class="paragraph"> -<p>Since the parameter is the default type for model entries, a minmal parameter model entry only only needs it’s -parameter type to be defined. In the example above we define a parameter minimalClass of type Class. -Types hereby are fully qualified class names, whereas as 'java.ui.lang' for built-in language types can be -ommitted.</p> -</div> -</div> -<div class="sect3"> -<h4 id="_model_locations">Model Locations</h4> -<div class="paragraph"> -<p>By default the configuration model can be defined at the following locations:</p> -</div> -<div class="ulist"> -<ul> -<li> -<p>classpath*:META-INF/configmodel.properties, separate to the current Configuration. This functionality is enabled -by default, but can be disabled by adding org.apache.tamaya.model.default.enabled=false to your current -Configuration.</p> -</li> -<li> -<p>implicitly as part of the current +Configuration. THis can be disabled by setting -the org.apache.tamaya.model.integrated.enabled configuration poarameter to false.</p> -</li> -<li> -<p>customized by configuring the org.apache.tamaya.model.resources in the current Configuration. This -parameter allows to define the locations from where the model extension is trying to read the -model configuration. If the <em>resources extension</em> is available in your system it is used to -evaluate the locations. If not the default Classloader.getResources command is issued. Also it -is required that the <em>formats extension</em> is available, since this is used to effectively read the -data. This extension also allows you to use alternate representation formats such as ini, xml, yml, json.</p> -</li> -</ul> -</div> -</div> -</div> -<div class="sect2"> -<h3 id="_tracking_configuration_access">Tracking Configuration Access</h3> -<div class="paragraph"> -<p>The model module also allows tracking which code accesses configuration properties or configuration parameters. -It checks the stacktrace to evaluate the calling code location, hereby any unwanted packages can be implicitly -ommitted from the stacktrace. Also the maximal length of the stacktrace retained can be constraint in length. -The usages are recorded as Usage instances. Hereby for each parameter accessed a corresponding Usage -instance is created. It can be accessed by calling Usage ConfigUsageStats.getUsage(String key). Usage -statistics for calling Configuration.getProperties() can be obtained calling Usage getUsageAllProps();.</p> -</div> -<div class="paragraph"> -<p>Usage tracking is disabled by default. It can be enabled by calling ConfigUsageStats.enableUsageTracking(true);. -ConfigUsageStats.isUsageTrackingEnabled() returns the current tracking status.</p> -</div> -<div class="paragraph"> -<p>The Usage class itself provides access to further fainer grained usage data (AccessDetail) containing:</p> -</div> -<div class="ulist"> -<ul> -<li> -<p>the access point (fqn.ClassName#method(line: xxx)).</p> -</li> -<li> -<p>the number of accesses</p> -</li> -<li> -<p>the first an last access</p> -</li> -<li> -<p>the values read</p> -</li> -<li> -<p>the access stacktrace (filtered by ignored packages).</p> -</li> -</ul> -</div> -<div class="listingblock"> -<div class="content"> -<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public final class Usage { - [...] - public String getKey(); - public void clearMetrics(); - public int getReferenceCount(); - public int getUsageCount(); - public Collection<AccessDetail> getAccessDetails(Class type); - public Collection<AccessDetail> getAccessDetails(Package pack); - public Collection<AccessDetail> getAccessDetails(String lookupExpression); - public Collection<AccessDetail> getAccessDetails(); - public void trackUsage(String value); - public void trackUsage(String value, int maxTraceLength); - - - public static final class AccessDetail { - [...] - public void clearStats(); - public long trackAccess(String value); - public long getAccessCount(); - public String getAccessPoint(); - public long getFirstAccessTS(); - public long getLastAccessTS(); - public String[] getStackTrace(); - public Map<Long, String> getTrackedValues(); - } - -}</code></pre> -</div> -</div> -<div class="paragraph"> -<p>With ConfigUsageStats.clearUsageStats() the collected statistics can be reset at any time. Summarizing the main -singleton for configuration statistics is defined as follows:</p> -</div> -<div class="listingblock"> -<div class="content"> -<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public final class ConfigUsageStats{ - public static Set<String> getIgnoredUsagePackages(); - public static void addIgnoredUsagePackages(String... packageName); - public static void enableUsageTracking(boolean enabled); - public static Usage getUsage(String key); - public static Collection<Usage> getUsages(); - public static void clearUsageStats(); - public static Usage getUsageAllProperties(); - public static boolean isUsageTrackingEnabled(); - public static String getUsageInfo(); -}</code></pre> -</div> -</div> -<div class="sect3"> -<h4 id="_customizing_the_stacktrage_for_usage_reporting">Customizing the Stacktrage for Usage Reporting</h4> -<div class="paragraph"> -<p>The stacktrace tracked by the system can be customized in several ways:</p> -</div> -<div class="ulist"> -<ul> -<li> -<p>ConfigUsageStats.addIgnoredPackageNames(String...) allows to add additional ignored package names.</p> -</li> -<li> -<p>With Usage.setMaxTraceLength(int) the maximal size of the stacktraces logged can be set. Setting a -negative value will disable stacktrace logging completelely.</p> -</li> -</ul> -</div> -</div> -</div> -<div class="sect2"> -<h3 id="_accessing_usage_statistics">Accessing Usage Statistics</h3> -<div class="paragraph"> -<p>Bascially usage statistics are available in two forms:</p> -</div> -<div class="ulist"> -<ul> -<li> -<p>The Usage/AccessDetail object tree can be accessed programmatically from the ConfigUsageStats -singleton.</p> -</li> -<li> -<p>With ConfigUsageStats.getUsageInfo() also a textual representation of the usage statistics -can be obtained, as illustrated below (a snipped from the current test output):</p> -</li> -</ul> -</div> -<div class="listingblock"> -<div class="content"> -<pre class="prettyprint highlight"><code class="language-listing" data-lang="listing">Apache Tamaya Configuration Usage Metrics -========================================= -DATE: Sat Apr 30 21:51:09 CEST 2016 - -220 <<all>>: - - 220 <unknown/filtered/internal> , first=Sat Apr 30 21:51:09 CEST 2016, last=Sat Apr 30 21:51:09 CEST 2016 -3 java.version: - - 2 test.model.TestConfigAccessor#readProperty(line:43), first=Sat Apr 30 21:51:09 CEST 2016, last=Sat Apr 30 21:51:09 CEST 2016 - - 1 <unknown/filtered/internal> , first=Sat Apr 30 21:51:09 CEST 2016, last=Sat Apr 30 21:51:09 CEST 2016</code></pre> -</div> -</div> -<div class="sect3"> -<h4 id="_programmatic_api">Programmatic API</h4> -<div class="paragraph"> -<p>Basically the configModel module provides a simple API to access the defined ConfigModel instances and -validating the current Configuration against the models as follows:</p> -</div> -<div class="listingblock"> -<div class="content"> -<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public final class ConfigModelManager { - - private ConfigModelManager() {} - - public static Collection<ConfigModel> getModels(); - public static Collection<ConfigModel> findModels(ModelType type, String namePattern); - public static <T extends ConfigModel> T getModel(String name, Class<T> modelType); - public static Collection<ConfigModel> findModels(String namePattern); - - public static Collection<ValidationResult> validate(); - public static Collection<ValidationResult> validate(boolean showUndefined); - public static Collection<ValidationResult> validate(Configuration config); - public static Collection<ValidationResult> validate(Configuration config, boolean showUndefined); - - public static void registerMBean(); - public static void registerMBean(String context); - -}</code></pre> -</div> -</div> -<div class="paragraph"> -<p>This singleton allows to validate the current or any Configuration instance. All the ConfigModels read also are -available from the getModels method. This models can be used to provide documentation, e.g. as part of a CLI interface -or shown on a documentation web server.</p> -</div> -<div class="paragraph"> -<p>A ConfigModel hereby is defined as one single part of configuration, typically corresponding to a specific concern -of your system. As an example you can define different models for different modules or products plugged together. -With resolution mechanism in place you can also define a shared module that is targeted by multiple modules as a -single configuration source (e.g. for configuring the machine’s IP address and subnet settings only once.</p> -</div> -<div class="listingblock"> -<div class="content"> -<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public interface ConfigModel { - - ModelTarget getType(); - String getName(); - String getProvider(); - boolean isRequired(); - String getDescription(); - Collection<ValidationResult> validate(Configuration config); -}</code></pre> -</div> -</div> -<div class="paragraph"> -<p>Hereby ModelTarget defines more details on the kind of model:</p> -</div> -<div class="listingblock"> -<div class="content"> -<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public enum ModelTarget { - /** - * A configuration section. - */ - Section, - /** - * A configuration paramter. - */ - Parameter, - /** - * ConfigModel that is a container of other validations. - */ - Group -}</code></pre> -</div> -</div> -<div class="paragraph"> -<p>A ValidationResult models one validation executed by a ConfigModel on a certain Configuration instance:</p> -</div> -<div class="listingblock"> -<div class="content"> -<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public final class ValidationResult { - - public static ValidationResult ofValid(ConfigModel configModel); - public static ValidationResult ofMissing(ConfigModel configModel); - public static ValidationResult ofMissing(ConfigModel configModel, String message); - public static ValidationResult ofError(ConfigModel configModel, String error); - public static ValidationResult ofWarning(ConfigModel configModel, String warning); - public static ValidationResult ofDeprecated(ConfigModel configModel, String alternateUsage); - public static ValidationResult ofDeprecated(ConfigModel configModel); - public static ValidationResult ofUndefined(final String key); - public static ValidationResult of(ConfigModel configModel, ValidationState result, String message); - - public ConfigModel getConfigModel(); - public ValidationState getResult(); - public String getMessage(), -}</code></pre> -</div> -</div> -<div class="paragraph"> -<p>The result of a complete validation on a concrete Configuration instance finally is mapped as a -Collection<ValidationResult>, refer to the methods on ConfigModelManager.</p> -</div> -</div> -</div> -<div class="sect2"> -<h3 id="_auto_documentation_of_classes_with_configuration_injection">Auto-Documentation of Classes with Configuration Injection</h3> -<div class="paragraph"> -<p>A special feature of this module is that it observes ConfigEvent published through Tamaya’as event channel -(tamaya-events module). If no metaconfiguration model is found the model manager by default automatically creates -models for all injected instances on the fly. In the case of CDI integration this happens typically during deployment -time, since CDI initializes during deployment time. Other runtime platforms, such as OSGI, may have rather different -behaviour. Nevertheless this means that after your system has been started you should have access to a complete -set of ConfigModel instances that automatically document all the classes in your system that consume configuration -(through injection).</p> -</div> -</div> -</div> -</div> -<div class="sect1"> -<h2 id="_model_spi">Model SPI</h2> -<div class="sectionbody"> -<div class="sect2"> -<h3 id="_registering_configuration_models">Registering Configuration Models</h3> -<div class="paragraph"> -<p>The model extension also provides an SPI where customized functionality can be added. The main abstraction hereby is -the ModelProviderSpi interface, which allows any kind of additional config models to be added to the system:</p> -</div> -<div class="listingblock"> -<div class="content"> -<pre class="prettyprint highlight"><code class="language-java" data-lang="java">public interface ModelProviderSpi { - - Collection<ConfigModel> getConfigModels(); - -}</code></pre> -</div> -</div> -<div class="paragraph"> -<p>New instances implementing this interface must be registered into the current ServiceContext, by default the -ServiceLoader is used.</p> -</div> -</div> -<div class="sect2"> -<h3 id="_the_configusagestatsspi">The ConfigUsageStatsSpi</h3> -<div class="paragraph"> -<p>The methods for managing and tracking of configuration changes are similarly delegated to an -implementation of the org.apache.tamaya.model.spi.ConfigUsageStatsSpi SPI. -By implementing this SPI and registerting it with the ServiceContext the usage tracking -logic can be adapted or replaced.</p> -</div> -</div> -<div class="sect2"> -<h3 id="_other_utility_classes">Other Utility Classes</h3> -<div class="paragraph"> -<p>The module also provides further utility classes that may be useful for implementing models or testing:</p> -</div> -<div class="ulist"> -<ul> -<li> -<p>AbstractModel provides a base class that can be extended, when implementing ConfigModel.</p> -</li> -<li> -<p>AreaConfigModel provides a ConfigModel implementation (with a corresponding Builder) to model the -requirement of certain configuration sections being present, or opionally present, in the model.</p> -</li> -<li> -<p>ParameterModel provides an implementation base class for validating parameters on existence and compliance -with a regular expression.</p> -</li> -<li> -<p>ConfigDocumentationMBean is the MBean registered that models similar functionality as ConfigModelManager.</p> -</li> -<li> -<p>ConfigModelGroup provides a ConfigModel that groups several child models.</p> -</li> -<li> -<p>ConfigModelReader allows to read ConfigModels from properties files as described at the beginning of this -document.</p> -</li> -</ul> -</div> -</div> -<div class="sect2"> -<h3 id="_switches_to_enable_disable_functionality">Switches to enable/disable functionality</h3> -<div class="paragraph"> -<p>The model module provides different switches that can be used to activate or deactivate features:</p> -</div> -<div class="ulist"> -<ul> -<li> -<p>tamaya.model.integrated.enabled allows to deactivate reading inline metaconfiguration delivered with -the normal Tamaya Configuration. By default inline entries (_.abcd.model.*) are evaluated.</p> -</li> -<li> -<p>tamaya.model.default.enabled allows to deactivate reading metamodel information from -classpath:META-INF/configmodel.properties. By default it is active.</p> -</li> -<li> -<p>tamaya.model.resources allows to define additional resources (loaded through the resources extension), -that can be used to read metamodel information in any format using Tamaya’s format module.</p> -</li> -<li> -<p>the system property tamaya.model.autoModelEvents allows to activate/deactivate the automatic -documentation of classes configured and published by Tamaya ConfiguredType event instances (e.g. published by -Tamaya’s injection modules).</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-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-11-02</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/97bc8884/extensions/mod_mutable_config.html ---------------------------------------------------------------------- diff --git a/extensions/mod_mutable_config.html b/extensions/mod_mutable_config.html deleted file mode 100644 index b29a13b..0000000 --- a/extensions/mod_mutable_config.html +++ /dev/null @@ -1,447 +0,0 @@ -<!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="../quickstart.html">Quickstart</a></li> - <li><a href="../index.html">Documentation</a></li> - <li><a href="..//apidocs/index.html">API</a></li> - <li><a href="../index.html">Development</a></li> - <li><a href="../index.html">Releases</a></li> - <li><a href="../about.html">About</a></li> - <li><a href="../sitemap.xml">Sitemap</a></li> - <li><a href="../feed.xml">Subscribe</a></li> -<!-- - <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> ---> - </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-10-31</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>{tamayaVersion}</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 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>Summarizing a MutableConfiguration can be obtained as follows:</p> -</div> -<div class="listingblock"> -<div class="title">Accessing and changing a configuration</div> -<div class="content"> -<pre class="prettyprint highlight"><code class="language-java" data-lang="java">MutableConfiguration config = MutableConfigurationProvider.createMutableConfiguration(); -config.set("newKey", "newValue") - .set("anotherKey", "updatedValue") - .remove("valueNotValid") - .commit();</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 is the complete listing of the MutableConfigurationProvider accessor:</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 getMutableConfiguration(); - public static MutableConfiguration getMutableConfiguration(Configuration configuration); - - [...] -}</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 { - - UUID startTransaction(); - void commitTransaction(); - void rollbackTransaction(); - UUID getTransactionId(); - boolean getAutoCommit(); - void setAutoCommit(boolean autoCommit); - - void setChangePropagationPolicy(ChangePropagationPolicy changePropagationPolicy); - ChangePropagationPolicy getChangePropagationPolicy(); - - boolean isWritable(String keyExpression); - boolean isRemovable(String keyExpression); - boolean isExisting(String keyExpression); - List<MutablePropertySource> getMutablePropertySources(); - List<MutablePropertySource> getPropertySourcesThatCanWrite(String keyExpression); - List<MutablePropertySource> getPropertySourcesThatCanRemove(String keyExpression); - List<MutablePropertySource> getPropertySourcesThatKnow(String keyExpression); - - 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 class="sect3"> -<h4 id="_targeting_the_right_mutablepropertysources">Targeting the right MutablePropertySources</h4> -<div class="paragraph"> -<p>A Configuration may have multiple MutablePropertySource 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 { - void applyChanges(Collection<PropertySource> propertySources, UUID transactionID, Map<String,String> changes); - void applyChange(Collection<PropertySource> propertySources, UUID transactionID, String key, String value); - void applyRemove(Collection<PropertySource> propertySources, UUID transactionID, String... keys); - -}</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 { - - private MutableConfigurationProvider(){} - - public static MutableConfiguration getMutableConfiguration(); - public static MutableConfiguration getMutableConfiguration(Configuration configuration); - - 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 easily 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 ordinal? 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.</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. To -support such fine granular scenarios a MutableConfiguration also offers methods to determine if a key -is writable at all or can be removed or updated:</p> -</div> -<div class="listingblock"> -<div class="title">Checking for mutability</div> -<div class="content"> -<pre class="prettyprint highlight"><code class="language-java" data-lang="java">MutableConfiguration config = MutableConfigurationProvider.createMutableConfiguration(); - -if(config,isWritable("mycluster.shared.appKey")){ - config.set("newKey", "newValue"); -} -if(config,isRemovable("mycluster.myapp.myKey")){ - config.remove("mycluster.myapp.myKey"); -} -config.commit();</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, following the java.util.Properties -format.</p> -</li> -<li> -<p>MutableXmlPropertySource resources, targeting local .xml property files, following the java.util.Properties -XML format.</p> -</li> -</ul> -</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 { - MutableConfiguration createMutableConfiguration(Configuration configuration); -}</code></pre> -</div> -</div> -<div class="paragraph"> -<p>Implementations are registered with the current ServiceContext, by default as a - java.util.ServiceLoader service.</p> -</div> -<div class="paragraph"> -<p>As convenience the following base classes are provided:</p> -</div> -<div class="ulist"> -<ul> -<li> -<p>org.apache.tamaya.mutableconfig.propertysource.AbstractMutablePropertySource simplifying implementation of -MutablePropertySource.</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-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-11-02</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/97bc8884/extensions/mod_optional.html ---------------------------------------------------------------------- diff --git a/extensions/mod_optional.html b/extensions/mod_optional.html deleted file mode 100644 index ea14244..0000000 --- a/extensions/mod_optional.html +++ /dev/null @@ -1,202 +0,0 @@ -<!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="../quickstart.html">Quickstart</a></li> - <li><a href="../index.html">Documentation</a></li> - <li><a href="..//apidocs/index.html">API</a></li> - <li><a href="../index.html">Development</a></li> - <li><a href="../index.html">Releases</a></li> - <li><a href="../about.html">About</a></li> - <li><a href="../sitemap.xml">Sitemap</a></li> - <li><a href="../feed.xml">Subscribe</a></li> -<!-- - <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> ---> - </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-10-31</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>{tamayaVersion}</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-11-02</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/97bc8884/extensions/mod_osgi.html ---------------------------------------------------------------------- diff --git a/extensions/mod_osgi.html b/extensions/mod_osgi.html deleted file mode 100644 index 8fd2d9c..0000000 --- a/extensions/mod_osgi.html +++ /dev/null @@ -1,292 +0,0 @@ -<!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="../quickstart.html">Quickstart</a></li> - <li><a href="../index.html">Documentation</a></li> - <li><a href="..//apidocs/index.html">API</a></li> - <li><a href="../index.html">Development</a></li> - <li><a href="../index.html">Releases</a></li> - <li><a href="../about.html">About</a></li> - <li><a href="../sitemap.xml">Sitemap</a></li> - <li><a href="../feed.xml">Subscribe</a></li> -<!-- - <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> ---> - </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-10-31</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:{tamayaVersion} -org.apache.tamaya:tamaya-core:{tamayaVersion} -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:{tamayaVersion} -org.apache.tamaya.ext:tamaya-injection:{tamayaVersion} -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:{tamayaVersion} -org.apache.tamaya.ext:tamaya-functions:{tamayaVersion}</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 defauklt 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-11-02</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/97bc8884/extensions/mod_remote.html ---------------------------------------------------------------------- diff --git a/extensions/mod_remote.html b/extensions/mod_remote.html deleted file mode 100644 index 30bfe5a..0000000 --- a/extensions/mod_remote.html +++ /dev/null @@ -1,265 +0,0 @@ -<!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="../quickstart.html">Quickstart</a></li> - <li><a href="../index.html">Documentation</a></li> - <li><a href="..//apidocs/index.html">API</a></li> - <li><a href="../index.html">Development</a></li> - <li><a href="../index.html">Releases</a></li> - <li><a href="../about.html">About</a></li> - <li><a href="../sitemap.xml">Sitemap</a></li> - <li><a href="../feed.xml">Subscribe</a></li> -<!-- - <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> ---> - </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-10-31</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>{tamayaVersion}</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 onfiguration 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-11-02</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>
