com.sun.faban.harness.logging
Class Listener

java.lang.Object
  extended by com.sun.faban.harness.logging.Listener
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
PrimaryListener

public class Listener
extends Object
implements Runnable

The generic listener listens to incoming requests and handles them appropriately.

Author:
Akara Sucharitakul

Field Summary
protected  LogConfig config
          The log configuration.
protected  Selector selector
          The selector instance used for listening.
 
Constructor Summary
Listener(Selector selector, LogConfig config, Queue<SocketChannel> acceptQueue)
          Constructs a new listener with this selector.
 
Method Summary
 void acceptNewClient(SelectionKey key)
          Accepts a new client and registers the resulting socket to the selector.
 void run()
          The thread's run method.
protected  void selectorOps(Selector selector)
          Hook for additional operations to be taken before the selector goes back to block on select.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

selector

protected Selector selector
The selector instance used for listening.


config

protected LogConfig config
The log configuration.

Constructor Detail

Listener

public Listener(Selector selector,
                LogConfig config,
                Queue<SocketChannel> acceptQueue)
Constructs a new listener with this selector. The selector is shared between multiple listener threads.

Parameters:
selector - The selector
config - The log configuration
acceptQueue - The queue for accepted connections
Method Detail

run

public void run()
The thread's run method.

Specified by:
run in interface Runnable

acceptNewClient

public void acceptNewClient(SelectionKey key)
                     throws IOException
Accepts a new client and registers the resulting socket to the selector.

Parameters:
key - The key result of the accept
Throws:
IOException - Error accepting new client
ClosedChannelException - Client has already disconnected

selectorOps

protected void selectorOps(Selector selector)
                    throws IOException
Hook for additional operations to be taken before the selector goes back to block on select. All changes to the channels/keys should be called here. The implementation in this class is empty.

Parameters:
selector - The selector
Throws:
IOException - An I/O error occurred