Thank you Dirk, those are very nice posts. I have come across these in the past and thought they were very informative.
If I am not mistaken, each of the methods you mention requires a @Reference. In this case, I am looking for a way to instantiate a service instance inline. Example: void someMethod() { if (someCondition) { // Do one thing } else { // Instantiate the required service using ConfigAdmin — don’t use @Reference here because it is done inline // Use the service // Delete the configuration, which will deactivate the service } } It is the meme above that I am not satisfied with: 1. Activate a service instance by creating a Configuration 2. Locate that specific service instance and use it 3. Delete the Configuration to deactivate the service instance Unless of course there is a clever way to use @Reference that I am missing which would provide an alternative means of accomplishing this. Best regards, =David > On Jul 4, 2018, at 14:45, Fauth Dirk (AA-AS/EIS2-EU) > <dirk.fa...@de.bosch.com> wrote: > > 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