felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r849586 [2/2] - in /websites/staging/felix/trunk/content: ./ documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-gettingstarted/
Date Wed, 06 Feb 2013 16:25:57 GMT
Modified: websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-gettingstarted/ipojo-in-10-minutes.html
==============================================================================
--- websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-gettingstarted/ipojo-in-10-minutes.html (original)
+++ websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-gettingstarted/ipojo-in-10-minutes.html Wed Feb  6 16:25:57 2013
@@ -152,7 +152,9 @@
     <div class="container">
         <div class="content">
             <h1 id="ipojo-in-10-minutes">iPOJO in 10 minutes</h1>
-<p><em>This page presents how to use the iPOJO runtime and its associated service component model. The concepts of the service component model are introduced, followed by a simple example that demonstrates the features of iPOJO. This tutorial uses XML to describe components.  However, iPOJO also supports</em> <em><a href="/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/how-to-use-ipojo-annotations.html">annotations</a></em> <em>and a Java</em> <em>[API|apache-felix-ipojo-api]</em> <em>for this purpose.</em></p>
+<p>This page presents how to use the iPOJO runtime and its associated service component model. The concepts of the service component model are introduced, followed by a simple example that demonstrates the features of iPOJO. This tutorial uses XML to describe components.  However, iPOJO also supports
+    * <a href="/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/how-to-use-ipojo-annotations.html">annotations</a>
+    * A Java [API|apache-felix-ipojo-api]</p>
 <h2 id="introduction">Introduction</h2>
 <p>iPOJO aims to simplify service-oriented programming on OSGi frameworks; the name iPOJO is an abbreviation for <em>injected POJO</em>. iPOJO provides a new way to develop OSGi service components, simplifying service component implementation by transparently managing the dynamics of the environment as well as other non-functional requirements. The iPOJO framework allows developers to more clearly separate functional code (i.e., POJOs) from the non-functional code (i.e., dependency management, service provision, configuration, etc.).  At run time, iPOJO combines the functional and non-functional aspects. To achieve this, iPOJO provides a simple and extensible service component model based on POJOs.</p>
 <h2 id="the-pojo-concept">The POJO concept</h2>
@@ -170,9 +172,9 @@
 <em> A component implementing a dictionary service
 </em> A component requiring the dictionary service and providing a spellchecker service
 * A component requiring the spellchecker and providing an user interface</p>
-<p>!spell.png!</p>
+<p><img src="spell.png"></p>
 <h3 id="preparing-the-tutorial">Preparing the tutorial</h3>
