// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/applicationinstance/events/ApplicationInstanceCreated.java
// public class ApplicationInstanceCreated extends ApplicationEvent {
// 
// 	public ApplicationInstanceCreated(ApplicationInstance instance) {
// 		super(instance);
// 	}
// 
// 	public ApplicationInstance getApplicationInstance() {
// 		return (ApplicationInstance) this.source;
// 	}
// 
// }
// 
// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/applicationinstance/events/ApplicationInstanceDeleted.java
// public class ApplicationInstanceDeleted extends ApplicationEvent {
// 
// 	public ApplicationInstanceDeleted(ApplicationInstance instance) {
// 		super(instance);
// 	}
// 
// 	public ApplicationInstance getApplicationInstance() {
// 		return (ApplicationInstance) this.source;
// 	}
// 
// }
// 
// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/discovery/events/ServiceDisappeared.java
// public class ServiceDisappeared extends ApplicationEvent {
// 
// 	public ServiceDisappeared(String service) {
// 		super(service);
// 	}
// 
// 	public String getService() {
// 		return (String) this.source;
// 	}
// 
// }
// 
// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/discovery/events/ServiceDiscovered.java
// public class ServiceDiscovered extends ApplicationEvent {
// 
// 	public ServiceDiscovered(String application) {
// 		super(application);
// 	}
// 
// 	public String getService() {
// 		return (String) this.source;
// 	}
// 
// }


import be.ordina.msdashboard.applicationinstance.events.ApplicationInstanceCreated;
import be.ordina.msdashboard.applicationinstance.events.ApplicationInstanceDeleted;
import be.ordina.msdashboard.discovery.events.ServiceDisappeared;
import be.ordina.msdashboard.discovery.events.ServiceDiscovered;
import org.springframework.context.event.EventListener;
/*
 * Copyright 2015-2019 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package be.ordina.msdashboard.catalog;



/**
 * Will update the {@link Catalog catalog} based on events that are happening throughout the system.
 *
 * @author Tim Ysewyn
 */
class CatalogUpdater {

	private final CatalogService catalogService;

	CatalogUpdater(CatalogService catalogService) {
		this.catalogService = catalogService;
	}

	@EventListener(ServiceDiscovered.class)
	public void addNewApplicationToCatalog(ServiceDiscovered event) {
		this.catalogService.addApplicationToCatalog(event.getService());
	}

	@EventListener(ServiceDisappeared.class)
	public void removeApplicationFromCatalog(ServiceDisappeared event) {
		this.catalogService.removeApplicationFromCatalog(event.getService());
	}

	@EventListener(ApplicationInstanceCreated.class)
	public void addNewApplicationInstanceToCatalog(ApplicationInstanceCreated event) {
		this.catalogService.addApplicationInstanceToCatalog(event.getApplicationInstance());
	}

	@EventListener(ApplicationInstanceDeleted.class)
// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/applicationinstance/events/ApplicationInstanceCreated.java
// public class ApplicationInstanceCreated extends ApplicationEvent {
// 
// 	public ApplicationInstanceCreated(ApplicationInstance instance) {
// 		super(instance);
// 	}
// 
// 	public ApplicationInstance getApplicationInstance() {
// 		return (ApplicationInstance) this.source;
// 	}
// 
// }
// 
// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/applicationinstance/events/ApplicationInstanceDeleted.java
// public class ApplicationInstanceDeleted extends ApplicationEvent {
// 
// 	public ApplicationInstanceDeleted(ApplicationInstance instance) {
// 		super(instance);
// 	}
// 
// 	public ApplicationInstance getApplicationInstance() {
// 		return (ApplicationInstance) this.source;
// 	}
// 
// }
// 
// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/discovery/events/ServiceDisappeared.java
// public class ServiceDisappeared extends ApplicationEvent {
// 
// 	public ServiceDisappeared(String service) {
// 		super(service);
// 	}
// 
// 	public String getService() {
// 		return (String) this.source;
// 	}
// 
// }
// 
// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/discovery/events/ServiceDiscovered.java
// public class ServiceDiscovered extends ApplicationEvent {
// 
// 	public ServiceDiscovered(String application) {
// 		super(application);
// 	}
// 
// 	public String getService() {
// 		return (String) this.source;
// 	}
// 
// }


// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/catalog/CatalogUpdater.java
import be.ordina.msdashboard.applicationinstance.events.ApplicationInstanceCreated;
import be.ordina.msdashboard.applicationinstance.events.ApplicationInstanceDeleted;
import be.ordina.msdashboard.discovery.events.ServiceDisappeared;
import be.ordina.msdashboard.discovery.events.ServiceDiscovered;
import org.springframework.context.event.EventListener;

/*
 * Copyright 2015-2019 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package be.ordina.msdashboard.catalog;



/**
 * Will update the {@link Catalog catalog} based on events that are happening throughout the system.
 *
 * @author Tim Ysewyn
 */
class CatalogUpdater {

	private final CatalogService catalogService;

	CatalogUpdater(CatalogService catalogService) {
		this.catalogService = catalogService;
	}

	@EventListener(ServiceDiscovered.class)
	public void addNewApplicationToCatalog(ServiceDiscovered event) {
		this.catalogService.addApplicationToCatalog(event.getService());
	}

	@EventListener(ServiceDisappeared.class)
	public void removeApplicationFromCatalog(ServiceDisappeared event) {
		this.catalogService.removeApplicationFromCatalog(event.getService());
	}

	@EventListener(ApplicationInstanceCreated.class)
	public void addNewApplicationInstanceToCatalog(ApplicationInstanceCreated event) {
		this.catalogService.addApplicationInstanceToCatalog(event.getApplicationInstance());
	}

	@EventListener(ApplicationInstanceDeleted.class)
	public void removeApplicationInstanceFromCatalog(ApplicationInstanceDeleted event) {