org.puremvc.java.multicore.patterns.observer
Class Notifier

java.lang.Object
  extended by org.puremvc.java.multicore.patterns.observer.Notifier
Direct Known Subclasses:
MacroCommand, Mediator, Proxy, SimpleCommand

public class Notifier
extends Object

A Base INotifier implementation.

MacroCommand, Command, Mediator and Proxy all have a need to send Notifications.

The INotifier interface provides a common method called sendNotification that relieves implementation code of the necessity to actually construct Notifications.

The Notifier class, which all of the above mentioned classes extend, provides an initialized reference to the Facade Singleton, which is required for the convienience method for sending Notifications, but also eases implementation as these classes have frequent Facade interactions and usually require access to the facade anyway.

See Also:
Facade, Mediator, Proxy, SimpleCommand, MacroCommand

Field Summary
protected  String multitonKey
           
 
Constructor Summary
Notifier()
           
 
Method Summary
protected  Facade getFacade()
           
 void initializeNotifier(String key)
          Initialize this INotifier instance.
 void sendNotification(String notificationName)
          Send an INotifications.
 void sendNotification(String notificationName, Object body)
          Send an INotifications.
 void sendNotification(String notificationName, Object body, String type)
          Send an INotifications.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

multitonKey

protected String multitonKey
Constructor Detail

Notifier

public Notifier()
Method Detail

getFacade

protected Facade getFacade()

sendNotification

public void sendNotification(String notificationName,
                             Object body,
                             String type)
Send an INotifications.

Keeps us from having to construct new notification instances in our implementation code.

Parameters:
notificationName - the name of the notiification to send
body - the body of the notification (optional)
type - the type of the notification (optional)

sendNotification

public void sendNotification(String notificationName,
                             Object body)
Send an INotifications.

Keeps us from having to construct new notification instances in our implementation code.

Parameters:
notificationName - the name of the notiification to send
body - the body of the notification (optional)

sendNotification

public void sendNotification(String notificationName)
Send an INotifications.

Keeps us from having to construct new notification instances in our implementation code.

Parameters:
notificationName - the name of the notiification to send

initializeNotifier

public void initializeNotifier(String key)
Initialize this INotifier instance.

This is how a Notifier gets its multitonKey. Calls to sendNotification or to access the facade will fail until after this method has been called.

Mediators, Commands or Proxies may override this method in order to send notifications or access the Multiton Facade instance as soon as possible. They CANNOT access the facade in their constructors, since this method will not yet have been called.

Parameters:
key - the multitonKey for this INotifier to use


Copyright © 2010. All Rights Reserved.