felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clem...@apache.org
Subject svn commit: r1498068 - in /felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo: apache-felix-ipojo-devguide/ apache-felix-ipojo-gettingstarted/
Date Sun, 30 Jun 2013 07:35:47 GMT
Author: clement
Date: Sun Jun 30 07:35:47 2013
New Revision: 1498068

URL: http://svn.apache.org/r1498068
Log:
update tutorials

Added:
    felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-gettingstarted/ipojo-10-min-tutorial.zip
  (with props)
    felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-gettingstarted/maven-tutorial.zip
  (with props)
Modified:
    felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-devguide/ipojo-handler-tutorial-project.zip
    felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-gettingstarted/ipojo-hello-word-maven-based-tutorial.mdtext
    felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-gettingstarted/ipojo-in-10-minutes.mdtext

Modified: felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-devguide/ipojo-handler-tutorial-project.zip
URL: http://svn.apache.org/viewvc/felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-devguide/ipojo-handler-tutorial-project.zip?rev=1498068&r1=1498067&r2=1498068&view=diff
==============================================================================
Binary files - no diff available.

Added: felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-gettingstarted/ipojo-10-min-tutorial.zip
URL: http://svn.apache.org/viewvc/felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-gettingstarted/ipojo-10-min-tutorial.zip?rev=1498068&view=auto
==============================================================================
Binary file - no diff available.

Propchange: felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-gettingstarted/ipojo-10-min-tutorial.zip
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-gettingstarted/ipojo-hello-word-maven-based-tutorial.mdtext
URL: http://svn.apache.org/viewvc/felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-gettingstarted/ipojo-hello-word-maven-based-tutorial.mdtext?rev=1498068&r1=1498067&r2=1498068&view=diff
==============================================================================
--- felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-gettingstarted/ipojo-hello-word-maven-based-tutorial.mdtext
(original)
+++ felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-gettingstarted/ipojo-hello-word-maven-based-tutorial.mdtext
Sun Jun 30 07:35:47 2013
@@ -25,7 +25,7 @@ The component is the central concept in 
 
 The following is a simple example illustrating how to use the core iPOJO concepts. The example
is comprised of two components, one providing a *Hello* service and one requiring any number
of *Hello* services. The components are packaged into three different bundles using Maven.
The *hello.service* bundle contains the service interface. The *hello.impl* bundle contains
a component implementing the service. The *hello.client* bundle contains the consumer component.
 
