Starts this bundle.
If this bundle's state is UNINSTALLED
then an IllegalStateException
is thrown.
If the Framework implements the optional Start Level service and the current start level is less than this bundle's start level:
- If the {@link #START_TRANSIENT} option is set, then a
BundleException
is thrown indicating this bundle cannot be started due to the Framework's current start level. - Otherwise, the Framework must set this bundle's persistent autostart setting to Started with declared activation if the {@link #START_ACTIVATION_POLICY} option is set orStarted with eager activation if not set.
When the Framework's current start level becomes equal to or more than this bundle's start level, this bundle will be started.
Otherwise, the following steps are required to start this bundle:
- 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 started. - If this bundle's state is
ACTIVE
then this method returns immediately. - If the {@link #START_TRANSIENT} option is not set then set thisbundle's autostart setting to Started with declared activation if the {@link #START_ACTIVATION_POLICY} option is set orStarted with eager activation if not set. When the Framework is restarted and this bundle's autostart setting is not Stopped, this bundle must be automatically started.
- If this bundle's state is not
RESOLVED
, an attempt is made to resolve this bundle. If the Framework cannot resolve this bundle, a BundleException
is thrown. - If the {@link #START_ACTIVATION_POLICY} option is set and thisbundle's declared activation policy is {@link Constants#ACTIVATION_LAZY lazy} then:
- If this bundle's state is
STARTING
then this method returns immediately. - This bundle's state is set to
STARTING
. - A bundle event of type {@link BundleEvent#LAZY_ACTIVATION} is fired.
- This method returns immediately and the remaining steps will be followed when this bundle's activation is later triggered.
- This bundle's state is set to
STARTING
. - A bundle event of type {@link BundleEvent#STARTING} is fired.
- The {@link BundleActivator#start} method of this bundle's
BundleActivator
, if one is specified, is called. If the BundleActivator
is invalid or throws an exception then: - This bundle's state is set to
STOPPING
. - A bundle event of type {@link BundleEvent#STOPPING} is fired.
- 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.
- This bundle's state is set to
RESOLVED
. - A bundle event of type {@link BundleEvent#STOPPED} is fired.
- A
BundleException
is then thrown.
- If this bundle's state is
UNINSTALLED
, because this bundle was uninstalled while the BundleActivator.start
method was running, a BundleException
is thrown. - This bundle's state is set to
ACTIVE
. - A bundle event of type {@link BundleEvent#STARTED} is fired.
Preconditions getState()
in { INSTALLED
, RESOLVED
} or { INSTALLED
, RESOLVED
, STARTING
} if this bundle has a lazy activation policy.
Postconditions, no exceptions thrown - Bundle autostart setting is modified unless the {@link #START_TRANSIENT} option was set.
getState()
in { ACTIVE
} unless the lazy activation policy was used. BundleActivator.start()
has been called and did not throw an exception unless the lazy activation policy was used.
Postconditions, when an exception is thrown - Depending on when the exception occurred, bundle autostart setting is modified unless the {@link #START_TRANSIENT} option was set.
getState()
not in { STARTING
, ACTIVE
}.
@param options The options for starting this bundle. See{@link #START_TRANSIENT} and {@link #START_ACTIVATION_POLICY}. The Framework must ignore unrecognized options.
@throws BundleException If this bundle could not be started. This couldbe because a code dependency could not be resolved or the specified
BundleActivator
could not be loaded or threw 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