Holger's Java API

## com.antelmann.util
Class NotificationService

    java.lang.Object
      com.antelmann.util.NotificationService

    public final class NotificationService

extends Object

a singleton that maintains Notifier objects

Since:
  16. Dezember 2006, 13:59
Author:
  Holger Antelmann
See Also:
  `NotificationListener`, `Notifier`

Nested Class Summary
`static interface` `NotificationService.Listener`

Method Summary
`void` `addListener(NotificationService.Listener l)`
`NotificationService.Listener[]` `getListeners()`
`Object[]` `getMonitoredObjects()`
`Notifier` `getNotifier(Object monitoredObject)` returns either the Notifier that monitors the given object or null if the given object is not monitored
`static NotificationService` `getService()`
`boolean` `isMonitored(Object monitoredObject)`
`Notifier` `monitorObject(Object monitoredObject)` starts monitoring the given object by creating a new Notifier
`Notifier` `obtainNotifier(Object monitoredObject)` first calls getNotifier() and if that returns null, monitorObject() is called
`boolean` `removeListener(NotificationService.Listener l)`
`void` `stopAll()` calls stopNotifier() on all monitored objects
`void` `stopInactiveNotifiers()` calls stopNotifier() on all monitored objects where their respective Notifier instances have no listeners
`boolean` `stopNotifier(Object monitoredObject)` the Notifier for the given object will be stopped (all listeners will be informed) and removed from this service.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### getService

    public static NotificationService getService()

### isMonitored

    public boolean isMonitored(Object monitoredObject)

### getMonitoredObjects

    public Object[] getMonitoredObjects()

### stopAll

    public void stopAll()

  calls stopNotifier() on all monitored objects

### stopInactiveNotifiers

    public void stopInactiveNotifiers()

  calls stopNotifier() on all monitored objects where their respective Notifier instances have no listeners

### stopNotifier

    public boolean stopNotifier(Object monitoredObject)

  the Notifier for the given object will be stopped (all listeners will be informed) and removed from this service.

### monitorObject

    public Notifier monitorObject(Object monitoredObject)
                           throws IllegalStateException

  starts monitoring the given object by creating a new Notifier

  Returns:
    the newly created Notifier that monitores the given object
  Throws:
    `IllegalStateException` - if the given object is already monitored

### getNotifier

    public Notifier getNotifier(Object monitoredObject)

  returns either the Notifier that monitors the given object or null if the given object is not monitored

### obtainNotifier

    public Notifier obtainNotifier(Object monitoredObject)

  first calls getNotifier() and if that returns null, monitorObject() is called

### addListener

    public void addListener(NotificationService.Listener l)

### removeListener

    public boolean removeListener(NotificationService.Listener l)

### getListeners

    public NotificationService.Listener[] getListeners()

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