FileDocCategorySizeDatePackage
ASServerSocketChannel.javaAPI DocGlassfish v2 API4618Fri May 04 22:35:52 BST 2007com.sun.enterprise.server.ss.provider

ASServerSocketChannel

public class ASServerSocketChannel extends ServerSocketChannel implements ASChannel

Fields Summary
private static final Logger
logger
private ServerSocketChannel
ssc
private ServerSocket
ssocket
private int
port
Constructors Summary
ASServerSocketChannel(ServerSocketChannel ssc, SelectorProvider p)


        
        super(p);
        this.ssc = ssc;
        // initialize the server port. It may be -1.
        port = ssc.socket().getLocalPort();
    
Methods Summary
public java.nio.channels.SocketChannelaccept()


	SocketChannel sc = ssc.accept();
        if ( logger.isLoggable(Level.FINE) ) {
             Socket s = sc.socket();
             logger.fine("In ASServerSocketChannel.accept got connection, s.port=" +
             s.getPort()+" s.localPort="+s.getLocalPort());
        }

        ASSocketFacadeUtils.getASSocketService().waitOnAccept(sc);

        return sc;
    
public java.nio.channels.SelectableChannelgetActualChannel()

        return ssc;

    
intgetPortNumber()

        return this.port;
    
public voidimplCloseSelectableChannel()
This is the place where a serversocket in socket service finally gets closed. Some services [eg. MQ] closes and recreates the serversocket while starting itself. However this can break, socket service logic, since the waiting connections can get a "connection reset" exception.

        ASSocketFacadeUtils.getASSocketService().close(port, null, ssc);
    
public voidimplConfigureBlocking(boolean b)

        ssc.configureBlocking(b);
    
voidsetPortNumber(int port)

        this.port = port;
    
voidsetServerSocketChannel(java.nio.channels.ServerSocketChannel ssc)

        this.ssc = ssc;
    
public java.net.ServerSocketsocket()

 
        try {
            if (ssocket == null) {
                ServerSocket ss = ssc.socket();
                ssocket = new ASServerSocket(ss, this);
            }
        } catch (Exception e ) {
            throw new RuntimeException(e);
        }
        return ssocket;
    
public java.lang.StringtoString()

	return "ASServerSocketChannel[" + ssc.toString() + "]";