view rep/channel/REPServerSocketChannel.java @ 140:01062be677e9

*** empty log message ***
author kono
date Wed, 27 Aug 2008 20:23:39 +0900
parents 5b1a0574b406
children 785a3e8ea858
line wrap: on
line source

package rep.channel;

import java.io.IOException;
import java.net.ServerSocket;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.nio.channels.spi.SelectorProvider;

public class REPServerSocketChannel<P> extends ServerSocketChannel{

	public static boolean isSimulation;
	private ServerSocketChannel ss;
	
	protected REPServerSocketChannel(SelectorProvider provider) {
		super(provider);
		
	}
	
	public REPServerSocketChannel(ServerSocketChannel channel){
		super(null);
		ss = channel;
	}

	public REPServerSocketChannel() {
		super(null);
		
	}

   public REPServerSocketChannel<P> create() throws IOException {
		if(isSimulation){
			return new ServerChannelSimulatorImpl<P>(null).open();
		}else{
			return new REPServerSocketChannel<P>(open());
		}
	}

	public REPSocketChannel<P> accept1() throws IOException {
		return new REPSocketChannel<P>(ss.accept());
	}

	@Override
	public ServerSocket socket() {
		return ss.socket();
	}

	@Override
	protected void implCloseSelectableChannel() throws IOException {
		ss.close();
	}

	@Override
	protected void implConfigureBlocking(boolean block) throws IOException {
		ss.configureBlocking(block);
	}

	@Override
	public SocketChannel accept() throws IOException {
		// TODO Auto-generated method stub
		return null;
	}
}