Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame^] | 2 | <html><head> |
| 3 | |
| 4 | |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 5 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame^] | 6 | <title>Apache Felix - Controller Lifecycle Handler</title> |
| 7 | <link rel="stylesheet" href="controller-lifecycle-handler_files/site.css" type="text/css" media="all"> |
| 8 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| 9 | </head><body> |
| 10 | <div class="title"><div class="logo"><a href="http://felix.apache.org/site/index.html"><img alt="Apache Felix" src="controller-lifecycle-handler_files/logo.png" border="0"></a></div><div class="header"><a href="http://www.apache.org/"><img alt="Apache" src="controller-lifecycle-handler_files/apache.png" border="0"></a></div></div> |
| 11 | <div class="menu"> |
| 12 | <ul> |
| 13 | <li><a href="http://felix.apache.org/site/news.html" title="news">news</a></li> |
| 14 | <li><a href="http://felix.apache.org/site/license.html" title="license">license</a></li> |
| 15 | <li><span class="nobr"><a href="http://felix.apache.org/site/downloads.cgi" title="Visit page outside Confluence" rel="nofollow">downloads<sup><img class="rendericon" src="controller-lifecycle-handler_files/linkext7.gif" alt="" align="absmiddle" border="0" width="7" height="7"></sup></a></span></li> |
| 16 | <li><a href="http://felix.apache.org/site/documentation.html" title="documentation">documentation</a></li> |
| 17 | <li><a href="http://felix.apache.org/site/mailinglists.html" title="mailinglists">mailing lists</a></li> |
| 18 | <li><a href="http://felix.apache.org/site/contributing.html" title="Contributing">contributing</a></li> |
| 19 | <li><span class="nobr"><a href="http://www.apache.org/" title="Visit page outside Confluence" rel="nofollow">asf<sup><img class="rendericon" src="controller-lifecycle-handler_files/linkext7.gif" alt="" align="absmiddle" border="0" width="7" height="7"></sup></a></span></li> |
| 20 | <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="controller-lifecycle-handler_files/linkext7.gif" alt="" align="absmiddle" border="0" width="7" height="7"></sup></a></span></li> |
| 21 | <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="controller-lifecycle-handler_files/linkext7.gif" alt="" align="absmiddle" border="0" width="7" height="7"></sup></a></span> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 22 | <!-- ApacheCon Ad --> |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame^] | 23 | <iframe src="controller-lifecycle-handler_files/button.html" style="border-width: 0pt; float: left;" scrolling="no" width="135" frameborder="0" height="135"></iframe> |
| 24 | <p style="height: 100px;"> |
| 25 | <!-- ApacheCon Ad --> |
| 26 | </p></li></ul> </div> |
| 27 | <div class="main"> |
| 28 | <table class="sectionMacro" border="0" cellpadding="5" cellspacing="0" width="100%"><tbody><tr> |
| 29 | <td class="confluenceTd" valign="top" width="80%"> |
| 30 | <p>The controller lifecycle handler allows a component implementation |
| 31 | to participate to the instance lifecycle. This handler allows you |
| 32 | checking instances configuration (file existence for instance).</p> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 33 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame^] | 34 | <h2><a name="ControllerLifecycleHandler-iPOJOInstanceLifecycle&Lifecyclecontroller"></a>iPOJO Instance Lifecycle & Lifecycle controller</h2> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 35 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame^] | 36 | <p>Once started, iPOJO instances can be either valid or invalid. The |
| 37 | decision comes from handlers. An instance is valid if every plugged |
| 38 | handler are valid. As soos as one handler becomes invalid, the instance |
| 39 | becomes invalid.</p> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 40 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame^] | 41 | <p>The lifecycle controller just monitors a field inside the POJO |
| 42 | class. When this field becomes 'false', the handler becomes invalid. |
| 43 | When the field get the 'true' value, the handler becomes valid.</p> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 44 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame^] | 45 | <h2><a name="ControllerLifecycleHandler-Anexemple"></a>An exemple</h2> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 46 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame^] | 47 | <p>Imagine the following component :</p> |
| 48 | <div class="code"><div class="codeContent"> |
| 49 | <pre class="code-java"><span class="code-keyword">public</span> class LifecycleControllerTest { |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 50 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame^] | 51 | <span class="code-keyword">private</span> <span class="code-object">boolean</span> m_state; |
| 52 | <span class="code-keyword">private</span> <span class="code-object">String</span> m_conf; |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 53 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame^] | 54 | <span class="code-keyword">public</span> void setConf(<span class="code-object">String</span> newConf) { |
| 55 | <span class="code-object">System</span>.out.println(<span class="code-quote">"setConf : "</span> + newConf); |
| 56 | <span class="code-keyword">if</span> (newConf.equals(<span class="code-quote">"foo"</span>)) { |
| 57 | m_state = <span class="code-keyword">true</span>; |
| 58 | } <span class="code-keyword">else</span> { |
| 59 | m_state = <span class="code-keyword">false</span>; |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 60 | } |
| 61 | } |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame^] | 62 | }</pre> |
| 63 | </div></div> |
| 64 | <p>with the following metadata :</p> |
| 65 | <div class="code"><div class="codeContent"> |
| 66 | <pre class="code-xml"><component |
| 67 | classname=<span class="code-quote">"org.apache.felix.ipojo.test.scenarios.component.LifecycleControllerTest"</span> |
| 68 | name=<span class="code-quote">"lcTest"</span> immediate=<span class="code-quote">"true"</span> architecture=<span class="code-quote">"true"</span>> |
| 69 | <span class="code-tag"><controller field=<span class="code-quote">"m_state"</span>/></span> |
| 70 | <span class="code-tag"><properties></span> |
| 71 | <span class="code-tag"><property name=<span class="code-quote">"conf"</span> field=<span class="code-quote">"m_conf"</span> method=<span class="code-quote">"setConf"</span>/></span> |
| 72 | <span class="code-tag"></properties></span> |
| 73 | <span class="code-tag"></component></span></pre> |
| 74 | </div></div> |
| 75 | <p>This component declares the 'm_state' field as a lifecycle controller (<controller/> element)</p> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 76 | |
| 77 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame^] | 78 | <p>The component requires the 'conf' property. iPOJO checks if this |
| 79 | property is inside the pushed configuration, but cannot checks if the |
| 80 | configuration is correct according to the component. When the instance |
| 81 | is created, the setConf method is called with the pushed value. If the |
| 82 | given 'conf' property is "foo" the 'm_state' field (i.e. the |
| 83 | controller) becomes true. Else, the 'm_state' receives the false value. |
| 84 | It means that the lifecycle controller handler becomes invalid and as a |
| 85 | consequence, the instance becomes invalid.</p> |
| 86 | </td> |
| 87 | <td class="confluenceTd" valign="top" width="20%"> |
| 88 | <h6><a name="ControllerLifecycleHandler-Overview"></a><b>Overview</b></h6> |
| 89 | <ul> |
| 90 | <li><a href="http://felix.apache.org/site/apache-felix-ipojo.html" title="Apache Felix iPOJO">Home Page</a></li> |
| 91 | <li><a href="http://felix.apache.org/site/apache-felix-ipojo-feature-overview.html" title="Apache Felix iPOJO Feature Overview">iPOJO Feature Overview</a></li> |
| 92 | <li><a href="http://felix.apache.org/site/download.html" title="Download">Download & Install </a></li> |
| 93 | </ul> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 94 | |
| 95 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame^] | 96 | <h6><a name="ControllerLifecycleHandler-GettingStarted"></a><b>Getting Started</b></h6> |
| 97 | <ul> |
| 98 | <li><a href="http://felix.apache.org/site/ipojo-in-10-minutes.html" title="iPOJO in 10 minutes">iPOJO in 10 minutes</a></li> |
| 99 | <li><a href="http://felix.apache.org/site/how-to-use-ipojo-annotations.html" title="How to use iPOJO Annotations">How to use iPOJO Annotations</a></li> |
| 100 | <li><a href="http://felix.apache.org/site/ipojo-hello-word-maven-based-tutorial.html" title="iPOJO Hello Word (Maven-Based) tutorial">iPOJO Hello Word (Maven-Based) tutorial</a></li> |
| 101 | <li><a href="http://felix.apache.org/site/ipojo-advanced-tutorial.html" title="iPOJO Advanced Tutorial">iPOJO Advanced Tutorial</a></li> |
| 102 | <li><a href="http://felix.apache.org/site/ipojo-composition-tutorial.html" title="iPOJO Composition Tutorial">iPOJO Composition Tutorial</a></li> |
| 103 | </ul> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 104 | |
| 105 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame^] | 106 | <h6><a name="ControllerLifecycleHandler-UserGuide"></a><b>User Guide</b></h6> |
| 107 | <ul> |
| 108 | <li><a href="http://felix.apache.org/site/describing-components.html" title="Describing components">Describing components (handler list) </a></li> |
| 109 | <li><a href="http://felix.apache.org/site/using-xml-schemas.html" title="Using XML Schemas">Using XML Schemas</a></li> |
| 110 | <li><a href="http://felix.apache.org/site/apache-felix-ipojo-testing-components.html" title="apache-felix-ipojo-testing-components">Testing components</a></li> |
| 111 | <li><a href="http://felix.apache.org/site/ipojo-advanced-topics.html" title="iPOJO Advanced Topics">Advanced Topics</a></li> |
| 112 | <li><a href="http://felix.apache.org/site/ipojo-faq.html" title="iPOJO FAQ">FAQ</a></li> |
| 113 | </ul> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 114 | |
| 115 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame^] | 116 | <h6><a name="ControllerLifecycleHandler-Tools"></a><b>Tools</b></h6> |
| 117 | <ul> |
| 118 | <li><a href="http://felix.apache.org/site/ipojo-eclipse-plug-in.html" title="iPOJO Eclipse Plug-in">iPOJO Eclipse Plug-in</a></li> |
| 119 | <li><a href="http://felix.apache.org/site/ipojo-ant-task.html" title="iPOJO Ant Task">iPOJO Ant Task</a></li> |
| 120 | <li><a href="http://felix.apache.org/site/ipojo-maven-plug-in.html" title="iPOJO Maven Plug-in">iPOJO Maven Plug-in</a></li> |
| 121 | <li><a href="http://felix.apache.org/site/apache-felix-ipojo-junit4osgi.html" title="apache-felix-ipojo-junit4osgi">Junit4OSGi</a></li> |
| 122 | <li><a href="http://felix.apache.org/site/ipojo-concepts-overview.html" title="iPOJO Concepts Overview">iPOJO concepts overview</a></li> |
| 123 | </ul> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 124 | |
| 125 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame^] | 126 | <h6><a name="ControllerLifecycleHandler-DeveloperGuide"></a><b>Developer Guide</b></h6> |
| 127 | <ul> |
| 128 | <li>API: <span class="nobr"><a href="http://people.apache.org/%7Eclement/ipojo/api/1.0/" title="Visit page outside Confluence" rel="nofollow">1.0<sup><img class="rendericon" src="controller-lifecycle-handler_files/linkext7.gif" alt="" align="absmiddle" border="0" width="7" height="7"></sup></a></span></li> |
| 129 | <li><a href="http://felix.apache.org/site/how-to-write-your-own-handler.html" title="How to write your own handler">How to write your own handler</a></li> |
| 130 | <li><a href="http://felix.apache.org/site/how-to-use-ipojo-manipulation-metadata.html" title="How to use iPOJO Manipulation Metadata">How to use iPOJO Manipulation Metadata</a></li> |
| 131 | <li><a href="http://felix.apache.org/site/dive-into-the-ipojo-manipulation-depths.html" title="Dive into the iPOJO Manipulation depths">Dive into the iPOJO Manipulation depths</a></li> |
| 132 | </ul> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 133 | |
| 134 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame^] | 135 | <h6><a name="ControllerLifecycleHandler-Misc&Contact"></a><b>Misc & Contact</b></h6> |
| 136 | <ul> |
| 137 | <li><a href="http://felix.apache.org/site/apache-felix-ipojo-issuestracker.html" title="apache-felix-ipojo-issuestracker">Issues Tracker</a></li> |
| 138 | <li><a href="http://felix.apache.org/site/apache-felix-ipojo-supportedvms.html" title="apache-felix-ipojo-supportedVMs">Supported JVMs</a></li> |
| 139 | <li><a href="http://felix.apache.org/site/apache-felix-ipojo-supportedosgi.html" title="apache-felix-ipojo-supportedOSGi">Supported OSGi Implementations</a></li> |
| 140 | <li><span class="nobr"><a href="http://ipojo-dark-side.blogspot.com/" title="Visit page outside Confluence" rel="nofollow">iPOJO's Dark Side Blog<sup><img class="rendericon" src="controller-lifecycle-handler_files/linkext7.gif" alt="" align="absmiddle" border="0" width="7" height="7"></sup></a></span></li> |
| 141 | <li><a href="http://felix.apache.org/site/future-ideas.html" title="Future Ideas">Future Ideas</a></li> |
| 142 | <li><a href="http://felix.apache.org/site/contact.html" title="Contact">Contact</a></li> |
| 143 | <li><a href="http://felix.apache.org/site/related-works.html" title="Related Works">Related Works</a></li> |
| 144 | <li><a href="http://felix.apache.org/site/article-presentations.html" title="Article & Presentations">Article & Presentations</a></li> |
| 145 | </ul> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 146 | |
| 147 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame^] | 148 | <hr> |
| 149 | <div class="" align="center"> |
| 150 | <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="controller-lifecycle-handler_files/feed-icon-32x32.png" align="absmiddle" border="0"><sup><img class="rendericon" src="controller-lifecycle-handler_files/linkext7.gif" alt="" align="absmiddle" border="0" width="7" height="7"></sup></a></span></p></div> |
Clement Escoffier | 5025402 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 151 | |
Clement Escoffier | 3e0db1e | 2009-01-15 15:35:17 +0000 | [diff] [blame^] | 152 | <script type="text/javascript"> |
| 153 | var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); |
| 154 | document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); |
| 155 | </script><script src="controller-lifecycle-handler_files/ga.js" type="text/javascript"></script> |
| 156 | <script type="text/javascript"> |
| 157 | var pageTracker = _gat._getTracker("UA-1518442-4"); |
| 158 | pageTracker._trackPageview(); |
| 159 | </script> |
| 160 | </td></tr></tbody></table> |
| 161 | </div> |
| 162 | </body></html> |