Modified: incubator/reef/site/tang.html
URL: 
http://svn.apache.org/viewvc/incubator/reef/site/tang.html?rev=1700380&r1=1700379&r2=1700380&view=diff
==============================================================================
--- incubator/reef/site/tang.html (original)
+++ incubator/reef/site/tang.html Tue Sep  1 02:08:00 2015
@@ -1,878 +1,878 @@
-<!DOCTYPE html>
-<!--
- | Generated by Apache Maven Doxia at 2015-08-20 
- | Rendered using Apache Maven Fluido Skin 1.4
--->
-<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
-  <head>
-    <meta charset="UTF-8" />
-    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
-    <meta name="Date-Revision-yyyymmdd" content="20150820" />
-    <meta http-equiv="Content-Language" content="en" />
-    <title>Apache REEF - Tang</title>
-    <link rel="stylesheet" href="./css/apache-maven-fluido-1.4.min.css" />
-    <link rel="stylesheet" href="./css/site.css" />
-    <link rel="stylesheet" href="./css/print.css" media="print" />
-
-      
-    <script type="text/javascript" 
src="./js/apache-maven-fluido-1.4.min.js"></script>
-
-                          
-        
-<script src="js/release.js" type="text/javascript"></script>
-          
-                  </head>
-        <body class="topBarEnabled">
-          
-                
-                    
-                
-
-    <div id="topbar" class="navbar navbar-fixed-top ">
-      <div class="navbar-inner">
-                <div class="container-fluid">
-        <a data-target=".nav-collapse" data-toggle="collapse" class="btn 
btn-navbar">
-          <span class="icon-bar"></span>
-          <span class="icon-bar"></span>
-          <span class="icon-bar"></span>
-        </a>
-                
-                                <ul class="nav">
-                          <li class="dropdown">
-        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Apache REEF 
<b class="caret"></b></a>
-        <ul class="dropdown-menu">
-        
-                      <li>      <a href="index.html"  
title="Overview">Overview</a>
-</li>
-                  
-                      <li>      <a href="faq.html"  title="FAQ">FAQ</a>
-</li>
-                  
-                      <li>      <a href="license.html"  
title="License">License</a>
-</li>
-                  
-                      <li>      <a href="downloads.html"  
title="Downloads">Downloads</a>
-</li>
-                          </ul>
-      </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="introduction.html"  
title="Introduction to REEF">Introduction to REEF</a>
-</li>
-                  
-                      <li>      <a 
href="https://cwiki.apache.org/confluence/display/REEF/Tutorials";  title="REEF 
Tutorial">REEF Tutorial</a>
-</li>
-                  
-                      <li>      <a href="talks.html"  title="Talks">Talks</a>
-</li>
-                  
-                      <li>      <a href="glossary.html"  
title="Glossary">Glossary</a>
-</li>
-                  
-                      <li>      <a href="tang.html"  title="Tang">Tang</a>
-</li>
-                  
-                      <li>      <a href="wake.html"  title="Wake">Wake</a>
-</li>
-                  
-                      <li>      <a href="apidocs/0.10.0-incubating/index.html" 
 title="0.10.0-incubating API">0.10.0-incubating API</a>
-</li>
-                  
-                      <li>      <a href="apidocs/0.11.0-incubating/index.html" 
 title="0.11.0-incubating API">0.11.0-incubating API</a>
-</li>
-                  
-                      <li>      <a href="apidocs/0.12.0-incubating/index.html" 
 title="0.12.0-incubating API">0.12.0-incubating API</a>
-</li>
-                          </ul>
-      </li>
-                <li class="dropdown">
-        <a href="#" class="dropdown-toggle" 
data-toggle="dropdown">Contribution <b class="caret"></b></a>
-        <ul class="dropdown-menu">
-        
-                      <li>      <a 
href="https://cwiki.apache.org/confluence/display/REEF/Contributing";  
title="Contributing">Contributing</a>
-</li>
-                  
-                      <li>      <a 
href="https://cwiki.apache.org/confluence/display/REEF/Committer+Guide";  
title="Committer Guide">Committer Guide</a>
-</li>
-                  
-                      <li>      <a 
href="https://cwiki.apache.org/confluence/display/REEF/Coding+Guidelines";  
title="Coding Guidelines">Coding Guidelines</a>
-</li>
-                          </ul>
-      </li>
-                <li class="dropdown">
-        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Community 
<b class="caret"></b></a>
-        <ul class="dropdown-menu">
-        
-                      <li>      <a href="team.html"  title="Team">Team</a>
-</li>
-                  
-                      <li>      <a href="mailing-list.html"  title="Mailing 
List">Mailing List</a>
-</li>
-                  
-                      <li>      <a 
href="https://issues.apache.org/jira/browse/REEF";  title="Issue Tracker">Issue 
Tracker</a>
-</li>
-                  
-                      <li>      <a 
href="https://cwiki.apache.org/confluence/display/REEF/Powered+by+REEF";  
title="Powered By">Powered By</a>
-</li>
-                          </ul>
-      </li>
-                <li class="dropdown">
-        <a href="#" class="dropdown-toggle" data-toggle="dropdown">ASF <b 
class="caret"></b></a>
-        <ul class="dropdown-menu">
-        
-                      <li>      <a href="http://www.apache.org/foundation/";  
title="Apache Software Foundation">Apache Software Foundation</a>
-</li>
-                  
-                      <li>      <a 
href="http://www.apache.org/foundation/how-it-works.html";  title="How Apache 
Works">How Apache Works</a>
-</li>
-                  
-                      <li>      <a href="http://incubator.apache.org/";  
title="Apache Incubator">Apache Incubator</a>
-</li>
-                  
-                      <li>      <a 
href="http://www.apache.org/licenses/LICENSE-2.0.html";  title="Apache 
License">Apache License</a>
-</li>
-                  
-                      <li>      <a 
href="http://www.apache.org/foundation/sponsorship.html";  
title="Sponsorship">Sponsorship</a>
-</li>
-                  
-                      <li>      <a 
href="http://www.apache.org/foundation/thanks.html";  title="Thanks">Thanks</a>
-</li>
-                          </ul>
-      </li>
-                  </ul>
-          
-          
-          
-                               <ul class="nav pull-right">
-              <li class="dropdown">
-                <a href="#" class="dropdown-toggle" 
data-toggle="dropdown">External Links <b class="caret"></b></a>
-                <ul class="dropdown-menu">
-                      <li>      <a 
href="https://github.com/apache/incubator-reef";  title="Apache REEF 
GitHub">Apache REEF GitHub</a>
-</li>
-      <li>      <a href="http://www.apache.org";  title="Apache">Apache</a>
-</li>
-      <li>      <a href="http://incubator.apache.org/";  title="Apache 
Incubator">Apache Incubator</a>
-</li>
-                  </ul>
-              </li>
-            </ul>
-          
-                      </div>
-          
-        </div>
-      </div>
-    </div>
-    
-        <div class="container-fluid">
-          <div id="banner">
-        <div class="pull-left">
-                                                          <a href="./" 
id="bannerLeft" title="Apache REEF">
-                                                                               
                 <img src="ApacheREEF_logo_no_margin_small.png"  alt="Apache 
REEF"/>
-                </a>
-                      </div>
-        <div class="pull-right">                  <a 
href="http://incubator.apache.org/"; id="bannerRight">
-                                                                               
                 <img src="ApacheIncubator.png" />
