final ApplicationContext ctx = ((ContextRefreshedEvent) event).getApplicationContext();
// Check that the JMXControl exists before registering all exportables
// see JMXControl javadocs for why we have to do it this way
JMXControl jmxControl = JMXControl.getFromContext(ctx);
if (jmxControl == null) {
throw new PanicInTheCougar("jmxControl bean not found in ApplicationContext");
}
if (exportables != null) {
for (Exportable exportable : exportables) {
exportable.export(jmxControl);
}
}
// Open the starting gate
notifyStartingGateListeners();
Collection<ServiceAware> serviceAwareImpls = getServiceAwareImplementations(ctx);
if (serviceAwareImpls != null && serviceAwareImpls.size() > 0) {
Set<Service> services = new HashSet<Service>();
Collection<Map<ServiceDefinition, Service>> serviceDefinitions = getServiceImplementationMap().values();
for (Map<ServiceDefinition, Service> serviceDefinition : serviceDefinitions) {
services.addAll(serviceDefinition.values());
}
for (ServiceAware serviceAware : serviceAwareImpls) {
serviceAware.setServices(services);
}
}
Status status = monitorRegistry
.getStatusAggregator()
.getStatus();
logger.log((status != Status.OK ? Level.WARNING : Level.INFO),
"Cougar returned status %s at startup", status);
} catch (Exception e) {
throw new PanicInTheCougar("Failed to initialise server", e);
}
logSuccessfulCougarStartup();
}
}