Updates this bundle from an
InputStream
.
If the specified InputStream
is null
, the Framework must create the InputStream
from which to read the updated bundle by interpreting, in an implementation dependent manner, this bundle's {@link Constants#BUNDLE_UPDATELOCATION Bundle-UpdateLocation} Manifest header, if present, or this bundle'soriginal location.
If this bundle's state is ACTIVE
, it must be stopped before the update and started after the update successfully completes.
If this bundle has exported any packages that are imported by another bundle, these packages must not be updated. Instead, the previous package version must remain exported until the PackageAdmin.refreshPackages
method has been has been called or the Framework is relaunched.
The following steps are required to update a bundle:
- If this bundle's state is
UNINSTALLED
then an IllegalStateException
is thrown. - 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, the exception is rethrown terminating the update. - The updated version of this bundle is read from the input stream and installed. If the Framework is unable to install the updated version of this bundle, the original version of this bundle must be restored and a
BundleException
must be thrown after completion of the remaining steps. - This bundle's state is set to
INSTALLED
. - If the updated version of this bundle was successfully installed, a bundle event of type {@link BundleEvent#UPDATED} is fired.
- If this bundle's state was originally
ACTIVE
, the updated bundle is started as described in the Bundle.start
method. If Bundle.start
throws an exception, a Framework event of type {@link FrameworkEvent#ERROR} is fired containing theexception.
Preconditions getState()
not in { UNINSTALLED
}.
Postconditions, no exceptions thrown getState()
in { INSTALLED
, RESOLVED
, ACTIVE
}. - This bundle has been updated.
Postconditions, when an exception is thrown getState()
in { INSTALLED
, RESOLVED
, ACTIVE
}. - Original bundle is still used; no update occurred.
@param input The
InputStream
from which to read the newbundle or
null
to indicate the Framework must create the input stream from this bundle's {@link Constants#BUNDLE_UPDATELOCATION Bundle-UpdateLocation}Manifest header, if present, or this bundle's original location. The input stream must always be closed when this method completes, even if an exception is thrown.
@throws BundleException If the input stream cannot be read or the updatefails.
@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,LIFECYCLE]
for both the current bundle and the updated bundle, and the Java Runtime Environment supports permissions.
@see #stop()
@see #start()