rabbit.io
Class SimpleHandlerRegistration

java.lang.Object
  extended by rabbit.io.SimpleHandlerRegistration
All Implemented Interfaces:
HandlerRegistration

public class SimpleHandlerRegistration
extends Object
implements HandlerRegistration

A class to hold information about when an operation was attached to the selector. Needed for timeout options.


Constructor Summary
SimpleHandlerRegistration(SocketHandler handler, long when)
           
 
Method Summary
 String getDescription()
          Get a text description
 SocketHandler getHandler(SelectionKey sk)
          Get the handler for the key.
 boolean isExpired(long now, long timeout)
          Check if this registration is expired.
 void register(int currentOps, int newOps, SelectionKey sk, SocketHandler sh, long when)
          Registers a new handler to the given selection key.
 void timeout()
          This handler has timed out.
 String toString()
           
 void unregister(SelectionKey sk, SocketHandler sh, String reason)
          unregister the given handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleHandlerRegistration

public SimpleHandlerRegistration(SocketHandler handler,
                                 long when)
Method Detail

toString

public String toString()
Overrides:
toString in class Object

isExpired

public boolean isExpired(long now,
                         long timeout)
Description copied from interface: HandlerRegistration
Check if this registration is expired.

Specified by:
isExpired in interface HandlerRegistration

getHandler

public SocketHandler getHandler(SelectionKey sk)
Description copied from interface: HandlerRegistration
Get the handler for the key.

Specified by:
getHandler in interface HandlerRegistration

register

public void register(int currentOps,
                     int newOps,
                     SelectionKey sk,
                     SocketHandler sh,
                     long when)
Description copied from interface: HandlerRegistration
Registers a new handler to the given selection key.

Specified by:
register in interface HandlerRegistration
Parameters:
currentOps - the current interest ops
newOps - the ops to handle
sk - the current channel key.
sh - the new handler to register.
when - the new timeout timing

unregister

public void unregister(SelectionKey sk,
                       SocketHandler sh,
                       String reason)
Description copied from interface: HandlerRegistration
unregister the given handler.

Specified by:
unregister in interface HandlerRegistration
Parameters:
sk - the current channel key.
sh - the handler to unregister.
reason - a text message saying why the unregistration happened.

timeout

public void timeout()
Description copied from interface: HandlerRegistration
This handler has timed out.

Specified by:
timeout in interface HandlerRegistration

getDescription

public String getDescription()
Description copied from interface: HandlerRegistration
Get a text description

Specified by:
getDescription in interface HandlerRegistration