1 36 37 import java.io.*; 38 import java.nio.channels.*; 39 import javax.net.ssl.*; 40 41 49 class Acceptor implements Runnable { 50 51 private ServerSocketChannel ssc; 52 private Dispatcher d; 53 54 private SSLContext sslContext; 55 56 Acceptor(ServerSocketChannel ssc, Dispatcher d, SSLContext sslContext) { 57 this.ssc = ssc; 58 this.d = d; 59 this.sslContext = sslContext; 60 } 61 62 public void run() { 63 for (;;) { 64 try { 65 SocketChannel sc = ssc.accept(); 66 67 ChannelIO cio = (sslContext != null ? 68 ChannelIOSecure.getInstance( 69 sc, false , sslContext) : 70 ChannelIO.getInstance( 71 sc, false )); 72 73 RequestHandler rh = new RequestHandler(cio); 74 75 d.register(cio.getSocketChannel(), SelectionKey.OP_READ, rh); 76 77 } catch (IOException x) { 78 x.printStackTrace(); 79 break; 80 } 81 } 82 } 83 } 84 | Popular Tags |