com.h3c.util.observer

## Class AbstractListenerHandler<T>

- java.lang.Object
- - com.h3c.util.observer.AbstractListenerHandler<T>

- Type Parameters:
    `T` - type of the listener.
  All Implemented Interfaces:
    ListenerHandler<T>, Observable<T>
  Direct Known Subclasses:
    MultiThreadListenerHandler, SingleThreadListenerHandler

      public abstract class AbstractListenerHandler<T>
      extends Object
      implements ListenerHandler<T>

  Abstract listener handler.

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractListenerHandler(Store<T> listenerStore, ErrorHandler<T,Exception> errorHandler)` Creates a new listener handler.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract void` | `executeCallback(T listener, Invoker<T> invoker)` Executes a call back method to notify the listener.
    `protected ErrorHandler<T,Exception>` | `getErrorHandler()` Gets the error handler used to delegate error handling when notifying a listener.
    `protected void` | `notify(Collection<T> listenersToNotify, Invoker<T> invoker)` Notifies listeners.
    `void` | `notifyListeners(Invoker<T> invoker)` Notifies listeners.
    `void` | `register(T listener)` Registers an observer (listener).
    `void` | `unregister(T listener)` Unregisters an observer (listener).

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AbstractListenerHandler

          protected AbstractListenerHandler(Store<T> listenerStore,
                                 ErrorHandler<T,Exception> errorHandler)

      Creates a new listener handler.
      Parameters:
        `listenerStore` - listener store.
        `errorHandler` - error handler used to delegate error handling when notifying a listener.

  - ### Method Detail

    - #### register

          public void register(T listener)

      Description copied from interface: `Observable`
      Registers an observer (listener).
      Specified by:
        `register` in interface `Observable<T>`
      Parameters:
        `listener` - observer to register

    - #### unregister

          public void unregister(T listener)

      Description copied from interface: `Observable`
      Unregisters an observer (listener).
      Specified by:
        `unregister` in interface `Observable<T>`
      Parameters:
        `listener` - observer to unregister

    - #### notifyListeners

          public void notifyListeners(Invoker<T> invoker)

      Description copied from interface: `ListenerHandler`
      Notifies listeners.
      Specified by:
        `notifyListeners` in interface `ListenerHandler<T>`
      Parameters:
        `invoker` - Invoker to perform the listener call back method.

    - #### getErrorHandler

          protected ErrorHandler<T,Exception> getErrorHandler()

      Gets the error handler used to delegate error handling when notifying a listener.
      Returns:
        the error handler.

    - #### notify

          protected void notify(Collection<T> listenersToNotify,
                    Invoker<T> invoker)

      Notifies listeners.
      Parameters:
        `listenersToNotify` - listeners to notify.
        `invoker` - invoker to use.

    - #### executeCallback

          protected abstract void executeCallback(T listener,
                             Invoker<T> invoker)

      Executes a call back method to notify the listener.
      Parameters:
        `listener` - Listener to notify.
        `invoker` - Invoker to use.

Copyright © 2014. All Rights Reserved.