net.israfil.foundation.notification
Class NotificationCentre

java.lang.Object
  extended by net.israfil.foundation.notification.NotificationCentre

public class NotificationCentre
extends java.lang.Object

Author:
cgruber

Nested Class Summary
 class NotificationCentre.ObservationSpec
          TODO Use WeakReferences
 
Constructor Summary
protected NotificationCentre()
           
 
Method Summary
 void addObserver(java.lang.Object observer, java.lang.String callbackSignature, java.lang.String notification, java.lang.Object sender)
          This registers an object as an observer of notifications.
 void clearObservers()
           
static NotificationCentre defaultCentre()
           
 void postNotification(Notification notification)
          Post a notification with the given nam and notifier.
 void postNotification(java.lang.Object sender, java.lang.String notification)
          Post a notification with the given name, notifier, and with additional context information presented in a java.util.Map.
 void postNotification(java.lang.Object sender, java.lang.String notification, java.util.Map info)
          Post a notification with the given name, notifier, and with additional context information presented in a java.util.Map.
 void removeObserver(java.lang.Object observer, java.lang.String notification, java.lang.Object sender)
          Removes an observer from any notofications with either or both a provided notification string, or notifier
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NotificationCentre

protected NotificationCentre()
Method Detail

defaultCentre

public static NotificationCentre defaultCentre()

addObserver

public void addObserver(java.lang.Object observer,
                        java.lang.String callbackSignature,
                        java.lang.String notification,
                        java.lang.Object sender)
This registers an object as an observer of notifications. The object registers interest in either a particular named notification, or a particular object who may issue the notifications, or the union of the two. The following table lists the possible combinations:
Notification Name Sender Object Effect
null a sender Notifications (of any name) from this sender are observed
notification string null Notifications with this name (from any sender) are observed.
notification string a sender Only notifications with this name and originating from this sender are observed
null null All Notifications from any source will be sent (big performance drag)

Parameters:
observer - The object instance that wants to be registered
callbackSignature - Must be a method that takes a single Object parameter which will be a Notification at run-time, or a single Notification parameter
notification - The name of the notification to watch for (if any)
sender - The name of the object to whose notifications should be paid attention. (if any)

postNotification

public void postNotification(Notification notification)
Post a notification with the given nam and notifier.


postNotification

public void postNotification(java.lang.Object sender,
                             java.lang.String notification)
Post a notification with the given name, notifier, and with additional context information presented in a java.util.Map.


postNotification

public void postNotification(java.lang.Object sender,
                             java.lang.String notification,
                             java.util.Map info)
Post a notification with the given name, notifier, and with additional context information presented in a java.util.Map.


removeObserver

public void removeObserver(java.lang.Object observer,
                           java.lang.String notification,
                           java.lang.Object sender)
Removes an observer from any notofications with either or both a provided notification string, or notifier


clearObservers

public void clearObservers()


Copyright © 2003-2006. All Rights Reserved.