| <!DOCTYPE html |
| PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "../xhtml1-strict.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| <link rel="stylesheet" type="text/css" href="../css/ot.css" /> |
| <link rel="stylesheet" type="text/css" href="../css/otjld.css" /> |
| <title>OT/J Language Definition v1.3.1</title> |
| </head> |
| <body class="otdt"> |
| <div id="content"> |
| <table class="nav"> |
| <tr> |
| <td class="back"><a id="top"></a><a href="s5.4.html" rel="prev"><< §5.4 Guard predicates</a></td> |
| <td class="top"><a href="index.html" rel="contents">↑ Table of Contents ↑</a></td> |
| <td class="next"></td> |
| </tr> |
| </table> |
| <div class="breadcrumb"><a class="nav" href="s5.html" rel="section">§5 Team Activation</a></div> |
| <div class="sect depth2" id="s5.5"> |
| <h2 class="sect">§5.5 Unanticipated team activation<a class="img" href="s5.5.html" |
| title="PermaLink to §5.5 Unanticipated team activation"><img style="vertical-align:text-top;margin-left:5px;" src="../images/permalink.png" |
| alt="" /></a></h2> |
| <p>If an application should be adapted unanticipatedly by one or more teams, |
| this can be achieved without explicitly changing the program code of this application. |
| |
| </p> |
| <p><span class="underline">General activation via config file:</span><br /> |
| Instead of adding the team initialization |
| and activation code to the main program, it is possible to add the respective teams via a config file. |
| Every line of this text file contains the fully qualified name of a compiled team, which has to be available |
| on the classpath. |
| For the instantiation of these teams the default constructor is used, which means adding a team to |
| an application this way requires the team to provide a default constructor. |
| The activation order (see <a href="s5.1.html" title="§5.1 Effect of team activation" |
| class="sect">§5.1</a>) for these teams corresponds to the order |
| in which they are listed in the config file.<br /> |
| Lines starting with a '#' denote comment lines. |
| |
| </p> |
| <h5 class="listing">Example config file:</h5> |
| <div class="listing config frame"><pre><span class="comment"># Config file for an ObjectTeams application:</span> |
| <em>mypackage1.MyTeam1</em> |
| <span class="comment"># ...</span> |
| <em>mypackageM.MyTeamN</em></pre></div> |
| <p>To get this config file recognized by the application the VM argument<br /><strong>'-Dot.teamconfig=<<em>config_file_name</em>>'</strong><br /> |
| has to be used when starting the application. |
| |
| </p> |
| <div class="note"> |
| <h5>Note:</h5> |
| In the ObjectTeams Development Tooling (OTDT) teams are activated unanticipatedly |
| via a special tab in the "Run-Configuration" (see <a href="http://www.objectteams.org/distrib/features.html#execution" class="ext">OTDT features</a>), instead. |
| |
| </div> |
| <p><span class="underline">Activation adjustment example:</span><br /> |
| Teams added via the config file mechanism are activated by default. Because no reference to them is |
| stored anywhere, it is not possible to deactivate them later. |
| If deactivation of unanticipated added teams is required, this can be achieved by adding a manager team |
| via config file and encapsulate the actual functionality in another team managed by the manager team. |
| This way a functional team can be activated and deactivated as needed. |
| |
| </p> |
| <h5 class="listing">Example code (Activation Adjustment):</h5> |
| <div class="listing example frame"> |
| <table class="listing"> |
| <tr class="line odd"> |
| <td class="ln">1</td> |
| <td><pre><b>public</b> <b>team</b> <b>class</b> MyManagerTeam {</pre></td> |
| </tr> |
| <tr class="line even"> |
| <td class="ln">2</td> |
| <td><pre> <b>private</b> FunctionalTeam myFunctionalTeam = <b>new</b> FunctionalTeam();</pre></td> |
| </tr> |
| <tr class="line odd"> |
| <td class="ln">3</td> |
| <td><pre> <b>protected</b> <b>class</b> MyRole <b>playedBy</b> MyApplication {</pre></td> |
| </tr> |
| <tr class="line even"> |
| <td class="ln">4</td> |
| <td><pre> <b>void</b> startAdaption() { myFunctionalTeam.activate(); }</pre></td> |
| </tr> |
| <tr class="line odd"> |
| <td class="ln">5</td> |
| <td><pre> startAdaption <b><-</b> <b>before</b> startMethod;</pre></td> |
| </tr> |
| <tr class="line even"> |
| <td class="ln">6</td> |
| <td><pre> <b>void</b> stopAdaption() { myFunctionalTeam.deactivate(); }</pre></td> |
| </tr> |
| <tr class="line odd"> |
| <td class="ln">7</td> |
| <td><pre> stopAdaption <b><-</b> <b>after</b> stopMethod;</pre></td> |
| </tr> |
| <tr class="line even"> |
| <td class="ln">8</td> |
| <td><pre> }</pre></td> |
| </tr> |
| <tr class="line odd"> |
| <td class="ln">9</td> |
| <td><pre>}</pre></td> |
| </tr> |
| </table> |
| </div> |
| <div class="listing config frame"><pre><span class="comment"># Config file for the manager team example:</span> |
| <em>MyManagerTeam</em></pre></div> |
| <div class="codecomment"> |
| <h5>Effects:</h5> |
| <ul> |
| <li><code>startMethod</code> and <code>stopMethod</code> are methods which demand |
| the activation and deactivation respectively. |
| |
| </li> |
| <li>If the activation/deactivation depends on other conditions these can be checked in addition. |
| |
| </li> |
| </ul> |
| </div> |
| </div> |
| <table class="nav"> |
| <tr> |
| <td class="back"><a href="s5.4.html" rel="prev"><< §5.4 Guard predicates</a></td> |
| <td class="top"><a href="index.html" rel="contents">↑ Table of Contents ↑</a></td> |
| <td class="next"></td> |
| </tr> |
| </table> |
| <div class="breadcrumb"><a class="nav" href="s5.html" rel="section">§5 Team Activation</a></div> |
| </div> |
| <div id="footer"> |
| <hr /><a class="w3c img" href="http://jigsaw.w3.org/css-validator/check/referer" |
| shape="rect"><img src="../images/valid-css2-blue.png" alt="Valid CSS!" height="31" width="88" /></a><a class="w3c img" href="http://validator.w3.org/check?uri=referer" shape="rect"><img src="../images/valid-xhtml10-blue.png" alt="Valid XHTML 1.0 Strict" height="31" |
| width="88" /></a><address>© Stephan Herrmann, Christine Hundt, Marco Mosconi</address> |
| OT/J version 1.3.1 — last modified: 2013-05-28 |
| </div> |
| </body> |
| </html> |