The temporal dependency handlerRegular 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. First of all, you need to configure the component type to use the handler such as: <iPOJO xmlns:temporal="org.apache.felix.ipojo.handler.temporal"> <component className="org.apache.felix.ipojo.example.Temporal"> <!-- Temporal dependency configuration --> <temporal:requires field="mytemporal"/> <provides/> </component> </iPOJO> Notice that, this handler is an external handler. So, it uses the "org.apache.felix.ipojo.handler.temporal" namespace. The handler has only one mandatory attributes:
The handler supports on specific optional attributes:
The attributes from "regular" dependencies are also supported (like filter). When a timeout occurs, you can specify what the handler must do. By default, it throws a runtime exception. However, four others actions can be set in the 'onTimeout' attribute.
<iPOJO xmlns:temporal="org.apache.felix.ipojo.handler.temporal"> <component className="org.apache.felix.ipojo.example.Temporal"> <!-- Temporal dependency configuration --> <temporal:requires field="fs" timeout="300" ontimeout="nullable"/> <provides/> </component> </iPOJO> Collection support [1.1.0-SNAPSHOT version ]Temporal dependencies can also be injected inside Collection. To achieve this, the 'specification' attribute must indicates the looked specification, and the field must be a Collection. <iPOJO xmlns:temporal="org.apache.felix.ipojo.handler.temporal"> <component className="org.apache.felix.ipojo.example.Temporal"> <!-- Temporal dependency configuration --> <temporal:requires field="mycollection" specification="my.service.specification"/> <provides/> </component> </iPOJO> Proxy support [1.1.0-SNAPSHOT version ]Temporal dependencies can also be injected as proxies. So it is possible to give the temporal dependency to helper object. To set a temporal dependency as a proxy, just add the proxy attribute as follows: <iPOJO xmlns:temporal="org.apache.felix.ipojo.handler.temporal"> <component className="org.apache.felix.ipojo.example.Temporal"> <!-- Temporal dependencies configuration --> <temporal:requires proxy="true" field="fs"/> <temporal:requires proxy="true" field="mycollection" specification="my.service.specification"/> <provides/> </component> </iPOJO> By default, proxies are disabled. DownloadThe handler is available on the download page. |
OverviewGetting Started
User GuideToolsDeveloper Guide
Misc & Contact
|