blob: d9762671c3e16aa16a0bd8aab644027cff75fb59 [file] [log] [blame]
Pierre De Rop6b4a6c42010-04-25 22:57:56 +00001This sample illustrates the usage of the new DependencyManager annotations.
2
3Sample description:
4
Pierre De Ropcf7d7a62010-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 Rop2b71cb12010-07-03 21:56:18 +00007 existence. The SpellChecker class has a required/multiple (1..N) dependency over every available
Pierre De Ropcf7d7a62010-06-21 09:46:37 +00008 "DictionaryService" services, which are internally used by the SpellChecker command, when checking
Pierre De Rop047d5ec2010-07-03 22:25:18 +00009 word existence.
Pierre De Ropa97580d2010-05-24 21:42:18 +000010
11 A DictionaryService is defined using a FactoryConfigurationAdapterService annotation, allowing to
Pierre De Rop9eca99b2010-07-04 21:07:59 +000012 instantiate many "DictionaryService" instances from webconsole. This annotation actually
Pierre De Ropcf7d7a62010-06-21 09:46:37 +000013 registers a ManagedServiceFactory into the Registry, and you can specify some meta type
Pierre De Rop9eca99b2010-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 Rop2b71cb12010-07-03 21:56:18 +000017 then a corresponding "DictionaryService" service is instantiated and is then injected
Pierre De Ropcf7d7a62010-06-21 09:46:37 +000018 into the SpellChecker service. So, before testing, you first have to go to webconsole
Pierre De Rop2b71cb12010-07-03 21:56:18 +000019 Configuration panel, and specify some dictionaries (see the "Dictionary Services" Factory PID).
Pierre De Ropcf7d7a62010-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 Ropa97580d2010-05-24 21:42:18 +000022
23 Notice that in the sample, you will also find a DictionaryAspect Service (DictionaryAspect.java), which
Pierre De Rop9eca99b2010-07-04 21:07:59 +000024 decorates the EnglishDictionary service, by adding some additional words to it.
25
Pierre De Rop6b4a6c42010-04-25 22:57:56 +000026How to test:
27
Pierre De Ropb14972d2010-09-14 19:42:56 +000028 - Install the following bundles (with same or higher version):
Pierre De Rop6b4a6c42010-04-25 22:57:56 +000029
Pierre De Ropb14972d2010-09-14 19:42:56 +000030 org.apache.felix.configadmin-1.2.8.jar
31 org.apache.felix.metatype-1.0.4.jar
Pierre De Rop8a607bb2011-02-26 22:25:16 +000032 org.apache.felix.http.jetty-2.2.0.jar
33 org.apache.felix.log-1.0.0.jar (optional)
34 org.apache.felix.webconsole-3.1.8.jar
35 org.apache.felix.shell-1.4.2.jar
Pierre De Rop6b4a6c42010-04-25 22:57:56 +000036
Pierre De Rop48a5aee2010-08-19 20:15:12 +000037 - compile dependency manager from trunk:
Pierre De Rop6b4a6c42010-04-25 22:57:56 +000038
Pierre De Rop48a5aee2010-08-19 20:15:12 +000039 svn checkout http://svn.apache.org/repos/asf/felix/trunk/dependencymanager dependencymanager
40 cd dependencymanager
Pierre De Ropdef36a42010-08-22 11:51:18 +000041 mvn -Dpackaging=plugins -Dmaven.test.skip=true install
Pierre De Rop48a5aee2010-08-19 20:15:12 +000042
43 - install the DM bundles into the fwk
44
45 dependencymanager/core/target/org.apache.felix.dependencymanager-3.0.0-SNAPSHOT.jar
46 dependencymanager/shell/target/org.apache.felix.dependencymanager.shell-3.0.0-SNAPSHOT.jar
47 dependencymanager/runtime/target/org.apache.felix.dependencymanager.runtime-3.0.0-SNAPSHOT.jar
48 dependencymanager/samples.annotation/target/org.apache.felix.dependencymanager.samples.annotation-3.0.0-SNAPSHOT.jar
49
50 - Start felix
51
52 At this point, you should have the following running bundles:
53
Pierre De Rop8a607bb2011-02-26 22:25:16 +000054 g! lb
Pierre De Rop48a5aee2010-08-19 20:15:12 +000055 START LEVEL 1
Pierre De Rop8a607bb2011-02-26 22:25:16 +000056 ID|State |Level|Name
57 0|Active | 0|System Bundle (3.0.8)
58 1|Active | 1|Apache Felix Bundle Repository (1.6.2)
59 2|Active | 1|Apache Felix Configuration Admin Service (1.2.8)
60 7|Active | 1|Apache Felix Gogo Command (0.8.0)
61 8|Active | 1|Apache Felix Gogo Runtime (0.8.0)
62 9|Active | 1|Apache Felix Gogo Shell (0.8.0)
63 10|Active | 1|Apache Felix Http Jetty (2.2.0)
64 11|Active | 1|Apache Felix Log Service (1.0.0)
65 12|Active | 1|Apache Felix Metatype Service (1.0.4)
66 13|Active | 1|Apache Felix Web Management Console (3.1.8)
67 14|Active | 1|Apache Felix Dependency Manager (3.0.0.SNAPSHOT)
68 16|Active | 1|Apache Felix Dependency Manager Runtime (3.0.0.SNAPSHOT)
69 17|Active | 1|Apache Felix Dependency Manager Shell (3.0.0.SNAPSHOT)
70 18|Active | 1|Apache Felix Dependency Manager Annotation Sample (3.0.0.SNAPSHOT)
Pierre De Rop48a5aee2010-08-19 20:15:12 +000071
72 - Go to web console: in the Configuration panel, edit the "Dictionary Services"
Pierre De Ropcf7d7a62010-06-21 09:46:37 +000073 Configuration, add some dictionaries. By default, an English dictionary is displayed. Just
Pierre De Rop9eca99b2010-07-04 21:07:59 +000074 click on "save", *then click on your refresh web browser*: you will see a new dictionary service
Pierre De Ropcf7d7a62010-06-21 09:46:37 +000075 instance. At this point, a DictionaryService service will be enabled (with the service property "lang=en"),
76 and the SpellCheck component will be injected with it. Then you should see the "spellcheck"
Pierre De Rop2b71cb12010-07-03 21:56:18 +000077 command, when typing "help" on the gogo shell.
Pierre De Rop6b4a6c42010-04-25 22:57:56 +000078
Pierre De Rop48a5aee2010-08-19 20:15:12 +000079 - Just type "spellcheck hello", and the command should reply a fantastic message, like "word hello is correct".
Pierre De Rop6b4a6c42010-04-25 22:57:56 +000080
Pierre De Rop48a5aee2010-08-19 20:15:12 +000081 - You can also click on the "Aspect Dictionary" button, in order to decorate the english dictionary with some
Pierre De Rop9eca99b2010-07-04 21:07:59 +000082 custom words.
Pierre De Ropa97580d2010-05-24 21:42:18 +000083 By default, the "aspect" word is pre configured, but you can click on the "+" button in order to add more words.
Pierre De Rop9eca99b2010-07-04 21:07:59 +000084 Then click on Save. At this point, the English DictionaryService will be decorated with the aspect service.
Pierre De Ropa97580d2010-05-24 21:42:18 +000085 So, now, if you type "spellcheck aspect", then the message: "word aspect is correct" should be displayed.