felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r942799 - in /websites/staging/felix/trunk/content: ./ documentation/subprojects/apache-felix-dependency-manager-4/reference/component-factory-configuration-adapter.html
Date Sat, 07 Mar 2015 23:05:45 GMT
Author: buildbot
Date: Sat Mar  7 23:05:45 2015
New Revision: 942799

Log:
Staging update by buildbot for felix

Modified:
    websites/staging/felix/trunk/content/   (props changed)
    websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager-4/reference/component-factory-configuration-adapter.html

Propchange: websites/staging/felix/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Sat Mar  7 23:05:45 2015
@@ -1 +1 @@
-1664926
+1664928

Modified: websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager-4/reference/component-factory-configuration-adapter.html
==============================================================================
--- websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager-4/reference/component-factory-configuration-adapter.html
(original)
+++ websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager-4/reference/component-factory-configuration-adapter.html
Sat Mar  7 23:05:45 2015
@@ -101,6 +101,13 @@ dot (".").</p>
 annotated service class. 
 (By default, the pid is the service class name). </p>
 <hr />
+<p><strong><code>factoryClass</code></strong>  <br />
+<em>Required</em>: False  <br />
+<em>Default</em>: The class name, including the package.</p>
+<p>Returns the factory 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).</p>
+<hr />
 <p><strong><code>updated</code></strong>  <br />
 <em>Required</em>: False  <br />
 <em>Default</em>: "updated"</p>
@@ -114,98 +121,10 @@ configuration is created or updated </p>
 along with the service. Any additional service properties specified directly 
 are merged with these. </p>
 <hr />
-<p><strong><code>heading</code></strong>  <br />
-<em>Required</em>: False  <br />
-<em>Default</em>: --</p>
-<p>The label used to display the tab name (or section) where the properties are 
-displayed. Example: "Printer Service". </p>
-<hr />
-<p><strong><code>description</code></strong>  <br />
-<em>Required</em>: False  <br />
-<em>Default</em>: --</p>
-<p>A human readable description of the PID this annotation is associated with. 
-Example: "Configuration for the PrinterService bundle". </p>
-<hr />
 <p><strong><code>factoryMethod</code></strong>  <br />
 <em>Required</em>: False  <br />
 <em>Default</em>: --</p>
 <p>Sets the static method used to create the adapter instance.</p>
-<hr />
-<p><strong><code>metadata</code></strong>  <br />
-<em>Required</em>: False  <br />
-<em>Default</em>: --
-An array of "PropertyMetaData annotations, specifying property types used to 
-expose properties in web console</p>
-<h3 id="propertymetadata-anotation-attributes">PropertyMetaData anotation attributes:</h3>
-<hr />
-<p><strong><code>description</code></strong>  <br />
-<em>Required</em>: True  <br />
-<em>Default</em>: --
-Returns the property description. The description may be localized and must 
-describe the semantics of this type and any constraints. 
-Example: "Select the log level for the Printer Service".</p>
-<hr />
-<p><strong><code>type</code></strong>  <br />
-<em>Required</em>: False  <br />
-<em>Default</em>: String</p>
-<p>Return the property primitive type (java.lang.String.class by default). 
-If must be either one of the following types:</p>
-<ul>
-<li>String.class</li>
-<li>Long.class</li>
-<li>Integer.class</li>
-<li>Character.class</li>
-<li>Byte.class</li>
-<li>Double.class</li>
-<li>Float.class</li>
-<li>Boolean.class</li>
-</ul>
-<hr />
-<p><strong><code>defaults</code></strong>  <br />
-<em>Required</em>: False  <br />
-<em>Default</em>: --</p>
-<p>Return a default for this property. The object must be of the appropriate 
-type as defined by the cardinality and getType(). The return type is a list of 
-String objects that can be converted to the appropriate type. 
-The cardinality of the return array must follow the absolute cardinality of
-this type. E.g. if the cardinality = 0, the array must contain 1 element. If 
-the cardinality is 1, it must contain 0 or 1 elements. If it is -5, it must 
-contain from 0 to max 5 elements. Note that the special case of a 0 
-cardinality, meaning a single value, does not allow arrays or vectors of 0 
-elements. </p>
-<hr />
-<p><strong><code>cardinality</code></strong>  <br />
-<em>Required</em>: False  <br />
-<em>Default</em>: --</p>
-<p>Returns the cardinality of this property (0 by default). The OSGi environment
-handles multi valued properties in arrays or in Vector objects. 
-The return value is defined as follows:</p>
-<ul>
-<li>x = Integer.MIN_VALUE:  no limit, but use Vector</li>
-<li>x &lt; 0: -x = max occurrences, store in Vector</li>
-<li>x &gt; 0: x = max occurrences, store in array <a href=""></a></li>
-<li>x = Integer.MAX_VALUE: no limit, but use array <a href=""></a></li>
-<li>x = 0: 1 occurrence required</li>
-</ul>
-<hr />
-<p><strong><code>required</code></strong>  <br />
-<em>Required</em>: False  <br />
-<em>Default</em>: true</p>
-<p>Tells if this property is required or not. </p>
-<hr />
-<p><strong><code>optionLabels</code></strong>  <br />
-<em>Required</em>: False  <br />
-<em>Default</em>: --</p>
-<p>Return a list of valid option labels for this property. The purpose of this 
-method is to allow menus with localized labels. It is associated with the 
-<em>optionValues</em> attribute. The labels returned here are ordered in the
same 
-way as the <em>optionValues</em> attribute values. </p>
-<hr />
-<p><strong><code>optionValues</code></strong>  <br />
-<em>Required</em>: False  <br />
-<em>Default</em>: --</p>
-<p>Return a list of option values that this property can take. This list must be 
-in the same sequence as the <em>optionLabels</em> attribute. </p>
 <h3 id="usage-examples">Usage Examples</h3>
 <p>Here, a "Dictionary" service instance is instantiated for each existing 
 factory configuration instances matching the "DictionaryServiceFactory" 
