Thx for your answer.

 

I don't think your approach does help us, because the vendor field was
only one example and there are more properties we want to get from an
application before initializing it. We cannot incorporate all into the
factory name.

 

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] 

________________________________

Von: [email protected]
[mailto:[email protected]] Im Auftrag von BJ Hargrave
Gesendet: Montag, 4. Mai 2009 18:58
An: OSGi Developer Mail List
Betreff: Re: [osgi-dev] ComponentFactory and Properties

 

You have 2 component factories with the exact same factory name:
org.example.ds.iintegratedapplication. 

You should use different factory names and incorporate the vendor
information into that name. org.example.ds.iintegratedapplication.DLR
for example. 

Both services will have the same interface name (objectClass) but will
have different component factory names distinguished by the vendor
(component.factory). 
-- 

BJ Hargrave
Senior Technical Staff Member, IBM
OSGi Fellow and CTO of the OSGi Alliance <http://www.osgi.org/> 
[email protected] <mailto:[email protected]>  


office: +1 386 848 1781
mobile: +1 386 848 3788





From: 

<[email protected]> 

To: 

<[email protected]> 

Date: 

2009/05/04 11:35 

Subject: 

[osgi-dev] ComponentFactory and Properties 

Sent by: 

[email protected]

 

________________________________




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 <http://www.dlr.de/sc>  

Fax: (02203) 601-3070  mailto:[email protected]
<mailto:[email protected]>
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev
<https://mail.osgi.org/mailman/listinfo/osgi-dev>  

_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to