-Download the tutorial archive [here](http://people.apache.org/~clement/ipojo/tutorials/maven/tutorial.zip).
This archive contains a version of Felix (configured with iPOJO), and the projects explained
below.
+Download the tutorial archive [here](maven-tutorial.zip). This archive contains a version
of Felix (configured with iPOJO), and the projects explained below.
 
 ### Preparing Maven & Installing the tutorial
 

Modified: felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-gettingstarted/ipojo-in-10-minutes.mdtext
URL: http://svn.apache.org/viewvc/felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-gettingstarted/ipojo-in-10-minutes.mdtext?rev=1498068&r1=1498067&r2=1498068&view=diff
==============================================================================
--- felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-gettingstarted/ipojo-in-10-minutes.mdtext
(original)
+++ felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-gettingstarted/ipojo-in-10-minutes.mdtext
Sun Jun 30 07:35:47 2013
@@ -1,13 +1,10 @@
 translation_pending: true
 Title: iPOJO in 10 minutes
 
-
-
-
 # iPOJO in 10 minutes
 
-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
-    * [annotations]({{ refs.how-to-use-ipojo-annotations.path }})
+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 annotations to describe components.
 However, iPOJO also supports
+    * XML
     * A Java [API|apache-felix-ipojo-api]
 
 ## Introduction
@@ -27,6 +24,7 @@ The component is a central concept in iP
 ## A simple example
 
 In this tutorial we will present how to:
+
 * Publish an OSGi service
 * Require an OSGi service
 * Use lifecycle callbacks to activate and deactivate components
@@ -42,7 +40,8 @@ To illustrate iPOJO features, we will im
 
 ### Preparing the tutorial
 
-This tutorial is based on Ant. So, you need to have the Ant program accessible in your path
(see [here](http://ant.apache.org/) 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:
+This tutorial is based on Ant. So, you need to have the Ant program accessible in your path
(see [here](http://ant.apache.org/) to download and install Ant). Download the tutorial archive
available [here](ipojo-10-min-tutorial.zip) and then unzip it. The archive contains seven
directories:
+
 * spell.services contains service interfaces used by the applications
 * spell.english contains an implementation of the Dictionary service (containing English
words)
 * 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).
@@ -55,7 +54,7 @@ This tutorial is based on Ant. So, you n
 
 The spell.services project contains only service interfaces. It is not an iPOJO powered bundle.
 
-Go inside the Spell.services directory and create the file "src/spell/services/DictionaryService.java"
for the following *Dictionary* service interface:
+Go inside the spell.services directory and open the file "src/spell/services/DictionaryService.java".
It's a very simple service interface with one method:
 
     :::java
     package spell.services;
@@ -73,7 +72,7 @@ Go inside the Spell.services directory a
         public boolean checkWord(String word);
     }
 
-Then, create the file `src/spell/services/SpellChecker.java` for the following _Spell Checker_
service interface:
+Then, open the file `src/spell/services/SpellChecker.java`, and replace the `TODO` comment
with for the following `check` method:
     
     :::java
     package spell.services;
@@ -104,18 +103,18 @@ Once created, you can build the project 
     Buildfile: build.xml
     clean:
     compile:
-        [mkdir]({{ refs.mkdir.path }}) Created dir: d:\clement\workspaces\sandbox\ipojo\examples\tutorial-ant\
+        [mkdir] Created dir: d:\clement\workspaces\sandbox\ipojo\examples\tutorial-ant\
                 spell.services\output
-        [mkdir]({{ refs.mkdir.path }}) Created dir: d:\clement\workspaces\sandbox\ipojo\examples\tutorial-ant\
+        [mkdir] Created dir: d:\clement\workspaces\sandbox\ipojo\examples\tutorial-ant\
                 spell.services\output\classes
-        [javac]({{ refs.javac.path }}) Compiling 2 source files to d:\clement\workspaces\sandbox\ipojo\examples\
+        [javac] Compiling 2 source files to d:\clement\workspaces\sandbox\ipojo\examples\
                 tutorial-ant\spell.services\output\classes
     package:
-          [bnd]({{ refs.bnd.path }}) spell.services 2
+          [bnd] spell.services 2
     BUILD SUCCESSFUL
     Total time: 0 seconds
 
-The created bundle is inside the output directory (spell.services.jar). The build process
use [BND](http://www.aqute.biz/Code/Bnd). The bundle manifest is described in the spell.services.bnd
file.
+The created bundle is inside the output directory (spell.services.jar). The build process
uses [BND](http://www.aqute.biz/Code/Bnd). The bundle manifest is described in the spell.services.bnd
file.
 
 Once this project is done, we are able to implement a Dictionary service.
     
@@ -123,18 +122,28 @@ Once this project is done, we are able t
     
 The spell.english project is a simple dictionary implementation of the Dictionary service.
It contains few English words. This implementation is an iPOJO component.
 
-The first step is to implement the service. Create the "src/spell/english/EnglishDictionary.java"
file for the following _Dictionary service_ implementation:
+The first step is to implement the service. Go in the spell.english directory and open the
"src/spell/english/EnglishDictionary.java" file. Replace its content with:
 
     :::java
     package spell.english;
+
+    import org.apache.felix.ipojo.annotations.Component;
+    import org.apache.felix.ipojo.annotations.Instantiate;
+    import org.apache.felix.ipojo.annotations.Provides;
     import spell.services.DictionaryService;
+
     /**
      * An implementation of the Dictionary service containing English words
      * see DictionaryService for details of the service.
      **/
+    @Component // It's an iPOJO Component
+    @Provides // We provide a service
+    @Instantiate // We declare an instance of our component
     public class EnglishDictionary implements DictionaryService {
+
         // The set of words contained in the dictionary.
-        String[] m_dictionary = { "welcome", "to", "the", "ipojo", "tutorial" };
+        String[] dictionary = { "welcome", "to", "the", "ipojo", "tutorial" };
+
         /**
          * Implements DictionaryService.checkWord(). Determines
          * if the passed in word is contained in the dictionary.
@@ -144,9 +153,10 @@ The first step is to implement the servi
          **/
         public boolean checkWord(String word) {
             word = word.toLowerCase();
+
             // This is very inefficient
-            for (int i = 0; i < m_dictionary.length; i++) {
-                if (m_dictionary[i].equals(word)) {
+            for (String dict : dictionary) {
+                if (dict.equals(word)) {
                     return true;
                 }
             }
@@ -154,49 +164,42 @@ The first step is to implement the servi
         }
     }
 
-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:
+Notice that this class does not contains neither OSGi nor iPOJO specific code except a few
annotations. It is just an implementation of the Dictionary Service interface.
 
-    :::xml
-    <ipojo>
-    <component classname="spell.english.EnglishDictionary">
-    	<provides/>
-    </component>
-    <instance component="spell.english.EnglishDictionary"/>
-    </ipojo>
-
-This file describes the Dictionary service implementation. First it creates a *component*.
This component has a *classname* attribute containing the implementation class name. The *'provides'*
element indicates that the component provide a service. Provided service interfaces are computed
by iPOJO, so it is not necessary to indicate them. The *instance* 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 *component* attribute indicates which component needs to be instantiated. By default,
component type name is the implementation class (i.e. the classname attribute).
+The `@Component` annotation is used to declare an iPOJO component. The `@Provides` annotation
indicates that the component provides a service. Provided service interfaces are computed
by iPOJO, so it is not necessary to specify them. Finally, the `@Instantiate` annotation instructs
iPOJO to create an instance of our component. The relation between components and instances
is the same than between classes and objects in the object oriented programming.
 
 Then, we are able to create the bundle. In the spell.english directory launch the ant command:
 
-    :::xml
+    :::sh
     $ ant
-    Buildfile: build.xml
+    Buildfile: /Users/clement/Projects/felix-trunk/ipojo/distributions/ten-minutes-tutorial/target/test/spell.english/build.xml
+
     clean:
-       [delete]({{ refs.delete.path }}) Deleting directory d:\clement\workspaces\sandbox\ipojo\examples\
-                tutorial-ant\spell.english\output\classes
-       [delete]({{ refs.delete.path }}) Deleting directory d:\clement\workspaces\sandbox\ipojo\examples\
-                tutorial-ant\spell.english\output
+
     buildclasspath:
+         [copy] Copying 1 file to /Users/clement/Projects/felix-trunk/ipojo/distributions/ten-minutes-tutorial/target/test/spell.english/libs
+         [copy] Copying 1 file to /Users/clement/Projects/felix-trunk/ipojo/distributions/ten-minutes-tutorial/target/test/spell.english/libs
+
     compile:
-        [mkdir]({{ refs.mkdir.path }}) Created dir: d:\clement\workspaces\sandbox\ipojo\examples\
-                tutorial-ant\spell.english\output
-        [mkdir]({{ refs.mkdir.path }}) Created dir: d:\clement\workspaces\sandbox\ipojo\examples\
-                tutorial-ant\spell.english\output\classes
-        [javac]({{ refs.javac.path }}) Compiling 1 source file to d:\clement\workspaces\sandbox\ipojo\examples\
-                tutorial-ant\spell.english\output\classes
+        [mkdir] Created dir: /Users/clement/Projects/felix-trunk/ipojo/distributions/ten-minutes-tutorial/target/test/spell.english/output
+        [mkdir] Created dir: /Users/clement/Projects/felix-trunk/ipojo/distributions/ten-minutes-tutorial/target/test/spell.english/output/classes
+        [javac] /Users/clement/Projects/felix-trunk/ipojo/distributions/ten-minutes-tutorial/target/test/spell.english/build.xml:57:
warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false
for repeatable builds
+        [javac] Compiling 1 source file to /Users/clement/Projects/felix-trunk/ipojo/distributions/ten-minutes-tutorial/target/test/spell.english/output/classes
+
     package:
-          [bnd]({{ refs.bnd.path }}) spell.english 1
-        [ipojo]({{ refs.ipojo.path }}) Input Bundle File : d:\clement\workspaces\sandbox\ipojo\examples\
-                tutorial-ant\spell.english\output\spell.english.jar
-        [ipojo]({{ refs.ipojo.path }}) Metadata File : d:\clement\workspaces\sandbox\ipojo\examples\
-                tutorial-ant\spell.english\metadata.xml
-        [ipojo]({{ refs.ipojo.path }}) Start bundle manipulation
-        [ipojo]({{ refs.ipojo.path }}) Bundle manipulation - SUCCESS
-        [ipojo]({{ refs.ipojo.path }}) Output File : d:\clement\workspaces\sandbox\ipojo\examples\
-                tutorial-ant\spell.english\output\spell.english.jar
+          [bnd] # addAll 'output/classes' with :,
+          [bnd] # addAll 'spell.english.bnd' with ,
+          [bnd] Updating classpath after classpathref setting
+          [bnd] # spell.english (spell.english.jar) 1
+        [ipojo] Input bundle file : /Users/clement/Projects/felix-trunk/ipojo/distributions/ten-minutes-tutorial/target/test/spell.english/output/spell.english.jar
+        [ipojo] No metadata file found - trying to use only annotations
+        [ipojo] Start manipulation
+    Apache Felix iPOJO Manipulator - 1.9.0-SNAPSHOT
+        [ipojo] Bundle manipulation - SUCCESS
+        [ipojo] Output file : /Users/clement/Projects/felix-trunk/ipojo/distributions/ten-minutes-tutorial/target/test/spell.english/output/spell.english.jar
+
     BUILD SUCCESSFUL
-    Total time: 1 second
+    Total time: 0 seconds
 
 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
`spell.english.bnd` file.
     
@@ -204,59 +207,73 @@ The created bundle is inside the output 
     
 The spell.checker project aims to provide a _spell checker_ service. However, to serve this
service, this implementation requires a _dictionary_ service. During this step, we will create
an iPOJO component requiring a Dictionary service and providing the Spell Checker service.
     
-First create the file `src/spell/checker/SpellCheck.java` in the spell.checker directory
for the following _Check Speller service_ implementation:
+First, go the the spell.checker directory and open the file `src/spell/checker/SpellCheck.java`.
Replace its content with:
 
     :::java
     package spell.checker;
+
+    import org.apache.felix.ipojo.annotations.Component;
+    import org.apache.felix.ipojo.annotations.Instantiate;
+    import org.apache.felix.ipojo.annotations.Provides;
+    import org.apache.felix.ipojo.annotations.Requires;
+    import spell.services.DictionaryService;
+    import spell.services.SpellChecker;
+
     import java.util.ArrayList;
     import java.util.List;
     import java.util.StringTokenizer;
-    import spell.services.DictionaryService;
-    import spell.services.SpellChecker;
+
+    @Component
+    @Provides
+    @Instantiate
     public class SpellCheck implements SpellChecker {
-        private DictionaryService m_dictionary;
+
+        @Requires // This is a service dependency.
+        private DictionaryService dictionary;
+
         /**
          * Implements SpellChecker.check(). Checks the given passage for misspelled words.
+         *
          * @param passage the passage to spell check.
          * @return An array of misspelled words or null if no words are misspelled.
          */
         public String[] check(String passage) {
             // No misspelled words for an empty string.
-            if ((passage == null) || (passage.length() == 0)) { return null; }
-            List errorList = new ArrayList();
+            if ((passage == null) || (passage.length() == 0)) {
+                return null;
+            }
+
+            List<String> errorList = new ArrayList<String>();
+
             // Tokenize the passage using spaces and punctuation.
             StringTokenizer st = new StringTokenizer(passage, " ,.!?;:");
+
             // Loop through each word in the passage.
             while (st.hasMoreTokens()) {
                 String word = st.nextToken();
+
                 // Check the current word.
-                if (! m_dictionary.checkWord(word)) {
+                if (!dictionary.checkWord(word)) {
                     // If the word is not correct, then add it
                     // to the incorrect word list.
                     errorList.add(word);
                 }
             }
+
             // Return null if no words are incorrect.
-            if (errorList.size() == 0) { return null; }
+            if (errorList.size() == 0) {
+                return null;
+            }
+
             // Return the array of incorrect words.
-            return (String[]) errorList.toArray(new String[errorList.size()]);
+            System.out.println("Wrong words:" + errorList);
+            return errorList.toArray(new String[errorList.size()]);
         }
     }
 
-This class implements the SpellChecker service interface as it will provide it. Moreover,
it has a *special* field `m_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.
-
-Once implemented, we need to describe this component. Create the `metadata.xml` file in the
spell.checker directory for the following component descriptor:
+This class implements the SpellChecker service interface as it provides it. Moreover, it
has a *special* field `dictionary`. This field represents the required service. iPOJO injects
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
and described using annotations. When the used dictionary service leaves, iPOJO tries to find
another provider. If no more providers are available, the instance is invalidated, and the
provided service is withdrawn from the service registry.
 
-    :::xml
-    <ipojo>
-    <component classname="spell.checker.SpellCheck">
-    	<requires field="m_dictionary"/>
-    	<provides/>
-    </component>
-    <instance component="spell.checker.SpellCheck"/>
-    </ipojo>
-
-This description contains a '*requires'* element. This element indicates to iPOJO to manage
the service dependency. The *field* attributes describe in which member of the class the service
need to be injected. It is not necessary to write the required service as it is computed by
iPOJO. Notice that iPOJO can inject required service by invoking methods too.
+The @Component, @Instantiate and @Provides annotations were already presented. The `@Requires`
annotation specifies a service dependency. This example shows field injection, but iPOJO also
supports constructor injection and method injection (with `@Bind` and `@Unbind`).
 
 Finally, we are able to build the bundle. As for previous projects, launch Ant from the project
directory.
 
@@ -264,37 +281,40 @@ Finally, we are able to build the bundle
 
 The spell.check.gui project contains a very simple user interface (in Swing) allowing a user
to interact with a *spell checker* service.
 
-Create the `src\spell\gui\SpellCheckerGui.java` for the following implementation:
+Go to the spell.checker.gui directory. Open the `src\spell\gui\SpellCheckerGui.java`. Replace
its content with:
 
     :::java
     package spell.gui;
-    import javax.swing.JButton;
-    import javax.swing.JFrame;
-    import javax.swing.JLabel;
-    import javax.swing.JTextField;
+
+    import org.apache.felix.ipojo.annotations.*;
     import spell.services.SpellChecker;
+
+    import javax.swing.*;
+
     /**
      * A very simple Gui interacting with the CheckSpeller service
      */
+    @Component
+    @Instantiate
     public class SpellCheckerGui extends JFrame {
-        /**
-         * Swing component where the user write the passage to check.
-         */
-        private JTextField m_passage = null;
+
+        private static final long serialVersionUID = 1L;
 
         /**
-         * Check button
+         * Swing component where the user write the passage to check.
          */
-        private JButton m_checkButton = null;
+        private JTextField passage = null;
 
         /**
          * Area where the result is displayed.
          */
-        private JLabel m_result = null;
+        private JLabel result = null;
+
         /**
          * Service dependency on the SpellChecker.
          */
-        private SpellChecker m_checker;
+        @Requires
+        private SpellChecker checker;
 
         /**
          * Constructor.
@@ -305,18 +325,23 @@ Create the `src\spell\gui\SpellCheckerGu
             initComponents();
             this.setTitle("Spellchecker Gui");
         }
+
         /**
          * Initialize the Swing Gui.
          */
         private void initComponents() {
             java.awt.GridBagConstraints gridBagConstraints;
-            m_checkButton = new javax.swing.JButton();
-            m_result = new javax.swing.JLabel();
-            m_passage = new javax.swing.JTextField();
-            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT*ON*CLOSE); //Stop Felix
+
+            // The check button
+            JButton checkButton = new JButton();
+            result = new JLabel();
+            passage = new JTextField();
+
+            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); // Stop
Felix...
             getContentPane().setLayout(new java.awt.GridBagLayout());
-            m_checkButton.setText("Check");
-            m_checkButton.addActionListener(new java.awt.event.ActionListener() {
+
+            checkButton.setText("Check");
+            checkButton.addActionListener(new java.awt.event.ActionListener() {
                 public void actionPerformed(java.awt.event.ActionEvent e) {
                     check();
                 }
@@ -325,93 +350,93 @@ Create the `src\spell\gui\SpellCheckerGu
             gridBagConstraints.gridx = 0;
             gridBagConstraints.gridy = 1;
             gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
-            getContentPane().add(m_checkButton, gridBagConstraints);
-            m_result.setPreferredSize(new java.awt.Dimension(175, 20));
+            getContentPane().add(checkButton, gridBagConstraints);
+
+            result.setPreferredSize(new java.awt.Dimension(175, 20));
             gridBagConstraints = new java.awt.GridBagConstraints();
             gridBagConstraints.gridx = 0;
             gridBagConstraints.gridy = 2;
             gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
             gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
-            getContentPane().add(m_result, gridBagConstraints);
-            m_passage.setPreferredSize(new java.awt.Dimension(175, 20));
+            getContentPane().add(result, gridBagConstraints);
+
+            passage.setPreferredSize(new java.awt.Dimension(175, 20));
             gridBagConstraints = new java.awt.GridBagConstraints();
             gridBagConstraints.gridx = 0;
             gridBagConstraints.gridy = 0;
             gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
             gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
-            getContentPane().add(m_passage, gridBagConstraints);
+            getContentPane().add(passage, gridBagConstraints);
+
             pack();
         }
+
         /**
          * Check Button action.
          * Collects the user input and checks it.
          */
         private void check() {
-            String[]({{ refs..path }}) result = m*checker.check(m*passage.getText());
+            String[] result = checker.check(passage.getText());
             if (result != null) {
-                m_result.setText(result.length + " word(s) are mispelled");
+                this.result.setText(result.length + " word(s) are misspelled");
             } else {
-                m_result.setText("All words are correct");
+                this.result.setText("All words are correct");
             }
         }
+
         /**
          * Start callback.
          * This method will be called when the instance becomes valid.
          * It set the Gui visibility to true.
          */
+        @Validate
         public void start() {
             this.setVisible(true);
         }
+
         /**
          * Stop callback.
-         *  This method will be called when the instance becomes invalid or stops.
-         *  It deletes the Gui.
+         * This method will be called when the instance becomes invalid or stops.
+         * It deletes the Gui.
          */
+        @Invalidate
         public void stop() {
             this.dispose();
         }
     }
 
-Look at the three last methods. The _check_ methods collect the user input and use a _Check
speller_ service to check this input. This method is called when the button is pressed by
the user. The _start_ and _stop_ methods are lifecycle callbacks. As we need to display the
user interface when the instance is created and to delete it when the instance stops, we need
a way to be notified when we need to execute these actions. iPOJO provide an easy way to do
this. The component provides two callback methods for its activation and deactivation, start
and stop, respectively. Callbacks are used when the component needs to be informed about a
component state change. In iPOJO, the component state is either *INVALID* (i.e., not all of
the component's constraints are satisfied) or *VALID* (i.e., all of the component's constraints
are satisfied). In this example, the start callback method set the GUI visibility to true;
the stop callback method deletes the GUI. The component metadata will inst
 ruct iPOJO to invoke these methods when the component's state changes to *VALID* or *INVALID*
respectively.
+Look at the three last methods. The _check_ methods collects the user input and uses a _Check
speller_ service to check this input. The speller is injected into the `checker` field thanks
to the `@Requires` annotation. This method is called when the button is pressed by the user.
The _start_ and _stop_ methods are lifecycle callbacks. As we display the user interface when
the instance is created and to dispose it when the instance stops, we need a way to be notified
when we need to execute these actions. iPOJO provides an easy way to do this. The component
provides two callback methods for its activation and deactivation. Callbacks are used when
the component needs to be informed about a component state change. In iPOJO, the component
state is either *INVALID* (i.e., not all of the component's constraints are satisfied) or
*VALID* (i.e., all of the component's constraints are satisfied). In this example, the start
callback method sets the GUI visibility to true; the stop callback me
 thod deletes the GUI. The `@Validate` and `@Invalidate` annotations are used to specify these
callbacks.
     
-Create the _metadata.xml_ file in the spell.chercker.gui directory with the following content:
-
-    :::xml
-    <ipojo>
-    <component classname="spell.gui.SpellCheckerGui">
-    	<requires field="m_checker"/>
-    	<callback transition="validate" method="start"/>
-    	<callback transition="invalidate" method="stop"/>
-    </component>
-    <instance component="spell.gui.SpellCheckerGui"/>
-    </ipojo>
-
-The component element again has the '*classname'* attribute that refers to the component
implementation class. The '*requires*' element describes the *Check Speller* service dependency
by simply specifying its associated component field. The '*callback'* elements describe which
method to invoke when the component's state changes. Then the *'instance'* element asks iPOJO
to create an instance of the component.
-
 Once this file is created, you can compile the project by launching *ant* in the spell.checker.gui
directory.
 
 ## Running the application
 
-To run the example, start Felix. A distribution of Felix is provided in the felix directory.
This version is configured to launch iPOJO automatically. From the Felix directory, launch
the following command to start the framework. Then enter a profile name.
+We have all the bundles required to start playing with the application.
+
+To run the example, start Felix. A distribution of Felix is provided in the felix-framework-VERSION
directory. This version is configured to launch iPOJO automatically. From the Felix directory,
launch the following command to start the framework. Then enter a profile name.
 
     :::sh
     java -jar bin/felix.jar
 
-You can check installed bundles by using the '_ps_' command:
+You can check installed bundles by using the '_lb_' command:
 
     :::sh
-    -> ps
+    ____________________________
+    Welcome to Apache Felix Gogo
+
+    g! lb
     START LEVEL 1
-       ID   State        Level  Name
-    [   0] [Active     ] [    0] System Bundle (2.0.5)
-    [   1] [Active     ] [    1] Apache Felix Bundle Repository (1.4.3)
-    [   2] [Active     ] [    1] Apache Felix iPOJO (1.6.0)
-    [   3] [Active     ] [    1] Apache Felix iPOJO Arch Command (1.6.0)
-    [   4] [Active     ] [    1] Apache Felix Shell Service (1.4.2)
-    [   5] [Active     ] [    1] Apache Felix Shell TUI (1.4.1)
-    ->
+       ID|State      |Level|Name
+        0|Active     |    0|System Bundle (4.2.1)
+        1|Active     |    1|Apache Felix Bundle Repository (1.6.6)
+        2|Active     |    1|Apache Felix Gogo Command (0.12.0)
+        3|Active     |    1|Apache Felix Gogo Runtime (0.10.0)
+        4|Active     |    1|Apache Felix Gogo Shell (0.10.0)
+        5|Active     |    1|Apache Felix iPOJO (1.9.0.SNAPSHOT)
+        6|Active     |    1|Apache Felix iPOJO Gogo Command (1.0.1)
+    g!
 
-iPOJO runtime is the bundle 4. Once started, install the four created bundles as above:
+iPOJO runtime is the bundle 5. Once started, install the four created bundles as below:
 
     :::sh
     start file:../spell.services/output/spell.services.jar
@@ -419,33 +444,62 @@ iPOJO runtime is the bundle 4. Once star
     start file:../spell.checker/output/spell.checker.jar
     start file:../spell.checker.gui/output/spell.checker.gui.jar
 
-When starting the GUI bundle, the user interface appears. Indeed, the _Check Speller_ service
is provided. You can interact with this service by entering a passage and clicking on the
check button:
+The new set of bundles is:
+
+    :::sh
+    g! lb
+    START LEVEL 1
+       ID|State      |Level|Name
+        0|Active     |    0|System Bundle (4.2.1)
+        1|Active     |    1|Apache Felix Bundle Repository (1.6.6)
+        2|Active     |    1|Apache Felix Gogo Command (0.12.0)
+        3|Active     |    1|Apache Felix Gogo Runtime (0.10.0)
+        4|Active     |    1|Apache Felix Gogo Shell (0.10.0)
+        5|Active     |    1|Apache Felix iPOJO (1.9.0.SNAPSHOT)
+        6|Active     |    1|Apache Felix iPOJO Gogo Command (1.0.1)
+        7|Active     |    1|spell.services (0.0.0)
+        8|Active     |    1|spell.english (0.0.0)
+        9|Active     |    1|spell.checker (0.0.0)
+       10|Active     |    1|spell.checker.gui (0.0.0)
+
+iPOJO provides a command to check created instances:
+
+    :::sh
+    g! instances
+    Instance org.apache.felix.ipojo.arch.gogo.Arch-0 -> valid
+    Instance spell.checker.SpellCheck-0 -> valid
+    Instance spell.gui.SpellCheckerGui-0 -> valid
+    Instance spell.english.EnglishDictionary-0 -> valid
+
+As you can see, all our instances are valid.
+
+In the gui (that should have appeared), you can interact with the spell service by entering
a passage and clicking on the check button:
 
 <img src="ss.png">
 
-Then, stop the _Dictionary_ service provider (with the _stop 7_) command. The GUI disappears.
Indeed, Spell Checker service cannot be provided as it depends on the Dictionary service.
+Then, stop the _Dictionary_ service provider (with the _stop 8_) command. The GUI disappears.
Indeed, Spell Checker service cannot be provided as it depends on the Dictionary service.
 
 <img src="spell2.png">
 
-Then, restart the Dictionary service provider with the _start 7_ command. The GUI reappears
immediately. You can try to stop the _check speller_ service provider without stopping the
_dictionary_ service provider with the _stop 8_ command. As for the last manipulation, the
GUI disappears.
+You can check the validity of the instances and see that the SpellChecker and the Gui are
invalid.
 
-<img src="spell3.png">
-
-To go further in the exploration, modify the spell.checker implementation. For example, add
a simple trace, printing wrong words:
-    
-    :::java
-    // ...
-    // Return null if no words are incorrect.
-    if (errorList.size() == 0) { return null; }
+    :::sh
+    g! instances
+    Instance org.apache.felix.ipojo.arch.gogo.Arch-0 -> valid
+    Instance spell.checker.SpellCheck-0 -> invalid
+    Instance spell.gui.SpellCheckerGui-0 -> invalid
 
-    // Return the array of incorrect words.
-    System.out.println("Wrong words:" + errorList); // <-- Add this line
-    return (String[]) errorList.toArray(new String[errorList.size()]);
+Then, restart the Dictionary service provider with the _start 8_ command. The GUI reappears
immediately. You can try to stop the _check speller_ service provider without stopping the
_dictionary_ service provider with the _stop 9_ command. As for the last manipulation, the
GUI disappears.
 
+<img src="spell3.png">
 
-Then rebuild the spell.checker bundle and update it (with the 'update 8' command). You will
see the gui "blinking". In fact, the gui was stopped as the required spell checker service
was no more available. As soon as it was back, the gui restarts. The gui didn't lose its state.
The other services weren't stopped during the update.
+This time, the Gui is invalid, but the English dictionary is valid:
 
-You can uninstall the check service bundle and then re-install a new one (or the same one),
you will see the same behavior.
+    :::sh
+    g! instances
+    Instance org.apache.felix.ipojo.arch.gogo.Arch-0 -> valid
+    Instance spell.gui.SpellCheckerGui-0 -> invalid
+    Instance spell.english.EnglishDictionary-0 -> valid
 
 ## Conclusion
 
@@ -455,8 +509,4 @@ We saw how to use easily iPOJO to build 
 * Require OSGi services
 * Use lifecycle callbacks to activate and deactivate components
 
-iPOJO provides a lot of others features that you can try in the others available tutorials.
Subscribe to the Felix users mailing list by sending a message to [users-subscribe@felix.apache.org](mailto:users-subscribe@felix.apache.org);
after subscribing, email questions or feedback to [users@felix.apache.org](mailto:users@felix.apache.org).
-  
-  
-  
-  
+iPOJO provides a lot of others features that you can try in the others available tutorials.
Subscribe to the Felix users mailing list by sending a message to [users-subscribe@felix.apache.org](mailto:users-subscribe@felix.apache.org);
after subscribing, email questions or feedback to [users@felix.apache.org](mailto:users@felix.apache.org).
\ No newline at end of file

Added: felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-gettingstarted/maven-tutorial.zip
URL: http://svn.apache.org/viewvc/felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-gettingstarted/maven-tutorial.zip?rev=1498068&view=auto
==============================================================================
Binary file - no diff available.

Propchange: felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-gettingstarted/maven-tutorial.zip
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



Mime
View raw message