com.sun.faban.harness.logging
Class PrimaryListener

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

public class PrimaryListener
extends Listener

The primary selector is the single entry point another thread may use to modify the select channels and configurations. Otherwise it behaves just like any other listener.

Author:
Akara Sucharitakul

Field Summary
 
Fields inherited from class com.sun.faban.harness.logging.Listener
config, selector
 
Constructor Summary
PrimaryListener(Selector selector, LogConfig config, Queue<SocketChannel> acceptQueue)
          Constructs the primary listener with this selector.
 
Method Summary
 void register(SelectableChannel channel, int operation, Object attachment)
          Adds/changes the channel registration from another thread.
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 com.sun.faban.harness.logging.Listener
acceptNewClient, run
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrimaryListener

public PrimaryListener(Selector selector,
                       LogConfig config,
                       Queue<SocketChannel> acceptQueue)
Constructs the primary listener with this selector.

Parameters:
selector - The selector
config - The log configuration
acceptQueue - The accept queue
Method Detail

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 logs changes to the channel.

Overrides:
selectorOps in class Listener
Parameters:
selector - The selector
Throws:
IOException - Error registering the selector with the channel

register

public void register(SelectableChannel channel,
                     int operation,
                     Object attachment)
Adds/changes the channel registration from another thread.

Parameters:
channel - The channel to register
operation - The operation of interest
attachment - The attachment