package com.hp.oo.orchestrator.services;

import com.hp.oo.internal.sdk.execution.events.EventBus;
import com.hp.oo.internal.sdk.execution.events.EventHandler;
import com.hp.oo.internal.sdk.execution.events.EventWrapper;

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

/**
 * User: hajyhia
 * Date: 1/19/14
 * Time: 5:51 PM
 */
public class EventBusImpl implements EventBus {

    private Map<EventHandler,Set<String>> handlers = new ConcurrentHashMap<>() ;


    public void register(EventHandler eventHandler, Set<String> eventTypes){
        handlers.put(eventHandler,eventTypes);
    }

    public void unRegister(EventHandler eventHandler){
        handlers.remove(eventHandler);
    }

    public void dispatch(EventWrapper... eventWrappers){
        for (EventHandler eventHandler : handlers.keySet()){
            Set<String> eventTypes = handlers.get(eventHandler);
            for (EventWrapper eventWrapper:eventWrappers){
                if (eventTypes.contains(eventWrapper.getEventType()))
                    eventHandler.handleEvent(eventWrapper);
            }
        }
    }

}

@@ -213,16 +213,65 @@
 Wrapper;
+%0Aimport org.springframework.stereotype.Component;
 %0A%0Aimport
@@ -415,16 +415,27 @@
  PM%0A */%0A
+@Component%0A
 public c

add missing @Component to EventBusImpl