Holger's
Java API

com.antelmann.util
Class Notifier

java.lang.Object
  extended by com.antelmann.util.Notifier

public final class Notifier
extends Object

Notifier objects are created exclusively by the NotificationService and deliver events as long as they are not stopped by the NotificationService. The mechanism of a Notifier is somewhat similar to a Observable object, but the Notifier can monitor any object without the restriction of the monitored object being a subclass of java.util.Observable.

Since:
16. Dezember 2006, 00:58
Author:
Holger Antelmann
See Also:
NotificationService, NotificationListener, Observable

Method Summary
 void addListener(NotificationListener listener)
           
 boolean contains(NotificationListener listener)
           
 boolean deliverNotification(EventObject event)
          runs synchronized on the embedded monitoredObject and delviers the event to all listeners
 boolean deliverNotification(Object source)
          generates and delivers a simple EventObject with the given object as source (which may be null)
 NotificationListener[] getListeners()
           
 Object getMonitoredObject()
           
 boolean hasListeners()
           
 boolean isStopped()
           
 void removeAll()
           
 void removeListener(NotificationListener listener)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isStopped

public boolean isStopped()

getMonitoredObject

public Object getMonitoredObject()

addListener

public void addListener(NotificationListener listener)
                 throws IllegalStateException
Throws:
IllegalStateException - if this Notifier has been stopped by the NotificationService

removeListener

public void removeListener(NotificationListener listener)

contains

public boolean contains(NotificationListener listener)

getListeners

public NotificationListener[] getListeners()

hasListeners

public boolean hasListeners()

removeAll

public void removeAll()

deliverNotification

public boolean deliverNotification(Object source)
generates and delivers a simple EventObject with the given object as source (which may be null)


deliverNotification

public boolean deliverNotification(EventObject event)
runs synchronized on the embedded monitoredObject and delviers the event to all listeners

Returns:
true if the notification was actually sent to all listeners; false if this Notifier instance was stopped


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads