blob: f033e8832fb8b2cad9f6a6f449efba0002c830eb [file] [log] [blame]
Pierre De Rop804f4be2010-04-25 22:57:56 +00001This sample illustrates the usage of the new DependencyManager annotations.
2
3Sample description:
4
Pierre De Rop452f4382010-06-21 09:46:37 +00005 This sample shows a basic "SpellChecker" application which provides a Felix "spellcheck" GOGO shell
6 command. The GOGO "spellcheck" command accepts a string as parameter, which is checked for proper
Pierre De Rop7e98d672010-07-03 21:56:18 +00007 existence. The SpellChecker class has a required/multiple (1..N) dependency over every available
Pierre De Rop452f4382010-06-21 09:46:37 +00008 "DictionaryService" services, which are internally used by the SpellChecker command, when checking
Pierre De Rop4c138482010-07-03 22:25:18 +00009 word existence.
Pierre De Ropd9c4e3c2010-05-24 21:42:18 +000010
11 A DictionaryService is defined using a FactoryConfigurationAdapterService annotation, allowing to
Pierre De Rop10839cc2010-07-04 21:07:59 +000012 instantiate many "DictionaryService" instances from webconsole. This annotation actually
Pierre De Rop452f4382010-06-21 09:46:37 +000013 registers a ManagedServiceFactory into the Registry, and you can specify some meta type
Pierre De Rop10839cc2010-07-04 21:07:59 +000014 informations in the annotation, allowing to configure the DictionaryService words and language from
15 WebConsole.
16 Each time you instantiate a factory configuration whose factory pid equals "Dictionary Services",
Pierre De Rop7e98d672010-07-03 21:56:18 +000017 then a corresponding "DictionaryService" service is instantiated and is then injected
Pierre De Rop452f4382010-06-21 09:46:37 +000018 into the SpellChecker service. So, before testing, you first have to go to webconsole
Pierre De Rop7e98d672010-07-03 21:56:18 +000019 Configuration panel, and specify some dictionaries (see the "Dictionary Services" Factory PID).
Pierre De Rop452f4382010-06-21 09:46:37 +000020 Then, go to the felix GOGO shell, and you will then see the "spellcheck" command (when typing
21 "help").
Pierre De Ropd9c4e3c2010-05-24 21:42:18 +000022
23 Notice that in the sample, you will also find a DictionaryAspect Service (DictionaryAspect.java), which
Pierre De Rop10839cc2010-07-04 21:07:59 +000024 decorates the EnglishDictionary service, by adding some additional words to it.
25
Pierre De Rop804f4be2010-04-25 22:57:56 +000026How to test:
27
Pierre De Rop634588d2010-08-19 20:15:12 +000028 - Install the following bundles:
Pierre De Rop804f4be2010-04-25 22:57:56 +000029
Pierre De Rop634588d2010-08-19 20:15:12 +000030 org.apache.felix.configadmin
31 org.apache.felix.metatype
32 org.apache.felix.http.jetty
Pierre De Rop804f4be2010-04-25 22:57:56 +000033 org.apache.felix.webconsole
34
Pierre De Rop634588d2010-08-19 20:15:12 +000035 - compile dependency manager from trunk:
Pierre De Rop804f4be2010-04-25 22:57:56 +000036
Pierre De Rop634588d2010-08-19 20:15:12 +000037 svn checkout http://svn.apache.org/repos/asf/felix/trunk/dependencymanager dependencymanager
38 cd dependencymanager
39 mvn -Dmaven.test.skip=true install
40
41 - install the DM bundles into the fwk
42
43 dependencymanager/core/target/org.apache.felix.dependencymanager-3.0.0-SNAPSHOT.jar
44 dependencymanager/shell/target/org.apache.felix.dependencymanager.shell-3.0.0-SNAPSHOT.jar
45 dependencymanager/runtime/target/org.apache.felix.dependencymanager.runtime-3.0.0-SNAPSHOT.jar
46 dependencymanager/samples.annotation/target/org.apache.felix.dependencymanager.samples.annotation-3.0.0-SNAPSHOT.jar
47
48 - Start felix
49
50 At this point, you should have the following running bundles:
51
52 START LEVEL 1
53 ID|State |Level|Name
54 0|Active | 0|System Bundle (3.0.1)
55 1|Active | 1|Apache Felix Bundle Repository (1.6.2)
56 7|Active | 1|Apache Felix Gogo Command (0.6.0)
57 8|Active | 1|Apache Felix Gogo Runtime (0.6.0)
58 9|Active | 1|Apache Felix Gogo Shell (0.6.0)
59 10|Active | 1|Apache Felix Http Jetty (2.0.4)
60 11|Active | 1|Apache Felix Metatype Service (1.0.4)
61 12|Active | 1|Apache Felix Web Management Console (3.1.2)
62 2|Active | 1|Apache Felix Configuration Admin Service (1.2.4)
63 3|Active | 1|Apache Felix Dependency Manager (3.0.0.SNAPSHOT)
64 6|Active | 1|Apache Felix Dependency Manager Shell (3.0.0.SNAPSHOT)
65 4|Active | 1|Apache Felix Dependency Manager Runtime (3.0.0.SNAPSHOT)
66 5|Active | 1|Apache Felix Dependency Manager Annotation Sample (3.0.0.SNAPSHOT)
67
68 - Go to web console: in the Configuration panel, edit the "Dictionary Services"
Pierre De Rop452f4382010-06-21 09:46:37 +000069 Configuration, add some dictionaries. By default, an English dictionary is displayed. Just
Pierre De Rop10839cc2010-07-04 21:07:59 +000070 click on "save", *then click on your refresh web browser*: you will see a new dictionary service
Pierre De Rop452f4382010-06-21 09:46:37 +000071 instance. At this point, a DictionaryService service will be enabled (with the service property "lang=en"),
72 and the SpellCheck component will be injected with it. Then you should see the "spellcheck"
Pierre De Rop7e98d672010-07-03 21:56:18 +000073 command, when typing "help" on the gogo shell.
Pierre De Rop804f4be2010-04-25 22:57:56 +000074
Pierre De Rop634588d2010-08-19 20:15:12 +000075 - Just type "spellcheck hello", and the command should reply a fantastic message, like "word hello is correct".
Pierre De Rop804f4be2010-04-25 22:57:56 +000076
Pierre De Rop634588d2010-08-19 20:15:12 +000077 - You can also click on the "Aspect Dictionary" button, in order to decorate the english dictionary with some
Pierre De Rop10839cc2010-07-04 21:07:59 +000078 custom words.
Pierre De Ropd9c4e3c2010-05-24 21:42:18 +000079 By default, the "aspect" word is pre configured, but you can click on the "+" button in order to add more words.
Pierre De Rop10839cc2010-07-04 21:07:59 +000080 Then click on Save. At this point, the English DictionaryService will be decorated with the aspect service.
Pierre De Ropd9c4e3c2010-05-24 21:42:18 +000081 So, now, if you type "spellcheck aspect", then the message: "word aspect is correct" should be displayed.