mx4j.remote
Class AbstractRemoteNotificationClientHandler

java.lang.Object
  extended bymx4j.remote.AbstractRemoteNotificationClientHandler
All Implemented Interfaces:
RemoteNotificationClientHandler
Direct Known 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
protected AbstractRemoteNotificationClientHandler(ConnectionNotificationEmitter emitter, HeartBeat heartbeat, java.util.Map environment)
          Creates a new remote notification client-side handler.
 
Method Summary
 void addNotificationListener(java.lang.Integer id, NotificationTuple tuple)
          Adds the given tuple with the given listener ID to this handler
 boolean contains(NotificationTuple tuple)
          Returns whether the tuple is already present in this handler
protected abstract  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.
 java.lang.Integer getNotificationListener(NotificationTuple tuple)
          Returns the ID of the listener for the given tuple
 java.lang.Integer[] getNotificationListeners(NotificationTuple tuple)
          Returns the IDs of the listeners for the given 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(java.lang.Integer[] ids)
          Removes the listeners with the given IDs from this handler
protected  void sendConnectionNotificationLost(long number)
          Sends the JMXConnectionNotification.NOTIFS_LOST notification using the emitter passed to AbstractRemoteNotificationClientHandler
 void start()
          Starts notification fetching
 void stop()
          Stops notification fetching
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractRemoteNotificationClientHandler

protected AbstractRemoteNotificationClientHandler(ConnectionNotificationEmitter emitter,
                                                  HeartBeat heartbeat,
                                                  java.util.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 Detail

isActive

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

See Also:
start(), stop()

start

public void start()
Description copied from interface: RemoteNotificationClientHandler
Starts notification fetching

Specified by:
start in interface RemoteNotificationClientHandler
See Also:
RemoteNotificationClientHandler.stop()

stop

public void stop()
Description copied from interface: RemoteNotificationClientHandler
Stops notification fetching

Specified by:
stop in interface RemoteNotificationClientHandler
See Also:
RemoteNotificationClientHandler.start()

contains

public boolean contains(NotificationTuple tuple)
Description copied from interface: RemoteNotificationClientHandler
Returns whether the tuple is already present in this handler

Specified by:
contains in interface RemoteNotificationClientHandler

addNotificationListener

public void addNotificationListener(java.lang.Integer id,
                                    NotificationTuple tuple)
Description copied from interface: RemoteNotificationClientHandler
Adds the given tuple with the given listener ID to this handler

Specified by:
addNotificationListener in interface RemoteNotificationClientHandler
See Also:
MBeanServerConnection.addNotificationListener(javax.management.ObjectName, javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object), RemoteNotificationClientHandler.removeNotificationListeners(java.lang.Integer[])

getNotificationListeners

public java.lang.Integer[] getNotificationListeners(NotificationTuple tuple)
Description copied from interface: RemoteNotificationClientHandler
Returns the IDs of the listeners for the given tuple

Specified by:
getNotificationListeners in interface RemoteNotificationClientHandler
See Also:
MBeanServerConnection.removeNotificationListener(javax.management.ObjectName, javax.management.NotificationListener), RemoteNotificationClientHandler.getNotificationListener(mx4j.remote.NotificationTuple)

getNotificationListener

public java.lang.Integer getNotificationListener(NotificationTuple tuple)
Description copied from interface: RemoteNotificationClientHandler
Returns the ID of the listener for the given tuple

Specified by:
getNotificationListener in interface RemoteNotificationClientHandler
See Also:
MBeanServerConnection.removeNotificationListener(javax.management.ObjectName, javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object), RemoteNotificationClientHandler.getNotificationListeners(mx4j.remote.NotificationTuple)

removeNotificationListeners

public void removeNotificationListeners(java.lang.Integer[] ids)
Description copied from interface: RemoteNotificationClientHandler
Removes the listeners with the given IDs from this handler

Specified by:
removeNotificationListeners in interface RemoteNotificationClientHandler
See Also:
RemoteNotificationClientHandler.addNotificationListener(java.lang.Integer, mx4j.remote.NotificationTuple)

fetchNotifications

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

Throws:
java.io.IOException

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(mx4j.remote.ConnectionNotificationEmitter, mx4j.remote.HeartBeat, java.util.Map)

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(mx4j.remote.ConnectionNotificationEmitter, mx4j.remote.HeartBeat, java.util.Map)

sendConnectionNotificationLost

protected void sendConnectionNotificationLost(long number)
Sends the JMXConnectionNotification.NOTIFS_LOST notification using the emitter passed to AbstractRemoteNotificationClientHandler


getNotificationsCount

protected int getNotificationsCount()

getLogger

protected Logger getLogger()


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