// Return if topology has not been initialized
if (!topology.isInitialized())
return false;
// Parse complete message and build event
ServiceCreatedEvent event = (ServiceCreatedEvent) Util.jsonToObject(message, ServiceCreatedEvent.class);
// Apply service filter
if (TopologyServiceFilter.getInstance().isActive()) {
if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) {
// Service is excluded, do not update topology or fire event
if (log.isDebugEnabled()) {
log.debug(String.format("Service is excluded: [service] %s", event.getServiceName()));
}
return false;
}
}
// Validate event against the existing topology
if (topology.serviceExists(event.getServiceName())) {
if (log.isWarnEnabled()) {
log.warn(String.format("Service already created: [service] %s", event.getServiceName()));
}
} else {
// Apply changes to the topology
Service service = new Service(event.getServiceName(), event.getServiceType());
service.addPorts(event.getPorts());
topology.addService(service);
if (log.isInfoEnabled()) {
log.info(String.format("Service created: [service] %s", event.getServiceName()));
}
}
notifyEventListeners(event);