Stops this bundle.
The following steps are required to stop a bundle:
- If this bundle's state is
UNINSTALLED then an IllegalStateException is thrown. - 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. - If the {@link #STOP_TRANSIENT} option is not set then then set thisbundle's persistent autostart setting to to Stopped. When the Framework is restarted and this bundle's autostart setting is Stopped, this bundle must not be automatically started.
- If this bundle's state is not
STARTING or ACTIVE then this method returns immediately. - This bundle's state is set to
STOPPING. - A bundle event of type {@link BundleEvent#STOPPING} is fired.
- If this bundle's state was
ACTIVE prior to setting the state to STOPPING, the {@link BundleActivator#stop} methodof this bundle's BundleActivator, if one is specified, is called. If that method throws an exception, this method must continue to stop this bundle and a BundleException must be thrown after completion of the remaining steps. - Any services registered by this bundle must be unregistered.
- Any services used by this bundle must be released.
- Any listeners registered by this bundle must be removed.
- If this bundle's state is
UNINSTALLED, because this bundle was uninstalled while the BundleActivator.stop method was running, a BundleException must be thrown. - This bundle's state is set to
RESOLVED. - A bundle event of type {@link BundleEvent#STOPPED} is fired.
Preconditions getState() in { ACTIVE }.
Postconditions, no exceptions thrown - Bundle autostart setting is modified unless the {@link #STOP_TRANSIENT} option was set.
getState() not in { ACTIVE, STOPPING }. BundleActivator.stop has been called and did not throw an exception.
Postconditions, when an exception is thrown - Bundle autostart setting is modified unless the {@link #STOP_TRANSIENT} option was set.
@param options The options for stoping this bundle. See{@link #STOP_TRANSIENT}. The Framework must ignore unrecognized options.
@throws BundleException If this bundle's
BundleActivatorthrew an exception or this bundle is a fragment.
@throws IllegalStateException If this bundle has been uninstalled or thisbundle tries to change its own state.
@throws SecurityException If the caller does not have the appropriate
AdminPermission[this,EXECUTE], and the Java Runtime Environment supports permissions.
@since 1.4