| <!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 (1.8.0_172) on Mon Oct 22 18:37:56 CEST 2018 --> |
| <title>Component</title> |
| <meta name="date" content="2018-10-22"> |
| <link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style"> |
| <script type="text/javascript" src="../../../../../../script.js"></script> |
| </head> |
| <body> |
| <script type="text/javascript"><!-- |
| try { |
| if (location.href.indexOf('is-external=true') == -1) { |
| parent.document.title="Component"; |
| } |
| } |
| catch(err) { |
| } |
| //--> |
| </script> |
| <noscript> |
| <div>JavaScript is disabled on your browser.</div> |
| </noscript> |
| <!-- ========= START OF TOP NAVBAR ======= --> |
| <div class="topNav"><a name="navbar.top"> |
| <!-- --> |
| </a> |
| <div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div> |
| <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/BundleDependency.html" title="annotation in org.apache.felix.dm.annotation.api"><span class="typeNameLink">Prev Class</span></a></li> |
| <li><a href="../../../../../../org/apache/felix/dm/annotation/api/Composition.html" title="annotation in org.apache.felix.dm.annotation.api"><span class="typeNameLink">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../../../index.html?org/apache/felix/dm/annotation/api/Component.html" target="_top">Frames</a></li> |
| <li><a href="Component.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: </li> |
| <li>Field | </li> |
| <li>Required | </li> |
| <li><a href="#annotation.type.optional.element.summary">Optional</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li>Field | </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 Component" class="title">Annotation Type Component</h2> |
| </div> |
| <div class="contentContainer"> |
| <div class="description"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <hr> |
| <br> |
| <pre>@Retention(value=CLASS) |
| @Target(value=TYPE) |
| public @interface <span class="memberNameLabel">Component</span></pre> |
| <div class="block">Annotates an OSGi Component class with its dependencies. Components are the main building |
| blocks for OSGi applications. They can publish themselves as a service, and/or they can have |
| dependencies. These dependencies will influence their life cycle as component will only be |
| activated when all required dependencies are available. |
| By default, all directly implemented interfaces are registered into the OSGi registry, |
| and the component is instantiated automatically, when the component bundle is started and |
| when the component dependencies are available. If you need to take control of when and how |
| much component instances must be created, then you can use the <code>factoryName</code> |
| annotation attribute.<p> |
| If a <code>factoryPid</code> attribute is set, the component is not started automatically |
| during bundle startup, and the component can then be instantiated multiple times using |
| Configuration Admin "Factory Configurations". |
| |
| <h3>Usage Examples</h3> |
| |
| Here is a sample showing a Hello component, which depends on a configuration dependency: |
| <blockquote> |
| |
| <pre> |
| /** |
| * This component will be activated once the bundle is started and when all required dependencies |
| * are available. |
| */ |
| @Component |
| class Hello implements HelloService { |
| @ConfigurationDependency(pid="my.pid") |
| void configure(Dictionary conf) { |
| // Configure or reconfigure our component. |
| } |
| |
| @Start |
| void start() { |
| // Our component is starting and is about to be registered in the OSGi registry as a HelloService service. |
| } |
| } |
| </pre> |
| </blockquote> |
| |
| Here is a sample showing how a HelloFactory component may dynamically instantiate several Hello component instances, |
| using Configuration Admin "Factory Configurations": |
| <blockquote> |
| |
| <pre> |
| /** |
| * All component instances will be created/updated/removed by the "HelloFactory" component |
| */ |
| @Component(factoryPid="my.factory.pid") |
| class Hello implements HelloService { |
| void updated(Dictionary conf) { |
| // Configure or reconfigure our component. The conf is provided by the factory, |
| } |
| |
| @Start |
| void start() { |
| // Our component is starting and is about to be registered in the OSGi registry as a Hello service. |
| } |
| } |
| |
| /** |
| * This class will instantiate some Hello component instances |
| */ |
| @Component |
| class HelloFactory { |
| @ServiceDependency |
| void bind(ConfigurationAdmin cm) { |
| // instantiate a first instance of Hello component |
| Configuration c1 = cm.createFactoryConfiguration("my.factory.pid", "?"); |
| Hashtable props = new Hashtable(); |
| newprops.put("key", "value1"); |
| c1.update(props); |
| |
| // instantiate another instance of Hello component |
| Configuration c2 = cm.createFactoryConfiguration("my.factory.pid", "?"); |
| props = new Hashtable(); |
| newprops.put("key", "value2"); |
| c2.update(props); |
| |
| // destroy the two instances of X component |
| c1.delete(); |
| c2.delete(); |
| } |
| } |
| </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="memberSummary" 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"> </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><span class="memberNameLink"><a href="../../../../../../org/apache/felix/dm/annotation/api/Component.html#factoryMethod--">factoryMethod</a></span></code> |
| <div class="block">Sets the static method used to create the components implementation instance.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code>java.lang.String</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/felix/dm/annotation/api/Component.html#factoryPid--">factoryPid</a></span></code> |
| <div class="block">Returns the factory pid whose configurations will instantiate the annotated service class.</div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code>boolean</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/felix/dm/annotation/api/Component.html#propagate--">propagate</a></span></code> |
| <div class="block">Returns true if the factory configuration properties must be published to the service properties.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code><a href="../../../../../../org/apache/felix/dm/annotation/api/Property.html" title="annotation in org.apache.felix.dm.annotation.api">Property</a>[]</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/felix/dm/annotation/api/Component.html#properties--">properties</a></span></code> |
| <div class="block"><span class="deprecatedLabel">Deprecated.</span> |
| <div class="block"><span class="deprecationComment">you can apply <a href="../../../../../../org/apache/felix/dm/annotation/api/Property.html" title="annotation in org.apache.felix.dm.annotation.api"><code>Property</code></a> annotation directly on the component class.</span></div> |
| </div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code>java.lang.Class<?>[]</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/felix/dm/annotation/api/Component.html#provides--">provides</a></span></code> |
| <div class="block">Sets list of provided interfaces.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code><a href="../../../../../../org/apache/felix/dm/annotation/api/ServiceScope.html" title="enum in org.apache.felix.dm.annotation.api">ServiceScope</a></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/felix/dm/annotation/api/Component.html#scope--">scope</a></span></code> |
| <div class="block">The service scope for the service of this Component.</div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code>java.lang.String</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/felix/dm/annotation/api/Component.html#updated--">updated</a></span></code> |
| <div class="block">The Update method to invoke (defaulting to "updated"), when a factory configuration is created or updated.</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="provides--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>provides</h4> |
| <pre>public abstract java.lang.Class<?>[] provides</pre> |
| <div class="block">Sets list of provided interfaces. By default, the directly implemented interfaces are provided.</div> |
| <dl> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the provided interfaces</dd> |
| </dl> |
| <dl> |
| <dt>Default:</dt> |
| <dd>{}</dd> |
| </dl> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| <ul class="blockList"> |
| <li class="blockList"><a name="factoryMethod--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>factoryMethod</h4> |
| <pre>public abstract java.lang.String factoryMethod</pre> |
| <div class="block">Sets the static method used to create the components implementation instance.</div> |
| <dl> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the factory method used to instantiate the component</dd> |
| </dl> |
| <dl> |
| <dt>Default:</dt> |
| <dd>""</dd> |
| </dl> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| <ul class="blockList"> |
| <li class="blockList"><a name="factoryPid--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>factoryPid</h4> |
| <pre>public abstract java.lang.String factoryPid</pre> |
| <div class="block">Returns the factory pid whose configurations will instantiate the annotated service class. Leaving this attribute |
| unset means your component is a singleton. If you specify a factory pid, then this component will be instantiated |
| each time a corresponding factory configuration is created.</div> |
| <dl> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the factory pid</dd> |
| </dl> |
| <dl> |
| <dt>Default:</dt> |
| <dd>""</dd> |
| </dl> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| <ul class="blockList"> |
| <li class="blockList"><a name="updated--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>updated</h4> |
| <pre>public abstract java.lang.String updated</pre> |
| <div class="block">The Update method to invoke (defaulting to "updated"), when a factory configuration is created or updated. |
| Only used if the factoryPid attribute is set. |
| The updated callback supported signatures are the following:<p> |
| <ul><li>callback(Dictionary) |
| <li>callback(Component, Dictionary) |
| <li>callback(Component, Configuration ... configTypes) // type safe configuration interface(s) |
| <li>callback(Configuration ... configTypes) // type safe configuration interface(s) |
| <li>callback(Dictionary, Configuration ... configTypes) // type safe configuration interfaces(s) |
| <li>callback(Component, Dictionary, Configuration ... configTypes) // type safe configuration interfaces(s) |
| </ul></div> |
| <dl> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the updated callback</dd> |
| </dl> |
| <dl> |
| <dt>Default:</dt> |
| <dd>"updated"</dd> |
| </dl> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| <ul class="blockList"> |
| <li class="blockList"><a name="propagate--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>propagate</h4> |
| <pre>public abstract boolean propagate</pre> |
| <div class="block">Returns true if the factory configuration properties must be published to the service properties. |
| Only used if the factoryPid attribute is set.</div> |
| <dl> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>true if configuration must be published along with the service, false if not.</dd> |
| </dl> |
| <dl> |
| <dt>Default:</dt> |
| <dd>false</dd> |
| </dl> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| <ul class="blockList"> |
| <li class="blockList"><a name="scope--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>scope</h4> |
| <pre>public abstract <a href="../../../../../../org/apache/felix/dm/annotation/api/ServiceScope.html" title="enum in org.apache.felix.dm.annotation.api">ServiceScope</a> scope</pre> |
| <div class="block">The service scope for the service of this Component. |
| |
| <p> |
| If not specified, the <a href="../../../../../../org/apache/felix/dm/annotation/api/ServiceScope.html#SINGLETON"><code>singleton</code></a> service |
| scope is used.</div> |
| <dl> |
| <dt>Default:</dt> |
| <dd>org.apache.felix.dm.annotation.api.ServiceScope.SINGLETON</dd> |
| </dl> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| <ul class="blockList"> |
| <li class="blockList"><a name="properties--"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>properties</h4> |
| <pre>public abstract <a href="../../../../../../org/apache/felix/dm/annotation/api/Property.html" title="annotation in org.apache.felix.dm.annotation.api">Property</a>[] properties</pre> |
| <div class="block"><span class="deprecatedLabel">Deprecated.</span> <span class="deprecationComment">you can apply <a href="../../../../../../org/apache/felix/dm/annotation/api/Property.html" title="annotation in org.apache.felix.dm.annotation.api"><code>Property</code></a> annotation directly on the component class.</span></div> |
| <div class="block">Sets list of provided service properties. Since R7 version, Property annotation is repeatable and you can directly |
| apply it on top of the component class multiple times, instead of using the Component properties attribute.</div> |
| <dl> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the component properties.</dd> |
| </dl> |
| <dl> |
| <dt>Default:</dt> |
| <dd>{}</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> |
| <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div> |
| <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/BundleDependency.html" title="annotation in org.apache.felix.dm.annotation.api"><span class="typeNameLink">Prev Class</span></a></li> |
| <li><a href="../../../../../../org/apache/felix/dm/annotation/api/Composition.html" title="annotation in org.apache.felix.dm.annotation.api"><span class="typeNameLink">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../../../index.html?org/apache/felix/dm/annotation/api/Component.html" target="_top">Frames</a></li> |
| <li><a href="Component.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: </li> |
| <li>Field | </li> |
| <li>Required | </li> |
| <li><a href="#annotation.type.optional.element.summary">Optional</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li>Field | </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> |