All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.kolibrifx.plovercrest.server.internal.DirectEventDispatcher Maven / Gradle / Ivy

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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy