You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by bu...@apache.org on 2015/03/07 22:39:59 UTC
svn commit: r942792 - in /websites/staging/felix/trunk/content: ./
documentation/subprojects/apache-felix-dependency-manager-4/reference/components.html
Author: buildbot
Date: Sat Mar 7 21:39:59 2015
New Revision: 942792
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/components.html
Propchange: websites/staging/felix/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Sat Mar 7 21:39:59 2015
@@ -1 +1 @@
-1664920
+1664922
Modified: websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager-4/reference/components.html
==============================================================================
--- websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager-4/reference/components.html (original)
+++ websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager-4/reference/components.html Sat Mar 7 21:39:59 2015
@@ -145,44 +145,26 @@ constructor of the class, but there are
take control of how the component is created. For instance, this method may
be used to create the component as a dynamic proxy ...</p>
<hr />
-<p><strong><code>factorySet</code></strong> <br />
+<p><strong><code>factoryName</code></strong> <br />
<em>Required</em>: No <br />
<em>Default</em>: -- </p>
<p>This attribute is the identifier for a component factory. By default, a
component is automatically instantiated as a singleton when the bundle is
started, and when all required dependencies are satisfied. But when a
component must be created, configured, or disposed dynamically, and when
-multiple instances of the same component are needed, a factorySet should be
-used. When you use this attribute, a java.util.Set<Dictionary> object is
-registered into the OSGi regitry, with a specific <em>dm.factory.name</em> service
-property matching the ID you specify in the attribute. </p>
-<p>This Set<Dictionary> will act as a Factory API, and another component may
-define a dependency on this Set and add some configuration dictionaries in it,
-in order to fire some component instantiation/activation. There is one
-component instantiated per added dictionary, which is passed to component
-instances via a configurable callback method (using the <em>factoryConfigure</em>
-attribute). All public properties will be propagated along with eventual
-published service. A public property is a property which does not start with
-a dot ("."). Properties starting with a dot are considered private to the
-component, and won't be propagated to published service. This model is
-actually similar to the Declarative Service "Component Factories" concept,
-except that you don't have a dependency on a specific API, but rather on a
-basic jdk class (java.util.Set<Dictionary>). </p>
-<p>Notice that, unlike in Declarative Service, the component factory is provided once the component
-bundle is started, even if required dependencies are not satisfied. This is
-useful when the component want to dynamically configure its dependency
-filters. So, to summarize:</p>
-<ul>
-<li>Each time a new Dictionary is added into the Set, then a new instance of the annotated component will be instantiated, and this dictionary is passed to the component callback specified with the factoryConfigure attribute.</li>
-<li>Each time an existing Dictionary is re-added into the Set, then the corresponding component instance is updated, and the updated dictionary is also passed to the callback specified in the factoryConfigure attribute.</li>
-<li>Each time an existing Dictionary is removed from the Set, then the corresponding component instance will be stopped and destroyed.</li>
-</ul>
+multiple instances of the same component are needed, a factoryName can be
+used. When you use this attribute, a <em>org.apache.felix.dm.runtime.api.ComponentFactory</em>
+OSGi Service will be provided with a <em>dm.factory.name</em> service property matching your
+specified factoryName attribute. The ComponentFactory will be provided once the
+component bundle is started, even if required dependencies are not available,
+and the ComponentFactory will be unregistered from the OSGi registry once the component
+bundle is stopped or being updated.. </p>
<hr />
<p><strong><code>factoryConfigure</code></strong> <br />
<em>Required</em>: No <br />
<em>Default</em>: -- </p>
<p>This attributes sets the <em>configure</em> method name to be called with the factory
-configuration. This attribute only makes sense if the factorySet() attribute
+configuration. This attribute only makes sense if the <em>factoryName</em> attribute
is used. If specified, then this attribute references a component callback
method, which is called for providing the configuration supplied by the
factory that instantiated this component. The current Service properties will
@@ -211,8 +193,11 @@ be also updated with all public properti
</pre></div>
-<p>Example using a factorySet, where the X component is instantiated/updated/disposed by another Y component:</p>
-<div class="codehilite"><pre> <span class="nd">@Component</span><span class="o">(</span><span class="n">factorySet</span><span class="o">=</span><span class="s">"MyComponentFactory"</span><span class="o">,</span> <span class="n">factoryConfigure</span><span class="o">=</span><span class="s">"configure"</span><span class="o">)</span>
+<p>Example using a factoryName, where the X component is instantiated/updated/disposed by another Y component:</p>
+<div class="codehilite"><pre> <span class="kn">import</span> <span class="nn">org.apache.felix.dm.runtime.api.ComponentFactory</span><span class="o">;</span>
+ <span class="kn">import</span> <span class="nn">org.apache.felix.dm.runtime.api.ComponentInstance</span><span class="o">;</span>
+
+ <span class="nd">@Component</span><span class="o">(</span><span class="n">factoryName</span><span class="o">=</span><span class="s">"MyComponentFactory"</span><span class="o">,</span> <span class="n">factoryConfigure</span><span class="o">=</span><span class="s">"configure"</span><span class="o">)</span>
<span class="kd">class</span> <span class="nc">X</span> <span class="kd">implements</span> <span class="n">Z</span> <span class="o">{</span>
<span class="kt">void</span> <span class="nf">configure</span><span class="o">(</span><span class="n">Dictionary</span> <span class="n">conf</span><span class="o">)</span> <span class="o">{</span>
<span class="c1">// Configure or reconfigure our component. The conf is provided by </span>
@@ -245,31 +230,30 @@ be also updated with all public properti
<span class="kd">class</span> <span class="nc">Y</span> <span class="o">{</span>
<span class="c1">// This Set acts as a Factory API for creating X component instances.</span>
<span class="nd">@ServiceDependency</span><span class="o">(</span><span class="n">filter</span><span class="o">=</span><span class="s">"(dm.factory.name=MyComponentFactory)"</span><span class="o">)</span>
- <span class="n">Set</span><span class="o"><</span><span class="n">Dictionary</span><span class="o">></span> <span class="n">_XFactory</span><span class="o">;</span>
+ <span class="n">ComponentFactory</span> <span class="n">_XFactory</span><span class="o">;</span>
<span class="nd">@Start</span>
<span class="kt">void</span> <span class="nf">start</span><span class="o">()</span> <span class="o">{</span>
<span class="c1">// Instantiate a X component instance</span>
<span class="n">Dictionary</span> <span class="n">x1</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Hashtable</span><span class="o">()</span> <span class="o">;</span>
- <span class="n">_XFactory</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">x1</span><span class="o">);</span>
+ <span class="n">ComponentInstance</span> <span class="n">i1</span> <span class="o">=</span> <span class="n">_XFactory</span><span class="o">.</span><span class="na">newInstance</span><span class="o">(</span><span class="n">x1</span><span class="o">);</span>
<span class="c1">// Instantiate another X component instance</span>
<span class="n">Dictionary</span> <span class="n">x2</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Hashtable</span><span class="o">()</span> <span class="o">;</span>
- <span class="n">_XFactory</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">x2</span><span class="o">);</span>
+ <span class="n">ComponentInstance</span> <span class="n">i2</span> <span class="o">=</span> <span class="n">_XFactory</span><span class="o">.</span><span class="na">newInstance</span><span class="o">(</span><span class="n">x2</span><span class="o">);</span>
<span class="c1">// Update the first X component instance</span>
- <span class="n">x1</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"foo"</span><span class="o">,</span> <span class="s">"bar1_modified"</span><span class="o">);</span>
- <span class="n">_XFactory</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">x1</span><span class="o">);</span>
+ <span class="n">x1</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Hashtable</span><span class="o">()</span> <span class="o">;</span>
+ <span class="n">i1</span><span class="o">.</span><span class="na">update</span><span class="o">(</span><span class="n">x1</span><span class="o">);</span>
- <span class="c1">// Destroy all components (Notice that invoking</span>
- <span class="c1">// _XFactory.clear() also destroys every X instances)</span>
- <span class="n">_XFactory</span><span class="o">.</span><span class="na">remove</span><span class="o">(</span><span class="n">x1</span><span class="o">);</span>
- <span class="n">_XFactory</span><span class="o">.</span><span class="na">remove</span><span class="o">(</span><span class="n">x2</span><span class="o">);</span>
+ <span class="c1">// Destroy components</span>
+ <span class="n">i1</span><span class="o">.</span><span class="na">dispose</span><span class="o">();</span>
+ <span class="n">i2</span><span class="o">.</span><span class="na">dispose</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. 1664129 by marrs on Wed, 4 Mar 2015 19:59:46 +0000
+ Rev. 1664922 by pderop on Sat, 7 Mar 2015 21:39:45 +0000
</div>
<div class="trademarkFooter">
Apache Felix, Felix, Apache, the Apache feather logo, and the Apache Felix project