Bundle.uninstall does not call Bundle.stop. It just says it stops the bundle as described in Bundle.stop. First Bundle.uninstall must obtain the state change lock. Once this occurs, the bundle can be stopped. Any exception thrown by BundleActivator.stop is published as a FrameworkEvent, but uninstall still completes normally. Only if the state change lock cannot be obtained in a reasonable time, will uninstall terminate with an exception.
So case 1 never happens during uninstall since uninstall does not call stop. -- BJ Hargrave Senior Technical Staff Member, IBM OSGi Fellow and CTO of the OSGi Alliance [email protected] office: +1 386 848 1781 mobile: +1 386 848 3788 From: Ikuo Yamasaki <[email protected]> To: OSGi Developer Mail List <[email protected]> Date: 2011/05/26 20:53 Subject: Re: [osgi-dev] Q on Bundle#uninstall() Sent by: [email protected] Hi BJ, On Thu, 26 May 2011 18:46:25 -0400 BJ Hargrave <[email protected]> wrote: BJ> No. If stop completes with an exception, uninstall can still proceed. BJ> Uninstall can fail if the state change lock is held by another thread and BJ> that thread does not release the lock in some reasonable time. Spec says: -- quote ------------------------------------------------------- public void stop( int options ) throws BundleException 2 If this bundle is in the process of being activated or deactivated then this method must wait for activation or deactivation to complete before continuing. If this does not occur in a reasonable time, a BundleException is thrown to indicate this bundle was unable to be stopped. -- quote ------------------------------------------------------- It seems to me there exists two cases: Case1: Bundle.stop() throws BundleException due to the above reason. (Bundle#uninstall() does not throw BundleException) Case2: the state change lock is held by another thread and that thread does not release the lock in some reasonable time. (Bundle#uninstall() throws BundleException) Q1. Does Case2 include Case1 or not ? For me, yes. Q2. when should those check for Case2 be done in the following steps described in "6.1.4.35 public void uninstall( )" --begin quote--- The following steps are required to uninstall a bundle: 1 If this bundle’s state is UNINSTALLED then an IllegalStateException is thrown. 2 If this bundle’s state is ACTIVE, STARTING or STOPPING, this bundle is stopped as described in the Bundle.stop method. If Bundle.stop throws an exception, a Framework event of type FrameworkEvent.ERROR is fired containing the exception. 3 This bundle’s state is set to UNINSTALLED. 4 A bundle event of type BundleEvent.UNINSTALLED is fired. 5 This bundle and any persistent storage area provided for this bundle by the Framework are removed. --end quote--- Q3. Even in Case2, step 3-5 should be done. Is my understanding correct ? ======= Ikuo YAMASAKI _______________________________________________ OSGi Developer Mail List [email protected] https://mail.osgi.org/mailman/listinfo/osgi-dev
_______________________________________________ OSGi Developer Mail List [email protected] https://mail.osgi.org/mailman/listinfo/osgi-dev
