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


Kane

>>However, the implementation of equinox's ds indeed do the enabling operation in a work thread.

This is how the OSGi spec requires the enableComponent method to behave:

112.5.1 Enabled
...
The enableComponent and disableComponent methods must return after changing the enabled state of the named component. Any actions that result from this, such as activating or deactivating a component configuration, must occur asynchronously to the method call. Therefore a component can disable itself.

>>My app intermittently suffer the NPE when using the service due to the enabling operation is not completed yet in other thread.

I would suggest not attempting to acquire a service registered by the recently enabled DS component, but rather create an entirely separate DS component that has a <reference> on the service you wish to acquire.  In this way you'll be certain to never get an NPE by having a DS component that will only have its configuration satisfied, and therefore activated, once you have enabled the DS component that provides the service.

Simon
http://equinoxosgi.org/


From: zhu kane <kane.mx@xxxxxxxxx>
To: equinox-dev@xxxxxxxxxxx
Date: 02/22/2010 05:16 AM
Subject: [equinox-dev] enable/disable component event
Sent by: equinox-dev-bounces@xxxxxxxxxxx





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