-                </a>
-      </div>
-        <div class="clear"><hr/></div>
-      </div>
-
-      <div id="breadcrumbs">
-        <ul class="breadcrumb">
-                
-                    
-                              <li class="">
-                    <a href="index.html" title="Apache REEF">
-        Apache REEF</a>
-                    <span class="divider">|</span>
-      </li>
-        <li class="active ">Tang</li>
-        
-                
-                    
-      
-                            </ul>
-      </div>
-
-                  
-      <div class="row-fluid">
-        <div id="leftColumn" class="span2">
-          <div class="well sidebar-nav">
-                
-                    
-                <ul class="nav nav-list">
-                    <li class="nav-header">Apache REEF</li>
-                              
-      <li>
-  
-                          <a href="index.html" title="Overview">
-          <span class="none"></span>
-        Overview</a>
-            </li>
-                
-      <li>
-  
-                          <a href="faq.html" title="FAQ">
-          <span class="none"></span>
-        FAQ</a>
-            </li>
-                
-      <li>
-  
-                          <a href="license.html" title="License">
-          <span class="none"></span>
-        License</a>
-            </li>
-                
-      <li>
-  
-                          <a href="downloads.html" title="Downloads">
-          <span class="none"></span>
-        Downloads</a>
-            </li>
-                              <li class="nav-header">Documentation</li>
-                              
-      <li>
-  
-                          <a href="introduction.html" title="Introduction to 
REEF">
-          <span class="none"></span>
-        Introduction to REEF</a>
-            </li>
-                
-      <li>
-  
-                          <a 
href="https://cwiki.apache.org/confluence/display/REEF/Tutorials"; 
class="externalLink" title="REEF Tutorial">
-          <span class="none"></span>
-        REEF Tutorial</a>
-            </li>
-                
-      <li>
-  
-                          <a href="talks.html" title="Talks">
-          <span class="none"></span>
-        Talks</a>
-            </li>
-                
-      <li>
-  
-                          <a href="glossary.html" title="Glossary">
-          <span class="none"></span>
-        Glossary</a>
-            </li>
-                
-      <li class="active">
-  
-            <a href="#"><span class="none"></span>Tang</a>
-          </li>
-                
-      <li>
-  
-                          <a href="wake.html" title="Wake">
-          <span class="none"></span>
-        Wake</a>
-            </li>
-                
-      <li>
-  
-                          <a href="apidocs/0.10.0-incubating/index.html" 
title="0.10.0-incubating API">
-          <span class="none"></span>
-        0.10.0-incubating API</a>
-            </li>
-                
-      <li>
-  
-                          <a href="apidocs/0.11.0-incubating/index.html" 
title="0.11.0-incubating API">
-          <span class="none"></span>
-        0.11.0-incubating API</a>
-            </li>
-                
-      <li>
-  
-                          <a href="apidocs/0.12.0-incubating/index.html" 
title="0.12.0-incubating API">
-          <span class="none"></span>
-        0.12.0-incubating API</a>
-            </li>
-                              <li class="nav-header">Contribution</li>
-                              
-      <li>
-  
-                          <a 
href="https://cwiki.apache.org/confluence/display/REEF/Contributing"; 
class="externalLink" title="Contributing">
-          <span class="none"></span>
-        Contributing</a>
-            </li>
-                
-      <li>
-  
-                          <a 
href="https://cwiki.apache.org/confluence/display/REEF/Committer+Guide"; 
class="externalLink" title="Committer Guide">
-          <span class="none"></span>
-        Committer Guide</a>
-            </li>
-                
-      <li>
-  
-                          <a 
href="https://cwiki.apache.org/confluence/display/REEF/Coding+Guidelines"; 
class="externalLink" title="Coding Guidelines">
-          <span class="none"></span>
-        Coding Guidelines</a>
-            </li>
-                              <li class="nav-header">Community</li>
-                              
-      <li>
-  
-                          <a href="team.html" title="Team">
-          <span class="none"></span>
-        Team</a>
-            </li>
-                
-      <li>
-  
-                          <a href="mailing-list.html" title="Mailing List">
-          <span class="none"></span>
-        Mailing List</a>
-            </li>
-                
-      <li>
-  
-                          <a href="https://issues.apache.org/jira/browse/REEF"; 
class="externalLink" title="Issue Tracker">
-          <span class="none"></span>
-        Issue Tracker</a>
-            </li>
-                
-      <li>
-  
-                          <a 
href="https://cwiki.apache.org/confluence/display/REEF/Powered+by+REEF"; 
class="externalLink" title="Powered By">
-          <span class="none"></span>
-        Powered By</a>
-            </li>
-                              <li class="nav-header">ASF</li>
-                              
-      <li>
-  
-                          <a href="http://www.apache.org/foundation/"; 
class="externalLink" title="Apache Software Foundation">
-          <span class="none"></span>
-        Apache Software Foundation</a>
-            </li>
-                
-      <li>
-  
-                          <a 
href="http://www.apache.org/foundation/how-it-works.html"; class="externalLink" 
title="How Apache Works">
-          <span class="none"></span>
-        How Apache Works</a>
-            </li>
-                
-      <li>
-  
-                          <a href="http://incubator.apache.org/"; 
class="externalLink" title="Apache Incubator">
-          <span class="none"></span>
-        Apache Incubator</a>
-            </li>
-                
-      <li>
-  
-                          <a 
href="http://www.apache.org/licenses/LICENSE-2.0.html"; class="externalLink" 
title="Apache License">
-          <span class="none"></span>
-        Apache License</a>
-            </li>
-                
-      <li>
-  
-                          <a 
href="http://www.apache.org/foundation/sponsorship.html"; class="externalLink" 
title="Sponsorship">
-          <span class="none"></span>
-        Sponsorship</a>
-            </li>
-                
-      <li>
-  
-                          <a 
href="http://www.apache.org/foundation/thanks.html"; class="externalLink" 
title="Thanks">
-          <span class="none"></span>
-        Thanks</a>
-            </li>
-            </ul>
-                
-                    
-                
-          <hr />
-
-           <div id="poweredBy">
-                            <div class="clear"></div>
-                            <div class="clear"></div>
-                            <div class="clear"></div>
-                            <div class="clear"></div>
-                             <a href="http://maven.apache.org/"; title="Built 
by Maven" class="poweredBy">
-        <img class="builtBy" alt="Built by Maven" 
src="./images/logos/maven-feather.png" />
-      </a>
-                  </div>
-          </div>
-        </div>
-        
-                        
-        <div id="bodyColumn"  class="span10" >
-                                  
-            <!-- Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied.  See the License for the
-specific language governing permissions and limitations
-under the License. --><h1>Tang</h1>
-<p>Tang is a configuration managment and checking framework that emphasizes 
explicit documentation and automatic checkability of configurations and 
applications instead of ad-hoc, application-specific configuration and 
bootstrapping logic. It supports distributed, multi-language applications, but 
gracefully handles simpler use cases as well.</p>
-<p>Tang makes use of dependency injection to automatically instantiate 
applications. Dependency injectors can be thought of as &#x201c;make for 
objects&#x201d; &#x2013; given a request for some type of object, and 
information that explains how dependencies between objects should be resolved, 
dependency injectors automatically instantiate the requested object and all of 
the objects it dependes upon. Tang makes use of a few simple wire formats to 
support remote and even cross-language dependency injection.</p>
-<div class="section">
-<h2>Outline<a name="Outline"></a></h2>
-
-<ul>
-  
-<li><a href="#motivation">Motivation</a></li>
-  
-<li><a href="#design-principles">Design principles</a></li>
-  
-<li><a href="#tutorial-getting-started">Tutorial: Getting started</a>
-  
-<ul>
-    
-<li><a href="#configuration-parameters">Defining configuration 
parameters</a></li>
-    
-<li><a href="#configuration-modules">Configuration Modules</a></li>
-    
-<li><a href="#injecting-objects-with-getinstance">Injecting objects with 
getInstance()</a></li>
-    
-<li><a href="#cyclic-injections">Cyclic Injections</a></li>
-  </ul></li>
-  
-<li><a href="#alternative-configuration-sources">Alternative configuration 
sources</a>
-  
-<ul>
-    
-<li><a href="#raw-configuration-api">Raw configuration API</a></li>
-  </ul></li>
-  
-<li><a href="#looking-under-the-hood">Looking under the hood</a>
-  
-<ul>
-    
-<li><a href="#injectionPlan">InjectionPlan</a></li>
-    
-<li><a href="#classHierarchy">ClassHierarchy</a></li>
-  </ul></li>
-</ul>
-<h1><a name="motivation"></a>Motivation</h1>
-<p>Distributed systems suffer from problems that arise due to complex 
compositions of software modules and configuration errors. These problems 
compound over time: best-practice object oriented design dictates that code be 
factored into independent reusable modules, and today&#x2019;s distributed 
applications are increasingly expected to run atop multiple runtime 
environments. This leads application developers to push complexity into 
configuration settings, to the point where misconfiguration is now a primary 
cause of unavailability in fault tolerant systems.</p>
-<p>Tang is our attempt to address these problems. It consists of a dependency 
injection framework and a set of configuration and debugging tools that 
automatically and transparently bootstrap applications. We have focused on 
providing a narrow set of primitives that support the full range of design 
patterns that arise in distributed system development, and that encourage 
application developers to build their systems in a maintainable and debuggable 
way.</p>
-<p>Tang leverages existing language type systems, allowing unmodified IDEs 
such as Eclipse or NetBeans to surface configuration information in tooltips, 
provide auto-complete of configuration parameters, and to detect a wide range 
of configuration problems as you edit your code. Since such functionality is 
surfaced in the tools you are already familiar with, there is no need to 
install (or learn) additional development software to get started with Tang. 
Furthermore, we provide a set of sophisticated build time and runtime tools 
that detect a wide range of common architectural problems and configuration 
errors.</p>
-<p>This documentation consists of tutorials that present prefered Tang design 
patterns. By structuring your application according to the patterns we suggest 
throughout the tutorials, you will allow our static analysis framework, Tint 
(&#x201c;Tang Lint&#x201d;), to detect problematic design patterns and 
high-level configuration problems as part of your build. These patterns provide 
the cornerstone for a number of more advanced features, such as interacting 
with legacy configuration systems, designing for cross-language applications, 
and multi-tenancy issues, such as secure injections of untrusted application 
code. To the best of our knowledge, implementing such tools and addressing 
these real-world implementation constraints would be difficult, or even 
impossible, atop competing frameworks.</p>
-<h1><a name="design-principles"></a>Design principles</h1>
-<p>Tang encourages application developers to specify default implementations 
and constructor parameters in terms of code annotations and configuration 
modules. This avoids the need for a number of subtle (and often confusing) 
dependency injection software patterns, though it does lead to a different 
approach to dependency injection than other frameworks encourage.</p>
-<p>In the process of building complicated systems built atop Tang, we found 
that, as the length of configurations that are passed around at runtime 
increased, it rapidly became impossible to debug or maintain our higher-level 
applications. In an attempt to address this problem, traditional dependency 
injection systems actually compound this issue. They encourage the developers 
of each application-level component to implement hand-written 
&#x201c;Modules&#x201d; that are executed at runtime. Hand-written modules 
introspect on the current runtime configuration, augment and modify it, and 
then return a new configuration that takes the new application component into 
account.</p>
-<p>In other systems, developers interact with modules by invoking ad-hoc 
builder methods, and passing configurations (in the correct order) from module 
to module. Modules frequently delgate to each other, either via inheritance or 
wrappers. This makes it difficult for developers and end-users to figure out 
which value of a given parameter will be used, or even to figure out why it was 
(or was not) set.</p>
-<p>Tang provides an alternative called <tt>ConfigurationModule</tt>s:</p>
-
-<ul>
-  
-<li><tt>Configurations</tt> and <tt>ConfigurationModules</tt> are &#x201c;just 
data,&#x201d; and can be read and written in human readable formats.</li>
-  
-<li>Interfaces and configuration parameters are encouraged to specify 
defaults, significantly shortening the configurations generated at runtime, and 
making it easy to see what was &#x201c;strange&#x201d; about a given run of the 
application.</li>
-  
-<li>Tang&#x2019;s static analysis and documentation tools sanity check 
<tt>ConfigurationModule</tt>s, and document their behavior and any extra 
parameters they export.</li>
-  
-<li>Configuration options can be set at most once. This avoids (or at least 
detects) situations in which users and application-level code inadvertantly 
&#x201c;fight&#x201d; over the setting of a particular option.</li>
-</ul>
-<p>The last property comes from Tang&#x2019;s use of <i>monotonic</i> set 
oriented primitives. This allows us to leverage recent theoretical results in 
commtative data types; particularly CRDTs, and the CALM theorem. Concretely:</p>
-
-<ul>
-  
-<li>A large subset of Tang&#x2019;s public API is commutative, which frees 
application-level configuration and bootstrapping logic from worrying about the 
order in which configuration sources are processed at runtime.</li>
-  
-<li>Tang can detect configuration and injection problems much earlier than is 
possible with other approaches. Also, upon detecting a conflict, Tang lists the 
configuration sources that contributed to the problem.</li>
-</ul>
-<p>Finally, Tang is divided into a set of &#x201c;core&#x201d; primtives, and 
higher-level configuration &#x201c;formats&#x201d;. Tang&#x2019;s core focuses 
on dependency injection and static checking of configurations. The formats 
provide higher-level configuration languages primitives, such as distributed, 
cross-language injection, configuration files, and 
<tt>ConfigurationModule</tt>. Each Tang format imports and/or exports standard 
Tang <tt>Configuration</tt> objects, which can then be composed with other 
configuration data at runtime.</p>
-<p>Improvements to these formats are planned, such as command-line tab 
completion, and improved APIs for extremely complex applications that are built 
by composing multiple Tang configurations to inject arbitrary object graphs. 
Furthermore, Tang formats include documentation facilities, and automatic 
command line and configuration file parsing. From an end-user perspective, this 
takes a lot of the guesswork out of configuration file formats.</p>
-<p>Although Tang surfaces a text-based interface for end-users of the 
applications built atop it, all configuration options and their types are 
specified in terms of Java classes and annotations. As with the core Tang 
primitives, this allows the Java compiler to statically check Tang formats for 
problems such as inconsistent usage of configuration parameters, naming 
conflicts and so on. This eliminates broad classes of runtime errors. These 
checks can be run independently of the application&#x2019;s runtime 
environment, and can find problems both in the Java-level implementation of the 
system, and with user-provided configuration files. The tools that perform 
these checks are designed to run as a post-processing step of projects built 
atop Tang. Like the Java compiler checks, this prevents such errors from making 
it to production environments. It also prevents such errors from being exposed 
to application logic or end-users, greatly simplifying applications built atop 
Tang.</p>
-<p>Taken together, these properties greatly simplify dependency injection in 
distributed environments. We expect Tang to be used in environments that are 
dominated by &#x201c;plugin&#x201d;-style APIs with many alternative 
implementations. Tang cleanly separates concerns over configuration management, 
dependency injection and object implementations, which hides most of the 
complexity of dependency injection from plugin implementers. It also prevents 
plugin implementations from inadvertently conflicting with each other or their 
runtime environements. Such clean semantics are crucial in distributed, 
heterogeneous environments.</p>
-<h1><a name="tutorial-getting-started"></a>Tutorial: Getting started</h1>
-<p>This tutorial is geared toward people that would like to quickly get 
started with Tang, or that are modifying an existing Tang application.</p></div>
-<div class="section">
-<h2><a name="configuration-parameters"></a>Constructors, @Inject and 
@Parameter<a name="Constructors_Inject_and_Parameter"></a></h2>
-<p>Suppose you are implementing a new class, and would like to automatically 
pass configuration parameters to it at runtime:</p>
-
-<div class="source"><pre class="prettyprint">package com.example;
-
-public class Timer {
-  private final int seconds;
-
-  public Timer(int seconds) {
-    if(seconds &lt; 0) {
-      throw new IllegalArgumentException(&quot;Cannot sleep for negative 
time!&quot;);
-    }
-    this.seconds = seconds;
-  }
-
-  public void sleep() throws Exception {
-    java.lang.Thread.sleep(seconds * 1000);
-  }
-}
-</pre></div>
-<p>Tang encourages applications to use Plain Old Java Objects (POJOs), and 
emphasizes the use of immutable state for configuration parameters. This 
reduces boiler plate (there is no need for extra setter methods), and does not 
interfere with encapsulation (the fields and even the constructor can be 
private). Furthermore, it is trivial for well-written classes to ensure that 
all objects are completely and properly instantiated: They simply need to check 
constructor parameters as any other POJO would, except that Tang never passes 
<tt>null</tt> references into constructors, allowing their implementations to 
assume that all parameter values are non-null.</p>
-<p>Tang aims to provide end users with error messages as early as possible, 
and encourages developers to throw exceptions inside of constructors. This 
allows it to automatically provide additional information to end-users when 
things go wrong:</p>
-
-<div class="source"><pre class="prettyprint">Exception in thread 
&quot;main&quot; org.apache.reef.tang.exceptions.InjectionException: Could not 
invoke constructor: new Timer(Integer Seconds = -1)
-    at 
org.apache.reef.tang.implementation.java.InjectorImpl.injectFromPlan(InjectorImpl.java:585)
-    at 
org.apache.reef.tang.implementation.java.InjectorImpl.getInstance(InjectorImpl.java:449)
-    at 
org.apache.reef.tang.implementation.java.InjectorImpl.getInstance(InjectorImpl.java:466)
-    at org.apache.reef.tang.examples.Timer.main(Timer.java:48)
-Caused by: java.lang.IllegalArgumentException: Cannot sleep for negative time!
-    at org.apache.reef.tang.examples.Timer.&lt;init&gt;(Timer.java:25)
-    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
-    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
-    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown 
Source)
-    at java.lang.reflect.Constructor.newInstance(Unknown Source)
-    at 
org.apache.reef.tang.implementation.java.InjectorImpl.injectFromPlan(InjectorImpl.java:569)
-    ... 3 more
-</pre></div>
-<p>In order for Tang to instantiate an object, we need to annotate the 
constructor with an <tt>@Inject</tt> annotation. While we&#x2019;re at it, 
we&#x2019;ll define a configuration parameter, allowing us to specify seconds 
on the command line and in a config file:</p>
-
-<div class="source"><pre class="prettyprint">package com.example;
-
-import javax.inject.Inject;
-
-import org.apache.reef.tang.annotations.Name;
-import org.apache.reef.tang.annotations.NamedParameter;
-import org.apache.reef.tang.annotations.Parameter;
-
-public class Timer {
-  @NamedParameter(default_value=&quot;10&quot;,
-      doc=&quot;Number of seconds to sleep&quot;, short_name=&quot;sec&quot;)
-  class Seconds implements Name&lt;Integer&gt; {}
-  private final int seconds;
-
-  @Inject
-  public Timer(@Parameter(Seconds.class) int seconds) {
-    if(seconds &lt; 0) {
-      throw new IllegalArgumentException(&quot;Cannot sleep for negative 
time!&quot;);
-    }
-    this.seconds = seconds;
-  }
-
-  public void sleep() throws Exception {
-    java.lang.Thread.sleep(seconds * 1000);
-  }
-}
-</pre></div>
-<p>A few things happened here. First, we create the new configuration 
parameter by declaring a dummy class that implements Tang&#x2019;s 
<tt>Name</tt> interface. <tt>Name</tt> is a generic type with a single 
mandatory parameter that specifies the type of object to be passed in. Since 
<tt>Seconds</tt> implements <tt>Name&lt;Integer&gt;</tt>, it is a parameter 
called <tt>Seconds</tt> that expects <tt>Integer</tt> values. More precisely, 
<tt>Seconds</tt> is actually named <tt>com.example.Timer.Seconds</tt>. This 
reliance on language types to define parameter names exposes parameters to the 
compiler and IDE. Concretely:</p>
-
-<ul>
-  
-<li><tt>javac</tt> maps from <tt>Seconds</tt> to the full class name in the 
usual way, preventing parameters with the same name, but in different packages 
from conflicting.</li>
-  
-<li>The Java classloader ensures that classes are unique at runtime.</li>
-  
-<li>Standard IDE features, such as code navigation, completion and refactoring 
work as they normally would for class names.</li>
-</ul>
-<p>All instances of <tt>Name</tt> must be annotated with 
<tt>@NamedParameter</tt>, which takes the following optional parameters:</p>
-
-<ul>
-  
-<li><tt>default_value</tt>: The default value of the constructor parameter, 
encoded as a string. Tang will parse this value (and ones in config files and 
on the command line), and pass it into the constructor. For convenience Tang 
includes a number of helper variants of default value. <tt>default_class</tt> 
takes a Class (instead of a String), while <tt>default_values</tt> and 
<tt>default_classes</tt> take sets of values.</li>
-  
-<li><tt>short_name</tt>: The name of the command line option associated with 
this parameter. If omitted, no command line option will be created. Short names 
must be registered by calling <tt>registerShortName()</tt> on the instance of 
<tt>org.apache.reef.tang.formats.CommandLine</tt> that will process the command 
line options.</li>
-  
-<li><tt>doc</tt> (optional): Human readable documentation that describes the 
purpose of the parameter.</li>
-</ul>
-<p>Tang only invokes constructors that have been annotated with 
<tt>@Inject</tt>. This allows injectable constructors to coexist with ones that 
should not be invoked via dependency injection (such as ones with destructive 
side effects, or that expect <tt>null</tt> references). Constructor parameters 
must not be ambiguous. If two parameters in the same constructor have the same 
type, then they must be annotated with <tt>@Parameter</tt>, which associates a 
named parameter with the argument. Furthermore, two parameters to the same 
constructor cannot have the same name. This allows Tang to safely invoke 
constructors without exposing low level details (such as parameter ordering) as 
configuration options.</p></div>
-<div class="section">
-<h2><a name="configuration-modules"></a>Configuration modules<a 
name="Configuration_modules"></a></h2>
-<p>Configuration modules allow applications to perform most configuration 
generation and verification tasks at build time. This allows Tang to 
automatically generate rich configuration-related documentation, to detect 
problematic design patterns, and to report errors before the application even 
begins to run.</p>
-<p>In the example below, we extend the Timer API to include a second 
implementation that simply outputs the amount of time a real timer would have 
slept to stderr. In a real unit testing example, it would likely interact with 
a scheduler based on logical time. Of course, in isolation, having the ability 
to specify configuration parameters is not particularly useful; this example 
also adds a <tt>main()</tt> method that invokes Tang, and instantiates an 
object.</p>
-<p>The process of instantiting an object with Tang is called <i>injection</i>. 
As with configurations, Tang&#x2019;s injection process is designed to catch as 
many potential runtime errors as possible before application code begins to 
run. This simplifies debugging and eliminates many types of runtime error 
handling code, since many configurations can be caught before running (or 
examining) application-specific initialization code. </p>
-
-<div class="source"><pre class="prettyprint">package 
org.apache.reef.tang.examples.timer;
-
-import javax.inject.Inject;
-
-import org.apache.reef.tang.Configuration;
-import org.apache.reef.tang.Tang;
-
-import org.apache.reef.tang.annotations.DefaultImplementation;
-import org.apache.reef.tang.annotations.Name;
-import org.apache.reef.tang.annotations.NamedParameter;
-import org.apache.reef.tang.annotations.Parameter;
-
-import org.apache.reef.tang.exceptions.BindException;
-import org.apache.reef.tang.exceptions.InjectionException;
-
-import org.apache.reef.tang.formats.ConfigurationModule;
-import org.apache.reef.tang.formats.ConfigurationModuleBuilder;
-import org.apache.reef.tang.formats.OptionalParameter;
-
-@DefaultImplementation(TimerImpl.class)
-public interface Timer {
-  @NamedParameter(default_value=&quot;10&quot;,
-      doc=&quot;Number of seconds to sleep&quot;, short_name=&quot;sec&quot;)
-  public static class Seconds implements Name&lt;Integer&gt; { }
-  public void sleep() throws Exception;
-}
-
-public class TimerImpl implements Timer {
-
-  private final int seconds;
-  @Inject
-  public TimerImpl(@Parameter(Timer.Seconds.class) int seconds) {
-    if(seconds &lt; 0) {
-      throw new IllegalArgumentException(&quot;Cannot sleep for negative 
time!&quot;);
-    }
-    this.seconds = seconds;
-  }
-  @Override
-  public void sleep() throws Exception {
-    java.lang.Thread.sleep(seconds);
-  }
-
-}
-
-public class TimerMock implements Timer {
-
-  public static class TimerMockConf extends ConfigurationModuleBuilder {
-    public static final OptionalParameter&lt;Integer&gt; MOCK_SLEEP_TIME = new 
OptionalParameter&lt;&gt;();
-  }
-  public static final ConfigurationModule CONF = new TimerMockConf()
-    .bindImplementation(Timer.class, TimerMock.class)
-    .bindNamedParameter(Timer.Seconds.class, TimerMockConf.MOCK_SLEEP_TIME)
-    .build();
-
-  private final int seconds;
-
-  @Inject
-  TimerMock(@Parameter(Timer.Seconds.class) int seconds) {
-    if(seconds &lt; 0) {
-      throw new IllegalArgumentException(&quot;Cannot sleep for negative 
time!&quot;);
-    }
-    this.seconds = seconds; 
-  }
-  @Override
-  public void sleep() {
-    System.out.println(&quot;Would have slept for &quot; + seconds + 
&quot;sec.&quot;);
-  }
-
-  public static void main(String[] args) throws BindException, 
InjectionException, Exception {
-    Configuration c = TimerMock.CONF
-      .set(TimerMockConf.MOCK_SLEEP_TIME, 1)
-      .build();
-    Timer t = Tang.Factory.getTang().newInjector(c).getInstance(Timer.class);
-    System.out.println(&quot;Tick...&quot;);
-    t.sleep();
-    System.out.println(&quot;...tock.&quot;);
-  }
-}
-</pre></div>
-<p>Again, there are a few things going on here:</p>
-
-<ul>
-  
-<li>First, we push the implementation of <tt>Timer</tt> into a new class, 
<tt>TimerImpl</tt>. The <tt>@DefaultImplementation</tt> tells Tang to use 
<tt>TimerImpl</tt> when no other implementation is explicitly provided.</li>
-  
-<li>We leave the <tt>Sleep</tt> class in the Timer interface. This, plus the 
<tt>@DefaultImplementation</tt> annotation maintain backward compatibility with 
code that used Tang to inject the old <tt>Timer</tt> class.</li>
-  
-<li>The <tt>TimerMock</tt> class includes a dummy implementation of Timer, 
along with a <tt>ConfigurationModule</tt> final static field called 
<tt>CONF</tt>.</li>
-  
-<li>The main method uses <tt>CONF</tt> to generate a configuration. Rather 
than set <tt>Timer.Sleep</tt> directly, it sets <tt>MOCK_SLEEP_TIME</tt>. In a 
more complicated example, this would allow <tt>CONF</tt> to route the sleep 
time to testing infrastructure, or other classes that are specific to the 
testing environment or implemenation of <tt>TimerMock</tt>.</li>
-</ul>
-<p><tt>ConfigurationModule</tt>s serve a number of purposes:</p>
-
-<ul>
-  
-<li>They allow application and library developers to encapsulate the details 
surrounding their code&#x2019;s instantiation.</li>
-  
-<li>They provide Java APIs that expose <tt>OptionalParameter</tt>, 
<tt>RequiredParameter</tt>, <tt>OptionalImplementation</tt>, 
<tt>RequiredImpementation</tt> fields. These fields tell users of the 
ConfigurationModule which subsystems of the application require which 
configuration parameters, and allow the author of the ConfigurationModule to 
use JavaDoc to document the parameters they export.</li>
-  
-<li>Finally, because ConfigurationModule data structures are populated at 
class load time (before the application begins to run), they can be inspected 
by Tang&#x2019;s static analysis tools.</li>
-</ul>
-<p>These tools are provided by <tt>org.apache.reef.tang.util.Tint</tt>, which 
is included by default in all Tang builds. As long as Tang is on the classpath, 
invoking:</p>
-
-<div class="source"><pre class="prettyprint">java 
org.apache.reef.tang.util.Tint --doc tangdoc.html
-</pre></div>
-<p>will perform full static analysis of all classes the class path, and emit a 
nicely formatted HTML document. The documentation generated by Tint includes 
cross-references between configuration options, interfaces, classes, and the 
<tt>ConfigurationModules</tt> that use and set them. </p>
-<p>Here are some sample Tint errors. These (and others) can be run by passing 
<tt>--tang-tests</tt> into Tint, and ensuring that Tang&#x2019;s unit tests are 
on the class path.:</p>
-
-<div class="source"><pre class="prettyprint">interface 
org.apache.reef.tang.MyEventHandlerIface declares its default implementation to 
be non-subclass class org.apache.reef.tang.MyEventHandler
-class org.apache.reef.tang.WaterBottleName defines a default class 
org.apache.reef.tang.GasCan with a type that does not extend its target's type 
org.apache.reef.tang.Bottle&lt;org.apache.reef.tang.Water&gt;
-Named parameters org.apache.reef.tang.examples.Timer$Seconds and 
org.apache.reef.tang.examples.TimerV1$Seconds have the same short name: sec
-Named parameter 
org.apache.reef.tang.implementation.AnnotatedNameMultipleInterfaces implements 
multiple interfaces.  It is only allowed to implement Name&lt;T&gt;
-Found illegal @NamedParameter 
org.apache.reef.tang.implementation.AnnotatedNotName does not implement 
Name&lt;?&gt;
-interface org.apache.reef.tang.implementation.BadIfaceDefault declares its 
default implementation to be non-subclass class java.lang.String
-class org.apache.reef.tang.implementation.BadName defines a default class 
java.lang.Integer with a raw type that does not extend of its target's raw type 
class java.lang.String
-Named parameter org.apache.reef.tang.implementation.BadParsableDefaultClass 
defines default implementation for parsable type java.lang.String
-Class org.apache.reef.tang.implementation.DanglingUnit has an @Unit 
annotation, but no non-static inner classes.  Such @Unit annotations would have 
no effect, and are therefore disallowed.
-Cannot @Inject non-static member class unless the enclosing class an @Unit.  
Nested class 
is:org.apache.reef.tang.implementation.InjectNonStaticLocalType$NonStaticLocal
-Named parameter org.apache.reef.tang.implementation.NameWithConstructor has a 
constructor.  Named parameters must not declare any constructors.
-Named parameter type mismatch.  Constructor expects a java.lang.String but Foo 
is a java.lang.Integer
-public org.apache.reef.tang.implementation.NonInjectableParam(int) is not 
injectable, but it has an @Parameter annotation.
-Detected explicit constructor in class enclosed in @Unit 
org.apache.reef.tang.implementation.OuterUnitBad$InA  Such constructors are 
disallowed.
-Repeated constructor parameter detected.  Cannot inject constructor 
org.apache.reef.tang.implementation.RepeatConstructorArg(int,int)
-Named parameters org.apache.reef.tang.implementation.ShortNameFooA and 
org.apache.reef.tang.implementation.ShortNameFooB have the same short name: foo
-Named parameter org.apache.reef.tang.implementation.UnannotatedName is missing 
its @NamedParameter annotation.
-Field org.apache.reef.tang.formats.MyMissingBindConfigurationModule.BAD_CONF: 
Found declared options that were not used in binds: { FOO_NESS }
-</pre></div></div>
-<div class="section">
-<h2><a name="injnecting-objects-with-getInstance"></a>Injecting objects with 
getInstance()<a name="Injecting_objects_with_getInstance"></a></h2>
-<p>Above, we explain how to register constructors with Tang, and how to 
configure Tang to inject the desired objects at runtime. This section explains 
how Tang actually instantiates objects, and how the primitives it provides can 
be combined to support sophisticated application architectures.</p>
-<p>In order to instantiate objects with Tang, one must invoke 
Tang.Factory.getTang().newInjector(Configuration&#x2026;). This returns a new 
&#x201c;empty&#x201d; injector that will honor the configuration options that 
were set in the provided configurations, and that will have access to a merged 
version of the classpath they refer to.</p>
-<p>In a given Tang injector, all classes are treated as singletons: at most 
one instance of each class may exist. Furthermore, Tang Configuration objects 
are designed to be built up from trees of related (but non-conflicting) 
configuration files, command line parameters, and so on. At first, this may 
seem to be overly restrictive, since it prevents applications from creating 
multiple instances of the same class (or even two classes that require 
different values of the same named parameter).</p>
-<p>Tang addresses this by providing the runtime environment more explicit 
control over object and configuration parameter scopes. Taken together, 
<tt>forkInjector()</tt>, <tt>bindVolatile()</tt> and 
<tt>InjectionFuture&lt;T&gt;</tt> allow Tang to inject arbitrary sets of 
objects (including ones with multiple instances of the same class).</p>
-<p>Other injection frameworks take a different approach, and allow class 
implementations to decide if they should be singletons across a given JVM 
(e.g., with an <tt>@Singleton</tt> annotation), user session (for web 
services), user connection, and so on. This approach has at least two 
problems:</p>
-
-<ul>
-  
-<li>It is not general purpose: after all, it encodes deployment scenarios into 
the injection framework and application APIs!</li>
-  
-<li>It trades one barrier to composability and reuse: <i>hard-coded 
constructor invocations</i> with another: <i>hard-coded runtime 
environments</i>. The former prevents runtime environments from adapting to 
application-level changes, while the latter prevents application code from 
adapting to new runtimes.</li>
-</ul>
-<p>Tang&#x2019;s approach avoids both issues by giving the implementation of 
the runtime environment explicit control over object scopes and lifetimes.</p>
-<p><tt>forkInjector()</tt> makes a copy of a given injector, including 
references to all the objects already instantiated by the original injector. 
This allows runtime environments to implement scopes. First, a root injector is 
created. In order to create a child scope, the runtime simply invokes 
<tt>forkInjector()</tt> on the root context, and optionally passes additional 
<tt>Configuration</tt> objects in. These additional configurations allow the 
runtime to specialize the root context.</p>
-<p>Although the forked injector will have access to any objects and 
configuration bindings that existed when <tt>forkInjector()</tt> was called, 
neither the original nor the forked injectors will reflect future changes to 
the other injector.</p>
-<p>The second primitive, <tt>bindVolatile()</tt>, provides an injector with an 
instance of a class or named parameter. The injector treats this instance as 
though it had injected the object directly. This:</p>
-
-<ul>
-  
-<li>allows passing of information between child scopes</li>
-  
-<li>makes it possible to create (for example) chains of objects of the same 
type</li>
-  
-<li>and allows objects that cannot be instantiated via Tang to be passed into 
injectable constructors.</li>
-</ul>
-<div class="section">
-<h3><a name="cyclic-injections"></a>Cyclic Injections<a 
name="Cyclic_Injections"></a></h3>
-<p>Although the above primitives allow applications to inject arbitrary DAGs 
(directed acyclic graphs) of objects, they do not support cycles of objects. 
Tang provides the <tt>InjectionFuture&lt;T&gt;</tt> interfaces to support such 
<i>cyclic injections</i>.</p>
-<p>When Tang encounters a constructor parameter of type 
<tt>InjectionFuture&lt;T&gt;</tt>, it injects an object that provides a method 
<tt>T get()</tt> that returns an injected instance of <tt>T</tt>. </p>
-<p>This can be used to break cycles:</p>
-
-<div class="source"><pre class="prettyprint">A(B b) {...}
-B(InjectionFuture&lt;A&gt; a) {...}
-</pre></div>
-<p>In order to inject an instance of <tt>A</tt>, Tang first injects an 
instance of <tt>B</tt> by passing it an <tt>InjectionFuture&lt;A&gt;</tt>. Tang 
then invoke&#x2019;s <tt>A</tt>&#x2019;s constructor, passing in the instance 
of <tt>B</tt>. Once the constructor returns, the new instance of <tt>A</tt> is 
passed into <tt>B</tt>&#x2019;s <tt>InjectionFuture&lt;A&gt;</tt>. At this 
point, it becomes safe for <tt>B</tt> to invoke <tt>get()</tt>, which 
establishes the circular reference.</p>
-<p>Therefore, along with <tt>forkInjector()</tt> and <tt>bindVolatile()</tt>, 
this allows Tang to inject arbitrary graphs of objects. This pattern avoids 
non-final fields (once set, all fields of all objects are constant), and it 
also avoids boiler plate error handling code that checks to see if 
<tt>B</tt>&#x2019;s instance of <tt>A</tt> has been set.</p>
-<p>When <tt>get()</tt> is called after the application-level call to 
<tt>getInstance()</tt> returns, it is guranteed to return a non-null reference 
to an injected instance of the object. However, if <tt>get()</tt> is called 
<i>before</i> the constructor it was passed to returns, then it is guaranteed 
to throw an exception. In between these two points in time, 
<tt>get()</tt>&#x2019;s behavior is undefined, but, for the sake of 
race-detection and forward compatibility it makes a best-effort attempt to 
throw an exception.</p>
-<p>Following Tang&#x2019;s singleton semantics, the instance returned by 
<tt>get()</tt> will be the same instance the injector would pass into other 
constructors or return from <tt>getInstance()</tt>.</p>
-<h1><a name="alternative-configuration-sources"></a>Alternative configuration 
sources</h1>
-<p>Tang provides a number of so-called <i>formats</i> that interface with 
external configuration data. <tt>ConfigurationModule</tt> is one such example 
(see above). These formats transform configuration data to and from 
Tang&#x2019;s raw configuration API. The raw API provides an implementation of 
ConfigurationBuilder, which implements most of Tang&#x2019;s configuration 
checks. It also provides a <tt>JavaConfigurationBuilder</tt> interface provides 
convenience methods that take Java Classes, and leverage Java&#x2019;s generic 
type system to push a range of static type checks to Java compilation 
time.</p></div></div>
-<div class="section">
-<h2><a name="raw-configuration-api"></a>Raw configuration API<a 
name="Raw_configuration_API"></a></h2>
-<p>Tang also provides a lower level configurtion API for applications that 
need more dynamic control over their configurations:</p>
-
-<div class="source"><pre class="prettyprint">...
-import org.apache.reef.tang.Tang;
-import org.apache.reef.tang.ConfigurationBuilder;
-import org.apache.reef.tang.Configuration;
-import org.apache.reef.tang.Injector;
-import org.apache.reef.tang.exceptions.BindException;
-import org.apache.reef.tang.exceptions.InjectionException;
-
-...
-  public static void main(String[] args) throws BindException, 
InjectionException {
-    Tang tang = Tang.Factory.getTang();
-    ConfigurationBuilder cb = 
(ConfigurationBuilder)tang.newConfigurationBuilder();
-    cb.bindNamedParameter(Timer.Seconds.class, 5);
-    Configuration conf = cb.build();
-    Injector injector = tang.newInjector(conf);
-    if(!injector.isInjectable(Timer.class)) {
-      System.err.println(&quot;If isInjectable returns false, the next line 
will throw an exception&quot;);
-    }
-    Timer timer = injector.getInstance(Timer.class);
-
-    try {
-      System.out.println(&quot;Tick...&quot;);
-      timer.sleep();
-      System.out.println(&quot;Tock.&quot;);
-    } catch(InterruptedException e) {
-      e.printStackTrace();
-    }
-  }
-</pre></div>
-<p>The first step in using Tang is to get a handle to a Tang object by calling 
&#x201c;Tang.Factory.getTang()&#x201d;. Having obtained a handle, we run 
through each of the phases of a Tang injection:</p>
-
-<ul>
-  
-<li>We use <tt>ConfigurationBuilder</tt> objects to tell Tang about the class 
hierarchy that it will be using to inject objects and (in later examples) to 
register the contents of configuration files, override default configuration 
values, and to set default implementations of classes. 
<tt>ConfigurationBuilder</tt> and <tt>ConfigurationModuleBuider</tt> export 
similar API&#x2019;s. The difference is that <tt>ConfigurationBuilder</tt> 
produces <tt>Configuration</tt> objects directly, and is designed to be used at 
runtime. <tt>ConfigurationModuleBuilder</tt> is desgined to produce data 
structures that will be generated and analyzed during the build, and at class 
load time.</li>
-  
-<li><tt>bindNamedParameter()</tt> overrides the default value of Timer.Sleep, 
setting it to 5. Tang inteprets the 5 as a string, but allows instances of 
Number to be passed in as syntactic sugar.</li>
-  
-<li>We call <tt>.build()</tt> on the <tt>ConfigurationBuilder</tt>, creating 
an immutable <tt>Configuration</tt> object. At this point, Tang ensures that 
all of the classes it has encountered so far are consistent with each other, 
and that they are suitable for injection. When Tang encounters conflicting 
classes or configuration files, it throws a <tt>BindException</tt> to indicate 
that the problem is due to configuration issues. Note that 
<tt>ConfigurationBuilder</tt> and <tt>Configuration</tt> do not determine 
whether or not a particular injection will succeed; that is the business of the 
<i>Injector</i>.</li>
-  
-<li>To obtain an instance of Injector, we pass our Configuration object into 
<tt>tang.newInjector()</tt>.</li>
-  
-<li><tt>injector.isInjectable(Timer.class)</tt> checks to see if Timer is 
injectable without actually performing an injection or running application 
code. (Note that, in this example, the Java classloader may have run 
application code. For more information, see the advanced tutorials on 
cross-language injections and securely building configurations for untrusted 
code.)</li>
-  
-<li>Finally, we call <tt>injector.getInstance(Timer.class)</tt>. Internally, 
this method considers all possible injection plans for <tt>Timer</tt>. If there 
is exactly one such plan, it performs the injection. Otherwise, it throws an 
<tt>InjectionException</tt>.</li>
-</ul>
-<p>Tang configuration information can be divided into two categories. The 
first type, <i>parameters</i>, pass values such as strings and integers into 
constructors. Users of Tang encode configuration parameters as strings, 
allowing them to be stored in configuration files, and passed in on the command 
line.</p>
-<p>The second type of configuration option, <i>implementation bindings</i>, 
are used to tell Tang which implementation should be used when an instance of 
an interface is requested. Like configuration parameters, implementation 
bindings are expressible as strings: Tang configuration files simply contain 
the raw (without the generic parameters) name of the Java Classes to be bound 
together.</p>
-<p>New parameters are created and passed into constructors as in the examples 
above, by creating implementations of <tt>Name&lt;T&gt;</tt>, and adding 
<tt>@NamedParameter</tt>, <tt>@Parameter</tt> and <tt>@Inject</tt> annotations 
as necessary. Specifying implementations for interfaces is a bit more involved, 
as a number of subtle use cases arise.</p>
-<p>However, all configuration settings in Tang can be unambiguously 
represented as a <tt>key=value</tt> pair that can be interpreted either asan 
<tt>interface=implementation</tt> pair or a 
<tt>configuration_parameter=value</tt> pair. This maps well to Java-style 
properties files. For example:</p>
-
-<div class="source"><pre 
class="prettyprint">com.examples.Interface=com.examples.Implementation
-</pre></div>
-<p>tells Tang to create a new Implementation each time it wants to invoke a 
constructor that asks for an instance of Interface. In most circumstances, 
Implementation extends or implements Interface (<tt>ExternalConstructors</tt> 
are the exception &#x2013; see the next section). In such cases, Tang makes 
sure that Implementation contains at least one constructor with an 
<tt>@Inject</tt> annotation, and performs the binding.</p>
-<p>See the <tt>ConfigurationFile</tt> API for more information about 
processing configuration files in this format.</p></div>
-<div class="section">
-<h2><a name="looking-under-the-hood"></a>Looking under the hood<a 
name="Looking_under_the_hood"></a></h2>
-<div class="section">
-<h3><a name="injectionPlan"></a>InjectionPlan<a name="InjectionPlan"></a></h3>
-<p>InjectionPlan objects explain what Tang would do to instantiate a new 
object, but don&#x2019;t actually instantiate anything. Add the following lines 
to the Timer example;</p>
-
-<div class="source"><pre class="prettyprint">import 
org.apache.reef.tang.implementation.InjectionPlan;
-import org.apache.reef.tang.implementation.InjectorImpl;
-...
-InjectorImpl injector = (InjectorImpl)tang.newInjector(conf);
-InjectionPlan&lt;Timer&gt; ip = injector.getInjectionPlan(Timer.class);
-System.out.println(ip.toPrettyString());
-System.out.println(&quot;Number of plans:&quot; + ip.getNumAlternatives());
-</pre></div>
-<p>Running the program now produces a bit of additional output:</p>
-
-<div class="source"><pre class="prettyprint">new Timer(Integer Seconds = 10)
-Number of plans:1
-</pre></div>
-<p>InjectionPlan objects can be serialized to protocol buffers. The following 
file documents their format:</p>
-<p><a class="externalLink" 
href="https://github.com/apache/incubator-reef/blob/master/lang/java/reef-tang/tang/src/main/proto/injection_plan.proto";>https://github.com/apache/incubator-reef/blob/master/lang/java/reef-tang/tang/src/main/proto/injection_plan.proto</a></p></div>
-<div class="section">
-<h3><a name="classHierarchy"></a>ClassHierarchy<a 
name="ClassHierarchy"></a></h3>
-<p>InjectionPlan explains what would happen if you asked Tang to take some 
action, but it doesn&#x2019;t provide much insight into Tang&#x2019;s view of 
the object hierarchy, parameter defaults and so on. ClassHierarchy objects 
encode the state that Tang gets from .class files, including class inheritance 
relationships, parameter annotations, and so on.</p>
-<p>Internally, in the example above, TypeHierarchy walks the class definition 
for Timer, looking for superclasses, interfaces, and classes referenced by its 
constructors.</p>
-<p>ClassHierarchy objects can be serialized to protocol buffers. The following 
file documents their format:</p>
-<p><a class="externalLink" 
href="https://github.com/apache/incubator-reef/blob/master/lang/java/reef-tang/tang/src/main/proto/class_hierarchy.proto";>https://github.com/apache/incubator-reef/blob/master/lang/java/reef-tang/tang/src/main/proto/class_hierarchy.proto</a></p>
-<p>The java interfaces are available in this package:</p>
-<p><a class="externalLink" 
href="https://github.com/apache/incubator-reef/tree/master/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/types";>https://github.com/apache/incubator-reef/tree/master/lang/java/reef-tang/tang/src/main/java/org/apache/reef/tang/types</a></p></div></div>
-                  </div>
-            </div>
-          </div>
-
-    <hr/>
-
-    <footer>
-            <div class="container-fluid">
-                      <div class="row-fluid">
-                                                                          
-<div class="container-fluid">
-  <div class="row-fluid">
-    <a href="http://www.apache.org";>Apache Software Foundation</a>
-  </div>
-</div>
-                                                          
-<div class="row span12">Apache REEF, REEF, Apache, the Apache feather logo, 
and the Apache REEF logo are trademarks
-                       of The Apache Software Foundation. All other marks 
mentioned may be trademarks or registered
-                       trademarks of their respective owners.</div>
-                          </div>
-
-        
-                </div>
-    </footer>
-        </body>
-</html>
\ No newline at end of file
+<!DOCTYPE html>
+<!--
+ | Generated by Apache Maven Doxia at 2015-09-01 
+ | Rendered using Apache Maven Fluido Skin 1.4
+-->
+<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
+  <head>
+    <meta charset="UTF-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <meta name="Date-Revision-yyyymmdd" content="20150901" />
+    <meta http-equiv="Content-Language" content="en" />
+    <title>Apache REEF - Tang</title>
+    <link rel="stylesheet" href="./css/apache-maven-fluido-1.4.min.css" />
+    <link rel="stylesheet" href="./css/site.css" />
+    <link rel="stylesheet" href="./css/print.css" media="print" />
+
+      
+    <script type="text/javascript" 
src="./js/apache-maven-fluido-1.4.min.js"></script>
+
+                          
+        
+<script src="js/release.js" type="text/javascript"></script>
+          
+                  </head>
+        <body class="topBarEnabled">
+          
+                
+                    
+                
+
+    <div id="topbar" class="navbar navbar-fixed-top ">
+      <div class="navbar-inner">
+                <div class="container-fluid">
+        <a data-target=".nav-collapse" data-toggle="collapse" class="btn 
btn-navbar">
+          <span class="icon-bar"></span>
+          <span class="icon-bar"></span>
+          <span class="icon-bar"></span>
+        </a>
+                
+                                <ul class="nav">
+                          <li class="dropdown">
+        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Apache REEF 
<b class="caret"></b></a>
+        <ul class="dropdown-menu">
+        
+                      <li>      <a href="index.html"  
title="Overview">Overview</a>
+</li>
+                  
+                      <li>      <a href="faq.html"  title="FAQ">FAQ</a>
+</li>
+                  
+                      <li>      <a href="license.html"  
title="License">License</a>
+</li>
+                  
+                      <li>      <a href="downloads.html"  
title="Downloads">Downloads</a>
+</li>
+                          </ul>
+      </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="introduction.html"  
title="Introduction to REEF">Introduction to REEF</a>
+</li>
+                  
+                      <li>      <a 
href="https://cwiki.apache.org/confluence/display/REEF/Tutorials";  title="REEF 
Tutorial">REEF Tutorial</a>
+</li>
+                  
+                      <li>      <a href="talks.html"  title="Talks">Talks</a>
+</li>
+                  
+                      <li>      <a href="glossary.html"  
title="Glossary">Glossary</a>
+</li>
+                  
+                      <li>      <a href="tang.html"  title="Tang">Tang</a>
+</li>
+                  
+                      <li>      <a href="wake.html"  title="Wake">Wake</a>
+</li>
+                  
+                      <li>      <a href="apidocs/0.10.0-incubating/index.html" 
 title="0.10.0-incubating API">0.10.0-incubating API</a>
+</li>
+                  
+                      <li>      <a href="apidocs/0.11.0-incubating/index.html" 
 title="0.11.0-incubating API">0.11.0-incubating API</a>
+</li>
+                  
+                      <li>      <a href="apidocs/0.12.0-incubating/index.html" 
 title="0.12.0-incubating API">0.12.0-incubating API</a>
+</li>
+                          </ul>
+      </li>
+                <li class="dropdown">
+        <a href="#" class="dropdown-toggle" 
data-toggle="dropdown">Contribution <b class="caret"></b></a>
+        <ul class="dropdown-menu">
+        
+                      <li>      <a 
href="https://cwiki.apache.org/confluence/display/REEF/Contributing";  
title="Contributing">Contributing</a>
+</li>
+                  
+                      <li>      <a 
href="https://cwiki.apache.org/confluence/display/REEF/Committer+Guide";  
title="Committer Guide">Committer Guide</a>
+</li>
+                  
+                      <li>      <a 
href="https://cwiki.apache.org/confluence/display/REEF/Coding+Guidelines";  
title="Coding Guidelines">Coding Guidelines</a>
+</li>
+                          </ul>
+      </li>
+                <li class="dropdown">
+        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Community 
<b class="caret"></b></a>
+        <ul class="dropdown-menu">
+        
+                      <li>      <a href="team.html"  title="Team">Team</a>
+</li>
+                  
+                      <li>      <a href="mailing-list.html"  title="Mailing 
List">Mailing List</a>
+</li>
+                  
+                      <li>      <a 
href="https://issues.apache.org/jira/browse/REEF";  title="Issue Tracker">Issue 
Tracker</a>
+</li>
+                  
+                      <li>      <a 
href="https://cwiki.apache.org/confluence/display/REEF/Powered+by+REEF";  
title="Powered By">Powered By</a>
+</li>
+                          </ul>
+      </li>
+                <li class="dropdown">
+        <a href="#" class="dropdown-toggle" data-toggle="dropdown">ASF <b 
class="caret"></b></a>
+        <ul class="dropdown-menu">
+        
+                      <li>      <a href="http://www.apache.org/foundation/";  
title="Apache Software Foundation">Apache Software Foundation</a>
+</li>
+                  
+                      <li>      <a 
href="http://www.apache.org/foundation/how-it-works.html";  title="How Apache 
Works">How Apache Works</a>
+</li>
+                  
+                      <li>      <a href="http://incubator.apache.org/";  
title="Apache Incubator">Apache Incubator</a>
+</li>
+                  
+                      <li>      <a 
href="http://www.apache.org/licenses/LICENSE-2.0.html";  title="Apache 
License">Apache License</a>
+</li>
+                  
+                      <li>      <a 
href="http://www.apache.org/foundation/sponsorship.html";  
title="Sponsorship">Sponsorship</a>
+</li>
+                  
+                      <li>      <a 
href="http://www.apache.org/foundation/thanks.html";  title="Thanks">Thanks</a>
+</li>
+                          </ul>
+      </li>
+                  </ul>
+          
+          
+          
+                               <ul class="nav pull-right">
+              <li class="dropdown">
+                <a href="#" class="dropdown-toggle" 
data-toggle="dropdown">External Links <b class="caret"></b></a>
+                <ul class="dropdown-menu">
+                      <li>      <a 
href="https://github.com/apache/incubator-reef";  title="Apache REEF 
GitHub">Apache REEF GitHub</a>
+</li>
+      <li>      <a href="http://www.apache.org";  title="Apache">Apache</a>
+</li>
+      <li>      <a href="http://incubator.apache.org/";  title="Apache 
Incubator">Apache Incubator</a>
+</li>
+                  </ul>
+              </li>
+            </ul>
+          
+                      </div>
+          
+        </div>
+      </div>
+    </div>
+    
+        <div class="container-fluid">
+          <div id="banner">
+        <div class="pull-left">
+                                                          <a href="./" 
id="bannerLeft" title="Apache REEF">
+                                                                               
                 <img src="ApacheREEF_logo_no_margin_small.png"  alt="Apache 
REEF"/>
+                </a>
+                      </div>
+        <div class="pull-right">                  <a 
href="http://incubator.apache.org/"; id="bannerRight">
+                                                                               
                 <img src="ApacheIncubator.png" />
+                </a>
+      </div>
+        <div class="clear"><hr/></div>
+      </div>
+
+      <div id="breadcrumbs">
+        <ul class="breadcrumb">
+                
+                    
+                              <li class="">
+                    <a href="index.html" title="Apache REEF">
+        Apache REEF</a>
+                    <span class="divider">|</span>
+      </li>
+        <li class="active ">Tang</li>
+        
+                
+                    
+      
+                            </ul>
+      </div>
+
+                  
+      <div class="row-fluid">
+        <div id="leftColumn" class="span2">
+          <div class="well sidebar-nav">
+                
+                    
+                <ul class="nav nav-list">
+                    <li class="nav-header">Apache REEF</li>
+                              
+      <li>
+  
+                          <a href="index.html" title="Overview">
+          <span class="none"></span>
+        Overview</a>
+            </li>
+                
+      <li>
+  
+                          <a href="faq.html" title="FAQ">
+          <span class="none"></span>
+        FAQ</a>
+            </li>
+                
+      <li>
+  
+                          <a href="license.html" title="License">
+          <span class="none"></span>
+        License</a>
+            </li>
+                
+      <li>
+  
+                          <a href="downloads.html" title="Downloads">
+          <span class="none"></span>
+        Downloads</a>
+            </li>
+                              <li class="nav-header">Documentation</li>
+                              
+      <li>
+  
+                          <a href="introduction.html" title="Introduction to 
REEF">
+          <span class="none"></span>
+        Introduction to REEF</a>
+            </li>
+                
+      <li>
+  
+                          <a 
href="https://cwiki.apache.org/confluence/display/REEF/Tutorials"; 
class="externalLink" title="REEF Tutorial">
+          <span class="none"></span>
+        REEF Tutorial</a>
+            </li>
+                
+      <li>
+  
+                          <a href="talks.html" title="Talks">
+          <span class="none"></span>
+        Talks</a>
+            </li>
+                
+      <li>
+  
+                          <a href="glossary.html" title="Glossary">
+          <span class="none"></span>
+        Glossary</a>
+            </li>
+                
+      <li class="active">
+  
+            <a href="#"><span class="none"></span>Tang</a>
+          </li>
+                
+      <li>
+  
+                          <a href="wake.html" title="Wake">
+          <span class="none"></span>
+        Wake</a>
+            </li>
+                
+      <li>
+  
+                          <a href="apidocs/0.10.0-incubating/index.html" 
title="0.10.0-incubating API">
+          <span class="none"></span>
+        0.10.0-incubating API</a>
+            </li>
+                
+      <li>
+  
+                          <a href="apidocs/0.11.0-incubating/index.html" 
title="0.11.0-incubating API">
+          <span class="none"></span>
+        0.11.0-incubating API</a>
+            </li>
+                
+      <li>
+  
+                          <a href="apidocs/0.12.0-incubating/index.html" 
title="0.12.0-incubating API">
+          <span class="none"></span>
+        0.12.0-incubating API</a>
+            </li>
+                              <li class="nav-header">Contribution</li>
+                              
+      <li>
+  
+                          <a 
href="https://cwiki.apache.org/confluence/display/REEF/Contributing"; 
class="externalLink" title="Contributing">
+          <span class="none"></span>
+        Contributing</a>
+            </li>
+                
+      <li>
+  
+                          <a 
href="https://cwiki.apache.org/confluence/display/REEF/Committer+Guide"; 
class="externalLink" title="Committer Guide">
+          <span class="none"></span>
+        Committer Guide</a>
+            </li>
+                
+      <li>
+  
+                          <a 
href="https://cwiki.apache.org/confluence/display/REEF/Coding+Guidelines"; 
class="externalLink" title="Coding Guidelines">
+          <span class="none"></span>
+        Coding Guidelines</a>
+            </li>
+                              <li class="nav-header">Community</li>
+                              
+      <li>
+  
+                          <a href="team.html" title="Team">
+          <span class="none"></span>
+        Team</a>
+            </li>
+                
+      <li>
+  
+                          <a href="mailing-list.html" title="Mailing List">
+          <span class="none"></span>
+        Mailing List</a>
+            </li>
+                
+      <li>
+  
+                          <a href="https://issues.apache.org/jira/browse/REEF"; 
class="externalLink" title="Issue Tracker">
+          <span class="none"></span>
+        Issue Tracker</a>
+            </li>
+                
+      <li>
+  
+                          <a 
href="https://cwiki.apache.org/confluence/display/REEF/Powered+by+REEF"; 
class="externalLink" title="Powered By">
+          <span class="none"></span>
+        Powered By</a>
+            </li>
+                              <li class="nav-header">ASF</li>
+                              
+      <li>
+  
+                          <a href="http://www.apache.org/foundation/"; 
class="externalLink" title="Apache Software Foundation">
+          <span class="none"></span>
+        Apache Software Foundation</a>
+            </li>
+                
+      <li>
+  
+                          <a 
href="http://www.apache.org/foundation/how-it-works.html"; class="externalLink" 
title="How Apache Works">
+          <span class="none"></span>
+        How Apache Works</a>
+            </li>
+                
+      <li>
+  
+                          <a href="http://incubator.apache.org/"; 
class="externalLink" title="Apache Incubator">
+          <span class="none"></span>
+        Apache Incubator</a>
+            </li>
+                
+      <li>
+  
+                          <a 
href="http://www.apache.org/licenses/LICENSE-2.0.html"; class="externalLink" 
title="Apache License">
+          <span class="none"></span>
+        Apache License</a>
+            </li>
+                
+      <li>
+  
+                          <a 
href="http://www.apache.org/foundation/sponsorship.html"; class="externalLink" 
title="Sponsorship">
+          <span class="none"></span>
+        Sponsorship</a>
+            </li>
+                
+      <li>
+  
+                          <a 
href="http://www.apache.org/foundation/thanks.html"; class="externalLink" 
title="Thanks">
+          <span class="none"></span>
+        Thanks</a>
+            </li>
+            </ul>
+                
+                    
+                
+          <hr />
+
+           <div id="poweredBy">
+                            <div class="clear"></div>
+                            <div class="clear"></div>
+                            <div class="clear"></div>
+                            <div class="clear"></div>
+                             <a href="http://maven.apache.org/"; title="Built 
by Maven" class="poweredBy">
+        <img class="builtBy" alt="Built by Maven" 
src="./images/logos/maven-feather.png" />
+      </a>
+                  </div>
+          </div>
+        </div>
+        
+                        
+        <div id="bodyColumn"  class="span10" >
+                                  
+            <!-- Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License. --><h1>Tang</h1>
+<p>Tang is a configuration managment and checking framework that emphasizes 
explicit documentation and automatic checkability of configurations and 
applications instead of ad-hoc, application-specific configuration and 
bootstrapping logic. It supports distributed, multi-language applications, but 
gracefully handles simpler use cases as well.</p>
+<p>Tang makes use of dependency injection to automatically instantiate 
applications. Dependency injectors can be thought of as &#x201c;make for 
objects&#x201d; &#x2013; given a request for some type of object, and 
information that explains how dependencies between objects should be resolved, 
dependency injectors automatically instantiate the requested object and all of 
the objects it dependes upon. Tang makes use of a few simple wire formats to 
support remote and even cross-language dependency injection.</p>
+<div class="section">
+<h2>Outline<a name="Outline"></a></h2>
+
+<ul>
+  
+<li><a href="#motivation">Motivation</a></li>
+  
+<li><a href="#design-principles">Design principles</a></li>
+  
+<li><a href="#tutorial-getting-started">Tutorial: Getting started</a>
+  
+<ul>
+    
+<li><a href="#configuration-parameters">Defining configuration 
parameters</a></li>
+    
+<li><a href="#configuration-modules">Configuration Modules</a></li>
+    
+<li><a href="#injecting-objects-with-getinstance">Injecting objects with 
getInstance()</a></li>
+    
+<li><a href="#cyclic-injections">Cyclic Injections</a></li>
+  </ul></li>
+  
+<li><a href="#alternative-configuration-sources">Alternative configuration 
sources</a>
+  
+<ul>
+    
+<li><a href="#raw-configuration-api">Raw configuration API</a></li>
+  </ul></li>
+  
+<li><a href="#looking-under-the-hood">Looking under the hood</a>
+  
+<ul>
+    
+<li><a href="#injectionPlan">InjectionPlan</a></li>
+    
+<li><a href="#classHierarchy">ClassHierarchy</a></li>
+  </ul></li>
+</ul>
+<h1><a name="motivation"></a>Motivation</h1>
+<p>Distributed systems suffer from problems that arise due to complex 
compositions of software modules and configuration errors. These problems 
compound over time: best-practice object oriented design dictates that code be 
factored into independent reusable modules, and today&#x2019;s distributed 
applications are increasingly expected to run atop multiple runtime 
environments. This leads application developers to push complexity into 
configuration settings, to the point where misconfiguration is now a primary 
cause of unavailability in fault tolerant systems.</p>
+<p>Tang is our attempt to address these problems. It consists of a dependency 
injection framework and a set of configuration and debugging tools that 
automatically and transparently bootstrap applications. We have focused on 
providing a narrow set of primitives that support the full range of design 
patterns that arise in distributed system development, and that encourage 
application developers to build their systems in a maintainable and debuggable 
way.</p>
+<p>Tang leverages existing language type systems, allowing unmodified IDEs 
such as Eclipse or NetBeans to surface configuration information in tooltips, 
provide auto-complete of configuration parameters, and to detect a wide range 
of configuration problems as you edit your code. Since such functionality is 
surfaced in the tools you are already familiar with, there is no need to 
install (or learn) additional development software to get started with Tang. 
Furthermore, we provide a set of sophisticated build time and runtime tools 
that detect a wide range of common architectural problems and configuration 
errors.</p>
+<p>This documentation consists of tutorials that present prefered Tang design 
patterns. By structuring your application according to the patterns we suggest 
throughout the tutorials, you will allow our static analysis framework, Tint 
(&#x201c;Tang Lint&#x201d;), to detect problematic design patterns and 
high-level configuration problems as part of your build. These patterns provide 
the cornerstone for a number of more advanced features, such as interacting 
with legacy configuration systems, designing for cross-language applications, 
and multi-tenancy issues, such as secure injections of untrusted application 
code. To the best of our knowledge, implementing such tools and addressing 
these real-world implementation constraints would be difficult, or even 
impossible, atop competing frameworks.</p>
+<h1><a name="design-principles"></a>Design principles</h1>
+<p>Tang encourages application developers to specify default implementations 
and constructor parameters in terms of code annotations and configuration 
modules. This avoids the need for a number of subtle (and often confusing) 
dependency injection software patterns, though it does lead to a different 
approach to dependency injection than other frameworks encourage.</p>
+<p>In the process of building complicated systems built atop Tang, we found 
that, as the length of configurations that are passed around at runtime 
increased, it rapidly became impossible to debug or maintain our higher-level 
applications. In an attempt to address this problem, traditional dependency 
injection systems actually compound this issue. They encourage the developers 
of each application-level component to implement hand-written 
&#x201c;Modules&#x201d; that are executed at runtime. Hand-written modules 
introspect on the current runtime configuration, augment and modify it, and 
then return a new configuration that takes the new application component into 
account.</p>
+<p>In other systems, developers interact with modules by invoking ad-hoc 
builder methods, and passing configurations (in the correct order) from module 
to module. Modules frequently delgate to each other, either via inheritance or 
wrappers. This makes it difficult for developers and end-users to figure out 
which value of a given parameter will be used, or even to figure out why it was 
(or was not) set.</p>
+<p>Tang provides an alternative called <tt>ConfigurationModule</tt>s:</p>
+
+<ul>
+  
+<li><tt>Configurations</tt> and <tt>ConfigurationModules</tt> are &#x201c;just 
data,&#x201d; and can be read and written in human readable formats.</li>
+  
+<li>Interfaces and configuration parameters are encouraged to specify 
defaults, significantly shortening the configurations generated at runtime, and 
making it easy to see what was &#x201c;strange&#x201d; about a given run of the 
application.</li>
+  
+<li>Tang&#x2019;s static analysis and documentation tools sanity check 
<tt>ConfigurationModule</tt>s, and document their behavior and any extra 
parameters they export.</li>
+  
+<li>Configuration options can be set at most once. This avoids (or at least 
detects) situations in which users and application-level code inadvertantly 
&#x201c;fight&#x201d; over the setting of a particular option.</li>
+</ul>
+<p>The last property comes from Tang&#x2019;s use of <i>monotonic</i> set 
oriented primitives. This allows us to leverage recent theoretical results in 
commtative data types; particularly CRDTs, and the CALM theorem. Concretely:</p>
+
+<ul>
+  
+<li>A large subset of Tang&#x2019;s public API is commutative, which frees 
application-level configuration and bootstrapping logic from worrying about the 
order in which configuration sources are processed at runtime.</li>
+  
+<li>Tang can detect configuration and injection problems much earlier than is 
possible with other approaches. Also, upon detecting a conflict, Tang lists the 
configuration sources that contributed to the problem.</li>
+</ul>
+<p>Finally, Tang is divided into a set of &#x201c;core&#x201d; primtives, and 
higher-level configuration &#x201c;formats&#x201d;. Tang&#x2019;s core focuses 
on dependency injection and static checking of configurations. The formats 
provide higher-level configuration languages primitives, such as distributed, 
cross-language injection, configuration files, and 
<tt>ConfigurationModule</tt>. Each Tang format imports and/or exports standard 
Tang <tt>Configuration</tt> objects, which can then be composed with other 
configuration data at runtime.</p>
+<p>Improvements to these formats are planned, such as command-line tab 
completion, and improved APIs for extremely complex applications that are built 
by composing multiple Tang configurations to inject arbitrary object graphs. 
Furthermore, Tang formats include documentation facilities, and automatic 
command line and configuration file parsing. From an end-user perspective, this 
takes a lot of the guesswork out of configuration file formats.</p>
+<p>Although Tang surfaces a text-based interface for end-users of the 
applications built atop it, all configuration options and their types are 
specified in terms of Java classes and annotations. As with the core Tang 
primitives, this allows the Java compiler to statically check Tang formats for 
problems such as inconsistent usage of configuration parameters, naming 
conflicts and so on. This eliminates broad classes of runtime errors. These 
checks can be run independently of the application&#x2019;s runtime 
environment, and can find problems both in the Java-level implementation of the 
system, and with user-provided configuration files. The tools that perform 
these checks are designed to run as a post-processing step of projects built 
atop Tang. Like the Java compiler checks, this prevents such errors from making 
it to production environments. It also prevents such errors from being exposed 
to application logic or end-users, greatly simplifying applications built atop 
Tang.</p>
+<p>Taken together, these properties greatly simplify dependency injection in 
distributed environments. We expect Tang to be used in environments that are 
dominated by &#x201c;plugin&#x201d;-style APIs with many alternative 
implementations. Tang cleanly separates concerns over configuration management, 
dependency injection and object implementations, which hides most of the 
complexity of dependency injection from plugin implementers. It also prevents 
plugin implementations from inadvertently conflicting with each other or their 
runtime environements. Such clean semantics are crucial in distributed, 
heterogeneous environments.</p>
+<h1><a name="tutorial-getting-started"></a>Tutorial: Getting started</h1>
+<p>This tutorial is geared toward people that would like to quickly get 
started with Tang, or that are modifying an existing Tang application.</p></div>
+<div class="section">
+<h2><a name="configuration-parameters"></a>Constructors, @Inject and 
@Parameter<a name="Constructors_Inject_and_Parameter"></a></h2>
+<p>Suppose you are implementing a new class, and would like to automatically 
pass configuration parameters to it at runtime:</p>
+
+<div class="source"><pre class="prettyprint">package com.example;
+
+public class Timer {
+  private final int seconds;
+
+  public Timer(int seconds) {
+    if(seconds &lt; 0) {
+      throw new IllegalArgumentException(&quot;Cannot sleep for negative 
time!&quot;);
+    }
+    this.seconds = seconds;
+  }
+
+  public void sleep() throws Exception {
+    java.lang.Thread.sleep(seconds * 1000);
+  }
+}
+</pre></div>
+<p>Tang encourages applications to use Plain Old Java Objects (POJOs), and 
emphasizes the use of immutable state for configuration parameters. This 
reduces boiler plate (there is no need for extra setter methods), and does not 
interfere with encapsulation (the fields and even the constructor can be 
private). Furthermore, it is trivial for well-written classes to ensure that 
all objects are completely and properly instantiated: They simply need to check 
constructor parameters as any other POJO would, except that Tang never passes 
<tt>null</tt> references into constructors, allowing their implementations to 
assume that all parameter values are non-null.</p>
+<p>Tang aims to provide end users with error messages as early as possible, 
and encourages developers to throw exceptions inside of constructors. This 
allows it to automatically provide additional information to end-users when 
things go wrong:</p>
+
+<div class="source"><pre class="prettyprint">Exception in thread 
&quot;main&quot; org.apache.reef.tang.exceptions.InjectionException: Could not 
invoke constructor: new Timer(Integer Seconds = -1)
+    at 
org.apache.reef.tang.implementation.java.InjectorImpl.injectFromPlan(InjectorImpl.java:585)
+    at 
org.apache.reef.tang.implementation.java.InjectorImpl.getInstance(InjectorImpl.java:449)
+    at 
org.apache.reef.tang.implementation.java.InjectorImpl.getInstance(InjectorImpl.java:466)
+    at org.apache.reef.tang.examples.Timer.main(Timer.java:48)
+Caused by: java.lang.IllegalArgumentException: Cannot sleep for negative time!
+    at org.apache.reef.tang.examples.Timer.&lt;init&gt;(Timer.java:25)
+    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
+    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
+    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown 
Source)
+    at java.lang.reflect.Constructor.newInstance(Unknown Source)
+    at 
org.apache.reef.tang.implementation.java.InjectorImpl.injectFromPlan(InjectorImpl.java:569)
+    ... 3 more
+</pre></div>
+<p>In order for Tang to instantiate an object, we need to annotate the 
constructor with an <tt>@Inject</tt> annotation. While we&#x2019;re at it, 
we&#x2019;ll define a configuration parameter, allowing us to specify seconds 
on the command line and in a config file:</p>
+
+<div class="source"><pre class="prettyprint">package com.example;
+
+import javax.inject.Inject;
+

[... 333 lines stripped ...]


Reply via email to