Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 1 | |
| 2 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 | <HTML> |
| 4 | |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 5 | <!-- Mirrored Site: felix.apache.org. File: /site/how-to-use-ipojo-annotations.html. Date: Mon, 13 Oct 2008 06:52:42 GMT --> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 6 | <HEAD> |
| 7 | <TITLE>Apache Felix - How to use iPOJO Annotations</TITLE> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 8 | <LINK rel="stylesheet" href="media.data/site.css" type="text/css" media="all"> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 9 | <META http-equiv="Content-Type" content="text/html;charset=UTF-8"> |
| 10 | </HEAD> |
| 11 | <BODY> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 12 | <DIV class="title"><DIV class="logo"><A href="index.html"><IMG border="0" alt="Apache Felix" src="media.data/logo.png"></A></DIV><DIV class="header"><A href="http://www.apache.org/"><IMG border="0" alt="Apache" src="media.data/apache.png"></A></DIV></DIV> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 13 | <DIV class="menu"> |
| 14 | <UL> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 15 | <LI><A href="news.html" title="news">news</A></LI> |
| 16 | <LI><A href="license.html" title="license">license</A></LI> |
| 17 | <LI><SPAN class="nobr"><A href="downloads.html" title="Visit page outside Confluence" rel="nofollow">downloads<SUP><IMG class="rendericon" src="../../cwiki.apache.org/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"></SUP></A></SPAN></LI> |
| 18 | <LI><A href="documentation.html" title="documentation">documentation</A></LI> |
| 19 | <LI><A href="mailinglists.html" title="mailinglists">mailing lists</A></LI> |
| 20 | <LI><A href="contributing.html" title="Contributing">contributing</A></LI> |
| 21 | <LI><SPAN class="nobr"><A href="http://www.apache.org/" title="Visit page outside Confluence" rel="nofollow">asf<SUP><IMG class="rendericon" src="../../cwiki.apache.org/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"></SUP></A></SPAN></LI> |
| 22 | <LI><SPAN class="nobr"><A href="http://www.apache.org/foundation/sponsorship.html" title="Visit page outside Confluence" rel="nofollow">sponsorship<SUP><IMG class="rendericon" src="../../cwiki.apache.org/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"></SUP></A></SPAN></LI> |
| 23 | <LI><SPAN class="nobr"><A href="http://www.apache.org/foundation/thanks.html" title="Visit page outside Confluence" rel="nofollow">sponsors<SUP><IMG class="rendericon" src="../../cwiki.apache.org/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"></SUP></A></SPAN> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 24 | <!-- ApacheCon Ad --> |
| 25 | <IFRAME src="http://www.apache.org/ads/button.html" style="border-width:0; float: left" frameborder="0" scrolling="no" width="135" height="135"></IFRAME> |
| 26 | <P style="height: 100px"> |
| 27 | <!-- ApacheCon Ad --></LI> |
| 28 | </UL> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 29 | </DIV> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 30 | <DIV class="main"> |
| 31 | <TABLE class="sectionMacro" border="0" cellpadding="5" cellspacing="0" width="100%"><TBODY><TR> |
| 32 | <TD class="confluenceTd" valign="top" width="80%"> |
| 33 | <P>iPOJO defines several annotations to help developer to define their components. This page presents an example of iPOJO annotation and describes provided annotations.</P> |
| 34 | |
| 35 | <H1><A name="HowtouseiPOJOAnnotations-GettingiPOJOAnnotations%3A"></A>Getting iPOJO Annotations:</H1> |
| 36 | |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 37 | <P>iPOJO Annotations are defines inside the org.apache.felix.ipojo.annotations project. You can download the Jar file of this project from the <A href="download.html" title="Download">download</A> page. Sources are available on the <SPAN class="nobr"><A href="sourcecode.html" title="Visit page outside Confluence" rel="nofollow">Felix trunk<SUP><IMG class="rendericon" src="../../cwiki.apache.org/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"></SUP></A></SPAN>.<BR> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 38 | Once added to your class path / build path / dependencies, you can use the annotations as normal annotations. These annotations are automatically processed by the iPOJO manipulator.</P> |
| 39 | |
| 40 | <H2><A name="HowtouseiPOJOAnnotations-InEclipse%3A"></A>In Eclipse:</H2> |
| 41 | |
| 42 | <P>Add the org.apache.felix.ipojo.annotations jar file in your build path. Do not forget to use a Java compiler accepting annotations (1.5 or higher).</P> |
| 43 | |
| 44 | <H2><A name="HowtouseiPOJOAnnotations-InMaven%3A"></A>In Maven:</H2> |
| 45 | |
| 46 | <P>Add the following dependency:</P> |
| 47 | <DIV class="code"><DIV class="codeContent"> |
| 48 | <PRE class="code-xml"><SPAN class="code-tag"><dependency></SPAN> |
| 49 | <SPAN class="code-tag"><groupId></SPAN>org.apache.felix<SPAN class="code-tag"></groupId></SPAN> |
| 50 | <SPAN class="code-tag"><artifactId></SPAN>org.apache.felix.ipojo.annotations<SPAN class="code-tag"></artifactId></SPAN> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 51 | <SPAN class="code-tag"><version></SPAN>0.8.0<SPAN class="code-tag"></version></SPAN> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 52 | <SPAN class="code-tag"></dependency></SPAN></PRE> |
| 53 | </DIV></DIV> |
| 54 | <P>Moreover, you need to set that the source code and the target code are Java 1.5 code. To achieve this, just add the following plugin in your plugins section:</P> |
| 55 | <DIV class="code"><DIV class="codeContent"> |
| 56 | <PRE class="code-xml"><SPAN class="code-tag"><plugin></SPAN> |
| 57 | <SPAN class="code-tag"><groupId></SPAN>org.apache.maven.plugins<SPAN class="code-tag"></groupId></SPAN> |
| 58 | <SPAN class="code-tag"><artifactId></SPAN>maven-compiler-plugin<SPAN class="code-tag"></artifactId></SPAN> |
| 59 | <SPAN class="code-tag"><configuration></SPAN> |
| 60 | <SPAN class="code-tag"><source></SPAN>1.5<SPAN class="code-tag"></source></SPAN> |
| 61 | <SPAN class="code-tag"><target></SPAN>1.5<SPAN class="code-tag"></target></SPAN> |
| 62 | <SPAN class="code-tag"></configuration></SPAN> |
| 63 | <SPAN class="code-tag"></plugin></SPAN></PRE> |
| 64 | </DIV></DIV> |
| 65 | |
| 66 | <H2><A name="HowtouseiPOJOAnnotations-InAnt%3A"></A>In Ant :</H2> |
| 67 | |
| 68 | <P>Just add the org.apache.felix.ipojo.annotations jar file in your class path.</P> |
| 69 | |
| 70 | <H1><A name="HowtouseiPOJOAnnotations-Anexampleofusage%3A"></A>An example of usage:</H1> |
| 71 | |
| 72 | <P>To illustrate annotations usage, let taking the tutorial example. In this tutorial, there are two components:</P> |
| 73 | <UL> |
| 74 | <LI>The first one provides the hello service</LI> |
| 75 | <LI>The second one uses the provided hello service<BR> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 76 | You can download the <SPAN class="nobr"><A href="how-to-use-ipojo-annotations.data/hello.impl.annotated-0.0.1-src.zip" title="hello.impl.annotated-0.0.1-src.zip attached to How to use iPOJO Annotations">provider<SUP><IMG class="rendericon" src="../../cwiki.apache.org/confluence/images/icons/link_attachment_7.gif" height="7" width="7" align="absmiddle" alt="" border="0"></SUP></A></SPAN> project and the <SPAN class="nobr"><A href="how-to-use-ipojo-annotations.data/hello.client.annotation-0.0.1-src.zip" title="hello.client.annotation-0.0.1-src.zip attached to How to use iPOJO Annotations">consumer<SUP><IMG class="rendericon" src="../../cwiki.apache.org/confluence/images/icons/link_attachment_7.gif" height="7" width="7" align="absmiddle" alt="" border="0"></SUP></A></SPAN> project.</LI> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 77 | </UL> |
| 78 | |
| 79 | |
| 80 | <H2><A name="HowtouseiPOJOAnnotations-HelloServiceProvider"></A>Hello Service Provider</H2> |
| 81 | |
| 82 | <P>The provider uses two annotations. The "component" annotation is mandatory and defines that the class defines a component type. Then the "provides" annotation just declare that the defined component type provides a service.</P> |
| 83 | <DIV class="code"><DIV class="codeContent"> |
| 84 | <PRE class="code-java"><SPAN class="code-keyword">package</SPAN> ipojo.example.hello.impl; |
| 85 | |
| 86 | <SPAN class="code-keyword">import</SPAN> ipojo.example.hello.Hello; |
| 87 | |
| 88 | <SPAN class="code-keyword">import</SPAN> org.apache.felix.ipojo.annotations.Component; |
| 89 | <SPAN class="code-keyword">import</SPAN> org.apache.felix.ipojo.annotations.Provides; |
| 90 | |
| 91 | /** |
| 92 | * Component implementing the Hello service. |
| 93 | **/ |
| 94 | @Component |
| 95 | @Provides |
| 96 | <SPAN class="code-keyword">public</SPAN> class HelloImpl <SPAN class="code-keyword">implements</SPAN> Hello { |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 97 | <SPAN class="code-keyword">public</SPAN> <SPAN class="code-object">String</SPAN> sayHello(<SPAN class="code-object">String</SPAN> name) { |
| 98 | <SPAN class="code-keyword">return</SPAN> <SPAN class="code-quote">"hello "</SPAN> + name; |
| 99 | } |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 100 | }</PRE> |
| 101 | </DIV></DIV> |
| 102 | |
| 103 | <H2><A name="HowtouseiPOJOAnnotations-HelloServiceConsumer"></A>Hello Service Consumer</H2> |
| 104 | |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 105 | <P>The Hello Service Consumer use more annotations. First it used the component annotation. To defines its "immediate" behavior, it add the 'immediate' attribute.<BR> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 106 | Then, it uses the requires annotation to define a service dependency. Finally, it uses the validate and invalidate annotations to define lifecycle callbacks.</P> |
| 107 | <DIV class="code"><DIV class="codeContent"> |
| 108 | <PRE class="code-java"><SPAN class="code-keyword">package</SPAN> ipojo.example.hello.client; |
| 109 | |
| 110 | <SPAN class="code-keyword">import</SPAN> org.apache.felix.ipojo.annotations.Component; |
| 111 | <SPAN class="code-keyword">import</SPAN> org.apache.felix.ipojo.annotations.Invalidate; |
| 112 | <SPAN class="code-keyword">import</SPAN> org.apache.felix.ipojo.annotations.Requires; |
| 113 | <SPAN class="code-keyword">import</SPAN> org.apache.felix.ipojo.annotations.Validate; |
| 114 | |
| 115 | <SPAN class="code-keyword">import</SPAN> ipojo.example.hello.Hello; |
| 116 | |
| 117 | @Component(name=<SPAN class="code-quote">"AnnotedHelloClient"</SPAN>, immediate=<SPAN class="code-keyword">true</SPAN>) |
| 118 | <SPAN class="code-keyword">public</SPAN> class HelloClient <SPAN class="code-keyword">implements</SPAN> <SPAN class="code-object">Runnable</SPAN> { |
| 119 | |
| 120 | @Requires |
| 121 | <SPAN class="code-keyword">private</SPAN> Hello[] m_hello; <SPAN class="code-comment">// Service Dependency |
| 122 | </SPAN> |
| 123 | <SPAN class="code-keyword">private</SPAN> <SPAN class="code-keyword">final</SPAN> <SPAN class="code-keyword">static</SPAN> <SPAN class="code-object">int</SPAN> DELAY=10000; |
| 124 | <SPAN class="code-keyword">private</SPAN> <SPAN class="code-object">boolean</SPAN> end; |
| 125 | |
| 126 | <SPAN class="code-keyword">public</SPAN> void run() { |
| 127 | <SPAN class="code-keyword">while</SPAN> (!end) { |
| 128 | <SPAN class="code-keyword">try</SPAN> { |
| 129 | invoke(); |
| 130 | <SPAN class="code-object">Thread</SPAN>.sleep(DELAY); |
| 131 | } <SPAN class="code-keyword">catch</SPAN> (InterruptedException ie) { } |
| 132 | /* will recheck end */ |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | <SPAN class="code-keyword">public</SPAN> void invoke() { |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 137 | <SPAN class="code-keyword">for</SPAN> (<SPAN class="code-object">int</SPAN> i = 0; i < m_hello.length; i++) { |
| 138 | <SPAN class="code-object">System</SPAN>.out.println(m_hello[i]. |
| 139 | sayHello(<SPAN class="code-quote">"Clement"</SPAN>)); |
| 140 | } |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | @Validate |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 144 | <SPAN class="code-keyword">public</SPAN> void starting() { |
| 145 | <SPAN class="code-object">Thread</SPAN> T = <SPAN class="code-keyword">new</SPAN> <SPAN class="code-object">Thread</SPAN>(<SPAN class="code-keyword">this</SPAN>); |
| 146 | end = <SPAN class="code-keyword">false</SPAN>; |
| 147 | T.start(); |
| 148 | } |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 149 | |
| 150 | @Invalidate |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 151 | <SPAN class="code-keyword">public</SPAN> void stopping() { |
| 152 | end = <SPAN class="code-keyword">true</SPAN>; |
| 153 | } |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 154 | }</PRE> |
| 155 | </DIV></DIV> |
| 156 | |
| 157 | <H1><A name="HowtouseiPOJOAnnotations-DefinedAnnotations"></A>Defined Annotations</H1> |
| 158 | |
| 159 | <P>This section lists defined annotations and how to use them.</P> |
| 160 | |
| 161 | <H2><A name="HowtouseiPOJOAnnotations-@Component"></A>@Component</H2> |
| 162 | |
| 163 | <P><B>Goal:</B> Defines a component type<BR> |
| 164 | <B>Target:</B> The component implementation class<BR> |
| 165 | <B>Attributes:</B></P> |
| 166 | <UL> |
| 167 | <LI>name : defines the component type name (optional, default = the class name)</LI> |
| 168 | <LI>factory: defines the factory name (optional, default = "false")</LI> |
| 169 | <LI>immediate: defines the component type as immediate (optional, default = "false")</LI> |
| 170 | <LI>architecture: enable the architecture exposition (optional, default = "false")</LI> |
| 171 | <LI>propagation: enable configuration property propagation (on provided services) (optional, default = "false")</LI> |
| 172 | </UL> |
| 173 | |
| 174 | |
| 175 | <H2><A name="HowtouseiPOJOAnnotations-@Provides"></A>@Provides</H2> |
| 176 | |
| 177 | <P><B>Goal:</B> Defines that the component type provide services<BR> |
| 178 | <B>Target:</B> The component implementation class<BR> |
| 179 | <B>Attributes:</B></P> |
| 180 | <UL> |
| 181 | <LI>specifications: defines the provided interface (optional, default = all implemented interfaces)</LI> |
| 182 | <LI>factory: defines the service object creation policy ("SINGLETON" or "SERVICE") (optional, default = "SINGLETON")</LI> |
| 183 | </UL> |
| 184 | |
| 185 | |
| 186 | <P><EM>Note:</EM> "SERVICE" means OSGi service factory.</P> |
| 187 | |
| 188 | <H2><A name="HowtouseiPOJOAnnotations-@Requires"></A>@Requires</H2> |
| 189 | |
| 190 | <P><B>Goal:</B> Defines a service dependency<BR> |
| 191 | <B>Target:</B> Field<BR> |
| 192 | <B>Attributes:</B></P> |
| 193 | <UL> |
| 194 | <LI>Filter: defines the LDAP filter (optional)</LI> |
| 195 | <LI>Optional: defines if the dependency is optional (optional, default = "false")</LI> |
| 196 | <LI>Id: defines the dependency Id (useful to identify bind & unbind methods) (optional, default = field name) (if a dependency with the same id is already created (by a @bind or @unbind annotation), it merges the dependencies).</LI> |
| 197 | <LI>Nullable: enable or disable the Null Object injection when the dependency is optional and no providers are available (optional, default = "true")</LI> |
| 198 | <LI>Default-Implementation: set the Default-Implmentation (optional, by default iPOJO uses a Null object)</LI> |
| 199 | <LI>Policy: defines the binding policy (accepted value : dynamic, static, dynamic-priority) (optional, default = "dynamic")</LI> |
| 200 | <LI>Comparator: defines the comparator to use to sort service references (optional, default = OSGi Service Reference Comparator)</LI> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 201 | <LI>From : defines the specific provider to use [New in the 0.9.0-SNAPSHOT version]</LI> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 202 | </UL> |
| 203 | |
| 204 | |
| 205 | <H2><A name="HowtouseiPOJOAnnotations-@ServiceProperty"></A>@ServiceProperty</H2> |
| 206 | |
| 207 | <P><B>Goal:</B> Defines a service property<BR> |
| 208 | <B>Target:</B> Field or Method<BR> |
| 209 | <B>Attributes:</B></P> |
| 210 | <UL> |
| 211 | <LI>name: property name (optional, default=field name or computed by removing "set" from the method name (for instance setFoo(String ff) will get the Foo name))</LI> |
| 212 | <LI>value: property value (optional, default=no value)</LI> |
| 213 | </UL> |
| 214 | |
| 215 | |
| 216 | <P><EM>note:</EM> if another service property with the same name is defined the method or the field is added to the existing property</P> |
| 217 | |
| 218 | <H2><A name="HowtouseiPOJOAnnotations-@Property"></A>@Property</H2> |
| 219 | |
| 220 | <P><B>Goal:</B> Defines a property<BR> |
| 221 | <B>Target:</B> Field or Method<BR> |
| 222 | <B>Attributes:</B></P> |
| 223 | <UL> |
| 224 | <LI>name: property name (optional, default=field name computed by removing "set" from the method name (for instance setFoo(String ff) will get the Foo name))</LI> |
| 225 | <LI>value: property value (optional, default=no value)</LI> |
| 226 | </UL> |
| 227 | |
| 228 | |
| 229 | <P><EM>note:</EM> if another property with the same name is defined the method or the field is added to the existing property</P> |
| 230 | |
| 231 | <H2><A name="HowtouseiPOJOAnnotations-@Bind"></A>@Bind</H2> |
| 232 | |
| 233 | <P><B>Goal:</B> Defines a bind method<BR> |
| 234 | <B>Target:</B> Method<BR> |
| 235 | <B>Attributes:</B></P> |
| 236 | <UL> |
| 237 | <LI>Id: Dependency Id, if the id is already defines in a "@requires " or "@unbind" annotation, it adds this method as a bind method of the already created dependency. (optional, default= no id, compute an id if the method name begin by "bind" (for instance "bindFoo" will have the "Foo" id))</LI> |
| 238 | <LI>Specification : required dependency (optional)</LI> |
| 239 | <LI>Aggregate : is the dependency an aggregate dependency (optional, default= "false")</LI> |
| 240 | <LI>Optional: is the dependency an optional dependency (optional, default= "false")</LI> |
| 241 | <LI>Filter: dependency LDAP filter (optional)</LI> |
| 242 | <LI>Policy: defines the binding policy (accepted value : dynamic, static, dynamic-priority) (optional, default = "dynamic")</LI> |
| 243 | <LI>Comparator: defines the comparator to use to sort service references (optional, default = OSGi Service Reference Comparator)</LI> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 244 | <LI>From : defines the specific provider to use [New in the 0.9.0-SNAPSHOT version]</LI> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 245 | </UL> |
| 246 | |
| 247 | |
| 248 | <H2><A name="HowtouseiPOJOAnnotations-@Unbind"></A>@Unbind</H2> |
| 249 | |
| 250 | <P><B>Goal:</B> Defines an unbind method<BR> |
| 251 | <B>Target:</B> Method<BR> |
| 252 | <B>Attributes:</B></P> |
| 253 | <UL> |
| 254 | <LI>Id: Dependency Id, if the id is already defines in a "@requires" or "@bind" annotation, it adds this method as an unbind method of the already created dependency. (optional, default= no id, compute an id if the method name begin by "unbind" (for instance "unbindFoo" will have the "Foo" id))</LI> |
| 255 | <LI>Specification : required dependency (optional)</LI> |
| 256 | <LI>Aggregate : is the dependency an aggregate dependency (optional, default= "false")</LI> |
| 257 | <LI>Optional: is the dependency an optional dependency (optional, default= "false")</LI> |
| 258 | <LI>Filter: dependency LDAP filter (optional)</LI> |
| 259 | <LI>Policy: defines the binding policy (accepted value : dynamic, static, dynamic-priority) (optional, default = "dynamic")</LI> |
| 260 | <LI>Comparator: defines the comparator to use to sort service references (optional, default = OSGi Service Reference Comparator)</LI> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 261 | <LI>From : defines the specific provider to use [New in the 0.9.0-SNAPSHOT version]</LI> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 262 | </UL> |
| 263 | |
| 264 | |
| 265 | <H2><A name="HowtouseiPOJOAnnotations-@Validate"></A>@Validate</H2> |
| 266 | |
| 267 | <P><B>Goal:</B> defines a validate lifecycle callback<BR> |
| 268 | <B>Target:</B> method</P> |
| 269 | |
| 270 | <H2><A name="HowtouseiPOJOAnnotations-@Invalidate"></A>@Invalidate</H2> |
| 271 | |
| 272 | <P><B>Goal:</B> defines a validate lifecycle callback<BR> |
| 273 | <B>Target:</B> method</P> |
| 274 | |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 275 | <H2><A name="HowtouseiPOJOAnnotations-TemporalDependencies%28externalhandler%29%5CNewinthe0.9.0SNAPSHOTversion%5C"></A>Temporal Dependencies (external handler) [New in the 0.9.0-SNAPSHOT version]</H2> |
| 276 | |
| 277 | <P>The temporal dependency handler is an external handler. However, it can be used with an annotation defined in the iPOJO annotations jar file. <BR> |
| 278 | The annotation is org.apache.felix.ipojo.handler.temporal.Requires and targets a field. <BR> |
| 279 | <B>Attributes:</B></P> |
| 280 | <UL> |
| 281 | <LI>filter : specify the dependency filter</LI> |
| 282 | <LI>timeout : specify the dependency timeout (optional)</LI> |
| 283 | <LI>onTimeout : specify the onTimeout action (null, nullable, empty-array, default-implementation (specify the class name in this case) (optional).</LI> |
| 284 | </UL> |
| 285 | |
| 286 | |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 287 | <H1><A name="HowtouseiPOJOAnnotations-Metadatafileandannotationmerge"></A>Metadata file and annotation merge</H1> |
| 288 | |
| 289 | <P>It is possible to defines component type both in the metadata file (in XML) and by using annotation. However, if a component type defined by using annotations has the same name than a type define in the XML file, the XML descriptor override the annotation defined type. However, a warning message is launched during the manipulation.</P> |
| 290 | |
| 291 | <H1><A name="HowtouseiPOJOAnnotations-Instancecreation"></A>Instance creation</H1> |
| 292 | |
| 293 | <P>Annotation can only be used to define component type. To define instances, you need to use the XML descriptor. Instance can refer to annotated types by referring to their names.</P> |
| 294 | <DIV class="code"><DIV class="codeContent"> |
| 295 | <PRE class="code-xml"><SPAN class="code-tag"><instance component=<SPAN class="code-quote">"ipojo.example.hello.impl.HelloImpl"</SPAN>/></SPAN> |
| 296 | <SPAN class="code-tag"><instance component=<SPAN class="code-quote">"AnnotedHelloClient"</SPAN>/></SPAN></PRE> |
| 297 | </DIV></DIV> |
| 298 | |
| 299 | <H1><A name="HowtouseiPOJOAnnotations-UsingCustomAnnotations"></A>Using Custom Annotations</H1> |
| 300 | |
| 301 | <P>External handlers can provides their own annotations. Using these annotations just requires to add them to your build path. To external handlers annotations, please refer to the external handler documentation.</P></TD> |
| 302 | <TD class="confluenceTd" valign="top" width="20%"> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 303 | <H6><A name="HowtouseiPOJOAnnotations-Overview"></A><B>Overview</B></H6> |
| 304 | <UL> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 305 | <LI><A href="apache-felix-ipojo.html" title="Apache Felix iPOJO">Home Page</A></LI> |
| 306 | <LI><A href="apache-felix-ipojo-feature-overview.html" title="Apache Felix iPOJO Feature Overview">iPOJO Feature Overview</A></LI> |
| 307 | <LI><A href="download.html" title="Download">Download & Install </A></LI> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 308 | </UL> |
| 309 | |
| 310 | |
| 311 | <H6><A name="HowtouseiPOJOAnnotations-GettingStarted"></A><B>Getting Started</B></H6> |
| 312 | <UL> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 313 | <LI><A href="ipojo-in-10-minutes.html" title="iPOJO in 10 minutes">iPOJO in 10 minutes</A></LI> |
| 314 | <LI><A href="ipojo-hello-word-maven-based-tutorial.html" title="iPOJO Hello Word (Maven-Based) tutorial">iPOJO Hello Word (Maven-Based) tutorial</A></LI> |
| 315 | <LI><A href="ipojo-advanced-tutorial.html" title="iPOJO Advanced Tutorial">iPOJO Advanced Tutorial</A></LI> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 316 | </UL> |
| 317 | |
| 318 | |
| 319 | <H6><A name="HowtouseiPOJOAnnotations-UserGuide"></A><B>User Guide</B></H6> |
| 320 | <UL> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 321 | <LI><A href="describing-components.html" title="Describing components">Describing components (handler list) </A></LI> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 322 | <LI><A href="#" title="How to use iPOJO Annotations">How to use iPOJO Annotations</A></LI> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 323 | <LI><A href="using-xml-schemas.html" title="Using XML Schemas">Using XML Schemas</A></LI> |
| 324 | <LI><A href="ipojo-advanced-topics.html" title="iPOJO Advanced Topics">Advanced Topics</A></LI> |
| 325 | <LI><A href="ipojo-faq.html" title="iPOJO FAQ">FAQ</A></LI> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 326 | </UL> |
| 327 | |
| 328 | |
| 329 | <H6><A name="HowtouseiPOJOAnnotations-Tools"></A><B>Tools</B></H6> |
| 330 | <UL> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 331 | <LI><A href="ipojo-eclipse-plug-in.html" title="iPOJO Eclipse Plug-in">iPOJO Eclipse Plug-in</A></LI> |
| 332 | <LI><A href="ipojo-ant-task.html" title="iPOJO Ant Task">iPOJO Ant Task</A></LI> |
| 333 | <LI><A href="ipojo-maven-plug-in.html" title="iPOJO Maven Plug-in">iPOJO Maven Plug-in</A></LI> |
| 334 | <LI><A href="ipojo-concepts-overview.html" title="iPOJO Concepts Overview">iPOJO concepts overview</A></LI> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 335 | </UL> |
| 336 | |
| 337 | |
| 338 | <H6><A name="HowtouseiPOJOAnnotations-DeveloperGuide"></A><B>Developer Guide</B></H6> |
| 339 | <UL> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 340 | <LI>API: <SPAN class="nobr"><A href="http://people.apache.org/~clement/ipojo/api/0.8/" title="Visit page outside Confluence" rel="nofollow">0.8<SUP><IMG class="rendericon" src="../../cwiki.apache.org/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"></SUP></A></SPAN></LI> |
| 341 | <LI><A href="how-to-write-your-own-handler.html" title="How to write your own handler">How to write your own handler</A></LI> |
| 342 | <LI><A href="how-to-use-ipojo-manipulation-metadata.html" title="How to use iPOJO Manipulation Metadata">How to use iPOJO Manipulation Metadata</A></LI> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 343 | </UL> |
| 344 | |
| 345 | |
| 346 | <H6><A name="HowtouseiPOJOAnnotations-Misc%26Contact"></A><B>Misc & Contact</B></H6> |
| 347 | <UL> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 348 | <LI><A href="apache-felix-ipojo-issuestracker.html" title="apache-felix-ipojo-issuestracker">Issues Tracker</A></LI> |
| 349 | <LI><A href="apache-felix-ipojo-supportedvms.html" title="apache-felix-ipojo-supportedVMs">Supported JVMs</A></LI> |
| 350 | <LI><A href="apache-felix-ipojo-supportedosgi.html" title="apache-felix-ipojo-supportedOSGi">Supported OSGi Implementations</A></LI> |
| 351 | <LI><A href="future-ideas.html" title="Future Ideas">Future Ideas</A></LI> |
| 352 | <LI><A href="contact.html" title="Contact">Contact</A></LI> |
| 353 | <LI><A href="related-works.html" title="Related Works">Related Works</A></LI> |
| 354 | <LI><A href="article-presentations.html" title="Article & Presentations">Article & Presentations</A></LI> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 355 | </UL> |
| 356 | |
| 357 | |
| 358 | <HR> |
| 359 | <DIV class="" align="center"> |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 360 | <P><SPAN class="nobr"><A href="http://cwiki.apache.org/confluence/createrssfeed.action?types=blogpost&statuses=created&statuses=modified&spaces=FELIX&labelString=iPOJO&rssType=atom&maxResults=10&timeSpan=5&publicFeed=true&title=iPOJO%20Atom%20Feed" title="Stay tuned!" rel="nofollow"><IMG src="../../cwiki.apache.org/confluence/images/icons/feed-icon-32x32.png" align="absmiddle" border="0"><SUP><IMG class="rendericon" src="../../cwiki.apache.org/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"></SUP></A></SPAN></P></DIV></TD></TR></TBODY></TABLE> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 361 | </DIV> |
| 362 | </BODY> |
| 363 | |
Clement Escoffier | 130ca57 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 364 | <!-- Mirrored Site: felix.apache.org. File: /site/how-to-use-ipojo-annotations.html. Date: Mon, 13 Oct 2008 06:52:42 GMT --> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 365 | </HTML> |