package de.ivu.elect.business.system.control;

import java.util.EnumMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.ivu.elect.business.system.entity.BackgroundServiceStatus;
import de.ivu.elect.business.system.entity.BackgroundServiceStatusFactory;
import de.ivu.elect.business.system.entity.SystemLogQuelle;

/**
 *  on 31.10.2016.
 */
public class BackgroundServiceStatusProvider {

  private static final Logger LOG = LoggerFactory.getLogger(BackgroundServiceStatusProvider.class);

  private static final Map<SystemLogQuelle, BackgroundServiceStatusFactory> FACTORY_MAP = new ConcurrentHashMap<>();

  public static void addFactory(SystemLogQuelle systemLogQuelle, BackgroundServiceStatusFactory factory) {
    LOG.info("Status für Quelle: " + systemLogQuelle);
    FACTORY_MAP.put(systemLogQuelle, factory);
  }

  public static Map<SystemLogQuelle, BackgroundServiceStatus> getStatus() {
    Map<SystemLogQuelle, BackgroundServiceStatus> result = new EnumMap<>(SystemLogQuelle.class);
    FACTORY_MAP.forEach((key, value) -> result.put(key, value.createStatus()));
    return result;
  }

}
