com.bigbross.bossa.notify
Class NotificationBus

java.lang.Object
  extended bycom.bigbross.bossa.notify.NotificationBus
All Implemented Interfaces:
Serializable

public class NotificationBus
extends Object
implements Serializable

This class manages all event notifications inside Bossa. The events are notified to listeners registered in the bus. This registration can happen either at the bus creation or at a later time.

The listeners registered after the bus is created will not be preserved if this bus is serialized. Due to this behaviour, objects outside the Bossa core that are registered as listeners may lose notification of events if a failure crashes the system.

Author:
BigBross Team
See Also:
Serialized Form

Constructor Summary
NotificationBus(Bossa engine)
          Creates a new empty notification bus.
NotificationBus(Bossa engine, List persistentListeners)
          Creates a new notification bus with some persistent listeners.
 
Method Summary
 void notifyEvent(Event event)
          Informs the occurrence of an event to all registered listeners.
 boolean registerListener(Listener listener)
          Registers a new listener of the notification bus.
 void removeListener(String id)
          Removes the listener from the notification bus, if present.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NotificationBus

public NotificationBus(Bossa engine,
                       List persistentListeners)
Creates a new notification bus with some persistent listeners.

Parameters:
engine - the bossa engine this notification bus is part.
persistentListeners - a list of the persistent listeners.

NotificationBus

public NotificationBus(Bossa engine)
Creates a new empty notification bus.

Parameters:
engine - the bossa engine this notification bus is part.
Method Detail

registerListener

public boolean registerListener(Listener listener)
Registers a new listener of the notification bus.

Parameters:
listener - the object that will act as a listener of the notification bus.
Returns:
true if the listener is registered, false if there is already a listener registered with the same id.

removeListener

public void removeListener(String id)
Removes the listener from the notification bus, if present.

Parameters:
id - the id of the listener.

notifyEvent

public void notifyEvent(Event event)
Informs the occurrence of an event to all registered listeners.

An event has an id and some attributes that are dependent on the event type. See the constructor of the Event class for more information.

Parameters:
event - the event.
See Also:
Event.Event(java.lang.String, int, java.util.Map, java.util.Date)


Copyright © 2003,2004 OpenBR Sistemas S/C Ltda.