Refreshes the specified bundles. This forces the update (replacement) or removal of packages exported by the specified bundles.
The technique by which the framework refreshes bundles may vary among different framework implementations. A permissible implementation is to stop and restart the framework.
This method returns to the caller immediately and then performs the following steps on a separate thread:
- Compute the {@link #getDependencyClosure(Collection) dependencyclosure} of the specified bundles. If no bundles are specified, computethe dependency closure of the {@link #getRemovalPendingBundles() removalpending} bundles.
- Each bundle in the dependency closure that is in the {@code ACTIVE}state will be stopped as described in the {@code Bundle.stop} method.
- Each bundle in the dependency closure that is in the {@code RESOLVED}state is unresolved and thus moved to the {@code INSTALLED} state. Theeffect of this step is that bundles in the dependency closure are no longer {@code RESOLVED}.
- Each bundle in the dependency closure that is in the {@code UNINSTALLED} state is removed from the dependency closure and isnow completely removed from the Framework.
- Each bundle in the dependency closure that was in the {@code ACTIVE}state prior to Step 2 is started as described in the {@code Bundle.start}method, causing all bundles required for the restart to be resolved. It is possible that, as a result of the previous steps, packages that were previously exported no longer are. Therefore, some bundles may be unresolvable until bundles satisfying the dependencies have been installed in the Framework.
For any exceptions that are thrown during any of these steps, a framework event of type {@code FrameworkEvent.ERROR} is fired containing theexception. The source bundle for these events should be the specific bundle to which the exception is related. If no specific bundle can be associated with the exception then the System Bundle must be used as the source bundle for the event. All framework events fired by this method are also delivered to the specified {@code FrameworkListener}s in the order they are specified.
When this process completes after the bundles are refreshed, the Framework will fire a Framework event of type {@code FrameworkEvent.PACKAGES_REFRESHED} to announce it has completedthe bundle refresh. The specified {@code FrameworkListener}s are notified in the order specified. Each specified {@code FrameworkListener} will becalled with a Framework event of type {@code FrameworkEvent.PACKAGES_REFRESHED}.
@param bundles The bundles to be refreshed, or {@code null} to refreshthe {@link #getRemovalPendingBundles() removal pending} bundles.
@param listeners Zero or more listeners to be notified when the bundlerefresh has been completed. The specified listeners do not need to be otherwise registered with the framework. If a specified listener is already registered with the framework, it will be notified twice.
@throws IllegalArgumentException If the specified {@code Bundle}s were not created by the same framework instance associated with this FrameworkWiring.
@throws SecurityException If the caller does not have{@code AdminPermission[System Bundle,RESOLVE]} and the Javaruntime environment supports permissions.