Search in sources :

Example 1 with ApplicationContextListenerManager

use of org.xwiki.container.ApplicationContextListenerManager 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!");
}
Also used : ApplicationContextListenerManager(org.xwiki.container.ApplicationContextListenerManager) Container(org.xwiki.container.Container) ObservationManager(org.xwiki.observation.ObservationManager) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException) ApplicationStoppedEvent(org.xwiki.observation.event.ApplicationStoppedEvent)

Aggregations

ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)1 ApplicationContextListenerManager (org.xwiki.container.ApplicationContextListenerManager)1 Container (org.xwiki.container.Container)1 ObservationManager (org.xwiki.observation.ObservationManager)1 ApplicationStoppedEvent (org.xwiki.observation.event.ApplicationStoppedEvent)1