You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Benson Margulies <be...@basistech.com> on 2015/07/23 16:22:36 UTC

bundle start order and service listeners

I'm about to write code in which I set up blueprint injection of the
bundle context so that I can obtain a service. It occurs to me that
I've seen, out of my peripheral vision, some talk about issues of
start order: how to I ensure that my bundle goes looking for the
service after the source of the service registers it? Do I register a
service listener, and defer initialization until it sets up?

Re: bundle start order and service listeners

Posted by Benson Margulies <be...@basistech.com>.
Thanks. I'm sorry if I haven't learned to pose clear questions in this
field yet, but you completely answered me.


On Thu, Jul 23, 2015 at 10:42 AM, David Jencks <da...@yahoo.com> wrote:
> I can’t understand your description of what your code is trying to do, however…..
>
> If you want to work really hard but have it work, use a ServiceTracker (not ServiceListener).
> If you want to make it easy on yourself, use a DeclarativeServices component.
>
> Practically speaking, you won’t be able to write correct code that deals with both existing services and service events, leave that to ServiceTracker.
>
> thanks
> david jencks
>
>> On Jul 23, 2015, at 10:22 AM, Benson Margulies <be...@basistech.com> wrote:
>>
>> I'm about to write code in which I set up blueprint injection of the
>> bundle context so that I can obtain a service. It occurs to me that
>> I've seen, out of my peripheral vision, some talk about issues of
>> start order: how to I ensure that my bundle goes looking for the
>> service after the source of the service registers it? Do I register a
>> service listener, and defer initialization until it sets up?
>

Re: bundle start order and service listeners

Posted by David Jencks <da...@yahoo.com>.
I can’t understand your description of what your code is trying to do, however…..

If you want to work really hard but have it work, use a ServiceTracker (not ServiceListener).
If you want to make it easy on yourself, use a DeclarativeServices component.

Practically speaking, you won’t be able to write correct code that deals with both existing services and service events, leave that to ServiceTracker. 

thanks
david jencks

> On Jul 23, 2015, at 10:22 AM, Benson Margulies <be...@basistech.com> wrote:
> 
> I'm about to write code in which I set up blueprint injection of the
> bundle context so that I can obtain a service. It occurs to me that
> I've seen, out of my peripheral vision, some talk about issues of
> start order: how to I ensure that my bundle goes looking for the
> service after the source of the service registers it? Do I register a
> service listener, and defer initialization until it sets up?