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