-<p>This tutorial is based on Ant. So, you need to have the Ant program accessible in your path (see <a href="http://ant.apache.org/">here</a> to download and install Ant). Download the tutorial archive available [here|http://people.apache.org/~clement/ipojo/tutorials/10min/tutorial.zip] and then unzip it. The archive contains seven directories:
+<p>This tutorial is based on Ant. So, you need to have the Ant program accessible in your path (see <a href="http://ant.apache.org/">here</a> to download and install Ant). Download the tutorial archive available <a href="http://people.apache.org/~clement/ipojo/tutorials/10min/tutorial.zip">here</a> and then unzip it. The archive contains seven directories:
 <em> spell.services contains service interfaces used by the applications
 </em> spell.english contains an implementation of the Dictionary service (containing English words)
 <em> spell.checker contains an implementation of a Spell Checker. The spell checker requires a dictionary service and check if an input passage is correct (according to the words contained in the dictionary).
@@ -182,103 +184,103 @@
 * Finally, the felix folder contains a configured version of the Felix runtime</p>
 <h3 id="the-spellservices-project">The spell.services project</h3>
 <p>The spell.services project contains only service interfaces. It is not an iPOJO powered bundle.</p>
-<p>Go inside the Spell.services directory and create the file "src/spell/services/DictionaryService.java" for the following <em>Dictionary</em> service interface:
-{code:java}
-package spell.services;
-/<strong>
- * A simple service interface that defines a dictionary service.
- * A dictionary service simply verifies the existence of a word.
-</strong>/
-public interface DictionaryService {
-    /<strong>
-     * Check for the existence of a word.
-     * @param word the word to be checked.
-     * @return true if the word is in the dictionary,
-     *         false otherwise.
-     </strong>/
-    public boolean checkWord(String word);
-}</p>
-<div class="codehilite"><pre><span class="n">Then</span><span class="p">,</span> <span class="n">create</span> <span class="n">the</span> <span class="n">file</span>  <span class="k">for</span> <span class="n">the</span> <span class="n">following</span> <span class="n">_Spell</span> <span class="n">Checker_</span> <span class="n">service</span> <span class="n">interface:</span>
-<span class="p">{</span><span class="n">code:java</span><span class="p">}</span>
-<span class="nb">package</span> <span class="n">spell</span><span class="o">.</span><span class="n">services</span><span class="p">;</span>
-<span class="o">/**</span>
- <span class="o">*</span> <span class="n">A</span> <span class="n">simple</span> <span class="n">service</span> <span class="n">interface</span> <span class="n">that</span> <span class="n">defines</span> <span class="n">a</span> <span class="n">spell</span> <span class="n">checker</span> <span class="n">service</span><span class="o">.</span>
- <span class="o">*</span> <span class="n">A</span> <span class="n">spell</span> <span class="n">checker</span> <span class="n">service</span> <span class="n">checks</span> <span class="n">the</span> <span class="n">spelling</span> <span class="n">of</span> <span class="n">all</span> <span class="n">words</span> <span class="n">in</span> <span class="n">a</span>
- <span class="o">*</span> <span class="n">given</span> <span class="n">passage</span><span class="o">.</span> <span class="n">A</span> <span class="n">passage</span> <span class="n">is</span> <span class="n">any</span> <span class="n">number</span> <span class="n">of</span> <span class="n">words</span> <span class="n">separated</span> <span class="n">by</span>
- <span class="o">*</span> <span class="n">a</span> <span class="n">space</span> <span class="n">character</span> <span class="ow">and</span> <span class="n">the</span> <span class="n">following</span> <span class="n">punctuation</span> <span class="n">marks:</span> <span class="n">comma</span><span class="p">,</span>
- <span class="o">*</span> <span class="n">period</span><span class="p">,</span> <span class="n">exclamation</span> <span class="n">mark</span><span class="p">,</span> <span class="n">question</span> <span class="n">mark</span><span class="p">,</span> <span class="n">semi</span><span class="o">-</span><span class="n">colon</span><span class="p">,</span> <span class="ow">and</span> <span class="n">colon</span><span class="o">.</span>
-<span class="o">**/</span>
-<span class="n">public</span> <span class="n">interface</span> <span class="n">SpellChecker</span> <span class="p">{</span>
-    <span class="o">/**</span>
-     <span class="o">*</span> <span class="n">Checks</span> <span class="n">a</span> <span class="n">given</span> <span class="n">passage</span> <span class="k">for</span> <span class="n">spelling</span> <span class="n">errors</span><span class="o">.</span> <span class="n">A</span> <span class="n">passage</span> <span class="n">is</span> <span class="n">any</span>
-     <span class="o">*</span> <span class="n">number</span> <span class="n">of</span> <span class="n">words</span> <span class="n">separated</span> <span class="n">by</span> <span class="n">a</span> <span class="n">space</span> <span class="ow">and</span> <span class="n">any</span> <span class="n">of</span> <span class="n">the</span> <span class="n">following</span>
-     <span class="o">*</span> <span class="n">punctuation</span> <span class="n">marks:</span> <span class="n">comma</span> <span class="p">(,),</span> <span class="n">period</span> <span class="p">(</span><span class="o">.</span><span class="p">),</span> <span class="n">exclamation</span> <span class="n">mark</span> <span class="p">(</span><span class="o">!</span><span class="p">),</span>
-     <span class="o">*</span> <span class="n">question</span> <span class="n">mark</span> <span class="p">(?),</span> <span class="n">semi</span><span class="o">-</span><span class="n">colon</span> <span class="p">(;),</span> <span class="ow">and</span> <span class="n">colon</span><span class="p">(:)</span><span class="o">.</span>
-     <span class="o">*</span> <span class="nv">@param</span> <span class="n">passage</span> <span class="n">the</span> <span class="n">passage</span> <span class="n">to</span> <span class="n">spell</span> <span class="n">check</span><span class="o">.</span>
-     <span class="o">*</span> <span class="nv">@return</span> <span class="n">An</span> <span class="n">array</span> <span class="n">of</span> <span class="n">misspelled</span> <span class="n">words</span> <span class="ow">or</span> <span class="n">null</span> <span class="k">if</span> <span class="nb">no</span>
-     <span class="o">*</span>         <span class="n">words</span> <span class="n">are</span> <span class="n">misspelled</span><span class="o">.</span>
-    <span class="o">**/</span>
-    <span class="n">public</span> <span class="n">String</span><span class="o">[]</span> <span class="n">check</span><span class="p">(</span><span class="n">String</span> <span class="n">passage</span><span class="p">);</span>
-<span class="p">}</span>
+<p>Go inside the Spell.services directory and create the file "src/spell/services/DictionaryService.java" for the following <em>Dictionary</em> service interface:</p>
+<div class="codehilite"><pre><span class="kn">package</span> <span class="n">spell</span><span class="o">.</span><span class="na">services</span><span class="o">;</span>
+<span class="cm">/**</span>
+<span class="cm"> * A simple service interface that defines a dictionary service.</span>
+<span class="cm"> * A dictionary service simply verifies the existence of a word.</span>
+<span class="cm">**/</span>
+<span class="kd">public</span> <span class="kd">interface</span> <span class="nc">DictionaryService</span> <span class="o">{</span>
+    <span class="cm">/**</span>
+<span class="cm">     * Check for the existence of a word.</span>
+<span class="cm">     * @param word the word to be checked.</span>
+<span class="cm">     * @return true if the word is in the dictionary,</span>
+<span class="cm">     *         false otherwise.</span>
+<span class="cm">     **/</span>
+    <span class="kd">public</span> <span class="kt">boolean</span> <span class="nf">checkWord</span><span class="o">(</span><span class="n">String</span> <span class="n">word</span><span class="o">);</span>
+<span class="o">}</span>
 </pre></div>
 
 
-<p>Once created, you can build the project by launching Ant from the project directory.
-{code:none}
-$ ant
+<p>Then, create the file <code>src/spell/services/SpellChecker.java</code> for the following <em>Spell Checker</em> service interface:</p>
+<div class="codehilite"><pre><span class="kn">package</span> <span class="n">spell</span><span class="o">.</span><span class="na">services</span><span class="o">;</span>
+<span class="cm">/**</span>
+<span class="cm"> * A simple service interface that defines a spell checker service.</span>
+<span class="cm"> * A spell checker service checks the spelling of all words in a</span>
+<span class="cm"> * given passage. A passage is any number of words separated by</span>
+<span class="cm"> * a space character and the following punctuation marks: comma,</span>
+<span class="cm"> * period, exclamation mark, question mark, semi-colon, and colon.</span>
+<span class="cm">**/</span>
+<span class="kd">public</span> <span class="kd">interface</span> <span class="nc">SpellChecker</span> <span class="o">{</span>
+    <span class="cm">/**</span>
+<span class="cm">     * Checks a given passage for spelling errors. A passage is any</span>
+<span class="cm">     * number of words separated by a space and any of the following</span>
+<span class="cm">     * punctuation marks: comma (,), period (.), exclamation mark (!),</span>
+<span class="cm">     * question mark (?), semi-colon (;), and colon(:).</span>
+<span class="cm">     * @param passage the passage to spell check.</span>
+<span class="cm">     * @return An array of misspelled words or null if no</span>
+<span class="cm">     *         words are misspelled.</span>
+<span class="cm">    **/</span>
+    <span class="kd">public</span> <span class="n">String</span><span class="o">[]</span> <span class="nf">check</span><span class="o">(</span><span class="n">String</span> <span class="n">passage</span><span class="o">);</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<p>Once created, you can build the project by launching Ant from the project directory.</p>
+<div class="codehilite"><pre><span class="nv">$ </span>ant
 Buildfile: build.xml
 clean:
 compile:
-    <a href="">mkdir</a> Created dir: d:\clement\workspaces\sandbox\ipojo\examples\tutorial-ant\
-            spell.services\output
-    <a href="">mkdir</a> Created dir: d:\clement\workspaces\sandbox\ipojo\examples\tutorial-ant\
-            spell.services\output\classes
-    <a href="">javac</a> Compiling 2 source files to d:\clement\workspaces\sandbox\ipojo\examples\
-            tutorial-ant\spell.services\output\classes
+    <span class="o">[</span>mkdir<span class="o">]()</span> Created dir: d:<span class="se">\c</span>lement<span class="se">\w</span>orkspaces<span class="se">\s</span>andbox<span class="se">\i</span>pojo<span class="se">\e</span>xamples<span class="se">\t</span>utorial-ant<span class="se">\</span>
+            spell.services<span class="se">\o</span>utput
+    <span class="o">[</span>mkdir<span class="o">]()</span> Created dir: d:<span class="se">\c</span>lement<span class="se">\w</span>orkspaces<span class="se">\s</span>andbox<span class="se">\i</span>pojo<span class="se">\e</span>xamples<span class="se">\t</span>utorial-ant<span class="se">\</span>
+            spell.services<span class="se">\o</span>utput<span class="se">\c</span>lasses
+    <span class="o">[</span>javac<span class="o">]()</span> Compiling 2 <span class="nb">source </span>files to d:<span class="se">\c</span>lement<span class="se">\w</span>orkspaces<span class="se">\s</span>andbox<span class="se">\i</span>pojo<span class="se">\e</span>xamples<span class="se">\</span>
+            tutorial-ant<span class="se">\s</span>pell.services<span class="se">\o</span>utput<span class="se">\c</span>lasses
 package:
-      <a href="">bnd</a> spell.services 2
+      <span class="o">[</span>bnd<span class="o">]()</span> spell.services 2
 BUILD SUCCESSFUL
-Total time: 0 seconds</p>
-<div class="codehilite"><pre><span class="n">The</span> <span class="n">created</span> <span class="n">bundle</span> <span class="n">is</span> <span class="n">inside</span> <span class="n">the</span> <span class="n">output</span> <span class="n">directory</span> <span class="p">(</span><span class="n">spell</span><span class="o">.</span><span class="n">services</span><span class="o">.</span><span class="n">jar</span><span class="p">)</span><span class="o">.</span> <span class="n">The</span> <span class="n">build</span> <span class="n">process</span> <span class="k">use</span> <span class="p">[</span><span class="n">BND</span><span class="o">|</span><span class="n">http:</span><span class="sr">//</span><span class="n">www</span><span class="o">.</span><span class="n">aqute</span><span class="o">.</span><span class="n">biz</span><span class="sr">/Code/</span><span class="n">Bnd</span><span class="p">]</span><span class="o">.</span> <span class="n">The</span> <span class="n">bu
 ndle</span> <span class="n">manifest</span> <span class="n">is</span> <span class="n">described</span> <span class="n">in</span> <span class="n">the</span> <span class="n">spell</span><span class="o">.</span><span class="n">services</span><span class="o">.</span><span class="n">bnd</span> <span class="n">file</span><span class="o">.</span>
-<span class="n">Once</span> <span class="n">this</span> <span class="n">project</span> <span class="n">is</span> <span class="n">done</span><span class="p">,</span> <span class="n">we</span> <span class="n">are</span> <span class="n">able</span> <span class="n">to</span> <span class="n">implement</span> <span class="n">a</span> <span class="n">Dictionary</span> <span class="n">service</span><span class="o">.</span>
-
-<span class="n">h3</span><span class="o">.</span> <span class="n">The</span> <span class="n">spell</span><span class="o">.</span><span class="n">english</span> <span class="n">project:</span> <span class="n">Providing</span> <span class="n">an</span> <span class="n">OSGi</span> <span class="n">service</span>
-
-<span class="n">The</span> <span class="n">spell</span><span class="o">.</span><span class="n">english</span> <span class="n">project</span> <span class="n">is</span> <span class="n">a</span> <span class="n">simple</span> <span class="n">dictionary</span> <span class="n">implementation</span> <span class="n">of</span> <span class="n">the</span> <span class="n">Dictionary</span> <span class="n">service</span><span class="o">.</span> <span class="n">It</span> <span class="n">contains</span> <span class="n">few</span> <span class="n">English</span> <span class="n">words</span><span class="o">.</span> <span class="n">This</span> <span class="n">implementation</span> <span class="n">is</span> <span class="n">an</span> <span class="n">iPOJO</span> <span class="n">component</span><span class="o">.</span>
-<span class="n">The</span> <span class="n">first</span> <span class="n">step</span> <span class="n">is</span> <span class="n">to</span> <span class="n">implement</span> <span class="n">the</span> <span class="n">service</span><span class="o">.</span> <span class="n">Create</span> <span class="n">the</span> <span class="s">&quot;src/spell/english/EnglishDictionary.java&quot;</span> <span class="n">file</span> <span class="k">for</span> <span class="n">the</span> <span class="n">following</span> <span class="n">_Dictionary</span> <span class="n">service_</span> <span class="n">implementation:</span>
-<span class="p">{</span><span class="n">code:java</span><span class="p">}</span>
-<span class="nb">package</span> <span class="n">spell</span><span class="o">.</span><span class="n">english</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">spell</span><span class="o">.</span><span class="n">services</span><span class="o">.</span><span class="n">DictionaryService</span><span class="p">;</span>
-<span class="o">/**</span>
- <span class="o">*</span> <span class="n">An</span> <span class="n">implementation</span> <span class="n">of</span> <span class="n">the</span> <span class="n">Dictionary</span> <span class="n">service</span> <span class="n">containing</span> <span class="n">English</span> <span class="n">words</span>
- <span class="o">*</span> <span class="n">see</span> <span class="n">DictionaryService</span> <span class="k">for</span> <span class="n">details</span> <span class="n">of</span> <span class="n">the</span> <span class="n">service</span><span class="o">.</span>
- <span class="o">**/</span>
-<span class="n">public</span> <span class="n">class</span> <span class="n">EnglishDictionary</span> <span class="n">implements</span> <span class="n">DictionaryService</span> <span class="p">{</span>
-    <span class="sr">//</span> <span class="n">The</span> <span class="n">set</span> <span class="n">of</span> <span class="n">words</span> <span class="n">contained</span> <span class="n">in</span> <span class="n">the</span> <span class="n">dictionary</span><span class="o">.</span>
-    <span class="n">String</span><span class="o">[]</span> <span class="n">m_dictionary</span> <span class="o">=</span> <span class="p">{</span> <span class="s">&quot;welcome&quot;</span><span class="p">,</span> <span class="s">&quot;to&quot;</span><span class="p">,</span> <span class="s">&quot;the&quot;</span><span class="p">,</span> <span class="s">&quot;ipojo&quot;</span><span class="p">,</span> <span class="s">&quot;tutorial&quot;</span> <span class="p">};</span>
-    <span class="o">/**</span>
-     <span class="o">*</span> <span class="n">Implements</span> <span class="n">DictionaryService</span><span class="o">.</span><span class="n">checkWord</span><span class="p">()</span><span class="o">.</span> <span class="n">Determines</span>
-     <span class="o">*</span> <span class="k">if</span> <span class="n">the</span> <span class="n">passed</span> <span class="n">in</span> <span class="n">word</span> <span class="n">is</span> <span class="n">contained</span> <span class="n">in</span> <span class="n">the</span> <span class="n">dictionary</span><span class="o">.</span>
-     <span class="o">*</span> <span class="nv">@param</span> <span class="n">word</span> <span class="n">the</span> <span class="n">word</span> <span class="n">to</span> <span class="n">be</span> <span class="n">checked</span><span class="o">.</span>
-     <span class="o">*</span> <span class="nv">@return</span> <span class="n">true</span> <span class="k">if</span> <span class="n">the</span> <span class="n">word</span> <span class="n">is</span> <span class="n">in</span> <span class="n">the</span> <span class="n">dictionary</span><span class="p">,</span>
-     <span class="o">*</span>         <span class="n">false</span> <span class="n">otherwise</span><span class="o">.</span>
-     <span class="o">**/</span>
-    <span class="n">public</span> <span class="n">boolean</span> <span class="n">checkWord</span><span class="p">(</span><span class="n">String</span> <span class="n">word</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">word</span> <span class="o">=</span> <span class="n">word</span><span class="o">.</span><span class="n">toLowerCase</span><span class="p">();</span>
-        <span class="sr">//</span> <span class="n">This</span> <span class="n">is</span> <span class="n">very</span> <span class="n">inefficient</span>
-        <span class="k">for</span> <span class="p">(</span><span class="nb">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="n">m_dictionary</span><span class="o">.</span><span class="nb">length</span><span class="p">;</span> <span class="n">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
-            <span class="k">if</span> <span class="p">(</span><span class="n">m_dictionary</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">equals</span><span class="p">(</span><span class="n">word</span><span class="p">))</span> <span class="p">{</span>
-                <span class="k">return</span> <span class="n">true</span><span class="p">;</span>
-            <span class="p">}</span>
-        <span class="p">}</span>
-        <span class="k">return</span> <span class="n">false</span><span class="p">;</span>
-    <span class="p">}</span>
-<span class="p">}</span>
+Total <span class="nb">time</span>: 0 seconds
+</pre></div>
+
+
+<p>The created bundle is inside the output directory (spell.services.jar). The build process use <a href="http://www.aqute.biz/Code/Bnd">BND</a>. The bundle manifest is described in the spell.services.bnd file.</p>
+<p>Once this project is done, we are able to implement a Dictionary service.</p>
+<h3 id="the-spellenglish-project-providing-an-osgi-service">The spell.english project: Providing an OSGi service</h3>
+<p>The spell.english project is a simple dictionary implementation of the Dictionary service. It contains few English words. This implementation is an iPOJO component.</p>
+<p>The first step is to implement the service. Create the "src/spell/english/EnglishDictionary.java" file for the following <em>Dictionary service</em> implementation:</p>
+<div class="codehilite"><pre><span class="kn">package</span> <span class="n">spell</span><span class="o">.</span><span class="na">english</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">spell.services.DictionaryService</span><span class="o">;</span>
+<span class="cm">/**</span>
+<span class="cm"> * An implementation of the Dictionary service containing English words</span>
+<span class="cm"> * see DictionaryService for details of the service.</span>
+<span class="cm"> **/</span>
+<span class="kd">public</span> <span class="kd">class</span> <span class="nc">EnglishDictionary</span> <span class="kd">implements</span> <span class="n">DictionaryService</span> <span class="o">{</span>
+    <span class="c1">// The set of words contained in the dictionary.</span>
+    <span class="n">String</span><span class="o">[]</span> <span class="n">m_dictionary</span> <span class="o">=</span> <span class="o">{</span> <span class="s">&quot;welcome&quot;</span><span class="o">,</span> <span class="s">&quot;to&quot;</span><span class="o">,</span> <span class="s">&quot;the&quot;</span><span class="o">,</span> <span class="s">&quot;ipojo&quot;</span><span class="o">,</span> <span class="s">&quot;tutorial&quot;</span> <span class="o">};</span>
+    <span class="cm">/**</span>
+<span class="cm">     * Implements DictionaryService.checkWord(). Determines</span>
+<span class="cm">     * if the passed in word is contained in the dictionary.</span>
+<span class="cm">     * @param word the word to be checked.</span>
+<span class="cm">     * @return true if the word is in the dictionary,</span>
+<span class="cm">     *         false otherwise.</span>
+<span class="cm">     **/</span>
+    <span class="kd">public</span> <span class="kt">boolean</span> <span class="nf">checkWord</span><span class="o">(</span><span class="n">String</span> <span class="n">word</span><span class="o">)</span> <span class="o">{</span>
+        <span class="n">word</span> <span class="o">=</span> <span class="n">word</span><span class="o">.</span><span class="na">toLowerCase</span><span class="o">();</span>
+        <span class="c1">// This is very inefficient</span>
+        <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="n">m_dictionary</span><span class="o">.</span><span class="na">length</span><span class="o">;</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
+            <span class="k">if</span> <span class="o">(</span><span class="n">m_dictionary</span><span class="o">[</span><span class="n">i</span><span class="o">].</span><span class="na">equals</span><span class="o">(</span><span class="n">word</span><span class="o">))</span> <span class="o">{</span>
+                <span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
+            <span class="o">}</span>
+        <span class="o">}</span>
+        <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
+    <span class="o">}</span>
+<span class="o">}</span>
 </pre></div>
 
 
 <p>Notice that this class does not contains neither OSGi nor iPOJO specific code. It is just an implementation of the Dictionary Service interface.
-Once created, we need to describe this component to ask iPOJO to manage it. To achieve this, create the "metadata.xml" file in the spell.english directory:</p>
+Once created, we need to describe this component to ask iPOJO to manage it. To achieve this, create the <code>metadata.xml</code> file in the spell.english directory:</p>
 <div class="codehilite"><pre><span class="nt">&lt;ipojo&gt;</span>
 <span class="nt">&lt;component</span> <span class="na">classname=</span><span class="s">&quot;spell.english.EnglishDictionary&quot;</span><span class="nt">&gt;</span>
     <span class="nt">&lt;provides/&gt;</span>
@@ -289,83 +291,81 @@ Once created, we need to describe this c
 
 
 <p>This file describes the Dictionary service implementation. First it creates a <em>component</em>. This component has a <em>classname</em> attribute containing the implementation class name. The <em>'provides'</em> element indicates that the component provide a service. Provided service interfaces are computed by iPOJO, so it is not necessary to indicate them. The <em>instance</em> element asks iPOJO to create an instance of the described component when the bundle starts. The relation between components and instances is the same than between classes and objects in the object oriented programming. The <em>component</em> attribute indicates which component needs to be instantiated. By default, component type name is the implementation class (i.e. the classname attribute).</p>
-<p>Then, we are able to create the bundle. In the spell.english directory launch the ant command:
-{code:none}
-$ ant
+<p>Then, we are able to create the bundle. In the spell.english directory launch the ant command:</p>
+<div class="codehilite"><pre>$ ant
 Buildfile: build.xml
 clean:
-   <a href="">delete</a> Deleting directory d:\clement\workspaces\sandbox\ipojo\examples\
+   [delete]() Deleting directory d:\clement\workspaces\sandbox\ipojo\examples\
             tutorial-ant\spell.english\output\classes
-   <a href="">delete</a> Deleting directory d:\clement\workspaces\sandbox\ipojo\examples\
+   [delete]() Deleting directory d:\clement\workspaces\sandbox\ipojo\examples\
             tutorial-ant\spell.english\output
 buildclasspath:
 compile:
-    <a href="">mkdir</a> Created dir: d:\clement\workspaces\sandbox\ipojo\examples\
+    [mkdir]() Created dir: d:\clement\workspaces\sandbox\ipojo\examples\
             tutorial-ant\spell.english\output
-    <a href="">mkdir</a> Created dir: d:\clement\workspaces\sandbox\ipojo\examples\
+    [mkdir]() Created dir: d:\clement\workspaces\sandbox\ipojo\examples\
             tutorial-ant\spell.english\output\classes
-    <a href="">javac</a> Compiling 1 source file to d:\clement\workspaces\sandbox\ipojo\examples\
+    [javac]() Compiling 1 source file to d:\clement\workspaces\sandbox\ipojo\examples\
             tutorial-ant\spell.english\output\classes
 package:
-      <a href="">bnd</a> spell.english 1
-    <a href="">ipojo</a> Input Bundle File : d:\clement\workspaces\sandbox\ipojo\examples\
+      [bnd]() spell.english 1
+    [ipojo]() Input Bundle File : d:\clement\workspaces\sandbox\ipojo\examples\
             tutorial-ant\spell.english\output\spell.english.jar
-    <a href="">ipojo</a> Metadata File : d:\clement\workspaces\sandbox\ipojo\examples\
+    [ipojo]() Metadata File : d:\clement\workspaces\sandbox\ipojo\examples\
             tutorial-ant\spell.english\metadata.xml
-    <a href="">ipojo</a> Start bundle manipulation
-    <a href="">ipojo</a> Bundle manipulation - SUCCESS
-    <a href="">ipojo</a> Output File : d:\clement\workspaces\sandbox\ipojo\examples\
+    [ipojo]() Start bundle manipulation
+    [ipojo]() Bundle manipulation - SUCCESS
+    [ipojo]() Output File : d:\clement\workspaces\sandbox\ipojo\examples\
             tutorial-ant\spell.english\output\spell.english.jar
 BUILD SUCCESSFUL
-Total time: 1 second</p>
-<div class="codehilite"><pre><span class="n">The</span> <span class="n">created</span> <span class="n">bundle</span> <span class="n">is</span> <span class="n">inside</span> <span class="n">the</span> <span class="n">output</span> <span class="n">directory</span> <span class="p">(</span><span class="n">spell</span><span class="o">.</span><span class="n">english</span><span class="o">.</span><span class="n">jar</span><span class="p">)</span><span class="o">.</span> <span class="n">The</span> <span class="n">build</span> <span class="n">process</span> <span class="n">is</span> <span class="n">based</span> <span class="n">on</span> <span class="n">BND</span> <span class="ow">and</span> <span class="n">on</span> <span class="n">the</span> <span class="n">iPOJO</span> <span class="n">Ant</span> <span class="n">task</span><span class="o">.</span> <span class="n">The</span> <span class="n">manifest</span> <span class="n">of</span> <span class="n">the</span> <span class="n">bundle</s
 pan> <span class="n">is</span> <span class="n">described</span> <span class="n">in</span> <span class="n">the</span>  <span class="n">file</span><span class="o">.</span>
-
-<span class="n">h3</span><span class="o">.</span> <span class="n">The</span> <span class="n">spell</span><span class="o">.</span><span class="n">checker</span> <span class="n">project:</span> <span class="n">Requiring</span> <span class="n">an</span> <span class="n">OSGi</span> <span class="n">service</span>
+Total time: 1 second
+</pre></div>
 
-<span class="n">The</span> <span class="n">spell</span><span class="o">.</span><span class="n">checker</span> <span class="n">project</span> <span class="n">aims</span> <span class="n">to</span> <span class="n">provide</span> <span class="n">a</span> <span class="n">_spell</span> <span class="n">checker_</span> <span class="n">service</span><span class="o">.</span> <span class="n">However</span><span class="p">,</span> <span class="n">to</span> <span class="n">serve</span> <span class="n">this</span> <span class="n">service</span><span class="p">,</span> <span class="n">this</span> <span class="n">implementation</span> <span class="n">requires</span> <span class="n">a</span> <span class="n">_dictionary_</span> <span class="n">service</span><span class="o">.</span> <span class="n">During</span> <span class="n">this</span> <span class="n">step</span><span class="p">,</span> <span class="n">we</span> <span class="n">will</span> <span class="n">create</span> <span class="n">an</
 span> <span class="n">iPOJO</span> <span class="n">component</span> <span class="n">requiring</span> <span class="n">a</span> <span class="n">Dictionary</span> <span class="n">service</span> <span class="ow">and</span> <span class="n">providing</span> <span class="n">the</span> <span class="n">Spell</span> <span class="n">Checker</span> <span class="n">service</span><span class="o">.</span>
 
-<span class="n">First</span> <span class="n">create</span> <span class="n">the</span> <span class="n">file</span> <span class="s">&quot;src/spell/checker/SpellCheck.java&quot;</span> <span class="n">in</span> <span class="n">the</span> <span class="n">spell</span><span class="o">.</span><span class="n">checker</span> <span class="n">directory</span> <span class="k">for</span> <span class="n">the</span> <span class="n">following</span> <span class="n">_Check</span> <span class="n">Speller</span> <span class="n">service_</span> <span class="n">implementation:</span>
-<span class="p">{</span><span class="n">code:java</span><span class="p">}</span>
-<span class="nb">package</span> <span class="n">spell</span><span class="o">.</span><span class="n">checker</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">java</span><span class="o">.</span><span class="n">util</span><span class="o">.</span><span class="n">ArrayList</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">java</span><span class="o">.</span><span class="n">util</span><span class="o">.</span><span class="n">List</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">java</span><span class="o">.</span><span class="n">util</span><span class="o">.</span><span class="n">StringTokenizer</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">spell</span><span class="o">.</span><span class="n">services</span><span class="o">.</span><span class="n">DictionaryService</span><span class="p">;</span>
-<span class="nb">import</span> <span class="n">spell</span><span class="o">.</span><span class="n">services</span><span class="o">.</span><span class="n">SpellChecker</span><span class="p">;</span>
-<span class="n">public</span> <span class="n">class</span> <span class="n">SpellCheck</span> <span class="n">implements</span> <span class="n">SpellChecker</span> <span class="p">{</span>
-    <span class="n">private</span> <span class="n">DictionaryService</span> <span class="n">m_dictionary</span><span class="p">;</span>
-    <span class="o">/**</span>
-     <span class="o">*</span> <span class="n">Implements</span> <span class="n">SpellChecker</span><span class="o">.</span><span class="n">check</span><span class="p">()</span><span class="o">.</span> <span class="n">Checks</span> <span class="n">the</span> <span class="n">given</span> <span class="n">passage</span> <span class="k">for</span> <span class="n">misspelled</span> <span class="n">words</span><span class="o">.</span>
-     <span class="o">*</span> <span class="nv">@param</span> <span class="n">passage</span> <span class="n">the</span> <span class="n">passage</span> <span class="n">to</span> <span class="n">spell</span> <span class="n">check</span><span class="o">.</span>
-     <span class="o">*</span> <span class="nv">@return</span> <span class="n">An</span> <span class="n">array</span> <span class="n">of</span> <span class="n">misspelled</span> <span class="n">words</span> <span class="ow">or</span> <span class="n">null</span> <span class="k">if</span> <span class="nb">no</span> <span class="n">words</span> <span class="n">are</span> <span class="n">misspelled</span><span class="o">.</span>
-     <span class="o">*/</span>
-    <span class="n">public</span> <span class="n">String</span><span class="o">[]</span> <span class="n">check</span><span class="p">(</span><span class="n">String</span> <span class="n">passage</span><span class="p">)</span> <span class="p">{</span>
-        <span class="sr">//</span> <span class="n">No</span> <span class="n">misspelled</span> <span class="n">words</span> <span class="k">for</span> <span class="n">an</span> <span class="n">empty</span> <span class="n">string</span><span class="o">.</span>
-        <span class="k">if</span> <span class="p">((</span><span class="n">passage</span> <span class="o">==</span> <span class="n">null</span><span class="p">)</span> <span class="o">||</span> <span class="p">(</span><span class="n">passage</span><span class="o">.</span><span class="nb">length</span><span class="p">()</span> <span class="o">==</span> <span class="mi">0</span><span class="p">))</span> <span class="p">{</span> <span class="k">return</span> <span class="n">null</span><span class="p">;</span> <span class="p">}</span>
-        <span class="n">List</span> <span class="n">errorList</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="p">();</span>
-        <span class="sr">//</span> <span class="n">Tokenize</span> <span class="n">the</span> <span class="n">passage</span> <span class="n">using</span> <span class="n">spaces</span> <span class="ow">and</span> <span class="n">punctuation</span><span class="o">.</span>
-        <span class="n">StringTokenizer</span> <span class="n">st</span> <span class="o">=</span> <span class="k">new</span> <span class="n">StringTokenizer</span><span class="p">(</span><span class="n">passage</span><span class="p">,</span> <span class="s">&quot; ,.!?;:&quot;</span><span class="p">);</span>
-        <span class="sr">//</span> <span class="n">Loop</span> <span class="n">through</span> <span class="nb">each</span> <span class="n">word</span> <span class="n">in</span> <span class="n">the</span> <span class="n">passage</span><span class="o">.</span>
-        <span class="k">while</span> <span class="p">(</span><span class="n">st</span><span class="o">.</span><span class="n">hasMoreTokens</span><span class="p">())</span> <span class="p">{</span>
-            <span class="n">String</span> <span class="n">word</span> <span class="o">=</span> <span class="n">st</span><span class="o">.</span><span class="n">nextToken</span><span class="p">();</span>
-            <span class="sr">//</span> <span class="n">Check</span> <span class="n">the</span> <span class="n">current</span> <span class="n">word</span><span class="o">.</span>
-            <span class="k">if</span> <span class="p">(</span><span class="o">!</span> <span class="n">m_dictionary</span><span class="o">.</span><span class="n">checkWord</span><span class="p">(</span><span class="n">word</span><span class="p">))</span> <span class="p">{</span>
-                <span class="sr">//</span> <span class="n">If</span> <span class="n">the</span> <span class="n">word</span> <span class="n">is</span> <span class="ow">not</span> <span class="n">correct</span><span class="p">,</span> <span class="k">then</span> <span class="n">add</span> <span class="n">it</span>
-                <span class="sr">//</span> <span class="n">to</span> <span class="n">the</span> <span class="n">incorrect</span> <span class="n">word</span> <span class="n">list</span><span class="o">.</span>
-                <span class="n">errorList</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">word</span><span class="p">);</span>
-            <span class="p">}</span>
-        <span class="p">}</span>
-        <span class="sr">//</span> <span class="n">Return</span> <span class="n">null</span> <span class="k">if</span> <span class="nb">no</span> <span class="n">words</span> <span class="n">are</span> <span class="n">incorrect</span><span class="o">.</span>
-        <span class="k">if</span> <span class="p">(</span><span class="n">errorList</span><span class="o">.</span><span class="n">size</span><span class="p">()</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span> <span class="k">return</span> <span class="n">null</span><span class="p">;</span> <span class="p">}</span>
-        <span class="sr">//</span> <span class="n">Return</span> <span class="n">the</span> <span class="n">array</span> <span class="n">of</span> <span class="n">incorrect</span> <span class="n">words</span><span class="o">.</span>
-        <span class="k">return</span> <span class="p">(</span><span class="n">String</span><span class="o">[]</span><span class="p">)</span> <span class="n">errorList</span><span class="o">.</span><span class="n">toArray</span><span class="p">(</span><span class="k">new</span> <span class="n">String</span><span class="p">[</span><span class="n">errorList</span><span class="o">.</span><span class="n">size</span><span class="p">()]);</span>
-    <span class="p">}</span>
-<span class="p">}</span>
+<p>The created bundle is inside the output directory (spell.english.jar). The build process is based on BND and on the iPOJO Ant task. The manifest of the bundle is described in the <code>spell.english.bnd</code> file.</p>
+<h3 id="the-spellchecker-project-requiring-an-osgi-service">The spell.checker project: Requiring an OSGi service</h3>
+<p>The spell.checker project aims to provide a <em>spell checker</em> service. However, to serve this service, this implementation requires a <em>dictionary</em> service. During this step, we will create an iPOJO component requiring a Dictionary service and providing the Spell Checker service.</p>
+<p>First create the file <code>src/spell/checker/SpellCheck.java</code> in the spell.checker directory for the following <em>Check Speller service</em> implementation:</p>
+<div class="codehilite"><pre><span class="kn">package</span> <span class="n">spell</span><span class="o">.</span><span class="na">checker</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">java.util.ArrayList</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">java.util.StringTokenizer</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">spell.services.DictionaryService</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">spell.services.SpellChecker</span><span class="o">;</span>
+<span class="kd">public</span> <span class="kd">class</span> <span class="nc">SpellCheck</span> <span class="kd">implements</span> <span class="n">SpellChecker</span> <span class="o">{</span>
+    <span class="kd">private</span> <span class="n">DictionaryService</span> <span class="n">m_dictionary</span><span class="o">;</span>
+    <span class="cm">/**</span>
+<span class="cm">     * Implements SpellChecker.check(). Checks the given passage for misspelled words.</span>
+<span class="cm">     * @param passage the passage to spell check.</span>
+<span class="cm">     * @return An array of misspelled words or null if no words are misspelled.</span>
+<span class="cm">     */</span>
+    <span class="kd">public</span> <span class="n">String</span><span class="o">[]</span> <span class="nf">check</span><span class="o">(</span><span class="n">String</span> <span class="n">passage</span><span class="o">)</span> <span class="o">{</span>
+        <span class="c1">// No misspelled words for an empty string.</span>
+        <span class="k">if</span> <span class="o">((</span><span class="n">passage</span> <span class="o">==</span> <span class="kc">null</span><span class="o">)</span> <span class="o">||</span> <span class="o">(</span><span class="n">passage</span><span class="o">.</span><span class="na">length</span><span class="o">()</span> <span class="o">==</span> <span class="mi">0</span><span class="o">))</span> <span class="o">{</span> <span class="k">return</span> <span class="kc">null</span><span class="o">;</span> <span class="o">}</span>
+        <span class="n">List</span> <span class="n">errorList</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">();</span>
+        <span class="c1">// Tokenize the passage using spaces and punctuation.</span>
+        <span class="n">StringTokenizer</span> <span class="n">st</span> <span class="o">=</span> <span class="k">new</span> <span class="n">StringTokenizer</span><span class="o">(</span><span class="n">passage</span><span class="o">,</span> <span class="s">&quot; ,.!?;:&quot;</span><span class="o">);</span>
+        <span class="c1">// Loop through each word in the passage.</span>
+        <span class="k">while</span> <span class="o">(</span><span class="n">st</span><span class="o">.</span><span class="na">hasMoreTokens</span><span class="o">())</span> <span class="o">{</span>
+            <span class="n">String</span> <span class="n">word</span> <span class="o">=</span> <span class="n">st</span><span class="o">.</span><span class="na">nextToken</span><span class="o">();</span>
+            <span class="c1">// Check the current word.</span>
+            <span class="k">if</span> <span class="o">(!</span> <span class="n">m_dictionary</span><span class="o">.</span><span class="na">checkWord</span><span class="o">(</span><span class="n">word</span><span class="o">))</span> <span class="o">{</span>
+                <span class="c1">// If the word is not correct, then add it</span>
+                <span class="c1">// to the incorrect word list.</span>
+                <span class="n">errorList</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">word</span><span class="o">);</span>
+            <span class="o">}</span>
+        <span class="o">}</span>
+        <span class="c1">// Return null if no words are incorrect.</span>
+        <span class="k">if</span> <span class="o">(</span><span class="n">errorList</span><span class="o">.</span><span class="na">size</span><span class="o">()</span> <span class="o">==</span> <span class="mi">0</span><span class="o">)</span> <span class="o">{</span> <span class="k">return</span> <span class="kc">null</span><span class="o">;</span> <span class="o">}</span>
+        <span class="c1">// Return the array of incorrect words.</span>
+        <span class="k">return</span> <span class="o">(</span><span class="n">String</span><span class="o">[])</span> <span class="n">errorList</span><span class="o">.</span><span class="na">toArray</span><span class="o">(</span><span class="k">new</span> <span class="n">String</span><span class="o">[</span><span class="n">errorList</span><span class="o">.</span><span class="na">size</span><span class="o">()]);</span>
+    <span class="o">}</span>
+<span class="o">}</span>
 </pre></div>
 
 
-<p>This class implements the SpellChecker service interface as it will provide it. Moreover, it has a <em>special</em> field "<em>m</em>dictionary_". This field represents the required service. iPOJO will inject a Dictionary service when needed. So, the class can use it directly. Notice that this class as no OSGi specific code, both the service providing and the requiring are managed by iPOJO. If the used dictionary service leaves, iPOJO will try to find another provider. If no more providers are available, the instance is invalidated, and the provided service is withdrawn from the service registry.</p>
-<p>Once implemented, we need to describe this component. Create the "metadata.xml" file in the spell.checker directory for the following component descriptor:</p>
+<p>This class implements the SpellChecker service interface as it will provide it. Moreover, it has a <em>special</em> field <code>m_dictionary</code>. This field represents the required service. iPOJO will inject a Dictionary service when needed. So, the class can use it directly. Notice that this class as no OSGi specific code, both the service providing and the requiring are managed by iPOJO. If the used dictionary service leaves, iPOJO will try to find another provider. If no more providers are available, the instance is invalidated, and the provided service is withdrawn from the service registry.</p>
+<p>Once implemented, we need to describe this component. Create the <code>metadata.xml</code> file in the spell.checker directory for the following component descriptor:</p>
 <div class="codehilite"><pre><span class="nt">&lt;ipojo&gt;</span>
 <span class="nt">&lt;component</span> <span class="na">classname=</span><span class="s">&quot;spell.checker.SpellCheck&quot;</span><span class="nt">&gt;</span>
     <span class="nt">&lt;requires</span> <span class="na">field=</span><span class="s">&quot;m_dictionary&quot;</span><span class="nt">/&gt;</span>
@@ -380,182 +380,184 @@ Total time: 1 second</p>
 <p>Finally, we are able to build the bundle. As for previous projects, launch Ant from the project directory.</p>
 <h3 id="the-spellcheckergui-project">The spell.checker.gui project</h3>
 <p>The spell.check.gui project contains a very simple user interface (in Swing) allowing a user to interact with a <em>spell checker</em> service.</p>
-<p>Create the "src\spell\gui\SpellCheckerGui.java" for the following implementation:
-{code:java}
-package spell.gui;
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JTextField;
-import spell.services.SpellChecker;
-/<strong>
- * A very simple Gui interacting with the CheckSpeller service
- */
-public class SpellCheckerGui extends JFrame {
-    /</strong>
-     * Swing component where the user write the passage to check.
-     */
-    private JTextField m_passage = null;</p>
-<div class="codehilite"><pre><span class="o">/**</span>
- <span class="o">*</span> <span class="n">Check</span> <span class="n">button</span>
- <span class="o">*/</span>
-<span class="n">private</span> <span class="n">JButton</span> <span class="n">m_checkButton</span> <span class="o">=</span> <span class="n">null</span><span class="p">;</span>
-
-<span class="o">/**</span>
- <span class="o">*</span> <span class="n">Area</span> <span class="n">where</span> <span class="n">the</span> <span class="n">result</span> <span class="n">is</span> <span class="n">displayed</span><span class="o">.</span>
- <span class="o">*/</span>
-<span class="n">private</span> <span class="n">JLabel</span> <span class="n">m_result</span> <span class="o">=</span> <span class="n">null</span><span class="p">;</span>
-<span class="o">/**</span>
- <span class="o">*</span> <span class="n">Service</span> <span class="n">dependency</span> <span class="n">on</span> <span class="n">the</span> <span class="n">SpellChecker</span><span class="o">.</span>
- <span class="o">*/</span>
-<span class="n">private</span> <span class="n">SpellChecker</span> <span class="n">m_checker</span><span class="p">;</span>
-
-<span class="o">/**</span>
- <span class="o">*</span> <span class="n">Constructor</span><span class="o">.</span>
- <span class="o">*</span> <span class="n">Initialize</span> <span class="n">the</span> <span class="n">GUI</span><span class="o">.</span>
- <span class="o">*/</span>
-<span class="n">public</span> <span class="n">SpellCheckerGui</span><span class="p">()</span> <span class="p">{</span>
-    <span class="n">super</span><span class="p">();</span>
-    <span class="n">initComponents</span><span class="p">();</span>
-    <span class="n">this</span><span class="o">.</span><span class="n">setTitle</span><span class="p">(</span><span class="s">&quot;Spellchecker Gui&quot;</span><span class="p">);</span>
-<span class="p">}</span>
-<span class="o">/**</span>
- <span class="o">*</span> <span class="n">Initialize</span> <span class="n">the</span> <span class="n">Swing</span> <span class="n">Gui</span><span class="o">.</span>
- <span class="o">*/</span>
-<span class="n">private</span> <span class="n">void</span> <span class="n">initComponents</span><span class="p">()</span> <span class="p">{</span>
-    <span class="n">java</span><span class="o">.</span><span class="n">awt</span><span class="o">.</span><span class="n">GridBagConstraints</span> <span class="n">gridBagConstraints</span><span class="p">;</span>
-    <span class="n">m_checkButton</span> <span class="o">=</span> <span class="k">new</span> <span class="n">javax</span><span class="o">.</span><span class="n">swing</span><span class="o">.</span><span class="n">JButton</span><span class="p">();</span>
-    <span class="n">m_result</span> <span class="o">=</span> <span class="k">new</span> <span class="n">javax</span><span class="o">.</span><span class="n">swing</span><span class="o">.</span><span class="n">JLabel</span><span class="p">();</span>
-    <span class="n">m_passage</span> <span class="o">=</span> <span class="k">new</span> <span class="n">javax</span><span class="o">.</span><span class="n">swing</span><span class="o">.</span><span class="n">JTextField</span><span class="p">();</span>
-    <span class="n">setDefaultCloseOperation</span><span class="p">(</span><span class="n">javax</span><span class="o">.</span><span class="n">swing</span><span class="o">.</span><span class="n">WindowConstants</span><span class="o">.</span><span class="n">EXIT</span><span class="o">*</span><span class="n">ON</span><span class="o">*</span><span class="n">CLOSE</span><span class="p">);</span> <span class="sr">//</span><span class="n">Stop</span> <span class="n">Felix</span>
-    <span class="n">getContentPane</span><span class="p">()</span><span class="o">.</span><span class="n">setLayout</span><span class="p">(</span><span class="k">new</span> <span class="n">java</span><span class="o">.</span><span class="n">awt</span><span class="o">.</span><span class="n">GridBagLayout</span><span class="p">());</span>
-    <span class="n">m_checkButton</span><span class="o">.</span><span class="n">setText</span><span class="p">(</span><span class="s">&quot;Check&quot;</span><span class="p">);</span>
-    <span class="n">m_checkButton</span><span class="o">.</span><span class="n">addActionListener</span><span class="p">(</span><span class="k">new</span> <span class="n">java</span><span class="o">.</span><span class="n">awt</span><span class="o">.</span><span class="n">event</span><span class="o">.</span><span class="n">ActionListener</span><span class="p">()</span> <span class="p">{</span>
-        <span class="n">public</span> <span class="n">void</span> <span class="n">actionPerformed</span><span class="p">(</span><span class="n">java</span><span class="o">.</span><span class="n">awt</span><span class="o">.</span><span class="n">event</span><span class="o">.</span><span class="n">ActionEvent</span> <span class="n">e</span><span class="p">)</span> <span class="p">{</span>
-            <span class="n">check</span><span class="p">();</span>
-        <span class="p">}</span>
-    <span class="p">});</span>
-    <span class="n">gridBagConstraints</span> <span class="o">=</span> <span class="k">new</span> <span class="n">java</span><span class="o">.</span><span class="n">awt</span><span class="o">.</span><span class="n">GridBagConstraints</span><span class="p">();</span>
-    <span class="n">gridBagConstraints</span><span class="o">.</span><span class="n">gridx</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
-    <span class="n">gridBagConstraints</span><span class="o">.</span><span class="n">gridy</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
-    <span class="n">gridBagConstraints</span><span class="o">.</span><span class="n">insets</span> <span class="o">=</span> <span class="k">new</span> <span class="n">java</span><span class="o">.</span><span class="n">awt</span><span class="o">.</span><span class="n">Insets</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span>
-    <span class="n">getContentPane</span><span class="p">()</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">m_checkButton</span><span class="p">,</span> <span class="n">gridBagConstraints</span><span class="p">);</span>
-    <span class="n">m_result</span><span class="o">.</span><span class="n">setPreferredSize</span><span class="p">(</span><span class="k">new</span> <span class="n">java</span><span class="o">.</span><span class="n">awt</span><span class="o">.</span><span class="n">Dimension</span><span class="p">(</span><span class="mi">175</span><span class="p">,</span> <span class="mi">20</span><span class="p">));</span>
-    <span class="n">gridBagConstraints</span> <span class="o">=</span> <span class="k">new</span> <span class="n">java</span><span class="o">.</span><span class="n">awt</span><span class="o">.</span><span class="n">GridBagConstraints</span><span class="p">();</span>
-    <span class="n">gridBagConstraints</span><span class="o">.</span><span class="n">gridx</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
-    <span class="n">gridBagConstraints</span><span class="o">.</span><span class="n">gridy</span> <span class="o">=</span> <span class="mi">2</span><span class="p">;</span>
-    <span class="n">gridBagConstraints</span><span class="o">.</span><span class="n">fill</span> <span class="o">=</span> <span class="n">java</span><span class="o">.</span><span class="n">awt</span><span class="o">.</span><span class="n">GridBagConstraints</span><span class="o">.</span><span class="n">HORIZONTAL</span><span class="p">;</span>
-    <span class="n">gridBagConstraints</span><span class="o">.</span><span class="n">insets</span> <span class="o">=</span> <span class="k">new</span> <span class="n">java</span><span class="o">.</span><span class="n">awt</span><span class="o">.</span><span class="n">Insets</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span>
-    <span class="n">getContentPane</span><span class="p">()</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">m_result</span><span class="p">,</span> <span class="n">gridBagConstraints</span><span class="p">);</span>
-    <span class="n">m_passage</span><span class="o">.</span><span class="n">setPreferredSize</span><span class="p">(</span><span class="k">new</span> <span class="n">java</span><span class="o">.</span><span class="n">awt</span><span class="o">.</span><span class="n">Dimension</span><span class="p">(</span><span class="mi">175</span><span class="p">,</span> <span class="mi">20</span><span class="p">));</span>
-    <span class="n">gridBagConstraints</span> <span class="o">=</span> <span class="k">new</span> <span class="n">java</span><span class="o">.</span><span class="n">awt</span><span class="o">.</span><span class="n">GridBagConstraints</span><span class="p">();</span>
-    <span class="n">gridBagConstraints</span><span class="o">.</span><span class="n">gridx</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
-    <span class="n">gridBagConstraints</span><span class="o">.</span><span class="n">gridy</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
-    <span class="n">gridBagConstraints</span><span class="o">.</span><span class="n">fill</span> <span class="o">=</span> <span class="n">java</span><span class="o">.</span><span class="n">awt</span><span class="o">.</span><span class="n">GridBagConstraints</span><span class="o">.</span><span class="n">HORIZONTAL</span><span class="p">;</span>
-    <span class="n">gridBagConstraints</span><span class="o">.</span><span class="n">insets</span> <span class="o">=</span> <span class="k">new</span> <span class="n">java</span><span class="o">.</span><span class="n">awt</span><span class="o">.</span><span class="n">Insets</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span>
-    <span class="n">getContentPane</span><span class="p">()</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">m_passage</span><span class="p">,</span> <span class="n">gridBagConstraints</span><span class="p">);</span>
-    <span class="nb">pack</span><span class="p">();</span>
-<span class="p">}</span>
-<span class="o">/**</span>
- <span class="o">*</span> <span class="n">Check</span> <span class="n">Button</span> <span class="n">action</span><span class="o">.</span>
- <span class="o">*</span> <span class="n">Collects</span> <span class="n">the</span> <span class="n">user</span> <span class="n">input</span> <span class="ow">and</span> <span class="n">checks</span> <span class="n">it</span><span class="o">.</span>
- <span class="o">*/</span>
-<span class="n">private</span> <span class="n">void</span> <span class="n">check</span><span class="p">()</span> <span class="p">{</span>
-    <span class="n">String</span><span class="o">[]</span><span class="p">()</span> <span class="n">result</span> <span class="o">=</span> <span class="n">m</span><span class="o">*</span><span class="n">checker</span><span class="o">.</span><span class="n">check</span><span class="p">(</span><span class="n">m</span><span class="o">*</span><span class="n">passage</span><span class="o">.</span><span class="n">getText</span><span class="p">());</span>
-    <span class="k">if</span> <span class="p">(</span><span class="n">result</span> <span class="o">!=</span> <span class="n">null</span><span class="p">)</span> <span class="p">{</span>
-        <span class="n">m_result</span><span class="o">.</span><span class="n">setText</span><span class="p">(</span><span class="n">result</span><span class="o">.</span><span class="nb">length</span> <span class="o">+</span> <span class="s">&quot; word(s) are mispelled&quot;</span><span class="p">);</span>
-    <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
-        <span class="n">m_result</span><span class="o">.</span><span class="n">setText</span><span class="p">(</span><span class="s">&quot;All words are correct&quot;</span><span class="p">);</span>
-    <span class="p">}</span>
-<span class="p">}</span>
-<span class="o">/**</span>
- <span class="o">*</span> <span class="n">Start</span> <span class="n">callback</span><span class="o">.</span>
- <span class="o">*</span> <span class="n">This</span> <span class="n">method</span> <span class="n">will</span> <span class="n">be</span> <span class="n">called</span> <span class="n">when</span> <span class="n">the</span> <span class="n">instance</span> <span class="n">becomes</span> <span class="n">valid</span><span class="o">.</span>
- <span class="o">*</span> <span class="n">It</span> <span class="n">set</span> <span class="n">the</span> <span class="n">Gui</span> <span class="n">visibility</span> <span class="n">to</span> <span class="n">true</span><span class="o">.</span>
- <span class="o">*/</span>
-<span class="n">public</span> <span class="n">void</span> <span class="n">start</span><span class="p">()</span> <span class="p">{</span>
-    <span class="n">this</span><span class="o">.</span><span class="n">setVisible</span><span class="p">(</span><span class="n">true</span><span class="p">);</span>
-<span class="p">}</span>
-<span class="o">/**</span>
- <span class="o">*</span> <span class="n">Stop</span> <span class="n">callback</span><span class="o">.</span>
- <span class="o">*</span>  <span class="n">This</span> <span class="n">method</span> <span class="n">will</span> <span class="n">be</span> <span class="n">called</span> <span class="n">when</span> <span class="n">the</span> <span class="n">instance</span> <span class="n">becomes</span> <span class="n">invalid</span> <span class="ow">or</span> <span class="n">stops</span><span class="o">.</span>
- <span class="o">*</span>  <span class="n">It</span> <span class="n">deletes</span> <span class="n">the</span> <span class="n">Gui</span><span class="o">.</span>
- <span class="o">*/</span>
-<span class="n">public</span> <span class="n">void</span> <span class="n">stop</span><span class="p">()</span> <span class="p">{</span>
-    <span class="n">this</span><span class="o">.</span><span class="n">dispose</span><span class="p">();</span>
-<span class="p">}</span>
-</pre></div>
-
-
-<p>}</p>
-<div class="codehilite"><pre><span class="n">Look</span> <span class="n">at</span> <span class="n">the</span> <span class="n">three</span> <span class="k">last</span> <span class="n">methods</span><span class="o">.</span> <span class="n">The</span> <span class="n">_check_</span> <span class="n">methods</span> <span class="n">collect</span> <span class="n">the</span> <span class="n">user</span> <span class="n">input</span> <span class="ow">and</span> <span class="k">use</span> <span class="n">a</span> <span class="n">_Check</span> <span class="n">speller_</span> <span class="n">service</span> <span class="n">to</span> <span class="n">check</span> <span class="n">this</span> <span class="n">input</span><span class="o">.</span> <span class="n">This</span> <span class="n">method</span> <span class="n">is</span> <span class="n">called</span> <span class="n">when</span> <span class="n">the</span> <span class="n">button</span> <span class="n">is</span> <span class="n">pressed</span
 > <span class="n">by</span> <span class="n">the</span> <span class="n">user</span><span class="o">.</span> <span class="n">The</span> <span class="n">_start_</span> <span class="ow">and</span> <span class="n">_stop_</span> <span class="n">methods</span> <span class="n">are</span> <span class="n">lifecycle</span> <span class="n">callbacks</span><span class="o">.</span> <span class="n">As</span> <span class="n">we</span> <span class="n">need</span> <span class="n">to</span> <span class="n">display</span> <span class="n">the</span> <span class="n">user</span> <span class="n">interface</span> <span class="n">when</span> <span class="n">the</span> <span class="n">instance</span> <span class="n">is</span> <span class="n">created</span> <span class="ow">and</span> <span class="n">to</span> <span class="nb">delete</span> <span class="n">it</span> <span class="n">when</span> <span class="n">the</span> <span class="n">instance</span> <span class="n">stops</span><span class="p">,</span
 > <span class="n">we</span> <span class="n">need</span> <span class="n">a</span> <span class="n">way</span> <span class="n">to</span> <span class="n">be</span> <span class="n">notified</span> <span class="n">when</span> <span class="n">we</span> <span class="n">need</span> <span class="n">to</span> <span class="n">execute</span> <span class="n">these</span> <span class="n">actions</span><span class="o">.</span> <span class="n">iPOJO</span> <span class="n">provide</span> <span class="n">an</span> <span class="n">easy</span> <span class="n">way</span> <span class="n">to</span> <span class="k">do</span> <span class="n">this</span><span class="o">.</span> <span class="n">The</span> <span class="n">component</span> <span class="n">provides</span> <span class="n">two</span> <span class="n">callback</span> <span class="n">methods</span> <span class="k">for</span> <span class="n">its</span> <span class="n">activation</span> <span class="ow">and</span> <span class="n">deactivation</s
 pan><span class="p">,</span> <span class="n">start</span> <span class="ow">and</span> <span class="n">stop</span><span class="p">,</span> <span class="n">respectively</span><span class="o">.</span> <span class="n">Callbacks</span> <span class="n">are</span> <span class="n">used</span> <span class="n">when</span> <span class="n">the</span> <span class="n">component</span> <span class="n">needs</span> <span class="n">to</span> <span class="n">be</span> <span class="n">informed</span> <span class="n">about</span> <span class="n">a</span> <span class="n">component</span> <span class="n">state</span> <span class="n">change</span><span class="o">.</span> <span class="n">In</span> <span class="n">iPOJO</span><span class="p">,</span> <span class="n">the</span> <span class="n">component</span> <span class="n">state</span> <span class="n">is</span> <span class="n">either</span> <span class="o">*</span><span class="n">INVALID</span><span class="o">*</span> <span class="p">(</span><span
  class="n">i</span><span class="o">.</span><span class="n">e</span><span class="o">.</span><span class="p">,</span> <span class="ow">not</span> <span class="n">all</span> <span class="n">of</span> <span class="n">the</span> <span class="n">component</span><span class="s">&#39;s constraints are satisfied) or *VALID* (i.e., all of the component&#39;</span><span class="n">s</span> <span class="n">constraints</span> <span class="n">are</span> <span class="n">satisfied</span><span class="p">)</span><span class="o">.</span> <span class="n">In</span> <span class="n">this</span> <span class="n">example</span><span class="p">,</span> <span class="n">the</span> <span class="n">start</span> <span class="n">callback</span> <span class="n">method</span> <span class="n">set</span> <span class="n">the</span> <span class="n">GUI</span> <span class="n">visibility</span> <span class="n">to</span> <span class="n">true</span><span class="p">;</span> <span class="n">the</span> <span class="n">st
 op</span> <span class="n">callback</span> <span class="n">method</span> <span class="n">deletes</span> <span class="n">the</span> <span class="n">GUI</span><span class="o">.</span> <span class="n">The</span> <span class="n">component</span> <span class="n">metadata</span> <span class="n">will</span> <span class="n">instruct</span> <span class="n">iPOJO</span> <span class="n">to</span> <span class="n">invoke</span> <span class="n">these</span> <span class="n">methods</span> <span class="n">when</span> <span class="n">the</span> <span class="n">component</span><span class="err">&#39;</span><span class="n">s</span> <span class="n">state</span> <span class="n">changes</span> <span class="n">to</span> <span class="o">*</span><span class="n">VALID</span><span class="o">*</span> <span class="ow">or</span> <span class="o">*</span><span class="n">INVALID</span><span class="o">*</span> <span class="n">respectively</span><span class="o">.</span>
-
-<span class="n">Create</span> <span class="n">the</span> <span class="n">_metadata</span><span class="o">.</span><span class="n">xml_</span> <span class="n">file</span> <span class="n">in</span> <span class="n">the</span> <span class="n">spell</span><span class="o">.</span><span class="n">chercker</span><span class="o">.</span><span class="n">gui</span> <span class="n">directory</span> <span class="n">with</span> <span class="n">the</span> <span class="n">following</span> <span class="n">content:</span>
-<span class="p">{</span><span class="n">code:xml</span><span class="p">}</span>
-<span class="sr">&lt;ipojo&gt;</span>
-<span class="o">&lt;</span><span class="n">component</span> <span class="n">classname</span><span class="o">=</span><span class="s">&quot;spell.gui.SpellCheckerGui&quot;</span><span class="o">&gt;</span>
-    <span class="o">&lt;</span><span class="n">requires</span> <span class="n">field</span><span class="o">=</span><span class="s">&quot;m_checker&quot;</span><span class="o">/&gt;</span>
-    <span class="o">&lt;</span><span class="n">callback</span> <span class="n">transition</span><span class="o">=</span><span class="s">&quot;validate&quot;</span> <span class="n">method</span><span class="o">=</span><span class="s">&quot;start&quot;</span><span class="o">/&gt;</span>
-    <span class="o">&lt;</span><span class="n">callback</span> <span class="n">transition</span><span class="o">=</span><span class="s">&quot;invalidate&quot;</span> <span class="n">method</span><span class="o">=</span><span class="s">&quot;stop&quot;</span><span class="o">/&gt;</span>
-<span class="sr">&lt;/component&gt;</span>
-<span class="o">&lt;</span><span class="n">instance</span> <span class="n">component</span><span class="o">=</span><span class="s">&quot;spell.gui.SpellCheckerGui&quot;</span><span class="o">/&gt;</span>
-<span class="sr">&lt;/ipojo&gt;</span>
+<p>Create the <code>src\spell\gui\SpellCheckerGui.java</code> for the following implementation:</p>
+<div class="codehilite"><pre><span class="kn">package</span> <span class="n">spell</span><span class="o">.</span><span class="na">gui</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">javax.swing.JButton</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">javax.swing.JFrame</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">javax.swing.JLabel</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">javax.swing.JTextField</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">spell.services.SpellChecker</span><span class="o">;</span>
+<span class="cm">/**</span>
+<span class="cm"> * A very simple Gui interacting with the CheckSpeller service</span>
+<span class="cm"> */</span>
+<span class="kd">public</span> <span class="kd">class</span> <span class="nc">SpellCheckerGui</span> <span class="kd">extends</span> <span class="n">JFrame</span> <span class="o">{</span>
+    <span class="cm">/**</span>
+<span class="cm">     * Swing component where the user write the passage to check.</span>
+<span class="cm">     */</span>
+    <span class="kd">private</span> <span class="n">JTextField</span> <span class="n">m_passage</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
+
+    <span class="cm">/**</span>
+<span class="cm">     * Check button</span>
+<span class="cm">     */</span>
+    <span class="kd">private</span> <span class="n">JButton</span> <span class="n">m_checkButton</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
+
+    <span class="cm">/**</span>
+<span class="cm">     * Area where the result is displayed.</span>
+<span class="cm">     */</span>
+    <span class="kd">private</span> <span class="n">JLabel</span> <span class="n">m_result</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
+    <span class="cm">/**</span>
+<span class="cm">     * Service dependency on the SpellChecker.</span>
+<span class="cm">     */</span>
+    <span class="kd">private</span> <span class="n">SpellChecker</span> <span class="n">m_checker</span><span class="o">;</span>
+
+    <span class="cm">/**</span>
+<span class="cm">     * Constructor.</span>
+<span class="cm">     * Initialize the GUI.</span>
+<span class="cm">     */</span>
+    <span class="kd">public</span> <span class="nf">SpellCheckerGui</span><span class="o">()</span> <span class="o">{</span>
+        <span class="kd">super</span><span class="o">();</span>
+        <span class="n">initComponents</span><span class="o">();</span>
+        <span class="k">this</span><span class="o">.</span><span class="na">setTitle</span><span class="o">(</span><span class="s">&quot;Spellchecker Gui&quot;</span><span class="o">);</span>
+    <span class="o">}</span>
+    <span class="cm">/**</span>
+<span class="cm">     * Initialize the Swing Gui.</span>
+<span class="cm">     */</span>
+    <span class="kd">private</span> <span class="kt">void</span> <span class="nf">initComponents</span><span class="o">()</span> <span class="o">{</span>
+        <span class="n">java</span><span class="o">.</span><span class="na">awt</span><span class="o">.</span><span class="na">GridBagConstraints</span> <span class="n">gridBagConstraints</span><span class="o">;</span>
+        <span class="n">m_checkButton</span> <span class="o">=</span> <span class="k">new</span> <span class="n">javax</span><span class="o">.</span><span class="na">swing</span><span class="o">.</span><span class="na">JButton</span><span class="o">();</span>
+        <span class="n">m_result</span> <span class="o">=</span> <span class="k">new</span> <span class="n">javax</span><span class="o">.</span><span class="na">swing</span><span class="o">.</span><span class="na">JLabel</span><span class="o">();</span>
+        <span class="n">m_passage</span> <span class="o">=</span> <span class="k">new</span> <span class="n">javax</span><span class="o">.</span><span class="na">swing</span><span class="o">.</span><span class="na">JTextField</span><span class="o">();</span>
+        <span class="n">setDefaultCloseOperation</span><span class="o">(</span><span class="n">javax</span><span class="o">.</span><span class="na">swing</span><span class="o">.</span><span class="na">WindowConstants</span><span class="o">.</span><span class="na">EXIT</span><span class="o">*</span><span class="n">ON</span><span class="o">*</span><span class="n">CLOSE</span><span class="o">);</span> <span class="c1">//Stop Felix</span>
+        <span class="n">getContentPane</span><span class="o">().</span><span class="na">setLayout</span><span class="o">(</span><span class="k">new</span> <span class="n">java</span><span class="o">.</span><span class="na">awt</span><span class="o">.</span><span class="na">GridBagLayout</span><span class="o">());</span>
+        <span class="n">m_checkButton</span><span class="o">.</span><span class="na">setText</span><span class="o">(</span><span class="s">&quot;Check&quot;</span><span class="o">);</span>
+        <span class="n">m_checkButton</span><span class="o">.</span><span class="na">addActionListener</span><span class="o">(</span><span class="k">new</span> <span class="n">java</span><span class="o">.</span><span class="na">awt</span><span class="o">.</span><span class="na">event</span><span class="o">.</span><span class="na">ActionListener</span><span class="o">()</span> <span class="o">{</span>
+            <span class="kd">public</span> <span class="kt">void</span> <span class="nf">actionPerformed</span><span class="o">(</span><span class="n">java</span><span class="o">.</span><span class="na">awt</span><span class="o">.</span><span class="na">event</span><span class="o">.</span><span class="na">ActionEvent</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span>
+                <span class="n">check</span><span class="o">();</span>
+            <span class="o">}</span>
+        <span class="o">});</span>
+        <span class="n">gridBagConstraints</span> <span class="o">=</span> <span class="k">new</span> <span class="n">java</span><span class="o">.</span><span class="na">awt</span><span class="o">.</span><span class="na">GridBagConstraints</span><span class="o">();</span>
+        <span class="n">gridBagConstraints</span><span class="o">.</span><span class="na">gridx</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span>
+        <span class="n">gridBagConstraints</span><span class="o">.</span><span class="na">gridy</span> <span class="o">=</span> <span class="mi">1</span><span class="o">;</span>
+        <span class="n">gridBagConstraints</span><span class="o">.</span><span class="na">insets</span> <span class="o">=</span> <span class="k">new</span> <span class="n">java</span><span class="o">.</span><span class="na">awt</span><span class="o">.</span><span class="na">Insets</span><span class="o">(</span><span class="mi">2</span><span class="o">,</span> <span class="mi">2</span><span class="o">,</span> <span class="mi">2</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span>
+        <span class="n">getContentPane</span><span class="o">().</span><span class="na">add</span><span class="o">(</span><span class="n">m_checkButton</span><span class="o">,</span> <span class="n">gridBagConstraints</span><span class="o">);</span>
+        <span class="n">m_result</span><span class="o">.</span><span class="na">setPreferredSize</span><span class="o">(</span><span class="k">new</span> <span class="n">java</span><span class="o">.</span><span class="na">awt</span><span class="o">.</span><span class="na">Dimension</span><span class="o">(</span><span class="mi">175</span><span class="o">,</span> <span class="mi">20</span><span class="o">));</span>
+        <span class="n">gridBagConstraints</span> <span class="o">=</span> <span class="k">new</span> <span class="n">java</span><span class="o">.</span><span class="na">awt</span><span class="o">.</span><span class="na">GridBagConstraints</span><span class="o">();</span>
+        <span class="n">gridBagConstraints</span><span class="o">.</span><span class="na">gridx</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span>
+        <span class="n">gridBagConstraints</span><span class="o">.</span><span class="na">gridy</span> <span class="o">=</span> <span class="mi">2</span><span class="o">;</span>
+        <span class="n">gridBagConstraints</span><span class="o">.</span><span class="na">fill</span> <span class="o">=</span> <span class="n">java</span><span class="o">.</span><span class="na">awt</span><span class="o">.</span><span class="na">GridBagConstraints</span><span class="o">.</span><span class="na">HORIZONTAL</span><span class="o">;</span>
+        <span class="n">gridBagConstraints</span><span class="o">.</span><span class="na">insets</span> <span class="o">=</span> <span class="k">new</span> <span class="n">java</span><span class="o">.</span><span class="na">awt</span><span class="o">.</span><span class="na">Insets</span><span class="o">(</span><span class="mi">2</span><span class="o">,</span> <span class="mi">2</span><span class="o">,</span> <span class="mi">2</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span>
+        <span class="n">getContentPane</span><span class="o">().</span><span class="na">add</span><span class="o">(</span><span class="n">m_result</span><span class="o">,</span> <span class="n">gridBagConstraints</span><span class="o">);</span>
+        <span class="n">m_passage</span><span class="o">.</span><span class="na">setPreferredSize</span><span class="o">(</span><span class="k">new</span> <span class="n">java</span><span class="o">.</span><span class="na">awt</span><span class="o">.</span><span class="na">Dimension</span><span class="o">(</span><span class="mi">175</span><span class="o">,</span> <span class="mi">20</span><span class="o">));</span>
+        <span class="n">gridBagConstraints</span> <span class="o">=</span> <span class="k">new</span> <span class="n">java</span><span class="o">.</span><span class="na">awt</span><span class="o">.</span><span class="na">GridBagConstraints</span><span class="o">();</span>
+        <span class="n">gridBagConstraints</span><span class="o">.</span><span class="na">gridx</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span>
+        <span class="n">gridBagConstraints</span><span class="o">.</span><span class="na">gridy</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span>
+        <span class="n">gridBagConstraints</span><span class="o">.</span><span class="na">fill</span> <span class="o">=</span> <span class="n">java</span><span class="o">.</span><span class="na">awt</span><span class="o">.</span><span class="na">GridBagConstraints</span><span class="o">.</span><span class="na">HORIZONTAL</span><span class="o">;</span>
+        <span class="n">gridBagConstraints</span><span class="o">.</span><span class="na">insets</span> <span class="o">=</span> <span class="k">new</span> <span class="n">java</span><span class="o">.</span><span class="na">awt</span><span class="o">.</span><span class="na">Insets</span><span class="o">(</span><span class="mi">2</span><span class="o">,</span> <span class="mi">2</span><span class="o">,</span> <span class="mi">2</span><span class="o">,</span> <span class="mi">2</span><span class="o">);</span>
+        <span class="n">getContentPane</span><span class="o">().</span><span class="na">add</span><span class="o">(</span><span class="n">m_passage</span><span class="o">,</span> <span class="n">gridBagConstraints</span><span class="o">);</span>
+        <span class="n">pack</span><span class="o">();</span>
+    <span class="o">}</span>
+    <span class="cm">/**</span>
+<span class="cm">     * Check Button action.</span>
+<span class="cm">     * Collects the user input and checks it.</span>
+<span class="cm">     */</span>
+    <span class="kd">private</span> <span class="kt">void</span> <span class="nf">check</span><span class="o">()</span> <span class="o">{</span>
+        <span class="n">String</span><span class="o">[]()</span> <span class="n">result</span> <span class="o">=</span> <span class="n">m</span><span class="o">*</span><span class="n">checker</span><span class="o">.</span><span class="na">check</span><span class="o">(</span><span class="n">m</span><span class="o">*</span><span class="n">passage</span><span class="o">.</span><span class="na">getText</span><span class="o">());</span>
+        <span class="k">if</span> <span class="o">(</span><span class="n">result</span> <span class="o">!=</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span>
+            <span class="n">m_result</span><span class="o">.</span><span class="na">setText</span><span class="o">(</span><span class="n">result</span><span class="o">.</span><span class="na">length</span> <span class="o">+</span> <span class="s">&quot; word(s) are mispelled&quot;</span><span class="o">);</span>
+        <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
+            <span class="n">m_result</span><span class="o">.</span><span class="na">setText</span><span class="o">(</span><span class="s">&quot;All words are correct&quot;</span><span class="o">);</span>
+        <span class="o">}</span>
+    <span class="o">}</span>
+    <span class="cm">/**</span>
+<span class="cm">     * Start callback.</span>
+<span class="cm">     * This method will be called when the instance becomes valid.</span>
+<span class="cm">     * It set the Gui visibility to true.</span>
+<span class="cm">     */</span>
+    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">start</span><span class="o">()</span> <span class="o">{</span>
+        <span class="k">this</span><span class="o">.</span><span class="na">setVisible</span><span class="o">(</span><span class="kc">true</span><span class="o">);</span>
+    <span class="o">}</span>
+    <span class="cm">/**</span>
+<span class="cm">     * Stop callback.</span>
+<span class="cm">     *  This method will be called when the instance becomes invalid or stops.</span>
+<span class="cm">     *  It deletes the Gui.</span>
+<span class="cm">     */</span>
+    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">stop</span><span class="o">()</span> <span class="o">{</span>
+        <span class="k">this</span><span class="o">.</span><span class="na">dispose</span><span class="o">();</span>
+    <span class="o">}</span>
+<span class="o">}</span>
+</pre></div>
+
+

[... 124 lines stripped ...]


Mime
View raw message