Java 类org.jboss.netty.channel.socket.oio.OioServerSocketChannelFactory 实例源码

项目:CacheStore    文件:TCPServer.java   
public static ChannelFactory getChannelFactory(boolean nio) {
    if ( nio )
        return new NioServerSocketChannelFactory(
            Executors.newCachedThreadPool(),
            Executors.newCachedThreadPool());
    else
        return new OioServerSocketChannelFactory(
            Executors.newCachedThreadPool(),
            Executors.newCachedThreadPool());
}
项目:graylog2-input-relp    文件:RELPInput.java   
@Override
public void initialize(Map<String, String> configuration, GraylogServer graylogServer) throws MessageInputConfigurationException {
    socketAddress = new InetSocketAddress(
            configuration.get("listen_address"),
            Integer.parseInt(configuration.get("listen_port"))
    );

    final ExecutorService bossThreadPool = Executors.newCachedThreadPool(
            new ThreadFactoryBuilder()
            .setNameFormat("input-relp-boss-%d")
            .build());

    final ExecutorService workerThreadPool = Executors.newCachedThreadPool(
            new ThreadFactoryBuilder()
            .setNameFormat("input-relp-worker-%d")
            .build());

    ServerBootstrap tcpBootstrap = new ServerBootstrap(
        new OioServerSocketChannelFactory(bossThreadPool, workerThreadPool)
    );

    tcpBootstrap.setPipelineFactory(new RELPPipelineFactory(graylogServer));

    try {
        tcpBootstrap.bind(socketAddress);
    } catch (ChannelException e) {
        LOG.error("Could not bind RELP input {}", socketAddress, e);
    }
}
项目:perfload-core    文件:DefaultServer.java   
/**
 * Creates a new server instance on the specified port.
 * 
 * @param port
 *            The port
 */
public DefaultServer(final int port) {
    this.port = port;

    // Configure the server.
    bootstrap = new ServerBootstrap(
            new OioServerSocketChannelFactory(
                    Executors.newCachedThreadPool(new DaemonThreadFactory()),
                    Executors.newCachedThreadPool(new DaemonThreadFactory())));

    // Set up the pipeline factory.
    bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
        @Override
        public ChannelPipeline getPipeline() throws Exception {
            return Channels.pipeline(
                    new ObjectEncoder(ENCODER_ESTIMATED_LENGTH), // 1 MB default size
                    new ObjectDecoder(DECODER_ESTIMATED_LENGTH, ClassResolvers.weakCachingResolver(null)), // 20 MB max. size - should be largely sufficient
                    new ServerHandshakeHandler(channelContainer, HANDSHAKE_TIMEOUT_MILLIS),
                    serverHandler);
        }
    });

    bootstrap.setOption("tcpNoDelay", true);
    bootstrap.setOption("keepAlive", true);
    bootstrap.setOption("child.tcpNoDelay", true);
    bootstrap.setOption("child.keepAlive", true);
}
项目:James    文件:OioPOP3Server.java   
@Override
protected ServerSocketChannelFactory createSocketChannelFactory() {
    return new OioServerSocketChannelFactory(createBossExecutor(), createWorkerExecutor());
}
项目:James    文件:OioIMAPServer.java   
@Override
protected ServerSocketChannelFactory createSocketChannelFactory() {
    return new OioServerSocketChannelFactory(createBossExecutor(), createWorkerExecutor());
}
项目:James    文件:OioLMTPServer.java   
@Override
protected ServerSocketChannelFactory createSocketChannelFactory() {
    return new OioServerSocketChannelFactory(createBossExecutor(), createWorkerExecutor());
}
项目:James    文件:OioSMTPServer.java   
@Override
protected ServerSocketChannelFactory createSocketChannelFactory() {
    return new OioServerSocketChannelFactory(createBossExecutor(), createWorkerExecutor());
}