use of org.xwiki.observation.event.ApplicationStoppedEvent in project xwiki-platform by xwiki.
the class XWikiServletContextListener method contextDestroyed.
@Override
public void contextDestroyed(ServletContextEvent sce) {
SHUTDOWN_LOGGER.debug("Stopping XWiki...");
// It's possible that the Component Manager failed to initialize some of the required components.
if (this.componentManager != null) {
// to do something on stop to do it.
try {
ObservationManager observationManager = this.componentManager.getInstance(ObservationManager.class);
observationManager.notify(new ApplicationStoppedEvent(), this);
} catch (ComponentLookupException e) {
// Nothing to do here.
// TODO: Log a warning
}
// below in an Event Listener and move it to the legacy module.
try {
ApplicationContextListenerManager applicationContextListenerManager = this.componentManager.getInstance(ApplicationContextListenerManager.class);
Container container = this.componentManager.getInstance(Container.class);
applicationContextListenerManager.destroyApplicationContext(container.getApplicationContext());
} catch (ComponentLookupException ex) {
// Nothing to do here.
// TODO: Log a warning
}
// Make sure to dispose all components before leaving
this.componentManager.dispose();
}
SHUTDOWN_LOGGER.debug("XWiki has been stopped!");
}
Aggregations