Hi BJ, Thank you for your reply.
That's what I had expected (callback of modifiedService() will not happen) and I agree that the case you descrived can be assumed as a pathological case. However, how about the following case ? ---- 1. The tracked service has been registered already. (ServiceRegistration has been returned to the registering bundle1). 2. Then the tracker gets open. ==> the addingService() will be called back. in 3. Asyncronously, bundle1 modifies the properties of the service during the callback of addingService(). Even in the case, modifiedService() will NOT be called back. That means, it could happen that a customizer cannot know the fact the service property it gets in its addingService() is stale. This seems not the pathlogical case. That would be a problem. ---- What do you think ? Best regards, Ikuo On Tue, 15 Sep 2009 10:31:58 -0400 BJ Hargrave <[email protected]> wrote: BJ> There is a pathological case. But it does not result in modifedService BJ> being called. BJ> BJ> The ServiceEvent for REGISTERED is delivered synchronously before the BJ> BundleContext.registerService method returns. In order for the service BJ> properties to be modified before the addingService call completes, the BJ> following would all have to occur: BJ> BJ> 1) Service was registered as a ServiceFactory BJ> 2) Tracker's addingService method gets the service by calling BJ> BundleContext.getService BJ> 3) The service's ServiceFactory.getService method would be called and BJ> provided the ServiceRegistration object for the service which it uses to BJ> modify the service properties. BJ> BJ> This would result in a ServiceEvent MODIFIED event being synchronously BJ> delivered. So the tracker will receive the event, but since the BJ> addingService method has not returned, the service will not have been BJ> added to tracker yet but the tracker (if the properties still match the BJ> tracker's filter) will see that it is already in the process of adding the BJ> service to the tracker and just return. No customizer method will be BJ> called. BJ> BJ> So the situation you describe can't occur. BJ> BJ> -- BJ> BJ> BJ Hargrave BJ> Senior Technical Staff Member, IBM BJ> OSGi Fellow and CTO of the OSGi Alliance BJ> [email protected] BJ> BJ> office: +1 386 848 1781 BJ> mobile: +1 386 848 3788 BJ> BJ> BJ> BJ> BJ> From: BJ> Ikuo Yamasaki <[email protected]> BJ> To: BJ> OSGi Developer Mail List <[email protected]> BJ> Date: BJ> 2009/09/15 07:37 BJ> Subject: BJ> [osgi-dev] service modification during addingService callback BJ> Sent by: BJ> [email protected] BJ> BJ> BJ> BJ> Hi all, BJ> BJ> I have a question on ServiceTracker. BJ> BJ> 1: tracker.open(); BJ> 2: The tracked Service is registered. BJ> ==>customizer#addingService() is called back BJ> synchronously. BJ> BJ> Question: If the tracked service's service props gets modified before BJ> addingService() returns, customizer#modifiedService() will be called BJ> back ? BJ> BJ> Best regards, BJ> BJ> ======= BJ> Ikuo YAMASAKI BJ> BJ> BJ> _______________________________________________ BJ> OSGi Developer Mail List BJ> [email protected] BJ> https://mail.osgi.org/mailman/listinfo/osgi-dev BJ> _______________________________________________ OSGi Developer Mail List [email protected] https://mail.osgi.org/mailman/listinfo/osgi-dev
