@Override public void destroyActivity(final Activity activity) { if (startedActivities.remove(activity) != null) { boolean isDependentScope = getBeanScope(activity) == Dependent.class; try { activity.onShutdown(); } catch (Exception ex) { lifecycleErrorHandler.handle(activity, LifecyclePhase.SHUTDOWN, ex); } if (isDependentScope) { iocManager.destroyBean(activity); } } else { throw new IllegalStateException("Activity " + activity + " is not currently in the started state"); } }