1 23 package com.sun.enterprise.server.ss.provider; 24 25 import java.io.*; 26 import java.net.*; 27 import java.nio.*; 28 import java.nio.channels.*; 29 import java.nio.channels.spi.*; 30 31 import java.util.logging.Logger ; 32 import java.util.logging.Level ; 33 import com.sun.enterprise.server.ss.ASSocketService; 34 import com.sun.enterprise.server.ss.spi.ASSocketFacadeUtils; 35 import com.sun.logging.LogDomains; 36 37 class ASServerSocketChannel extends ServerSocketChannel implements ASChannel { 38 private static Logger logger = LogDomains.getLogger(LogDomains.CORE_LOGGER); 39 40 private ServerSocketChannel ssc = null; 41 private ServerSocket ssocket = null; 42 private int port = 0; 43 44 ASServerSocketChannel(ServerSocketChannel ssc, SelectorProvider p) { 45 super(p); 46 this.ssc = ssc; 47 port = ssc.socket().getLocalPort(); 49 } 50 51 public ServerSocket socket() { 52 try { 53 if (ssocket == null) { 54 ServerSocket ss = ssc.socket(); 55 ssocket = new ASServerSocket(ss, this); 56 } 57 } catch (Exception e ) { 58 throw new RuntimeException (e); 59 } 60 return ssocket; 61 } 62 63 public SocketChannel accept() throws IOException { 64 65 SocketChannel sc = ssc.accept(); 66 if ( logger.isLoggable(Level.FINE) ) { 67 Socket s = sc.socket(); 68 logger.fine("In ASServerSocketChannel.accept got connection, s.port=" + 69 s.getPort()+" s.localPort="+s.getLocalPort()); 70 } 71 72 ASSocketFacadeUtils.getASSocketService().waitOnAccept(sc); 73 74 return sc; 75 } 76 77 public void implConfigureBlocking(boolean b) throws IOException { 78 ssc.configureBlocking(b); 79 } 80 81 90 public void implCloseSelectableChannel() throws IOException { 91 ASSocketFacadeUtils.getASSocketService().close(port, null, ssc); 92 } 93 94 95 public SelectableChannel getActualChannel() { 96 return ssc; 97 98 } 99 100 void setPortNumber(int port) { 101 this.port = port; 102 } 103 104 int getPortNumber() { 105 return this.port; 106 } 107 108 void setServerSocketChannel(ServerSocketChannel ssc) { 109 this.ssc = ssc; 110 } 111 112 public String toString() 114 { 115 return "ASServerSocketChannel[" + ssc.toString() + "]"; 116 } 117 } 118 119 121 122 | Popular Tags |