Clement Escoffier | 3575f07 | 2008-06-06 12:12:01 +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 | |
| 5 | |
| 6 | <HEAD> |
| 7 | <TITLE>Apache Felix - Temporal Service Dependency</TITLE> |
| 8 | <LINK rel="stylesheet" href="http://felix.apache.org/site/media.data/site.css" type="text/css" media="all"> |
| 9 | <META http-equiv="Content-Type" content="text/html;charset=UTF-8"> |
| 10 | </HEAD> |
| 11 | <BODY> |
| 12 | <DIV class="title"><DIV class="logo"><A href="http://felix.apache.org/site/index.html"><IMG border="0" alt="Apache Felix" src="http://felix.apache.org/site/media.data/logo.png"></A></DIV><DIV class="header"><A href="http://www.apache.org/"><IMG border="0" alt="Apache" src="http://felix.apache.org/site/media.data/apache.png"></A></DIV></DIV> |
| 13 | <DIV class="menu"> |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | > |
| 20 | <LI><A href="http://felix.apache.org/site/news.html" title="news">news</A></LI> |
| 21 | <LI><A href="http://felix.apache.org/site/license.html" title="license">license</A></LI> |
| 22 | <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="http://cwiki.apache.org/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"></SUP></A></SPAN></LI> |
| 23 | <LI><A href="http://felix.apache.org/site/documentation.html" title="documentation">documentation</A></LI> |
| 24 | <LI><A href="http://felix.apache.org/site/mailinglists.html" title="mailinglists">mailing lists</A></LI> |
| 25 | <LI><A href="http://felix.apache.org/site/contributing.html" title="Contributing">contributing</A></LI> |
| 26 | <LI><SPAN class="nobr"><A href="http://www.apache.org/" title="Visit page outside Confluence" rel="nofollow">asf<SUP><IMG class="rendericon" src="http://cwiki.apache.org/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"></SUP></A></SPAN></LI> |
| 27 | <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="http://cwiki.apache.org/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"></SUP></A></SPAN></LI> |
| 28 | <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="http://cwiki.apache.org/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"></SUP></A></SPAN> |
| 29 | <!-- ApacheCon Ad --> |
| 30 | <IFRAME src="http://www.apache.org/ads/button.html" style="border-width:0; float: left" frameborder="0" scrolling="no" width="135" height="135"></IFRAME> |
| 31 | <P style="height: 100px"> |
| 32 | <!-- ApacheCon Ad --></LI> |
| 33 | < |
| 34 | </DIV> |
| 35 | <DIV class="main"> |
| 36 | <TABLE class="sectionMacro" border="0" cellpadding="5" cellspacing="0" width="100%"><TBODY><TR> |
| 37 | <TD class="confluenceTd" valign="top" width="80%"> |
| 38 | <H1><A name="TemporalServiceDependency-Thetemporaldependencyhandler"></A>The temporal dependency handler</H1> |
| 39 | <P>Regular service dependencies participate to the instance lifecycle. Moreover, the injected service object is either available or not available. A temporal dependency handler is a little different and provides a different resolution pattern. Indeed, the temporal dependency does not invalidate the instance. Moreover, if not available, the temporal dependency waits (and so blocks the current thread) for a provider. Of course, the maximum waiting time can be specified. If a timeout occurs, the handler throws a runtime exception.</P> |
| 40 | <H2><A name="TemporalServiceDependency-Usingthehandler"></A>Using the handler</H2> |
| 41 | <P>First of all, you need to configure the component type to use the handler such as:</P> |
| 42 | <DIV class="code"><DIV class="codeContent"> |
| 43 | <PRE class="code-xml"><SPAN class="code-tag"><iPOJO <SPAN class="code-keyword">xmlns:temporal</SPAN>=<SPAN class="code-quote">"org.apache.felix.ipojo.handler.temporal"</SPAN>></SPAN> |
| 44 | <component |
| 45 | className=<SPAN class="code-quote">"org.apache.felix.ipojo.example.Temporal"</SPAN>> |
| 46 | |
| 47 | <SPAN class="code-tag"><!-—Temporal dependency configuration --></SPAN> |
| 48 | <temporal:requires field=<SPAN class="code-quote">"mytemporal"</SPAN> |
| 49 | /> |
| 50 | <SPAN class="code-tag"><provides /></SPAN> |
| 51 | <SPAN class="code-tag"></component></SPAN> |
| 52 | <SPAN class="code-tag"></iPOJO></SPAN></PRE> |
| 53 | </DIV></DIV> |
| 54 | <P>Notice that, this handler is an external handler. So, it uses the "org.apache.felix.ipojo.handler.temporal" namespace.<BR> |
| 55 | Once described, you can implement your component. The specified field will be mapped to the temporal dependency. As for regular field injection, aggregation, targeted service specification (i.e. interface) are discovered automatically. Filter, comparator and binding policy are also supported. However, the optional attribute is not supported. In fact, this attribute is meaningless in the case of a temporal dependency.<BR> |
| 56 | Using the field in your code will try to find a matching service provider. If a provider is available, the field receives the service object immediately. Else, the thread is stopped and waits for a provider. The default wait time is 3s (you can also specify this time). If no provider is available after this time, the thread throws a RuntimeException. If a provider becomes available during this time, the field receives immediately the value and the execution can continue.</P> |
| 57 | <H2><A name="TemporalServiceDependency-Configuration"></A>Configuration</H2> |
| 58 | <P>The handler has only one mandatory attributes:</P> |
| 59 | <UL> |
| 60 | <LI>Field: the implementation field supporting the dependency</LI> |
| 61 | </UL> |
| 62 | |
| 63 | |
| 64 | <P>The handler supports on specific optional attributes:</P> |
| 65 | <UL> |
| 66 | <LI>Timeout: the maximum time waited in order to find a provider (default: 3s)</LI> |
| 67 | </UL> |
| 68 | |
| 69 | |
| 70 | <P>The attribute form regular dependencies are also supported.</P> |
| 71 | <H2><A name="TemporalServiceDependency-Download"></A>Download</H2> |
| 72 | <P>The handler is available on the <A href="http://felix.apache.org/site/download.html" title="Download">download</A> page.<BR> |
| 73 | Sources are available on the Felix trunk at the following location: <SPAN class="nobr"><A href="https://svn.apache.org/repos/asf/felix/trunk/ipojo/temporal.dependency.handler" title="Visit page outside Confluence" rel="nofollow">https://svn.apache.org/repos/asf/felix/trunk/ipojo/temporal.dependency.handler<SUP><IMG class="rendericon" src="http://cwiki.apache.org/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"></SUP></A></SPAN></P></TD> |
| 74 | <TD class="confluenceTd" valign="top" width="20%"> |
| 75 | <H6><A name="TemporalServiceDependency-Overview"></A><B>Overview</B></H6> |
| 76 | <UL> |
| 77 | <LI><A href="http://felix.apache.org/site/apache-felix-ipojo.html" title="Apache Felix iPOJO">Home Page</A></LI> |
| 78 | <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> |
| 79 | <LI><A href="http://felix.apache.org/site/download.html" title="Download">Download & Install </A></LI> |
| 80 | </UL> |
| 81 | |
| 82 | |
| 83 | <H6><A name="TemporalServiceDependency-GettingStarted"></A><B>Getting Started</B></H6> |
| 84 | <UL> |
| 85 | <LI><A href="http://felix.apache.org/site/ipojo-in-10-minutes.html" title="iPOJO in 10 minutes">iPOJO in 10 minutes</A></LI> |
| 86 | <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> |
| 87 | <LI><A href="http://felix.apache.org/site/ipojo-advanced-tutorial.html" title="iPOJO Advanced Tutorial">iPOJO Advanced Tutorial</A></LI> |
| 88 | </UL> |
| 89 | |
| 90 | |
| 91 | <H6><A name="TemporalServiceDependency-UserGuide"></A><B>User Guide</B></H6> |
| 92 | <UL> |
| 93 | <LI><A href="http://felix.apache.org/site/describing-components.html" title="Describing components">Describing components</A></LI> |
| 94 | <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> |
| 95 | <LI><A href="http://felix.apache.org/site/ipojo-advanced-topics.html" title="iPOJO Advanced Topics">Advanced Topics</A></LI> |
| 96 | <LI><A href="http://felix.apache.org/site/ipojo-faq.html" title="iPOJO FAQ">FAQ</A></LI> |
| 97 | </UL> |
| 98 | |
| 99 | |
| 100 | <H6><A name="TemporalServiceDependency-Tools"></A><B>Tools</B></H6> |
| 101 | <UL> |
| 102 | <LI><A href="http://felix.apache.org/site/ipojo-eclipse-plug-in.html" title="iPOJO Eclipse Plug-in">iPOJO Eclipse Plug-in</A></LI> |
| 103 | <LI><A href="http://felix.apache.org/site/ipojo-ant-task.html" title="iPOJO Ant Task">iPOJO Ant Task</A></LI> |
| 104 | <LI><A href="http://felix.apache.org/site/ipojo-maven-plug-in.html" title="iPOJO Maven Plug-in">iPOJO Maven Plug-in</A></LI> |
| 105 | <LI><A href="http://felix.apache.org/site/ipojo-concepts-overview.html" title="iPOJO Concepts Overview">iPOJO concepts overview</A></LI> |
| 106 | </UL> |
| 107 | |
| 108 | |
| 109 | <H6><A name="TemporalServiceDependency-DeveloperGuide"></A><B>Developer Guide</B></H6> |
| 110 | <UL> |
| 111 | <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> |
| 112 | <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> |
| 113 | </UL> |
| 114 | |
| 115 | |
| 116 | <H6><A name="TemporalServiceDependency-Misc%26Contact"></A><B>Misc & Contact</B></H6> |
| 117 | <UL> |
| 118 | <LI><A href="http://felix.apache.org/site/apache-felix-ipojo-issuestracker.html" title="apache-felix-ipojo-issuestracker">Issues Tracker</A></LI> |
| 119 | <LI><A href="http://felix.apache.org/site/apache-felix-ipojo-supportedvms.html" title="apache-felix-ipojo-supportedVMs">Supported JVMs</A></LI> |
| 120 | <LI><A href="http://felix.apache.org/site/apache-felix-ipojo-supportedosgi.html" title="apache-felix-ipojo-supportedOSGi">Supported OSGi Implementations</A></LI> |
| 121 | <LI><A href="http://felix.apache.org/site/future-ideas.html" title="Future Ideas">Future Ideas</A></LI> |
| 122 | <LI><A href="http://felix.apache.org/site/contact.html" title="Contact">Contact</A></LI> |
| 123 | <LI><A href="http://felix.apache.org/site/related-works.html" title="Related Works">Related Works</A></LI> |
| 124 | <LI><A href="http://felix.apache.org/site/article-presentations.html" title="Article & Presentations">Article & Presentations</A></LI> |
| 125 | </UL> |
| 126 | |
| 127 | |
| 128 | <HR> |
| 129 | <DIV class="" align="center"> |
| 130 | <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="http://cwiki.apache.org/confluence/images/icons/feed-icon-32x32.png" align="absmiddle" border="0"><SUP><IMG class="rendericon" src="http://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> |
| 131 | </DIV> |
| 132 | </BODY> |
| 133 | |
| 134 | |
| 135 | </HTML> |