Pierre De Rop | 6b4a6c4 | 2010-04-25 22:57:56 +0000 | [diff] [blame] | 1 | This sample illustrates the usage of the new DependencyManager annotations. |
| 2 | |
| 3 | Sample description: |
| 4 | |
| 5 | This sample shows a basic "SpellChecker" application which provides a Felix "spellcheck" shell |
| 6 | command. The SpellChecker class is a Felix Shell command (it provides the "Command" service), |
| 7 | which accepts a string as parameter. So, when you type a string, the command just says if the |
| 8 | specified string has been found from one of its injected dictionaries. The SpellChecker class has a |
| 9 | required/multiple dependency over any available DictionaryService. Currently, there is one |
| 10 | "EnglishDictionary" which implements the DictionaryService. The EnglishDictionary service uses |
| 11 | MetaType, allowing to configure english words through ConfigAdmin and WebConsole. |
| 12 | So, before testing, you first have to go to webconsole Configuration panel, and specify some |
| 13 | english words in the configuration for the "English Dictionary" PID. Then, go to the felix shell, |
| 14 | and you will then see the "spellcheck" command (when typing "help"). |
| 15 | Notice that in the sample, you will also find an Aspect Service (DictionaryAspect.java), which |
| 16 | decorates the EnglishDictionary service, by adding an "aspect" word in the dictionary. |
| 17 | |
| 18 | How to test: |
| 19 | |
| 20 | 1) Install the following bundles: |
| 21 | |
| 22 | org.apache.felix.configadmin |
| 23 | org.apache.felix.metatype |
| 24 | org.apache.felix.http.jetty |
| 25 | org.apache.felix.webconsole |
| 26 | |
| 27 | org.apache.felix.dependencymanager |
| 28 | org.apache.felix.dependencymanager.shell |
| 29 | org.apache.felix.dependencymanager.runtime |
| 30 | org.apache.felix.dependencymanager.samples.annotation |
| 31 | |
| 32 | 2) Start felix |
| 33 | 3) Go to web console, in the Configuration pannel |
| 34 | 4) Edit the "English Dictionary" Configuration, add some words, then click on "save". |
| 35 | At this point, the "EnglishDictionary" service will be enabled and the SpellCheck component |
| 36 | will be injected with it. Then you should see the "spellcheck" command, when typing "help" on the shell. |
| 37 | |
| 38 | 5) Just type "spellcheck hello", and the command should reply a fantastic message, like "word hello is correct". |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |