Hi Heinrich
I have a similar problem, but I'm taking a completely different
approach. DS allows components to be instantiated based on
Configuration Admin ManagedServiceFactory configurations (instead of
DS ComponentFactories). For each instance of a ManagedServiceFactory
with the same PID as the component name, DS will instantiate the
component and initialise its properties to those specified in the
configuration. I can search for the components in the service
registry, and filter on name if I want to.
This approach may not be appropriate, as it sounds like you have a pre-
set list of possible configurations and you just want the user to be
able to select one. Also, DS v1.0 (OSGi 4.1) seems to have a semantic
issue where it will create at least one instance of your component,
even if no ManagedServiceFactory exists - and I believe that you can't
just use a ComponentFactory. DS v1.1 fixes that, but its currently a
proposal, although there seems to be an implementation in Equinox
3.5M*, which is what I'm currently playing with.
Cheers
Chris
On 05/05/2009, at 1:25 AM, <[email protected]> <[email protected]
> wrote:
Hi all,
We are designing some kind of registry for special kinds of
applications, based on OSGi Services. This registry shall create
instances of those applications on demand and as many instances as
needed by the consumers. We found the ComponentFactory of the OSGi
Declarative Services specification fitting those needs.
Unfortunately we still see a small problem. The user shall be able
to decide which application he wants to create, based on some kind
of metadata. This metadata is provided by means of Properties, which
can be declared in the service description XML file. Example of two
applications, using the same component factory, with different
property values for the “vendor” property:
<component factory="org.example.ds.iintegratedapplication"
name="Test Application">
<implementation class="org.example.ia.TestApplication"/>
<service>
<provide
interface="org.example.ia.IIntegratedApplication"/>
</service>
<property name=“vendor“ value=”Sistec”>
</component>
<component factory="org.example.ds.iintegratedapplication"
name="Another Test Application">
<implementation
class="org.example.ia.AnotherTestApplication"/>
<service>
<provide
interface="org.example.ia.IIntegratedApplication"/>
</service>
<property name=“vendor“ value=”DLR”>
</component>
The Registry of the applications looks similar to this:
public class Registry {
private List<ComponentFactory> apps = new
ArrayList<ComponentFactory>();
protected synchronized void addApplication(ComponentFactory
c) {
apps.add(c);
}
protected synchronized void
removeApplication(ComponentFactory c) {
apps.remove(c);
}
}
Now we want to add a “getApplications” method, which returns a list
of the names of the applications and its properties:
Name Vendor
org.example.ia.TestApplication Sistec
org.example.ia.AnotherTestApplication DLR
As far as we see, the properties can only be read after calling
newInstance() of the ComponentFactory, since the Declarative
Services specification states:
“The service properties of the Component Factory service must not
include the component properties.”
But we would like to select which service to create based on that
properties before initializing it. Is there any way to do that?
Regards,
Heinrich Wendel
-----------------------------------------------------
Dipl.-Ing. (BA) Heinrich Wendel
Deutsches Zentrum fuer Luft- und Raumfahrt e.V. (DLR)
Simulations- und Softwaretechnik (SISTEC) Koeln-Porz
Tel: (02203) 601-3305 http://www.dlr.de/sc
Fax: (02203) 601-3070 mailto:[email protected]
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev
--------
Christopher Armstrong
[email protected]
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev