com.flat502.rox.server
Interface AcceptPolicy


public interface AcceptPolicy

A very simple accept policy interface.

An instance of this interface may be associated with an instance of HttpRpcServer. After a new connection has been accepted, and before that connection is added to the underlying Selector the installed AcceptPolicy is consulted to check if the accepted connection should be retained.

If policy dictates that the connection not be retained it is closed immediately.


Method Summary
 boolean shouldRetain(java.nio.channels.SocketChannel channel, int activeChannels)
          Consulted to determine whether or not the given SocketChannel should be retained.
 

Method Detail

shouldRetain

boolean shouldRetain(java.nio.channels.SocketChannel channel,
                     int activeChannels)
Consulted to determine whether or not the given SocketChannel should be retained.

Implementations should avoid any calls on the channel that may block. Blocking the calling thread will have a significant impact on throughput on the server.

Parameters:
channel - The SocketChannel that has just been accepted.
activeChannels - An (approximate) value indicating the number of active channels.
Returns:
true if the channel should be retained, or false if it should be closed and discarded.