org.jboss.webbeans.event
Class EventManager

java.lang.Object
  extended by org.jboss.webbeans.event.EventManager
All Implemented Interfaces:
java.io.Serializable

public class EventManager
extends java.lang.Object
implements java.io.Serializable

The event bus is where observers are registered and events are fired.

Author:
David Allen
See Also:
Serialized Form

Constructor Summary
EventManager()
          Initializes a new instance of the EventManager.
 
Method Summary
<T> void
addObserver(Observer<T> observer, java.lang.Class<T> eventType, java.lang.annotation.Annotation... bindings)
          Adds an observer to the event bus so that it receives event notifications.
<T> java.util.Set<Observer<T>>
getObservers(T event, java.lang.annotation.Annotation... bindings)
          Resolves the list of observers to be notified for a given event and optional event bindings.
<T> void
notifyObservers(java.util.Set<Observer<T>> observers, T event)
          Iterates over the interested observers.
<T> void
removeObserver(Observer<T> observer, java.lang.Class<T> eventType, java.lang.annotation.Annotation... bindings)
          Removes an observer from the event bus.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EventManager

public EventManager()
Initializes a new instance of the EventManager.

Method Detail

addObserver

public <T> void addObserver(Observer<T> observer,
                            java.lang.Class<T> eventType,
                            java.lang.annotation.Annotation... bindings)
Adds an observer to the event bus so that it receives event notifications.

Parameters:
observer - The observer that should receive events
eventType - The event type the observer is interested in
bindings - The bindings the observer wants to filter on

getObservers

public <T> java.util.Set<Observer<T>> getObservers(T event,
                                                   java.lang.annotation.Annotation... bindings)
Resolves the list of observers to be notified for a given event and optional event bindings.

Parameters:
event - The event object
bindings - Optional event bindings
Returns:
A set of Observers. An empty set is returned if there are no matches.

notifyObservers

public <T> void notifyObservers(java.util.Set<Observer<T>> observers,
                                T event)
Iterates over the interested observers. If an observer is transactional and there is a transaction currently in progress, the event is deferred. In other cases, the observer is notified immediately.

Parameters:
observers - The interested observers
event - The event type

removeObserver

public <T> void removeObserver(Observer<T> observer,
                               java.lang.Class<T> eventType,
                               java.lang.annotation.Annotation... bindings)
Removes an observer from the event bus.

Parameters:
observer - The observer to remove
eventType - The event type of the observer to remove
bindings - The bindings of the observer to remove

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2008. All Rights Reserved.