blob: 4bce26befe9ff879d644cbf7bbca4b9d278e1c74 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_67) on Tue Mar 24 21:21:23 CET 2015 -->
<title>ServiceDependency</title>
<meta name="date" content="2015-03-24">
<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="ServiceDependency";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../org/apache/felix/dm/annotation/api/package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../../org/apache/felix/dm/annotation/api/ResourceDependency.html" title="annotation in org.apache.felix.dm.annotation.api"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../../../org/apache/felix/dm/annotation/api/Start.html" title="annotation in org.apache.felix.dm.annotation.api"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../../index.html?org/apache/felix/dm/annotation/api/ServiceDependency.html" target="_top">Frames</a></li>
<li><a href="ServiceDependency.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Required&nbsp;|&nbsp;</li>
<li><a href="#annotation_type_optional_element_summary">Optional</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#annotation_type_element_detail">Element</a></li>
</ul>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.apache.felix.dm.annotation.api</div>
<h2 title="Annotation Type ServiceDependency" class="title">Annotation Type ServiceDependency</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>@Retention(value=CLASS)
@Target(value={METHOD,FIELD})
public @interface <span class="strong">ServiceDependency</span></pre>
<div class="block">Annotates a method or a field for injecting a Service Dependency. When applied on a class
field, optional unavailable dependencies are injected with a NullObject.
<h3>Usage Examples</h3>
Here, the MyComponent component is injected with a dependency over a "MyDependency" service
<blockquote><pre>
&#64;Component
class MyComponent {
&#64;ServiceDependency(timeout=15000)
MyDependency dependency;
</pre></blockquote></div>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- =========== ANNOTATION TYPE OPTIONAL MEMBER SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="annotation_type_optional_element_summary">
<!-- -->
</a>
<h3>Optional Element Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Optional Element Summary table, listing optional elements, and an explanation">
<caption><span>Optional Elements</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Optional Element and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/felix/dm/annotation/api/ServiceDependency.html#added()">added</a></strong></code>
<div class="block">The callback method to be invoked when the service is available.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/felix/dm/annotation/api/ServiceDependency.html#changed()">changed</a></strong></code>
<div class="block">The callback method to be invoked when the service properties have changed.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>java.lang.Class&lt;?&gt;</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/felix/dm/annotation/api/ServiceDependency.html#defaultImpl()">defaultImpl</a></strong></code>
<div class="block">The class for the default implementation, if the dependency is not available.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/felix/dm/annotation/api/ServiceDependency.html#filter()">filter</a></strong></code>
<div class="block">The Service dependency OSGi filter.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/felix/dm/annotation/api/ServiceDependency.html#name()">name</a></strong></code>
<div class="block">The name used when dynamically configuring this dependency from the init method.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/felix/dm/annotation/api/ServiceDependency.html#propagate()">propagate</a></strong></code>
<div class="block">Returns true if the dependency service properties must be published along with the service.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>java.lang.String</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/felix/dm/annotation/api/ServiceDependency.html#removed()">removed</a></strong></code>
<div class="block">The callback method to invoke when the service is lost.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/felix/dm/annotation/api/ServiceDependency.html#required()">required</a></strong></code>
<div class="block">Whether the Service dependency is required or not.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>java.lang.Class&lt;?&gt;</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/felix/dm/annotation/api/ServiceDependency.html#service()">service</a></strong></code>
<div class="block">The type if the service this dependency is applying on.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>long</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/felix/dm/annotation/api/ServiceDependency.html#timeout()">timeout</a></strong></code>
<div class="block">The max time in millis to wait for the dependency availability.</div>
</td>
</tr>
</table>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ ANNOTATION TYPE MEMBER DETAIL =========== -->
<ul class="blockList">
<li class="blockList"><a name="annotation_type_element_detail">
<!-- -->
</a>
<h3>Element Detail</h3>
<a name="service()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>service</h4>
<pre>public abstract&nbsp;java.lang.Class&lt;?&gt;&nbsp;service</pre>
<div class="block">The type if the service this dependency is applying on. By default, the method parameter
(or the class field) is used as the type.</div>
<dl>
<dt>Default:</dt>
<dd>java.lang.Object.class</dd>
</dl>
</li>
</ul>
<a name="filter()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>filter</h4>
<pre>public abstract&nbsp;java.lang.String&nbsp;filter</pre>
<div class="block">The Service dependency OSGi filter.</div>
<dl>
<dt>Default:</dt>
<dd>""</dd>
</dl>
</li>
</ul>
<a name="defaultImpl()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>defaultImpl</h4>
<pre>public abstract&nbsp;java.lang.Class&lt;?&gt;&nbsp;defaultImpl</pre>
<div class="block">The class for the default implementation, if the dependency is not available.</div>
<dl>
<dt>Default:</dt>
<dd>java.lang.Object.class</dd>
</dl>
</li>
</ul>
<a name="required()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>required</h4>
<pre>public abstract&nbsp;boolean&nbsp;required</pre>
<div class="block">Whether the Service dependency is required or not.</div>
<dl>
<dt>Default:</dt>
<dd>true</dd>
</dl>
</li>
</ul>
<a name="added()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>added</h4>
<pre>public abstract&nbsp;java.lang.String&nbsp;added</pre>
<div class="block">The callback method to be invoked when the service is available. This attribute is only meaningful when
the annotation is applied on a class field.</div>
<dl>
<dt>Default:</dt>
<dd>""</dd>
</dl>
</li>
</ul>
<a name="changed()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>changed</h4>
<pre>public abstract&nbsp;java.lang.String&nbsp;changed</pre>
<div class="block">The callback method to be invoked when the service properties have changed.</div>
<dl>
<dt>Default:</dt>
<dd>""</dd>
</dl>
</li>
</ul>
<a name="removed()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>removed</h4>
<pre>public abstract&nbsp;java.lang.String&nbsp;removed</pre>
<div class="block">The callback method to invoke when the service is lost.</div>
<dl>
<dt>Default:</dt>
<dd>""</dd>
</dl>
</li>
</ul>
<a name="timeout()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>timeout</h4>
<pre>public abstract&nbsp;long&nbsp;timeout</pre>
<div class="block">The max time in millis to wait for the dependency availability.
Specifying a positive number allow to block the caller thread between service updates. Only
useful for required stateless dependencies that can be replaced transparently.
A Dynamic Proxy is used to wrap the actual service dependency (which must be an interface).
When the dependency goes away, an attempt is made to replace it with another one which satisfies
the service dependency criteria. If no service replacement is available, then any method invocation
(through the dynamic proxy) will block during a configurable timeout. On timeout, an unchecked
<code>IllegalStateException</code> exception is raised (but the service is not deactivated).<p>
Notice that the changed/removed callbacks are not used when the timeout parameter is > -1.
<p>
-1 means no timeout at all (default). 0 means that invocation on a missing service will fail
immediately. A positive number represents the max timeout in millis to wait for the service availability.
<p> Sample Code:<p>
<blockquote><pre>
&#64;Component
class MyServer implements Runnable {
&#64;ServiceDependency(timeout=15000)
MyDependency dependency;.
&#64;Start
void start() {
(new Thread(this)).start();
}
public void run() {
try {
dependency.doWork();
} catch (IllegalStateException e) {
t.printStackTrace();
}
}
</pre></blockquote></div>
<dl>
<dt>Default:</dt>
<dd>-1L</dd>
</dl>
</li>
</ul>
<a name="name()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>name</h4>
<pre>public abstract&nbsp;java.lang.String&nbsp;name</pre>
<div class="block">The name used when dynamically configuring this dependency from the init method.
Specifying this attribute allows to dynamically configure the dependency
<code>filter</code> and <code>required</code> flag from the Service's init method.
All unnamed dependencies will be injected before the init() method; so from the init() method, you can
then pick up whatever information needed from already injected (unnamed) dependencies, and configure dynamically
your named dependencies, which will then be calculated once the init() method returns.
<p> See <a href="../../../../../../org/apache/felix/dm/annotation/api/Init.html" title="annotation in org.apache.felix.dm.annotation.api"><code>Init</code></a> annotation for an example usage of a dependency dynamically configured from the init method.</div>
<dl>
<dt>Default:</dt>
<dd>""</dd>
</dl>
</li>
</ul>
<a name="propagate()">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>propagate</h4>
<pre>public abstract&nbsp;boolean&nbsp;propagate</pre>
<div class="block">Returns true if the dependency service properties must be published along with the service.
Any additional service properties specified directly are merged with these.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>true if dependency service properties must be published along with the service, false if not.</dd></dl>
<dl>
<dt>Default:</dt>
<dd>false</dd>
</dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../org/apache/felix/dm/annotation/api/package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../../org/apache/felix/dm/annotation/api/ResourceDependency.html" title="annotation in org.apache.felix.dm.annotation.api"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../../../org/apache/felix/dm/annotation/api/Start.html" title="annotation in org.apache.felix.dm.annotation.api"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../../index.html?org/apache/felix/dm/annotation/api/ServiceDependency.html" target="_top">Frames</a></li>
<li><a href="ServiceDependency.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Required&nbsp;|&nbsp;</li>
<li><a href="#annotation_type_optional_element_summary">Optional</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#annotation_type_element_detail">Element</a></li>
</ul>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>