public void start(int listenPort, final ExecutorService threadPool) throws Exception { if (!startFlag.compareAndSet(false, true)) { return; } bootstrap.setPipelineFactory(new ChannelPipelineFactory() { public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = new DefaultChannelPipeline(); pipeline.addLast("decoder", new NettyProtocolDecoder()); pipeline.addLast("encoder", new NettyProtocolEncoder()); pipeline.addLast("handler", new NettyServerHandler(threadPool)); return pipeline; } }); bootstrap.bind(new InetSocketAddress(listenPort)); LOGGER.warn("Server started,listen at: " + listenPort); }
public void start() { bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory( Executors.newFixedThreadPool(1), Executors.newCachedThreadPool() )); bootstrap.setPipelineFactory(new ChannelPipelineFactory() { public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = new DefaultChannelPipeline(); pipeline.addLast("ssl", new SslHandler(getSSLEngine())); pipeline.addLast("decoder", new LumberjackDecoder()); pipeline.addLast("logHandler", new LogEventHandler(eventListener)); return pipeline; } }); bootstrap.bind(new InetSocketAddress(configuration.getIpAddress(), configuration.getPort())); }
public void start() { bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory( Executors.newFixedThreadPool(1), Executors.newCachedThreadPool() )); bootstrap.setPipelineFactory(new ChannelPipelineFactory() { public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = new DefaultChannelPipeline(); if(configuration.isSslEnabled()) { pipeline.addLast("ssl", new SslHandler(getSSLEngine())); } pipeline.addLast("decoder", new LumberjackDecoder()); pipeline.addLast("logHandler", new EventHandler(eventListener)); return pipeline; } }); bootstrap.bind(new InetSocketAddress(configuration.getIpAddress(), configuration.getPort())); }
public void start(int listenPort, final ExecutorService threadPool, final long timeout) throws Exception { if (!startFlag.compareAndSet(false, true)) { return; } bootstrap.setPipelineFactory(new ChannelPipelineFactory() { public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = new DefaultChannelPipeline(); pipeline.addLast("decoder", new StringDecoder()); pipeline.addLast("encoder", new StringEncoder()); pipeline.addLast("handler", new NettyServerHandler(threadPool, timeout)); return pipeline; } }); bootstrap.bind(new InetSocketAddress(listenPort)); log.warn("Server started,listen at: " + listenPort); }
public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = new DefaultChannelPipeline(); pipeline.addLast("decoder", new NettyProtocolDecoder()); pipeline.addLast("encoder", new NettyProtocolEncoder()); pipeline.addLast("handler", handler); return pipeline; }
@Override public ChannelPipeline getPipeline() throws Exception { final ChannelPipeline pipeline = new DefaultChannelPipeline(); pipeline.addLast("timeout", new ReadTimeoutHandler(timer, 10)); pipeline.addLast("encoder", new RS2Encoder()); pipeline.addLast("decoder", new RS2LoginProtocol()); pipeline.addLast("handler", new ChannelHandler()); return pipeline; }
@Override protected SSLAwareChannelHandler createChannelPipelineFactory(final SSLConfiguration config, final StorageManager storageManager) { return new SSLAwareChannelHandler(this, config, Thread.currentThread().getContextClassLoader(), storageManager) { @Override public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = new DefaultChannelPipeline(); PgBackendProtocol pgBackendProtocol = new PgBackendProtocol(maxLobSize, maxBufferSize, config, requireSecure); pipeline.addLast("odbcFrontendProtocol", new PgFrontendProtocol(pgBackendProtocol, 1 << 20)); //$NON-NLS-1$ pipeline.addLast("odbcBackendProtocol", pgBackendProtocol); //$NON-NLS-1$ pipeline.addLast("handler", this); //$NON-NLS-1$ return pipeline; } }; }
@Override public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = new DefaultChannelPipeline(); pipeline.addLast("decoder", new StringDecoder()); pipeline.addLast("encoder", new StringEncoder()); pipeline.addLast("handler", handler); return pipeline; }
public void run() { // Configure the server. this.bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool())); // Set up the event pipeline factory. this.bootstrap.setPipelineFactory(new ChannelPipelineFactory() { @Override public ChannelPipeline getPipeline() throws Exception { WebServerSocketHandler webServerSocketHandler = new WebServerSocketHandler(); ChannelPipeline pipeline = new DefaultChannelPipeline(); pipeline.addLast("decoder", new HttpRequestDecoder()); pipeline.addLast("aggregator", new HttpChunkAggregator(65536)); pipeline.addLast("encoder", new HttpResponseEncoder()); pipeline.addLast("handler", webServerSocketHandler); WebSocketServer.this.t.notifyAccept(webServerSocketHandler); return pipeline; } }); // Bind and start to accept incoming connections. this.bind = this.bootstrap.bind(new InetSocketAddress(this.host, this.port)); this.port = ((InetSocketAddress) this.bind.getLocalAddress()).getPort(); System.out.println("Web socket server started at port " + this.port + '.'); System.out.println("Open your browser and navigate to http://" + this.host + ":" + this.port + '/'); }
public ChannelPipeline getPipeline() { ChannelPipeline pipeline = new DefaultChannelPipeline(); pipeline.addLast("framer", new CreeperDelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter())); pipeline.addLast("decoder", new CreeperStringDecoder()); pipeline.addLast("encoder", new StringEncoder()); pipeline.addLast("handler", handler); return pipeline; }
@Test public void addChunkHandlesNonExistingChunkList() { DefaultLocalClientChannelFactory channelFactory = new DefaultLocalClientChannelFactory(); DefaultChannelPipeline pipeline = new DefaultChannelPipeline(); Channel channel = channelFactory.newChannel(pipeline); chunkedRequestAssembler.addChunk(channel, EMPTY_CHUNK); }
@Test public void addChunkHandlesNullChunk() { DefaultLocalClientChannelFactory channelFactory = new DefaultLocalClientChannelFactory(); DefaultChannelPipeline pipeline = new DefaultChannelPipeline(); Channel channel = channelFactory.newChannel(pipeline); chunkedRequestAssembler.addChunk(channel, null); }
@Test public void addChunkHandlesExistingChunkList() { DefaultLocalClientChannelFactory channelFactory = new DefaultLocalClientChannelFactory(); DefaultChannelPipeline pipeline = new DefaultChannelPipeline(); Channel channel = channelFactory.newChannel(pipeline); HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, ""); chunkedRequestAssembler.setup(channel, httpRequest); chunkedRequestAssembler.addChunk(channel, EMPTY_CHUNK); }