List of usage examples for io.netty.channel ChannelPipeline addLast
ChannelPipeline addLast(EventExecutorGroup group, ChannelHandler... handlers);
From source file:com.leadtone.riders.server.RidersWebSocketServerInitializer.java
License:Apache License
@Override public void initChannel(SocketChannel ch) throws Exception { ChannelPipeline pipeline = ch.pipeline(); pipeline.addLast("codec-http", new HttpServerCodec()); pipeline.addLast("aggregator", new HttpObjectAggregator(65536)); pipeline.addLast("handler", InitEnvironment.getAppclicatContextInstance().getBean(RidersWebSocketServerHandler.class)); // pipeline.addLast("handler",new RidersWebSocketServerHandler()); }
From source file:com.linkedin.mitm.proxy.channel.ChannelMediator.java
License:Open Source License
private void initChannelPipeline(ChannelPipeline pipeline, ServerChannelHandler serverChannelHandler, int idleTimeoutMsec) { pipeline.addLast("decoder", new HttpResponseDecoder()); pipeline.addLast("encoder", new HttpRequestEncoder()); pipeline.addLast("idle", new IdleStateHandler(0, 0, idleTimeoutMsec / 1000)); pipeline.addLast("handler", serverChannelHandler); }
From source file:com.linkedin.proxy.netty.MysqlInitializer.java
License:Apache License
public void initChannel(SocketChannel ch) { String thrName = Thread.currentThread().getName() + ": "; _LOG.debug(thrName + "Initializing SocketChannel..."); ChannelPipeline p = ch.pipeline(); //HttpMessage encoder/decoder p.addLast("httpDecoder", new HttpRequestDecoder()); p.addLast("httpAggr", new HttpObjectAggregator(_httpBufferSize)); p.addLast("httpEncoder", new HttpResponseEncoder()); //MysqlQuery encoder/decoder p.addLast("mysqlDecoder", new MysqlQueryDecoder()); p.addLast("mysqlEncoder", new MysqlQueryEncoder()); //MysqlQuery handler p.addLast("mysqlHandler", new MysqlQueryHandler(_connPool)); }
From source file:com.linkedin.proxy.netty.RocksdbInitializer.java
License:Apache License
public void initChannel(SocketChannel ch) { String thrName = Thread.currentThread().getName() + ": "; m_log.debug(thrName + "Initializing SocketChannel..."); ChannelPipeline p = ch.pipeline(); //HttpMessage encoder/decoder p.addLast("httpDecoder", new HttpRequestDecoder()); p.addLast("httpAggr", new HttpObjectAggregator(_httpBufferSize)); p.addLast("httpEncoder", new HttpResponseEncoder()); //Rocksdb encoder/decoder p.addLast("rocksdbDecoder", new RocksdbQueryDecoder()); p.addLast("rocksdbEncoder", new RocksdbQueryEncoder()); //Rocksdb query handler p.addLast("rocksdbHandler", new RocksdbQueryHandler(m_connPool)); }
From source file:com.ltln.modules.openflow.controller.manager.OFChannelInitializer.java
License:Apache License
@Override protected void initChannel(Channel ch) throws Exception { ChannelPipeline pipeline = ch.pipeline(); OFChannelHandler handler = new OFChannelHandler(switchManager, connectionListener, pipeline, timer, ofBitmaps, defaultFactory);/* ww w. j ava 2s . c o m*/ if (keyStore != null && keyStorePassword != null) { try { /* Set up factories and stores. */ TrustManagerFactory tmFactory = TrustManagerFactory .getInstance(TrustManagerFactory.getDefaultAlgorithm()); KeyStore tmpKS = null; tmFactory.init(tmpKS); /* Use keystore/pass defined in properties file. */ KeyStore ks = KeyStore.getInstance("JKS"); ks.load(new FileInputStream(keyStore), keyStorePassword.toCharArray()); KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmf.init(ks, keyStorePassword.toCharArray()); KeyManager[] km = kmf.getKeyManagers(); TrustManager[] tm = tmFactory.getTrustManagers(); /* Set up SSL prereqs for Netty. */ SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(km, tm, null); SSLEngine sslEngine = sslContext.createSSLEngine(); /* We are the server and we will create secure sessions. */ sslEngine.setUseClientMode(false); sslEngine.setEnableSessionCreation(true); /* These are redundant (default), but for clarity... */ sslEngine.setEnabledProtocols(sslEngine.getSupportedProtocols()); sslEngine.setEnabledCipherSuites(sslEngine.getSupportedCipherSuites()); /* First, decrypt w/handler+engine; then, proceed with rest of handlers. */ pipeline.addLast(PipelineHandler.SSL_TLS_ENCODER_DECODER, new SslHandler(sslEngine)); log.info("SSL OpenFlow socket initialized and handler ready for switch."); } catch (Exception e) { /* There are lots of possible exceptions to catch, so this should get them all. */ log.error("Exception initializing SSL OpenFlow socket: {}", e.getMessage()); throw e; /* If we wanted secure but didn't get it, we should bail. */ } } pipeline.addLast(PipelineHandler.OF_MESSAGE_DECODER, new OFMessageDecoder()); pipeline.addLast(PipelineHandler.OF_MESSAGE_ENCODER, new OFMessageEncoder()); pipeline.addLast(PipelineHandler.MAIN_IDLE, new IdleStateHandler(PipelineIdleReadTimeout.MAIN, PipelineIdleWriteTimeout.MAIN, 0)); pipeline.addLast(PipelineHandler.READ_TIMEOUT, new ReadTimeoutHandler(30)); pipeline.addLast(PipelineHandler.CHANNEL_HANDSHAKE_TIMEOUT, new HandshakeTimeoutHandler(handler, timer, PipelineHandshakeTimeout.CHANNEL)); pipeline.addLast(PipelineHandler.CHANNEL_HANDLER, handler); }
From source file:com.mastfrog.acteur.server.PipelineFactoryImpl.java
License:Open Source License
@Override public void initChannel(SocketChannel ch) throws Exception { if (maxContentLength == 0) { maxContentLength = 1048576;/* w w w .j av a 2s . c om*/ } // Create a default pipeline implementation. ChannelPipeline pipeline = ch.pipeline(); // SSLEngine engine = SecureChatSslContextFactory.getServerContext().createSSLEngine(); // engine.setUseClientMode(false); // pipeline.addLast("ssl", new SslHandler(engine)); ChannelHandler decoder = (ChannelHandler) new HttpRequestDecoder(); pipeline.addLast("decoder", decoder); // Uncomment the following line if you don't want to handle HttpChunks. if (aggregateChunks) { ChannelHandler aggregator = (ChannelHandler) new HttpObjectAggregator(maxContentLength); pipeline.addLast("aggregator", aggregator); } pipeline.addLast("bytes", new MessageBufEncoder()); ChannelHandler encoder = (ChannelHandler) new HttpResponseEncoder(); pipeline.addLast("encoder", encoder); // Remove the following line if you don't want automatic content compression. if (httpCompression) { ChannelHandler compressor = (ChannelHandler) new SelectiveCompressor(); pipeline.addLast("deflater", compressor); } pipeline.addLast("handler", handler.get()); }
From source file:com.mastfrog.netty.http.client.Initializer.java
License:Open Source License
@Override protected void initChannel(Channel ch) throws Exception { ChannelPipeline pipeline = ch.pipeline(); if (ssl) {//from w ww. j a v a 2 s . c o m SslContext clientContext = context == null ? SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build() : context; pipeline.addLast("ssl", new ExceptionForwardingSslHandler( clientContext.newEngine(ByteBufAllocator.DEFAULT, hostPort.host(), hostPort.port()))); } pipeline.addLast("http-codec", new HttpClientCodec(maxInitialLineLength, maxChunkSize, maxChunkSize)); if (compress) { pipeline.addLast("decompressor", new HttpContentDecompressor()); } pipeline.addLast("handler", handler); }
From source file:com.mc.netty.handler.TcpChannelInitializer.java
License:Open Source License
@Override protected void initChannel(SocketChannel ch) throws Exception { ChannelPipeline pipeline = ch.pipeline(); pipeline.addLast("encoder", new ImMessageEncoder()); pipeline.addLast("decoder", new ImMessageDecoder()); // pipeline.addLast("steelImHandler", new ImMessageHandler()); }
From source file:com.mpush.netty.client.NettyClient.java
License:Apache License
protected void initPipeline(ChannelPipeline pipeline) { pipeline.addLast("decoder", getDecoder()); pipeline.addLast("encoder", getEncoder()); pipeline.addLast("handler", getChannelHandler()); }
From source file:com.mpush.netty.server.NettyTCPServer.java
License:Apache License
/** * ?/*from ww w.j ava 2s. c om*/ * * @param pipeline */ protected void initPipeline(ChannelPipeline pipeline) { pipeline.addLast("decoder", getDecoder()); pipeline.addLast("encoder", getEncoder()); pipeline.addLast("handler", getChannelHandler()); }