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

org.ow2.util.event.api.IEventDispatcher Maven / Gradle / Ivy

/**
 * OW2 Util
 * Copyright (C) 2008 Bull S.A.S.
 * Contact: [email protected]
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 *
 * --------------------------------------------------------------------------
 * $Id: IEventDispatcher.java 4389 2008-12-15 13:48:57Z alitokmen $
 * --------------------------------------------------------------------------
 */

package org.ow2.util.event.api;



/**
 * Define methods needed to register listeners and dispatch events.
 * @author missonng
 */
public interface IEventDispatcher {
    /**
     * Start the dispatcher.
     */
    void start();

    /**
     * Stop the dispatcher.
     */
    void stop();

    /**
     * Get the number of workers.
     * @return The number of workers.
     */
    int getNbWorkers();

    /**
     * Set the number of workers.
     * @param nbWorkers The number of workers.
     */
    void setNbWorkers(final int nbWorkers);

    /**
     * Add an event listener.
     * @param listener The event listener to add.
     */
    void addListener(IEventListener listener);

    /**
     * Remove an event listener.
     * @param listener The event listener to remove.
     */
    void removeListener(IEventListener listener);

    /**
     * Dispatch this event.
     * @param event The event to dispatch.
     * @return A token to manage the event processing, or null if the dispatcher is not available.
     */
    IEventToken dispatch(IEvent event);

    /**
     * Dispatch an event.
     * @param event The event to dispatch.
     * @param priority the priority to synchronize with, or null to get the token immediately.
     * @return A token to manage the event processing, or null if the dispatcher is not available.
     */
    IEventToken dispatch(IEvent event, EventPriority priority);

    /**
     * Dispatch an event.
     * @param event The event to dispatch.
     * @param timeout The maximum time dispatch waits for synchronous listeners to process.
     * @return A token to manage the event processing, or null if the dispatcher is not available.
     */
    IEventToken dispatch(IEvent event, long timeout);

    /**
     * Dispatch an event.
     * @param event The event to dispatch.
     * @param nbWorker The number of worker to allocate.
     * @return A token to manage the event processing, or null if the dispatcher is not available.
     */
    IEventToken dispatch(IEvent event, int nbWorker);

    /**
     * Dispatch an event.
     * @param event The event to dispatch.
     * @param priority the priority to synchronize with, or null to get the token immediately.
     * @param timeout The maximum time dispatch waits for synchronous listeners to process.
     * @return A token to manage the event processing, or null if the dispatcher is not available.
     */
    IEventToken dispatch(IEvent event, EventPriority priority, long timeout);

    /**
     * Dispatch an event.
     * @param event The event to dispatch.
     * @param priority the priority to synchronize with, or null to get the token immediately.
     * @param nbWorker The number of worker to allocate.
     * @return A token to manage the event processing, or null if the dispatcher is not available.
     */
    IEventToken dispatch(IEvent event, EventPriority priority, int nbWorker);

    /**
     * Dispatch an event.
     * @param event The event to dispatch.
     * @param timeout The maximum time dispatch waits for synchronous listeners to process.
     * @param nbWorker The number of worker to allocate.
     * @return A token to manage the event processing, or null if the dispatcher is not available.
     */
    IEventToken dispatch(IEvent event, long timeout, int nbWorker);

    /**
     * Dispatch an event.
     * @param event The event to dispatch.
     * @param priority the priority to synchronize with, or null to get the token immediately.
     * @param timeout The maximum time dispatch waits for synchronous listeners to process.
     * @param nbWorker The number of worker to allocate.
     * @return A token to manage the event processing, or null if the dispatcher is not available.
     */
    IEventToken dispatch(IEvent event, EventPriority priority, long timeout, int nbWorker);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy