keepalive.keepalive
Class PassiveKeepAlive

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--keepalive.keepalive.KeepAlive
              |
              +--keepalive.keepalive.PassiveKeepAlive
All Implemented Interfaces:
MessageListener, java.lang.Runnable

public class PassiveKeepAlive
extends KeepAlive
implements MessageListener

Resembles the ActiveKeepAlive in that it sends out dummy messages to see if it gets an IOException, but does not send out dummy messages periodically; rather, only if no incoming data is forthcoming for a long time do we test the connection.


Fields inherited from class keepalive.keepalive.KeepAlive
ARE_YOU_THERE, endRequested, I_HEAR_YOU, TIME_BETWEEN_ACTIVE_PROBES
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
PassiveKeepAlive()
          Used for dynamic classloading
PassiveKeepAlive(Receiver receiver, Sender sender)
           
 
Method Summary
 boolean messageReceived(java.lang.String s)
          Whenever we receive a message, wake up the listening thread for another loop.
 void run()
          Require the subclasses to implement run(), to prevent them from using the run() method in class Thread with a null body.
 void setReceiver(Receiver receiver)
           
 
Methods inherited from class keepalive.keepalive.KeepAlive
end, endRequested, getDummyString, getReceiver, getSender, getSilentTimeForIncoming, setSender
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PassiveKeepAlive

public PassiveKeepAlive(Receiver receiver,
                        Sender sender)

PassiveKeepAlive

public PassiveKeepAlive()
Used for dynamic classloading
Method Detail

setReceiver

public void setReceiver(Receiver receiver)
Overrides:
setReceiver in class KeepAlive

run

public void run()
Description copied from class: KeepAlive
Require the subclasses to implement run(), to prevent them from using the run() method in class Thread with a null body.
Overrides:
run in class KeepAlive

messageReceived

public boolean messageReceived(java.lang.String s)
Whenever we receive a message, wake up the listening thread for another loop. (The alternative mechanism would have the listening thread sleep() for a fixed time each loop, then check to see if the connection was silent. This might mean waking up uselessly, however.
Specified by:
messageReceived in interface MessageListener
Following copied from interface: keepalive.communication.MessageListener
Parameters:
s - the message that was received
Returns:
true if this MessageListener processed the incoming message, false if it ignored it.


© 2000 Joshua Fox