## mx4j.remote
Class AbstractHeartBeat

    java.lang.Object
      mx4j.remote.AbstractHeartBeat

All Implemented Interfaces:
  HeartBeat, java.lang.Runnable

Direct Known Subclasses:
  HTTPHeartBeat, RMIHeartBeat

public abstract class AbstractHeartBeat
extends java.lang.Object
implements HeartBeat, java.lang.Runnable

Base implementation for the HeartBeat interface.

Version:
  $Revision: 1.4 $

Constructor Summary
`protected` `AbstractHeartBeat(ConnectionNotificationEmitter emitter, java.util.Map environment)` Creates a new HeartBeat.

Method Summary
`int` `getMaxRetries()` Returns the maximum number of retries this heart beat attempts after a first connection failure before declaring the connection or the server as dead.
`long` `getPulsePeriod()` Returns the period of time in milliseconds between two heart beats
`protected abstract void` `pulse()` Subclasses will implement this method using protocol specific connections.
`void` `run()`
`protected void` `sendConnectionNotificationFailed()` Sends the connection failed notification using the emitter specified in `AbstractHeartBeat(mx4j.remote.ConnectionNotificationEmitter, java.util.Map)`
`void` `start()` Starts the heart beat
`void` `stop()` Stops the heart beat

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

Constructor Detail

### AbstractHeartBeat

    protected AbstractHeartBeat(ConnectionNotificationEmitter emitter,
                                java.util.Map environment)

  Creates a new HeartBeat.

Parameters:
  `emitter` - The NotificationEmitter that sends connection failures notifications.
  `environment` - The environment that may contain properties that specify heart beat's behavior
See Also:
  `sendConnectionNotificationFailed()`, `MX4JRemoteConstants.CONNECTION_HEARTBEAT_PERIOD`, `MX4JRemoteConstants.CONNECTION_HEARTBEAT_RETRIES`

Method Detail

### getPulsePeriod

    public long getPulsePeriod()

  Description copied from interface: `HeartBeat`
  Returns the period of time in milliseconds between two heart beats

  Specified by:
    `getPulsePeriod` in interface `HeartBeat`
  See Also:
    `MX4JRemoteConstants.CONNECTION_HEARTBEAT_PERIOD`, `HeartBeat.getMaxRetries()`

### getMaxRetries

    public int getMaxRetries()

  Description copied from interface: `HeartBeat`
  Returns the maximum number of retries this heart beat attempts after a first connection failure before declaring the connection or the server as dead.

  Specified by:
    `getMaxRetries` in interface `HeartBeat`
  See Also:
    `MX4JRemoteConstants.CONNECTION_HEARTBEAT_RETRIES`, `HeartBeat.getPulsePeriod()`

### pulse

    protected abstract void pulse()
                           throws java.io.IOException

  Subclasses will implement this method using protocol specific connections. Normally the method `MBeanServerConnection.getDefaultDomain()` is used to "ping" the server side.

  Throws:
    `java.io.IOException`

### start

    public void start()
               throws java.io.IOException

  Description copied from interface: `HeartBeat`
  Starts the heart beat

  Specified by:
    `start` in interface `HeartBeat`
  Throws:
    `java.io.IOException` - If there are problems contacting the server
  See Also:
    `HeartBeat.stop()`

### stop

    public void stop()
              throws java.io.IOException

  Description copied from interface: `HeartBeat`
  Stops the heart beat

  Specified by:
    `stop` in interface `HeartBeat`
  Throws:
    `java.io.IOException` - If there are problems contacting the server
  See Also:
    `HeartBeat.start()`

### run

    public void run()

  Specified by:
    `run` in interface `java.lang.Runnable`

### sendConnectionNotificationFailed

    protected void sendConnectionNotificationFailed()

  Sends the connection failed notification using the emitter specified in `AbstractHeartBeat(mx4j.remote.ConnectionNotificationEmitter, java.util.Map)`

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