Clement Escoffier | 6b928e9 | 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 | 8350751 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 5 | <!-- Mirrored Site: felix.apache.org. File: /site/controller-lifecycle-handler.html. Date: Mon, 13 Oct 2008 06:53:07 GMT --> |
Clement Escoffier | 6b928e9 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 6 | <HEAD> |
| 7 | <TITLE>Apache Felix - Controller Lifecycle Handler</TITLE> |
Clement Escoffier | 8350751 | 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 | 6b928e9 | 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 | 8350751 | 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 | 6b928e9 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 13 | <DIV class="menu"> |
| 14 | <UL> |
Clement Escoffier | 8350751 | 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 | 6b928e9 | 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 | 8350751 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 29 | </DIV> |
Clement Escoffier | 6b928e9 | 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>The controller lifecycle handler allows a component implementation to participate to the instance lifecycle. This handler allows you checking instances configuration (file existence for instance).</P> |
| 34 | |
| 35 | <H2><A name="ControllerLifecycleHandler-iPOJOInstanceLifecycle%26Lifecyclecontroller"></A>iPOJO Instance Lifecycle & Lifecycle controller</H2> |
| 36 | |
| 37 | <P>Once started, iPOJO instances can be either valid or invalid. The decision comes from handlers. An instance is valid if every plugged handler are valid. As soos as one handler becomes invalid, the instance becomes invalid.</P> |
| 38 | |
| 39 | <P>The lifecycle controller just monitors a field inside the POJO class. When this field becomes 'false', the handler becomes invalid. When the field get the 'true' value, the handler becomes valid.</P> |
| 40 | |
| 41 | <H2><A name="ControllerLifecycleHandler-Anexemple"></A>An exemple</H2> |
| 42 | |
| 43 | <P>Imagine the following component :</P> |
| 44 | <DIV class="code"><DIV class="codeContent"> |
| 45 | <PRE class="code-java"><SPAN class="code-keyword">public</SPAN> class LifecycleControllerTest { |
| 46 | |
| 47 | <SPAN class="code-keyword">private</SPAN> <SPAN class="code-object">boolean</SPAN> m_state; |
| 48 | <SPAN class="code-keyword">private</SPAN> <SPAN class="code-object">String</SPAN> m_conf; |
| 49 | |
| 50 | <SPAN class="code-keyword">public</SPAN> void setConf(<SPAN class="code-object">String</SPAN> newConf) { |
| 51 | <SPAN class="code-object">System</SPAN>.out.println(<SPAN class="code-quote">"setConf : "</SPAN> + newConf); |
| 52 | <SPAN class="code-keyword">if</SPAN> (newConf.equals(<SPAN class="code-quote">"foo"</SPAN>)) { |
| 53 | m_state = <SPAN class="code-keyword">true</SPAN>; |
| 54 | } <SPAN class="code-keyword">else</SPAN> { |
| 55 | m_state = <SPAN class="code-keyword">false</SPAN>; |
| 56 | } |
| 57 | } |
| 58 | }</PRE> |
| 59 | </DIV></DIV> |
| 60 | <P>with the following metadata :</P> |
| 61 | <DIV class="code"><DIV class="codeContent"> |
Clement Escoffier | 8350751 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 62 | <PRE class="code-xml"><component |
| 63 | classname=<SPAN class="code-quote">"org.apache.felix.ipojo.test.scenarios.component.LifecycleControllerTest"</SPAN> |
| 64 | name=<SPAN class="code-quote">"lcTest"</SPAN> immediate=<SPAN class="code-quote">"true"</SPAN> architecture=<SPAN class="code-quote">"true"</SPAN>> |
Clement Escoffier | 6b928e9 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 65 | <SPAN class="code-tag"><controller field=<SPAN class="code-quote">"m_state"</SPAN>/></SPAN> |
| 66 | <SPAN class="code-tag"><properties></SPAN> |
| 67 | <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> |
| 68 | <SPAN class="code-tag"></properties></SPAN> |
| 69 | <SPAN class="code-tag"></component></SPAN></PRE> |
| 70 | </DIV></DIV> |
| 71 | <P>This component declares the 'm_state' field as a lifecycle controller (<controller/> element)</P> |
| 72 | |
| 73 | |
| 74 | <P>The component requires the 'conf' property. iPOJO checks if this property is inside the pushed configuration, but cannot checks if the configuration is correct according to the component. When the instance is created, the setConf method is called with the pushed value. If the given 'conf' property is "foo" the 'm_state' field (i.e. the controller) becomes true. Else, the 'm_state' receives the false value. It means that the lifecycle controller handler becomes invalid and as a consequence, the instance becomes invalid.</P> |
| 75 | </TD> |
| 76 | <TD class="confluenceTd" valign="top" width="20%"> |
Clement Escoffier | 6b928e9 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 77 | <H6><A name="ControllerLifecycleHandler-Overview"></A><B>Overview</B></H6> |
| 78 | <UL> |
Clement Escoffier | 8350751 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 79 | <LI><A href="apache-felix-ipojo.html" title="Apache Felix iPOJO">Home Page</A></LI> |
| 80 | <LI><A href="apache-felix-ipojo-feature-overview.html" title="Apache Felix iPOJO Feature Overview">iPOJO Feature Overview</A></LI> |
| 81 | <LI><A href="download.html" title="Download">Download & Install </A></LI> |
Clement Escoffier | 6b928e9 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 82 | </UL> |
| 83 | |
| 84 | |
| 85 | <H6><A name="ControllerLifecycleHandler-GettingStarted"></A><B>Getting Started</B></H6> |
| 86 | <UL> |
Clement Escoffier | 8350751 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 87 | <LI><A href="ipojo-in-10-minutes.html" title="iPOJO in 10 minutes">iPOJO in 10 minutes</A></LI> |
| 88 | <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> |
| 89 | <LI><A href="ipojo-advanced-tutorial.html" title="iPOJO Advanced Tutorial">iPOJO Advanced Tutorial</A></LI> |
Clement Escoffier | 6b928e9 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 90 | </UL> |
| 91 | |
| 92 | |
| 93 | <H6><A name="ControllerLifecycleHandler-UserGuide"></A><B>User Guide</B></H6> |
| 94 | <UL> |
Clement Escoffier | 8350751 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 95 | <LI><A href="describing-components.html" title="Describing components">Describing components (handler list) </A></LI> |
| 96 | <LI><A href="how-to-use-ipojo-annotations.html" title="How to use iPOJO Annotations">How to use iPOJO Annotations</A></LI> |
| 97 | <LI><A href="using-xml-schemas.html" title="Using XML Schemas">Using XML Schemas</A></LI> |
| 98 | <LI><A href="ipojo-advanced-topics.html" title="iPOJO Advanced Topics">Advanced Topics</A></LI> |
| 99 | <LI><A href="ipojo-faq.html" title="iPOJO FAQ">FAQ</A></LI> |
Clement Escoffier | 6b928e9 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 100 | </UL> |
| 101 | |
| 102 | |
| 103 | <H6><A name="ControllerLifecycleHandler-Tools"></A><B>Tools</B></H6> |
| 104 | <UL> |
Clement Escoffier | 8350751 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 105 | <LI><A href="ipojo-eclipse-plug-in.html" title="iPOJO Eclipse Plug-in">iPOJO Eclipse Plug-in</A></LI> |
| 106 | <LI><A href="ipojo-ant-task.html" title="iPOJO Ant Task">iPOJO Ant Task</A></LI> |
| 107 | <LI><A href="ipojo-maven-plug-in.html" title="iPOJO Maven Plug-in">iPOJO Maven Plug-in</A></LI> |
| 108 | <LI><A href="ipojo-concepts-overview.html" title="iPOJO Concepts Overview">iPOJO concepts overview</A></LI> |
Clement Escoffier | 6b928e9 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 109 | </UL> |
| 110 | |
| 111 | |
| 112 | <H6><A name="ControllerLifecycleHandler-DeveloperGuide"></A><B>Developer Guide</B></H6> |
| 113 | <UL> |
Clement Escoffier | 8350751 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 114 | <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> |
| 115 | <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> |
| 116 | <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 | 6b928e9 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 117 | </UL> |
| 118 | |
| 119 | |
| 120 | <H6><A name="ControllerLifecycleHandler-Misc%26Contact"></A><B>Misc & Contact</B></H6> |
| 121 | <UL> |
Clement Escoffier | 8350751 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 122 | <LI><A href="apache-felix-ipojo-issuestracker.html" title="apache-felix-ipojo-issuestracker">Issues Tracker</A></LI> |
| 123 | <LI><A href="apache-felix-ipojo-supportedvms.html" title="apache-felix-ipojo-supportedVMs">Supported JVMs</A></LI> |
| 124 | <LI><A href="apache-felix-ipojo-supportedosgi.html" title="apache-felix-ipojo-supportedOSGi">Supported OSGi Implementations</A></LI> |
| 125 | <LI><A href="future-ideas.html" title="Future Ideas">Future Ideas</A></LI> |
| 126 | <LI><A href="contact.html" title="Contact">Contact</A></LI> |
| 127 | <LI><A href="related-works.html" title="Related Works">Related Works</A></LI> |
| 128 | <LI><A href="article-presentations.html" title="Article & Presentations">Article & Presentations</A></LI> |
Clement Escoffier | 6b928e9 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 129 | </UL> |
| 130 | |
| 131 | |
| 132 | <HR> |
| 133 | <DIV class="" align="center"> |
Clement Escoffier | 8350751 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 134 | <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 | 6b928e9 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 135 | </DIV> |
| 136 | </BODY> |
| 137 | |
Clement Escoffier | 8350751 | 2008-10-13 07:33:03 +0000 | [diff] [blame] | 138 | <!-- Mirrored Site: felix.apache.org. File: /site/controller-lifecycle-handler.html. Date: Mon, 13 Oct 2008 06:53:07 GMT --> |
Clement Escoffier | 6b928e9 | 2008-05-16 20:33:54 +0000 | [diff] [blame] | 139 | </HTML> |