| <!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 Fri Mar 06 23:14:53 CET 2015 --> |
| <title>ConfigurationDependency</title> |
| <meta name="date" content="2015-03-06"> |
| <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="ConfigurationDependency"; |
| } |
| //--> |
| </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/Composition.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/Destroy.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/ConfigurationDependency.html" target="_top">Frames</a></li> |
| <li><a href="ConfigurationDependency.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>Required | </li> |
| <li><a href="#annotation_type_optional_element_summary">Optional</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </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 ConfigurationDependency" class="title">Annotation Type ConfigurationDependency</h2> |
| </div> |
| <div class="contentContainer"> |
| <div class="description"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <hr> |
| <br> |
| <pre>@Retention(value=CLASS) |
| @Target(value=METHOD) |
| public @interface <span class="strong">ConfigurationDependency</span></pre> |
| <div class="block">Annotates a method for injecting a Configuration Dependency. A configuration dependency |
| is always required, and allows you to depend on the availability of a valid configuration |
| for your component. This dependency requires the OSGi Configuration Admin Service. |
| |
| <h3>Usage Examples</h3> |
| |
| <p> In the following example, the "Printer" component depends on a configuration |
| whose PID name is "sample.PrinterConfiguration". This service will initialize |
| its ip/port number from the provided configuration. |
| <p> First, we define the configuration metadata, using standard bndtools metatatype annotations |
| (see http://www.aqute.biz/Bnd/MetaType): |
| |
| <blockquote> |
| <pre> |
| package sample; |
| import aQute.bnd.annotation.metatype.Meta.AD; |
| import aQute.bnd.annotation.metatype.Meta.OCD; |
| |
| @OCD(description = "Declare here the Printer Configuration.") |
| public interface PrinterConfiguration { |
| @AD(description = "Enter the printer ip address") |
| String ipAddress(); |
| |
| @AD(description = "Enter the printer address port number.") |
| int portNumber(); |
| } |
| </pre> |
| </blockquote> |
| |
| Next, we define our Printer service which depends on the PrinterConfiguration: |
| |
| <blockquote> |
| <pre> |
| package sample; |
| import aQute.bnd.annotation.metatype.*; |
| |
| @Component |
| public class Printer { |
| @ConfigurationDependency(pidClass = PrinterConfiguration.class) // Will use pid "sample.PrinterConfiguration" |
| void updated(Dictionary props) { |
| // load configuration from the provided dictionary, or throw an exception of any configuration error. |
| PrinterConfig cnf = Configurable.createConfigurable(PrinterConfig.class, props); |
| String ip = cnf.ipAddress(); |
| int port = cnf.portNumber(); |
| ... |
| } |
| } |
| </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"> </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/ConfigurationDependency.html#description()">description</a></strong></code> |
| <div class="block"><strong>Deprecated.</strong> |
| <div class="block"><i>use standard bndtools metatype annotations instead (see http://www.aqute.biz/Bnd/MetaType)</i></div> |
| </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/ConfigurationDependency.html#heading()">heading</a></strong></code> |
| <div class="block"><strong>Deprecated.</strong> |
| <div class="block"><i>use standard bndtools metatype annotations instead (see http://www.aqute.biz/Bnd/MetaType)</i></div> |
| </div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code><a href="../../../../../../org/apache/felix/dm/annotation/api/PropertyMetaData.html" title="annotation in org.apache.felix.dm.annotation.api">PropertyMetaData</a>[]</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../org/apache/felix/dm/annotation/api/ConfigurationDependency.html#metadata()">metadata</a></strong></code> |
| <div class="block"><strong>Deprecated.</strong> |
| <div class="block"><i>use standard bndtools metatype annotations instead (see http://www.aqute.biz/Bnd/MetaType)</i></div> |
| </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/ConfigurationDependency.html#name()">name</a></strong></code> |
| <div class="block">The name for this configuration dependency.</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/ConfigurationDependency.html#pid()">pid</a></strong></code> |
| <div class="block">Returns the pid for a given service (by default, the pid is the service class name).</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code>java.lang.Class<?></code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../org/apache/felix/dm/annotation/api/ConfigurationDependency.html#pidClass()">pidClass</a></strong></code> |
| <div class="block">Returns the pid from a class name.</div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code>boolean</code></td> |
| <td class="colLast"><code><strong><a href="../../../../../../org/apache/felix/dm/annotation/api/ConfigurationDependency.html#propagate()">propagate</a></strong></code> |
| <div class="block">Returns true if the configuration properties must be published along with the service.</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="pid()"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>pid</h4> |
| <pre>public abstract java.lang.String pid</pre> |
| <div class="block">Returns the pid for a given service (by default, the pid is the service class name).</div> |
| <dl><dt><span class="strong">Returns:</span></dt><dd>the pid for a given service (default = Service class name)</dd></dl> |
| <dl> |
| <dt>Default:</dt> |
| <dd>""</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="pidClass()"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>pidClass</h4> |
| <pre>public abstract java.lang.Class<?> pidClass</pre> |
| <div class="block">Returns the pid from a class name. The full class name will be used as the configuration PID. |
| You can use this method when you use an interface annoted with standard bndtols metatype annotations. |
| (see http://www.aqute.biz/Bnd/MetaType).</div> |
| <dl> |
| <dt>Default:</dt> |
| <dd>java.lang.Object.class</dd> |
| </dl> |
| </li> |
| </ul> |
| <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 configuration 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 configuration must be published along with the service, false if not.</dd></dl> |
| <dl> |
| <dt>Default:</dt> |
| <dd>false</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="name()"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>name</h4> |
| <pre>public abstract java.lang.String name</pre> |
| <div class="block">The name for this configuration dependency. When you give a name a dependency, it won't be evaluated |
| immediately, but after the component's init method has been called, and from the init method, you can then return |
| a map in order to dynamically configure the configuration dependency (the map has to contain a "pid" and/or "propagate" |
| flag, prefixed with the dependency name). Then the dependency will be evaluated after the component init method, and will |
| be injected before the start method. |
| |
| <p> Usage example of a Configuration dependency whose pid and propagate flag is configured dynamically from init method: |
| |
| <blockquote><pre> |
| /** |
| * A Service that dynamically defines an extra dynamic configuration dependency from its init method. |
| */ |
| @Component |
| class X { |
| private Dictionary m_config; |
| |
| // Inject initial Configuration (injected before any other required dependencies) |
| @ConfigurationDependency |
| void componentConfiguration(Dictionary config) { |
| // you must throw an exception if the configuration is not valid |
| m_config = config; |
| } |
| |
| /** |
| * All unnamed dependencies are injected: we can now configure our dynamic configuration whose dependency name is "global". |
| */ |
| @Init |
| Map init() { |
| return new HashMap() {{ |
| put("global.pid", m_config.get("globalConfig.pid")); |
| put("global.propagate", m_config.get("globalConfig.propagate")); |
| }}; |
| } |
| |
| // Injected after init, and dynamically configured by the init method. |
| @ConfigurationDependency(name="global") |
| void globalConfiguration(Dictionary globalConfig) { |
| // you must throw an exception if the configuration is not valid |
| } |
| |
| /** |
| * All dependencies are injected and our service is now ready to be published. |
| */ |
| @Start |
| void start() { |
| } |
| } |
| </pre></blockquote></div> |
| <dl> |
| <dt>Default:</dt> |
| <dd>""</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="heading()"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>heading</h4> |
| <pre>public abstract java.lang.String heading</pre> |
| <div class="block"><span class="strong">Deprecated.</span> <i>use standard bndtools metatype annotations instead (see http://www.aqute.biz/Bnd/MetaType)</i></div> |
| <div class="block">The label used to display the tab name (or section) where the properties are displayed. Example: "Printer Service".</div> |
| <dl><dt><span class="strong">Returns:</span></dt><dd>The label used to display the tab name where the properties are displayed.</dd></dl> |
| <dl> |
| <dt>Default:</dt> |
| <dd>""</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="description()"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>description</h4> |
| <pre>public abstract java.lang.String description</pre> |
| <div class="block"><span class="strong">Deprecated.</span> <i>use standard bndtools metatype annotations instead (see http://www.aqute.biz/Bnd/MetaType)</i></div> |
| <div class="block">A human readable description of the PID this annotation is associated with. Example: "Configuration for the PrinterService bundle".</div> |
| <dl><dt><span class="strong">Returns:</span></dt><dd>A human readable description of the PID this annotation is associated with.</dd></dl> |
| <dl> |
| <dt>Default:</dt> |
| <dd>""</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="metadata()"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>metadata</h4> |
| <pre>public abstract <a href="../../../../../../org/apache/felix/dm/annotation/api/PropertyMetaData.html" title="annotation in org.apache.felix.dm.annotation.api">PropertyMetaData</a>[] metadata</pre> |
| <div class="block"><span class="strong">Deprecated.</span> <i>use standard bndtools metatype annotations instead (see http://www.aqute.biz/Bnd/MetaType)</i></div> |
| <div class="block">The list of properties types used to expose properties in web console.</div> |
| <dl><dt><span class="strong">Returns:</span></dt><dd>The list of properties types used to expose properties in web console.</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><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/Composition.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/Destroy.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/ConfigurationDependency.html" target="_top">Frames</a></li> |
| <li><a href="ConfigurationDependency.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>Required | </li> |
| <li><a href="#annotation_type_optional_element_summary">Optional</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </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> |