org.ow2.util.event.impl
Class EventDispatcher

java.lang.Object
  extended by org.ow2.util.event.impl.EventDispatcher
All Implemented Interfaces:
org.ow2.util.event.api.IEventDispatcher

public class EventDispatcher
extends java.lang.Object
implements org.ow2.util.event.api.IEventDispatcher

Define methods needed to register listeners and dispatch events.

Author:
missonng

Constructor Summary
EventDispatcher()
          The dispatcher constructor.
 
Method Summary
 void addListener(org.ow2.util.event.api.IEventListener listener)
          Add a listener.
 org.ow2.util.event.api.IEventToken dispatch(org.ow2.util.event.api.IEvent event)
          Dispatch this event.
 org.ow2.util.event.api.IEventToken dispatch(org.ow2.util.event.api.IEvent event, org.ow2.util.event.api.EventPriority priority)
          Dispatch an event.
 org.ow2.util.event.api.IEventToken dispatch(org.ow2.util.event.api.IEvent event, org.ow2.util.event.api.EventPriority priority, int nbWorker)
          Dispatch an event.
 org.ow2.util.event.api.IEventToken dispatch(org.ow2.util.event.api.IEvent event, org.ow2.util.event.api.EventPriority priority, long timeout)
          Dispatch an event.
 org.ow2.util.event.api.IEventToken dispatch(org.ow2.util.event.api.IEvent event, org.ow2.util.event.api.EventPriority priority, long timeout, int nbWorker)
          Dispatch an event.
 org.ow2.util.event.api.IEventToken dispatch(org.ow2.util.event.api.IEvent event, int nbWorker)
          Dispatch an event.
 org.ow2.util.event.api.IEventToken dispatch(org.ow2.util.event.api.IEvent event, long timeout)
          Dispatch an event.
 org.ow2.util.event.api.IEventToken dispatch(org.ow2.util.event.api.IEvent event, long timeout, int nbWorker)
          Dispatch an event.
 int getNbWorkers()
          Get the number of workers.
 boolean isAvailable()
          Get the dispatcher state.
 void removeListener(org.ow2.util.event.api.IEventListener listener)
          Remove a listener.
 void setNbWorkers(int nbWorkers)
          Set the number of workers.
 void start()
          Start the dispatcher.
 void stop()
          Stop the dispatcher.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventDispatcher

public EventDispatcher()
The dispatcher constructor.

Method Detail

start

public void start()
Start the dispatcher.

Specified by:
start in interface org.ow2.util.event.api.IEventDispatcher

stop

public void stop()
Stop the dispatcher.

Specified by:
stop in interface org.ow2.util.event.api.IEventDispatcher

isAvailable

public boolean isAvailable()
Get the dispatcher state.

Returns:
The dispatcher state.

getNbWorkers

public int getNbWorkers()
Get the number of workers.

Specified by:
getNbWorkers in interface org.ow2.util.event.api.IEventDispatcher
Returns:
The number of workers.

setNbWorkers

public void setNbWorkers(int nbWorkers)
Set the number of workers.

Specified by:
setNbWorkers in interface org.ow2.util.event.api.IEventDispatcher
Parameters:
nbWorkers - The number of workers.

addListener

public void addListener(org.ow2.util.event.api.IEventListener listener)
Add a listener.

Specified by:
addListener in interface org.ow2.util.event.api.IEventDispatcher
Parameters:
listener - The listener to add.

removeListener

public void removeListener(org.ow2.util.event.api.IEventListener listener)
Remove a listener.

Specified by:
removeListener in interface org.ow2.util.event.api.IEventDispatcher
Parameters:
listener - The listener to remove.

dispatch

public org.ow2.util.event.api.IEventToken dispatch(org.ow2.util.event.api.IEvent event)
Dispatch this event.

Specified by:
dispatch in interface org.ow2.util.event.api.IEventDispatcher
Parameters:
event - The event to dispatch.
Returns:
A token to manage the event processing, or null if the dispatcher is not available.

dispatch

public org.ow2.util.event.api.IEventToken dispatch(org.ow2.util.event.api.IEvent event,
                                                   org.ow2.util.event.api.EventPriority priority)
Dispatch an event.

Specified by:
dispatch in interface org.ow2.util.event.api.IEventDispatcher
Parameters:
event - The event to dispatch.
priority - the priority to synchronize with, or null to get the token immediately.
Returns:
A token to manage the event processing, or null if the dispatcher is not available.

dispatch

public org.ow2.util.event.api.IEventToken dispatch(org.ow2.util.event.api.IEvent event,
                                                   long timeout)
Dispatch an event.

Specified by:
dispatch in interface org.ow2.util.event.api.IEventDispatcher
Parameters:
event - The event to dispatch.
timeout - The maximum time dispatch waits for synchronous listeners to process.
Returns:
A token to manage the event processing, or null if the dispatcher is not available.

dispatch

public org.ow2.util.event.api.IEventToken dispatch(org.ow2.util.event.api.IEvent event,
                                                   int nbWorker)
Dispatch an event.

Specified by:
dispatch in interface org.ow2.util.event.api.IEventDispatcher
Parameters:
event - The event to dispatch.
nbWorker - The number of worker to allocate.
Returns:
A token to manage the event processing, or null if the dispatcher is not available.

dispatch

public org.ow2.util.event.api.IEventToken dispatch(org.ow2.util.event.api.IEvent event,
                                                   org.ow2.util.event.api.EventPriority priority,
                                                   long timeout)
Dispatch an event.

Specified by:
dispatch in interface org.ow2.util.event.api.IEventDispatcher
Parameters:
event - The event to dispatch.
priority - the priority to synchronize with, or null to get the token immediately.
timeout - The maximum time dispatch waits for synchronous listeners to process.
Returns:
A token to manage the event processing, or null if the dispatcher is not available.

dispatch

public org.ow2.util.event.api.IEventToken dispatch(org.ow2.util.event.api.IEvent event,
                                                   org.ow2.util.event.api.EventPriority priority,
                                                   int nbWorker)
Dispatch an event.

Specified by:
dispatch in interface org.ow2.util.event.api.IEventDispatcher
Parameters:
event - The event to dispatch.
priority - the priority to synchronize with, or null to get the token immediately.
nbWorker - The number of worker to allocate.
Returns:
A token to manage the event processing, or null if the dispatcher is not available.

dispatch

public org.ow2.util.event.api.IEventToken dispatch(org.ow2.util.event.api.IEvent event,
                                                   long timeout,
                                                   int nbWorker)
Dispatch an event.

Specified by:
dispatch in interface org.ow2.util.event.api.IEventDispatcher
Parameters:
event - The event to dispatch.
timeout - The maximum time dispatch waits for synchronous listeners to process.
nbWorker - The number of worker to allocate.
Returns:
A token to manage the event processing, or null if the dispatcher is not available.

dispatch

public org.ow2.util.event.api.IEventToken dispatch(org.ow2.util.event.api.IEvent event,
                                                   org.ow2.util.event.api.EventPriority priority,
                                                   long timeout,
                                                   int nbWorker)
Dispatch an event.

Specified by:
dispatch in interface org.ow2.util.event.api.IEventDispatcher
Parameters:
event - The event to dispatch.
priority - the priority to synchronize with, or null to get the token immediately.
timeout - The maximum time dispatch waits for synchronous listeners to process.
nbWorker - The number of worker to allocate.
Returns:
A token to manage the event processing, or null if the dispatcher is not available.


Copyright © 2007-2009 OW2 Consortium. All Rights Reserved.