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;
}
}
Aggregations