[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] enable/disable component event

Hello Kane,

It's not 100% clear from your description, but it sounds like you are
calling BundleContext.getServiceReference() immediately after calling
enableComponent, and expecting it to always return non-null. As you
have noticed, this is not the case. Not only do you have potential
race conditions because of asynchronous registration of the service,
but you might find that the service will never appear because of a
missing mandatory reference, or because of configuration policy.

The event you are looking for is simply ServiceEvent... but it is not
a good idea to program at such a low level. The best way to access the
service published by a DS component is to write another component that
has a reference to the first. DS will take care to only activate the
second component once the service from the first is published.

Regards,
Neil

On Mon, Feb 22, 2010 at 10:15 AM, zhu kane <kane.mx@xxxxxxxxx> wrote:
> I have a DS component that is not enabled when started. It won't be enabled
> until some conditions are satisfied. So I manually call
> ComponentContext.enableComponent to enable the specified component. However,
> the implementation of equinox's ds indeed do the enabling operation in a
> work thread. My app intermittently suffer the NPE when using the service due
> to the enabling operation is not completed yet in other thread.
> I read the source code of equinox's ds, but I don't see any event is
> broadcasted after enabling a component.
> Is there a way to be notified after the component is changed? Or enable the
> component via a synchronized calling.
>
> Best Regards
> Kane
>
>
> _______________________________________________
> equinox-dev mailing list
> equinox-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/equinox-dev
>
>