Search in sources :

Example 1 with DestroyListener

use of org.glassfish.jersey.server.monitoring.DestroyListener in project jersey by jersey.

the class MonitoringEventListener method onEvent.

@Override
public void onEvent(final ApplicationEvent event) {
    final ApplicationEvent.Type type = event.getType();
    switch(type) {
        case INITIALIZATION_START:
            break;
        case RELOAD_FINISHED:
        case INITIALIZATION_FINISHED:
            this.monitoringStatisticsProcessor = new MonitoringStatisticsProcessor(injectionManager, this);
            this.monitoringStatisticsProcessor.startMonitoringWorker();
            break;
        case DESTROY_FINISHED:
            if (monitoringStatisticsProcessor != null) {
                try {
                    monitoringStatisticsProcessor.shutDown();
                } catch (final InterruptedException e) {
                    Thread.currentThread().interrupt();
                    throw new ProcessingException(LocalizationMessages.ERROR_MONITORING_SHUTDOWN_INTERRUPTED(), e);
                }
            }
            // onDestroy
            final List<DestroyListener> listeners = injectionManager.getAllInstances(DestroyListener.class);
            for (final DestroyListener listener : listeners) {
                try {
                    listener.onDestroy();
                } catch (final Exception e) {
                    LOGGER.log(Level.WARNING, LocalizationMessages.ERROR_MONITORING_STATISTICS_LISTENER_DESTROY(listener.getClass()), e);
                }
            }
            break;
    }
}
Also used : ApplicationEvent(org.glassfish.jersey.server.monitoring.ApplicationEvent) DestroyListener(org.glassfish.jersey.server.monitoring.DestroyListener) ProcessingException(javax.ws.rs.ProcessingException) ProcessingException(javax.ws.rs.ProcessingException)

Aggregations

ProcessingException (javax.ws.rs.ProcessingException)1 ApplicationEvent (org.glassfish.jersey.server.monitoring.ApplicationEvent)1 DestroyListener (org.glassfish.jersey.server.monitoring.DestroyListener)1