Hi,

not sure about your use case in detail, but it sounds like you either could use 
the ConfigurationAdmin approach like I explained here: 
http://blog.vogella.com/2017/02/13/control-osgi-ds-component-instances/
Probably that is what you have already tried.
 
But maybe the target reference property is what satisfies your need in a more 
easy way. I explained that at the bottom of a blog post here: 
http://blog.vogella.com/2016/09/26/configuring-osgi-declarative-services/

As an alternative you could also try if the available DS mechanisms would help, 
like servicefactory, scope or factory. I explained that here: 
http://blog.vogella.com/2017/02/13/control-osgi-ds-component-instances/

From your question that you want to request one special instance, I suppose the 
target property on a reference is what you need, but there are several ways for 
different scenarios. :)

Mit freundlichen Grüßen / Best regards

 Dirk Fauth

Automotive Service Solutions, ESI application (AA-AS/EIS2-EU) 
Robert Bosch GmbH | Postfach 11 29 | 73201 Plochingen | GERMANY | www.bosch.com
Tel. +49 7153 666-1155 | dirk.fa...@de.bosch.com

Sitz: Stuttgart, Registergericht: Amtsgericht Stuttgart, HRB 14000; 
Aufsichtsratsvorsitzender: Franz Fehrenbach; Geschäftsführung: Dr. Volkmar 
Denner, 
Prof. Dr. Stefan Asenkerschbaumer, Dr. Michael Bolle, Dr. Rolf Bulander, Dr. 
Stefan Hartung, Dr. Markus Heyn,
Dr. Dirk Hoheisel, Christoph Kübel, Uwe Raschke, Peter Tyroller


-----Ursprüngliche Nachricht-----
Von: osgi-dev-boun...@mail.osgi.org [mailto:osgi-dev-boun...@mail.osgi.org] Im 
Auftrag von David Leangen via osgi-dev
Gesendet: Mittwoch, 4. Juli 2018 07:12
An: osgi-dev@mail.osgi.org
Betreff: [osgi-dev] DS factory-type pattern


Hi,

This may be another really dumb question… but is there a smart way to use DS as 
a kind of factory?

What I have been doing so far:

 * Creating a Configuration via ConfigurationAdmin (I need to configure my 
component first)
 * In the config, including a kind of “secret” so I know which is MY instance
 * Listening for the existence of a service (which includes the secret)


It works very well, but there is a bit more cruft then I would like, and it 
doesn’t seem as elegant as it ought to.


Am I missing something, or is this the “right” was to do it at this time?


Cheers,
=David


_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev
_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to