You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Pierre De Rop (JIRA)" <ji...@apache.org> on 2011/05/18 12:15:47 UTC

[jira] [Resolved] (FELIX-2954) DM/ annotated component factory does not allow to provide a component instance explicitly

     [ https://issues.apache.org/jira/browse/FELIX-2954?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Pierre De Rop resolved FELIX-2954.
----------------------------------

    Resolution: Fixed

Fixed in trunk.

> DM/ annotated component factory does not allow to provide a component instance explicitly
> -----------------------------------------------------------------------------------------
>
>                 Key: FELIX-2954
>                 URL: https://issues.apache.org/jira/browse/FELIX-2954
>             Project: Felix
>          Issue Type: Improvement
>          Components: Dependency Manager
>            Reporter: Pierre De Rop
>            Assignee: Pierre De Rop
>            Priority: Minor
>
> This change request concerns dependency manager annotations.
> Currently, it is possible to trigger an instantiation of a given annotated dependency manager Component, using the "factorySet" attribute of the "@Component" annotation.
> A "factory set" is similar to declarative service "component factory", except that a Set<Dictionary> is provided in the OSGi registry, instead of the
> "org.osgi.service.component.ComponentFactory" SCR object.
> This Set<Dicionary> acts as a factory API and can be considered as a repository of component instances configurations.
> (there is one component created per each dictionary stored in the set).
> For instance, in the following example, the component X is instantiated by the component Y, like this:
>   @Component(factorySet="MyComponentFactory")
>   class X implements Z {
>         ...
>   }
>   @Component
>   class Y {
>       @ServiceDependency(filter="(dm.factory.name=MyComponentFactory)")
>       Set<Dictionary> _XFactory; // This Set acts as a Factory API for creating X component instances.
>       @Start
>       void start() {
>           // Instantiate a X component instance
>           Dictionary x1 = new Hashtable() {{ put("foo", "bar"); }};
>           _XFactory.add(x1); // create a new X component instance
>       }
>   }
> In the above example, Y instantiates one X component, by passing an instance dictionary configuration into the set "_XFactory".
> The X component is instantiated using the X default constructor, and currently, the Y component can not create itself the X component instance object.
> The purpose of this change request is to allow the Y class to explicitly provide the X component instance, by passing a special
> key in the component configuration (x1), whose value may contain the actual component instance object.
> For instance:
>   @Component
>   class Y {
>       @ServiceDependency(filter="(dm.factory.name=MyComponentFactory)")
>       Set<Dictionary> _XFactory;
>       @Start
>       void start() {
>           // Instantiate a X component instance, and pass the real component instance in the dictionary:
>           Dictionary x1 = new Hashtable() {{ 
>                put("foo", "bar"); 
>                put("dm.factory.instance", new X(whatever params));
>            }};
>           _XFactory.add(x1); // create a new X dependency manager component instance, using the object instance passed to the "dm.factory.instance" key
>       }
>   }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira