class EventSpyDispatcher {
    private final Logger logger = LoggerFactory.getLogger(getClass());

    private final List<EventSpy> eventSpies;

    @Inject
    public EventSpyDispatcher(List<EventSpy> eventSpies) {
        // make copy to get rid of needless overhead for dynamic lookups
        this.eventSpies = new ArrayList<>(eventSpies);
    }

    public ExecutionListener chainListener(ExecutionListener listener) {
        if (eventSpies.isEmpty()) {
            return listener;
        }
        return new EventSpyExecutionListener(this, listener);
    }

    public RepositoryListener chainListener(RepositoryListener listener) {
        if (eventSpies.isEmpty()) {
            return listener;
        }
        return new EventSpyRepositoryListener(this, listener);
    }

    public void init(EventSpy.Context context) {<FILL_FUNCTION_BODY>}

    public void onEvent(Object event) {
        if (eventSpies.isEmpty()) {
            return;
        }
        for (EventSpy eventSpy : eventSpies) {
            try {
                eventSpy.onEvent(event);
            } catch (Exception | LinkageError e) {
                logError("notify", e, eventSpy);
            }
        }
    }

    public void close() {
        if (eventSpies.isEmpty()) {
            return;
        }
        for (EventSpy eventSpy : eventSpies) {
            try {
                eventSpy.close();
            } catch (Exception | LinkageError e) {
                logError("close", e, eventSpy);
            }
        }
    }

    private void logError(String action, Throwable e, EventSpy spy) {
        String msg = "Failed to " + action + " spy " + spy.getClass().getName() + ": " + e.getMessage();

        if (logger.isDebugEnabled()) {
            logger.warn(msg, e);
        } else {
            logger.warn(msg);
        }
    }
}

        if (eventSpies.isEmpty()) {
            return;
        }
        for (EventSpy eventSpy : eventSpies) {
            try {
                eventSpy.init(context);
            } catch (Exception | LinkageError e) {
                logError("initialize", e, eventSpy);
            }
        }
    
<no_super_class>