mx4j.remote

Class AbstractRemoteNotificationClientHandler

Implemented Interfaces:
RemoteNotificationClientHandler
Known Direct Subclasses:
HTTPRemoteNotificationClientHandler, RMIRemoteNotificationClientHandler

public abstract class AbstractRemoteNotificationClientHandler
extends java.lang.Object
implements RemoteNotificationClientHandler

Base implementation of the RemoteNotificationClientHandler interface.

Version:
$Revision: 1.7 $

Constructor Summary

AbstractRemoteNotificationClientHandler(ConnectionNotificationEmitter emitter, HeartBeat heartbeat, Map environment)
Creates a new remote notification client-side handler.

Method Summary

void
addNotificationListener(Integer id, NotificationTuple tuple)
boolean
contains(NotificationTuple tuple)
protected javax.management.remote.NotificationResult
fetchNotifications(long sequence, int maxNumber, long timeout)
Calls the server side to fetch notifications.
protected Logger
getLogger()
protected int
getMaxRetries()
Returns the maximum number of attempts that should be made before declaring a connection failed.
Integer
getNotificationListener(NotificationTuple tuple)
Integer[]
getNotificationListeners(NotificationTuple tuple)
protected int
getNotificationsCount()
protected long
getRetryPeriod()
Returns the period between two retries if the connection with the server side fails.
boolean
isActive()
Returns whether this client handler is fetching notifications or not.
void
removeNotificationListeners(Integer[] ids)
protected void
sendConnectionNotificationLost(long number)
Sends the javax.management.remote.JMXConnectionNotification.NOTIFS_LOST notification using the emitter passed to AbstractRemoteNotificationClientHandler
void
start()
void
stop()

Constructor Details

AbstractRemoteNotificationClientHandler

protected AbstractRemoteNotificationClientHandler(ConnectionNotificationEmitter emitter,
                                                  HeartBeat heartbeat,
                                                  Map environment)
Creates a new remote notification client-side handler. It uses an emitter, an heartbeat and an environment to perform the job. All 3 can be null, but the corrispondent methods must be overridden

Parameters:
emitter - The NotificationEmitter that emits connection failures notifications
heartbeat - The heart beat is used to get the retry parameters in case of connection failure
environment - Contains environment variables used to configure this handler

See Also:
MX4JRemoteConstants.FETCH_NOTIFICATIONS_MAX_NUMBER, MX4JRemoteConstants.FETCH_NOTIFICATIONS_SLEEP, MX4JRemoteConstants.FETCH_NOTIFICATIONS_TIMEOUT, sendConnectionNotificationLost(long), getMaxRetries(), getRetryPeriod()

Method Details

addNotificationListener

public void addNotificationListener(Integer id,
                                    NotificationTuple tuple)
Specified by:
addNotificationListener in interface RemoteNotificationClientHandler


contains

public boolean contains(NotificationTuple tuple)
Specified by:
contains in interface RemoteNotificationClientHandler


fetchNotifications

protected javax.management.remote.NotificationResult fetchNotifications(long sequence,
                                                                        int maxNumber,
                                                                        long timeout)
            throws IOException
Calls the server side to fetch notifications.


getLogger

protected Logger getLogger()


getMaxRetries

protected int getMaxRetries()
Returns the maximum number of attempts that should be made before declaring a connection failed. This implementation returns the heartbeat max retries, but can be overridden.

See Also:
getRetryPeriod(), AbstractRemoteNotificationClientHandler


getNotificationListener

public Integer getNotificationListener(NotificationTuple tuple)
Specified by:
getNotificationListener in interface RemoteNotificationClientHandler


getNotificationListeners

public Integer[] getNotificationListeners(NotificationTuple tuple)
Specified by:
getNotificationListeners in interface RemoteNotificationClientHandler


getNotificationsCount

protected int getNotificationsCount()


getRetryPeriod

protected long getRetryPeriod()
Returns the period between two retries if the connection with the server side fails. This implementation returns the heartbeat pulse period, but can be overridden.

See Also:
getMaxRetries(), AbstractRemoteNotificationClientHandler


isActive

public boolean isActive()
Returns whether this client handler is fetching notifications or not.

See Also:
start(), stop()


removeNotificationListeners

public void removeNotificationListeners(Integer[] ids)
Specified by:
removeNotificationListeners in interface RemoteNotificationClientHandler


sendConnectionNotificationLost

protected void sendConnectionNotificationLost(long number)


start

public void start()
Specified by:
start in interface RemoteNotificationClientHandler


stop

public void stop()
Specified by:
stop in interface RemoteNotificationClientHandler


Copyright © 2001-2003 MX4J Team. All Rights Reserved.