package com.timgroup.eventsubscription;

import java.util.List;

import com.timgroup.eventstore.api.Position;
import org.joda.time.DateTime;

public class BroadcastingEventHandler<T> implements EventHandler<T> {
    private final List<EventHandler<? super T>> handlers;

    public BroadcastingEventHandler(List<EventHandler<? super T>> handlers) {
        this.handlers = handlers;
    }

    @Override
    public void apply(Position position, DateTime timestamp, T deserialized, boolean endOfBatch) {
        for (EventHandler<? super T> handler : handlers) {
            handler.apply(position, timestamp, deserialized, endOfBatch);
        }
    }
}

@@ -38,32 +38,8 @@
 n;%0A%0A
-import java.util.List;%0A%0A
 impo
@@ -111,16 +111,90 @@
 eTime;%0A%0A
+import java.util.List;%0Aimport java.util.concurrent.CopyOnWriteArrayList;%0A%0A
 public c
@@ -416,24 +416,51 @@
 dlers = 
+new CopyOnWriteArrayList%3C%3E(
 handlers
 ;%0A    %7D%0A
@@ -451,16 +451,17 @@
 handlers
+)
 ;%0A    %7D%0A

store event handlers in CopyOnWriteArrayList