## mx4j.remote
Class DefaultRemoteNotificationServerHandler

    java.lang.Object
      mx4j.remote.DefaultRemoteNotificationServerHandler

All Implemented Interfaces:
  RemoteNotificationServerHandler

public class DefaultRemoteNotificationServerHandler
extends java.lang.Object
implements RemoteNotificationServerHandler

Base implementation of the RemoteNotificationServerHandler interface.

Version:
  $Revision: 1.12 $

Constructor Summary
`DefaultRemoteNotificationServerHandler(java.util.Map environment)` Creates a new remote notification server handler.

Method Summary
`void` `addNotificationListener(java.lang.Integer id, NotificationTuple tuple)` Adds the given tuple with the given listener ID to this handler
`NotificationTuple[]` `close()` Closes this handler, that will not accept anymore add or removal of listeners
`javax.management.remote.NotificationResult` `fetchNotifications(long sequenceNumber, int maxNotifications, long timeout)` Fetches notifications from the notification buffer in order to send them to the client side
`protected javax.management.remote.TargetedNotification[]` `filterNotifications(javax.management.remote.TargetedNotification[] notifications)` This method filters the given notification array and returns a possibly smaller array containing only notifications that passed successfully the filtering.
`java.lang.Integer` `generateListenerID(javax.management.ObjectName name, javax.management.NotificationFilter filter)` Returns a unique ID for a client-side NotificationListener
`protected Logger` `getLogger()`
`javax.management.NotificationListener` `getServerNotificationListener()` Returns the unique server side listener that will represent client-side listeners on MBeans.
`NotificationTuple` `removeNotificationListener(java.lang.Integer id)` Removes the listener with the given ID from this handler
`protected boolean` `waitForNotifications(java.lang.Object lock, long timeout)` Called when there are no notifications to send to the client.

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

Constructor Detail

### DefaultRemoteNotificationServerHandler

    public DefaultRemoteNotificationServerHandler(java.util.Map environment)

  Creates a new remote notification server handler.

Parameters:
  `environment` - Contains environment variables used to configure this handler
See Also:
  `MX4JRemoteConstants.NOTIFICATION_BUFFER_CAPACITY`, `MX4JRemoteConstants.NOTIFICATION_PURGE_DISTANCE`

Method Detail

### generateListenerID

    public java.lang.Integer generateListenerID(javax.management.ObjectName name,
                                                javax.management.NotificationFilter filter)

  Description copied from interface: `RemoteNotificationServerHandler`
  Returns a unique ID for a client-side NotificationListener

  Specified by:
    `generateListenerID` in interface `RemoteNotificationServerHandler`
  See Also:
    `RemoteNotificationServerHandler.addNotificationListener(java.lang.Integer, mx4j.remote.NotificationTuple)`

### getServerNotificationListener

    public javax.management.NotificationListener getServerNotificationListener()

  Description copied from interface: `RemoteNotificationServerHandler`
  Returns the unique server side listener that will represent client-side listeners on MBeans.

  Specified by:
    `getServerNotificationListener` in interface `RemoteNotificationServerHandler`

### addNotificationListener

    public void addNotificationListener(java.lang.Integer id,
                                        NotificationTuple tuple)

  Description copied from interface: `RemoteNotificationServerHandler`
  Adds the given tuple with the given listener ID to this handler

  Specified by:
    `addNotificationListener` in interface `RemoteNotificationServerHandler`
  See Also:
    `RemoteNotificationServerHandler.removeNotificationListener(java.lang.Integer)`

### removeNotificationListener

    public NotificationTuple removeNotificationListener(java.lang.Integer id)

  Description copied from interface: `RemoteNotificationServerHandler`
  Removes the listener with the given ID from this handler

  Specified by:
    `removeNotificationListener` in interface `RemoteNotificationServerHandler`
  See Also:
    `RemoteNotificationServerHandler.addNotificationListener(java.lang.Integer, mx4j.remote.NotificationTuple)`

### fetchNotifications

    public javax.management.remote.NotificationResult fetchNotifications(long sequenceNumber,
                                                                         int maxNotifications,
                                                                         long timeout)
                                                                  throws java.io.IOException

  Description copied from interface: `RemoteNotificationServerHandler`
  Fetches notifications from the notification buffer in order to send them to the client side

  Specified by:
    `fetchNotifications` in interface `RemoteNotificationServerHandler`
  Throws:
    `java.io.IOException` - If this handler has already been closed

### close

    public NotificationTuple[] close()

  Description copied from interface: `RemoteNotificationServerHandler`
  Closes this handler, that will not accept anymore add or removal of listeners

  Specified by:
    `close` in interface `RemoteNotificationServerHandler`
  Returns:
    The NotificationTuples currently held
  See Also:
    `RemoteNotificationServerHandler.fetchNotifications(long, int, long)`

### waitForNotifications

    protected boolean waitForNotifications(java.lang.Object lock,
                                           long timeout)

  Called when there are no notifications to send to the client. It is guaranteed that no notification can be added before this method waits on the given lock. It should wait on the given lock for the specified timeout, and return true to send notifications (if no notifications arrived, an empty notification array will be returned to the client), or false if no notifications should be sent to the client.

  Parameters:
    `lock` - The object on which `Object.wait()` should be called
    `timeout` - The amount of time to wait (guaranteed to be strictly greater than 0)

### filterNotifications

    protected javax.management.remote.TargetedNotification[] filterNotifications(javax.management.remote.TargetedNotification[] notifications)

  This method filters the given notification array and returns a possibly smaller array containing only notifications that passed successfully the filtering. Default behavior is no filtering, but subclasses may choose to change this bahavior. For example, for RMI, one can assure that all notifications are truly serializable, and log those that are not.

### getLogger

    protected Logger getLogger()

Copyright © 2001-2005 The MX4J Contributors. All Rights Reserved.