mx4j.remote

Class DefaultRemoteNotificationServerHandler

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(Map environment)
Creates a new remote notification server handler.

Method Summary

void
addNotificationListener(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.
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(Integer id)
Removes the listener with the given ID from this handler
protected boolean
waitForNotifications(Object lock, long timeout)
Called when there are no notifications to send to the client.

Constructor Details

DefaultRemoteNotificationServerHandler

public DefaultRemoteNotificationServerHandler(Map environment)
Creates a new remote notification server handler.
Parameters:
environment - Contains environment variables used to configure this handler

Method Details

addNotificationListener

public void addNotificationListener(Integer id,
                                    NotificationTuple tuple)
Adds the given tuple with the given listener ID to this handler
Specified by:
addNotificationListener in interface RemoteNotificationServerHandler

close

public NotificationTuple[] close()
Closes this handler, that will not accept anymore add or removal of listeners
Specified by:
close in interface RemoteNotificationServerHandler
Returns:
The NotificationTuples currently held

fetchNotifications

public javax.management.remote.NotificationResult fetchNotifications(long sequenceNumber,
                                                                     int maxNotifications,
                                                                     long timeout)
            throws IOException
Fetches notifications from the notification buffer in order to send them to the client side
Specified by:
fetchNotifications in interface RemoteNotificationServerHandler

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.

generateListenerID

public Integer generateListenerID(javax.management.ObjectName name,
                                  javax.management.NotificationFilter filter)
Returns a unique ID for a client-side NotificationListener
Specified by:
generateListenerID in interface RemoteNotificationServerHandler

getLogger

protected Logger getLogger()

getServerNotificationListener

public javax.management.NotificationListener getServerNotificationListener()
Returns the unique server side listener that will represent client-side listeners on MBeans.
Specified by:
getServerNotificationListener in interface RemoteNotificationServerHandler

removeNotificationListener

public NotificationTuple removeNotificationListener(Integer id)
Removes the listener with the given ID from this handler
Specified by:
removeNotificationListener in interface RemoteNotificationServerHandler

waitForNotifications

protected boolean waitForNotifications(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 DefaultRemoteNotificationServerHandler should be called
timeout - The amount of time to wait (guaranteed to be strictly greater than 0)

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