// #3 This module's state is set to {@code STOPPING}
setState(State.STOPPING);
// #4 A module event of type {@link ModuleEvent#STOPPING} is fired.
RuntimeEventsManager eventHandler = getRuntime().adapt(RuntimeEventsManager.class);
eventHandler.fireModuleEvent(this, ModuleEvent.STOPPING);
// #5 The {@link ModuleActivator#stop(ModuleContext)} is called
Throwable stopException = null;
try {
ModuleActivator moduleActivator = getAttachment(MODULE_ACTIVATOR_KEY);
if (moduleActivator != null) {
moduleActivator.stop(getModuleContext());
}
} catch (Throwable th) {
stopException = th;
}
// #6 [TODO] Any services registered by this module must be unregistered.
// #7 [TODO] Any services used by this module must be released.
// #8 [TODO] Any listeners registered by this module must be removed.
// #9 This module's state is set to {@code RESOLVED}.
setState(State.RESOLVED);
// #10 A module event of type {@link ModuleEvent#STOPPED} is fired.
eventHandler.fireModuleEvent(this, ModuleEvent.STOPPED);
// Destroy the {@link ModuleContext}
destroyModuleContext();
if (stopException != null)