FileDocCategorySizeDatePackage
AcceptHandler.javaAPI DocSun JDK 1.5.0 Example2909Sat Jan 08 15:08:43 GMT 2005None

AcceptHandler

public class AcceptHandler extends Object implements Handler
A single threaded Handler that performs accepts SocketChannels and registers the Channels with the read/write Selector.
author
Mark Reinhold
author
Brad R. Wetmore
version
1.2, 04/07/26

Fields Summary
private ServerSocketChannel
channel
private Dispatcher
dsp
private SSLContext
sslContext
Constructors Summary
AcceptHandler(ServerSocketChannel ssc, Dispatcher dsp, SSLContext sslContext)

	channel = ssc;
	this.dsp = dsp;
	this.sslContext = sslContext;
    
Methods Summary
public voidhandle(java.nio.channels.SelectionKey sk)


	if (!sk.isAcceptable())
	    return;

	SocketChannel sc = channel.accept();
	if (sc == null) {
	    return;
	}

	ChannelIO cio = (sslContext != null ?
	    ChannelIOSecure.getInstance(
		sc, false /* non-blocking */, sslContext) :
	    ChannelIO.getInstance(
		sc, false /* non-blocking */));

	RequestHandler rh = new RequestHandler(cio);
	dsp.register(cio.getSocketChannel(), SelectionKey.OP_READ, rh);