org.blojsom.event
Class SimpleBlojsomEventBroadcaster

java.lang.Object
  extended byorg.blojsom.event.SimpleBlojsomEventBroadcaster
All Implemented Interfaces:
BlojsomEventBroadcaster

public class SimpleBlojsomEventBroadcaster
extends java.lang.Object
implements BlojsomEventBroadcaster

SimpleBlojsomEventBroadcaster.

Events are broadcast to each event in a separate thread so that the broadcaster is not a bottleneck. No defined order is set for how each event will receive an event, so you should not assume any order in listeners being called. No steps are taken to ensure a event does not receive an event if it is removed at the same time an event is being broadcast.

The addition of the processEvent(BlojsomEvent) method adds the capability for components to have an event processed after the call instead of asynchronously as with the broadcastEvent(BlojsomEvent) method.

Since:
blojsom 2.18
Version:
$Id: SimpleBlojsomEventBroadcaster.java,v 1.6 2006/01/04 16:59:54 czarneckid Exp $
Author:
David Czarnecki

Nested Class Summary
protected  class SimpleBlojsomEventBroadcaster.EventHandler
          Event handler helper class.
 
Constructor Summary
SimpleBlojsomEventBroadcaster()
          Default constructor.
 
Method Summary
 void addListener(BlojsomListener listener)
          Add a event to this event broadcaster
 void addListener(BlojsomListener listener, BlojsomFilter filter)
          Add a event to this event broadcaster.
 void broadcastEvent(BlojsomEvent event)
          Broadcast an event to all listeners
 void processEvent(BlojsomEvent event)
          Process an event with all listeners
 void removeListener(BlojsomListener listener)
          Remove a event from this event broadcaster
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleBlojsomEventBroadcaster

public SimpleBlojsomEventBroadcaster()
Default constructor.

Method Detail

addListener

public void addListener(BlojsomListener listener)
Add a event to this event broadcaster

Specified by:
addListener in interface BlojsomEventBroadcaster
Parameters:
listener - BlojsomListener

addListener

public void addListener(BlojsomListener listener,
                        BlojsomFilter filter)
Add a event to this event broadcaster. Events are filtered using the BlojsomFilter instance passed to this method.

Specified by:
addListener in interface BlojsomEventBroadcaster
Parameters:
listener - BlojsomListener
filter - BlojsomFilter used to filter events

removeListener

public void removeListener(BlojsomListener listener)
Remove a event from this event broadcaster

Specified by:
removeListener in interface BlojsomEventBroadcaster
Parameters:
listener - BlojsomListener

broadcastEvent

public void broadcastEvent(BlojsomEvent event)
Broadcast an event to all listeners

Specified by:
broadcastEvent in interface BlojsomEventBroadcaster
Parameters:
event - BlojsomEvent to be broadcast to all listeners

processEvent

public void processEvent(BlojsomEvent event)
Process an event with all listeners

Specified by:
processEvent in interface BlojsomEventBroadcaster
Parameters:
event - BlojsomEvent to be processed by all listeners
Since:
blojsom 2.24