com.kolibrifx.plovercrest.server.internal.DirectEventDispatcher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plovercrest-server Show documentation
Show all versions of plovercrest-server Show documentation
Plovercrest server library.
The newest version!
/*
* Copyright (c) 2010-2017, KolibriFX AS. Licensed under the Apache License, version 2.0.
*/
package com.kolibrifx.plovercrest.server.internal;
/**
* Event dispatcher that simple invokes the listener directly on the current thread.
*
* This is intended mostly for unit tests that don't need to test thread race conditions.
*/
public class DirectEventDispatcher implements EventDispatcher {
private volatile boolean isShutDown = false;
@Override
public void dispatch(final TableListener listener, final TableEvent event) {
if (isShutDown)
throw new IllegalStateException("Event dispatched after shut down");
listener.handleTableEvent(event);
}
@Override
public void shutDown() {
isShutDown = true;
}
}