@@ -247,66 +166,46 @@ factory pid:</p>
 </pre></div>
 
 
-<p>Here, this is the same example as above, but using meta types:</p>
-<div class="codehilite"><pre><span class="nd">@FactoryConfigurationAdapterService</span><span
class="o">(</span>
-      <span class="n">factoryPid</span><span class="o">=</span><span
class="s">&quot;DictionaryServiceFactory&quot;</span><span class="o">,</span>

-      <span class="n">propagate</span><span class="o">=</span><span
class="kc">true</span><span class="o">,</span> 
-      <span class="n">updated</span><span class="o">=</span><span
class="s">&quot;updated&quot;</span><span class="o">,</span>
-      <span class="n">heading</span><span class="o">=</span><span
class="s">&quot;Dictionary Services&quot;</span><span class="o">,</span>
-      <span class="n">description</span><span class="o">=</span><span
class="s">&quot;Declare here some Dictionary instances, allowing to instantiates some
DictionaryService services for a given dictionary language&quot;</span><span
class="o">,</span>
-      <span class="n">metadata</span><span class="o">={</span>
-          <span class="nd">@PropertyMetaData</span><span class="o">(</span>
-                 <span class="n">heading</span><span class="o">=</span><span
class="s">&quot;Dictionary Language&quot;</span><span class="o">,</span>
-                 <span class="n">description</span><span class="o">=</span><span
class="s">&quot;Declare here the language supported by this dictionary. &quot;</span>
<span class="o">+</span>
-                     <span class="s">&quot;This property will be propagated with
the Dictionary Service properties.&quot;</span><span class="o">,</span>
-                 <span class="n">defaults</span><span class="o">={</span><span
class="s">&quot;en&quot;</span><span class="o">},</span>
-                 <span class="n">id</span><span class="o">=</span><span
class="n">DictionaryImpl</span><span class="o">.</span><span class="na">LANG</span><span
class="o">,</span>
-                 <span class="n">cardinality</span><span class="o">=</span><span
class="mi">0</span><span class="o">),</span>
-          <span class="nd">@PropertyMetaData</span><span class="o">(</span>
-                 <span class="n">heading</span><span class="o">=</span><span
class="s">&quot;Dictionary words&quot;</span><span class="o">,</span>
-                 <span class="n">description</span><span class="o">=</span><span
class="s">&quot;Declare here the list of words supported by this dictionary. This properties
starts with a Dot and won&#39;t be propagated with Dictionary OSGi service properties.&quot;</span><span
class="o">,</span>
-                 <span class="n">defaults</span><span class="o">={</span><span
class="s">&quot;hello&quot;</span><span class="o">,</span> <span
class="s">&quot;world&quot;</span><span class="o">},</span>
-                 <span class="n">id</span><span class="o">=</span><span
class="n">DictionaryImpl</span><span class="o">.</span><span class="na">WORDS</span><span
class="o">,</span>
-                 <span class="n">cardinality</span><span class="o">=</span><span
class="n">Integer</span><span class="o">.</span><span class="na">MAX_VALUE</span><span
class="o">)</span>
-      <span class="o">}</span>
-  <span class="o">)</span>  
-  <span class="kd">public</span> <span class="kd">class</span> <span
class="nc">DictionaryImpl</span> <span class="kd">implements</span> <span
class="n">DictionaryService</span>
-  <span class="o">{</span>
-     <span class="cm">/**</span>
-<span class="cm">       * The key of our config admin dictionary language.</span>
-<span class="cm">       */</span>
-     <span class="kd">final</span> <span class="kd">static</span>
<span class="n">String</span> <span class="n">LANG</span> <span
class="o">=</span> <span class="s">&quot;lang&quot;</span><span
class="o">;</span>
-
-     <span class="cm">/**</span>
-<span class="cm">       * The key of our config admin dictionary values.</span>
-<span class="cm">       */</span>
-     <span class="kd">final</span> <span class="kd">static</span>
<span class="n">String</span> <span class="n">WORDS</span> <span
class="o">=</span> <span class="s">&quot;words&quot;</span><span
class="o">;</span>
-
-     <span class="cm">/**</span>
-<span class="cm">       * We store all configured words in a thread-safe data structure,
because ConfigAdmin</span>
-<span class="cm">       * may invoke our updated method at any time.</span>
-<span class="cm">       */</span>
-     <span class="kd">private</span> <span class="n">CopyOnWriteArrayList</span><span
class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span>
<span class="n">m_words</span> <span class="o">=</span> <span class="k">new</span>
<span class="n">CopyOnWriteArrayList</span><span class="o">&lt;</span><span
class="n">String</span><span class="o">&gt;();</span>
-
-     <span class="cm">/**</span>
-<span class="cm">       * Our Dictionary language.</span>
-<span class="cm">       */</span>
-     <span class="kd">private</span> <span class="n">String</span>
<span class="n">m_lang</span><span class="o">;</span>
-
-     <span class="kd">protected</span> <span class="kt">void</span>
<span class="nf">updated</span><span class="o">(</span><span class="n">Dictionary</span><span
class="o">&lt;</span><span class="n">String</span><span class="o">,</span>
<span class="o">?&gt;</span> <span class="n">config</span><span
class="o">)</span> <span class="o">{</span>
-         <span class="n">m_lang</span> <span class="o">=</span> <span
class="o">(</span><span class="n">String</span><span class="o">)</span>
<span class="n">config</span><span class="o">.</span><span class="na">get</span><span
class="o">(</span><span class="n">LANG</span><span class="o">);</span>
-         <span class="n">m_words</span><span class="o">.</span><span
class="na">clear</span><span class="o">();</span>
-         <span class="n">String</span><span class="o">[]</span> <span
class="n">words</span> <span class="o">=</span> <span class="o">(</span><span
class="n">String</span><span class="o">[])</span> <span class="n">config</span><span
class="o">.</span><span class="na">get</span><span class="o">(</span><span
class="n">WORDS</span><span class="o">);</span>
-         <span class="k">for</span> <span class="o">(</span><span
class="n">String</span> <span class="n">word</span> <span class="o">:</span>
<span class="n">words</span><span class="o">)</span> <span class="o">{</span>
-             <span class="n">m_words</span><span class="o">.</span><span
class="na">add</span><span class="o">(</span><span class="n">word</span><span
class="o">);</span>
-         <span class="o">}</span>
-     <span class="o">}</span>
+<p>Here is the same example as above, but using meta types (the DM annotations metatype
attributes are deprecated and 
+it's better to use standard bnd metatype annotations, the following example are using bnd
metatypes):</p>
+<p>First, we declare our factory configuration metadata using standard bndtools metatype
annotations (see http://www.aqute.biz/Bnd/MetaType):</p>
+<div class="codehilite"><pre><span class="kn">package</span> <span
class="n">sample</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">java.util.List</span><span
class="o">;</span>
+<span class="kn">import</span> <span class="nn">aQute.bnd.annotation.metatype.Meta.AD</span><span
class="o">;</span>
+<span class="kn">import</span> <span class="nn">aQute.bnd.annotation.metatype.Meta.OCD</span><span
class="o">;</span>
+
+<span class="nd">@OCD</span><span class="o">(</span><span class="n">factory</span>
<span class="o">=</span> <span class="kc">true</span><span class="o">,</span>
<span class="n">description</span> <span class="o">=</span> <span
class="s">&quot;Declare here some Dictionary instances.&quot;</span><span
class="o">)</span>
+<span class="kd">public</span> <span class="kd">interface</span>
<span class="nc">DictionaryConfiguration</span> <span class="o">{</span>
+   <span class="nd">@AD</span><span class="o">(</span><span class="n">description</span>
<span class="o">=</span> <span class="s">&quot;Describes the dictionary
language.&quot;</span><span class="o">,</span> <span class="n">deflt</span>
<span class="o">=</span> <span class="s">&quot;en&quot;</span><span
class="o">)</span>
+   <span class="n">String</span> <span class="nf">lang</span><span
class="o">();</span>
 
-     <span class="c1">// ...</span>
+   <span class="nd">@AD</span><span class="o">(</span><span class="n">description</span>
<span class="o">=</span> <span class="s">&quot;Declare here the list
of words supported by this dictionary.&quot;</span><span class="o">)</span>
+   <span class="n">List</span> <span class="nf">words</span><span
class="o">();</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<p>And here is the Dictionary service, and we instantiate our DictionaryConfiguration
interface using the bndlib <em>Configurable</em> helper class.</p>
+<div class="codehilite"><pre><span class="kn">import</span> <span
class="nn">java.util.List</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">aQute.bnd.annotation.metatype.Configurable</span><span
class="o">;</span>
+
+<span class="nd">@FactoryConfigurationAdapterService</span><span class="o">(</span><span
class="n">factoryPidClass</span><span class="o">=</span><span class="n">DictionaryConfiguration</span><span
class="o">.</span><span class="na">class</span><span class="o">)</span>
 
+<span class="kd">public</span> <span class="kd">class</span> <span
class="nc">DictionaryImpl</span> <span class="kd">implements</span> <span
class="n">DictionaryService</span> <span class="o">{</span>
+    <span class="kd">protected</span> <span class="kt">void</span>
<span class="nf">updated</span><span class="o">(</span><span class="n">Dictionary</span><span
class="o">&lt;</span><span class="n">String</span><span class="o">,</span>
<span class="o">?&gt;</span> <span class="n">props</span><span
class="o">)</span> <span class="o">{</span>
+        <span class="c1">// load configuration from the provided dictionary, or throw
an exception of any configuration error.</span>
+        <span class="n">DictionaryConfiguration</span> <span class="n">cnf</span>
<span class="o">=</span> <span class="n">Configurable</span><span
class="o">.</span><span class="na">createConfigurable</span><span
class="o">(</span><span class="n">DictionaryConfiguration</span><span
class="o">.</span><span class="na">class</span><span class="o">,</span>
<span class="n">props</span><span class="o">);</span>
+
+        <span class="n">m_lang</span> <span class="o">=</span> <span
class="n">config</span><span class="o">.</span><span class="na">lang</span><span
class="o">();</span>
+        <span class="n">m_words</span><span class="o">.</span><span
class="na">clear</span><span class="o">();</span>
+        <span class="k">for</span> <span class="o">(</span><span
class="n">String</span> <span class="n">word</span> <span class="o">:</span>
<span class="n">conf</span><span class="o">.</span><span class="na">words</span><span
class="o">())</span> <span class="o">{</span>
+            <span class="n">m_words</span><span class="o">.</span><span
class="na">add</span><span class="o">(</span><span class="n">word</span><span
class="o">);</span>
+        <span class="o">}</span>
+    <span class="o">}</span>
+    <span class="o">...</span>
 <span class="o">}</span>
 </pre></div>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1664040 by marrs on Wed, 4 Mar 2015 15:21:58 +0000
+        Rev. 1664928 by pderop on Sat, 7 Mar 2015 23:05:23 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Felix, Felix, Apache, the Apache feather logo, and the Apache Felix project



Mime
View raw message