本文整理匯總了Java中io.netty.channel.socket.SocketChannel.pipeline方法的典型用法代碼示例。如果您正苦於以下問題:Java SocketChannel.pipeline方法的具體用法?Java SocketChannel.pipeline怎麽用?Java SocketChannel.pipeline使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.netty.channel.socket.SocketChannel
的用法示例。
在下文中一共展示了SocketChannel.pipeline方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initChannel
import io.netty.channel.socket.SocketChannel; //導入方法依賴的package包/類
@Override
protected void initChannel(SocketChannel socketChannel) throws Exception {
Backend backend = this.backendManager.getBackendBalancing().getBackend();
if (backend == null) {
throw new OutOfBackendsException();
}
/*SelfSignedCertificate ssc = new SelfSignedCertificate();
SslContext sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey())
.build();*/
ChannelPipeline pipeline = socketChannel.pipeline();
//pipeline.addLast(sslCtx.newHandler(socketChannel.alloc()));
//pipeline.addLast(new LoggingHandler(LogLevel.INFO));
pipeline.addLast(new CardeaServerFrontEndHandler(backend.getHost(), backend.getPort()));
}
示例2: initChannel
import io.netty.channel.socket.SocketChannel; //導入方法依賴的package包/類
@Override
public void initChannel(SocketChannel ch) {
ChannelPipeline pipeline = ch.pipeline();
SslHandler sslHandler = null;
if (sslHandlerProvider != null) {
sslHandler = sslHandlerProvider.getSslHandler();
pipeline.addLast(sslHandler);
}
pipeline.addLast("decoder", new MqttDecoder(MAX_PAYLOAD_SIZE));
pipeline.addLast("encoder", MqttEncoder.INSTANCE);
MqttTransportHandler handler = new MqttTransportHandler(msgProducer, deviceService, authService, assetService,
assetAuthService, relationService, sslHandler);
pipeline.addLast(handler);
// ch.closeFuture().addListener(handler);
}
示例3: initChannel
import io.netty.channel.socket.SocketChannel; //導入方法依賴的package包/類
@Override
protected void initChannel(SocketChannel ch) throws Exception {
final ChannelPipeline pipeline = ch.pipeline();
NettyPipelineInit.serializePipeline(serializeProtocolEnum, pipeline);
pipeline.addLast("timeout",
new IdleStateHandler(nettyConfig.getHeartTime(), nettyConfig.getHeartTime(), nettyConfig.getHeartTime(), TimeUnit.SECONDS));
pipeline.addLast(nettyServerMessageHandler);
}
示例4: initChannel
import io.netty.channel.socket.SocketChannel; //導入方法依賴的package包/類
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline p = ch.pipeline();
p.addLast("codec", new HttpServerCodec(4096, 8192, 8192, false));
p.addLast("servletInput", new ServletContentHandler(servletContext));
p.addLast(servletExecutor, "filterChain", requestDispatcherHandler);
}
示例5: initChannel
import io.netty.channel.socket.SocketChannel; //導入方法依賴的package包/類
@Override
public void initChannel(SocketChannel socketChannel) throws Exception {
ChannelPipeline p = socketChannel.pipeline();
p.addLast(new SocksInitRequestDecoder());
p.addLast(socksMessageEncoder);
p.addLast(socksServerHandler);
p.addLast(trafficHandler);
}
示例6: initChannel
import io.netty.channel.socket.SocketChannel; //導入方法依賴的package包/類
@Override
protected void initChannel(SocketChannel ch) throws Exception
{
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
pipeline.addLast(new MessageDecoder());
pipeline.addLast(new MessageEncoder());
pipeline.addLast(new ClientHandler());
}
示例7: prepare
import io.netty.channel.socket.SocketChannel; //導入方法依賴的package包/類
@Override public void prepare(final Benchmark benchmark) {
this.concurrencyLevel = benchmark.concurrencyLevel;
this.targetBacklog = benchmark.targetBacklog;
ChannelInitializer<SocketChannel> channelInitializer = new ChannelInitializer<SocketChannel>() {
@Override public void initChannel(SocketChannel channel) throws Exception {
ChannelPipeline pipeline = channel.pipeline();
if (benchmark.tls) {
SslClient sslClient = SslClient.localhost();
SSLEngine engine = sslClient.sslContext.createSSLEngine();
engine.setUseClientMode(true);
pipeline.addLast("ssl", new SslHandler(engine));
}
pipeline.addLast("codec", new HttpClientCodec());
pipeline.addLast("inflater", new HttpContentDecompressor());
pipeline.addLast("handler", new HttpChannel(channel));
}
};
bootstrap = new Bootstrap();
bootstrap.group(new NioEventLoopGroup(concurrencyLevel))
.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
.channel(NioSocketChannel.class)
.handler(channelInitializer);
}
示例8: initChannel
import io.netty.channel.socket.SocketChannel; //導入方法依賴的package包/類
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
// SSL的安全鏈接
if (ServerConfig.isSsl()) {
SSLContext sslcontext = SSLContext.getInstance("TLS");
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
KeyStore ks = KeyStore.getInstance("JKS");
String keyStorePath = ServerConfig.getKeyStorePath();
String keyStorePassword = ServerConfig.getKeyStorePassword();
ks.load(new FileInputStream(keyStorePath), keyStorePassword.toCharArray());
String keyPassword = ServerConfig.getKeyPassword();
kmf.init(ks, keyPassword.toCharArray());
sslcontext.init(kmf.getKeyManagers(), null, null);
SSLEngine sslEngine = sslcontext.createSSLEngine();
sslEngine.setUseClientMode(false);
sslEngine.setNeedClientAuth(false);
/**
* 務必放在第一位
*/
pipeline.addLast(new SslHandler(sslEngine));
logger.info("initChannel: addLast SslHandler");
/**
* Generates a temporary self-signed certificate for testing purposes.
*/
/*SelfSignedCertificate ssc = new SelfSignedCertificate();
SslContext sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).build();
//SslContext sslCtx = SslContext.newServerContext(ssc.certificate(), ssc.privateKey());
if (sslCtx != null) {
pipeline.addLast(sslCtx.newHandler(ch.alloc()));
}*/
}
// Register HTTP handler chain.
this.appendHttpPipeline(pipeline);
}
示例9: initChannel
import io.netty.channel.socket.SocketChannel; //導入方法依賴的package包/類
@Override
protected void initChannel(SocketChannel socketChannel) throws Exception {
ChannelPipeline cp = socketChannel.pipeline();
cp.addLast(new HttpServerCodec()); //添加服務端http編、解碼器
cp.addLast(new HttpObjectAggregator(512*1024)); //http消息聚合
cp.addLast(new HttpContentCompressor()); //開啟壓縮
cp.addLast(new HttpServerHandler(kurdran));
}
示例10: initChannel
import io.netty.channel.socket.SocketChannel; //導入方法依賴的package包/類
@Override
public void initChannel(SocketChannel ch) {
ChannelPipeline pipeline = ch.pipeline();
if (sslCtx != null) {
pipeline.addLast(sslCtx.newHandler(ch.alloc(), ip, port));
}
pipeline.addLast(DECODER);
pipeline.addLast(ENCODER);
// and then business logic.
pipeline.addLast(CLIENT_HANDLER);
}
示例11: initChannel
import io.netty.channel.socket.SocketChannel; //導入方法依賴的package包/類
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline p = ch.pipeline();
if(sslCtx!=null)
{
p.addLast(new SslHandler(sslCtx.newEngine(ch.alloc())));
}
p.addLast(new HttpResponseDecoder());
//限製contentLength
p.addLast(new HttpObjectAggregator(65536));
p.addLast(new HttpRequestEncoder());
//大文件傳輸處理
// p.addLast(new ChunkedWriteHandler());
p.addLast(new DefaultListenerHandler<HttpResponse>(listener));
}
示例12: initChannel
import io.netty.channel.socket.SocketChannel; //導入方法依賴的package包/類
@Override
public void initChannel(SocketChannel ch) {
ChannelPipeline p = ch.pipeline();
if (sslCtx != null) {
p.addLast(sslCtx.newHandler(ch.alloc()));
}
p.addLast(new HttpServerCodec());
p.addLast(new HttpObjectAggregator(1048576));
p.addLast(new FeatureServerHandler(provider));
}
示例13: initChannel
import io.netty.channel.socket.SocketChannel; //導入方法依賴的package包/類
@Override
public void initChannel(SocketChannel ch) {
ChannelPipeline pipeline = ch.pipeline();
if (sslContext != null) {
pipeline.addLast("ssl", sslContext.newHandler(ch.alloc()));
}
pipeline.addLast(new HttpServerCodec())
.addLast(new HttpObjectAggregator(65536))
.addLast(new ChunkedWriteHandler())
.addLast(new NettyHttpServerHandler());
}
示例14: initChannel
import io.netty.channel.socket.SocketChannel; //導入方法依賴的package包/類
@Override
public void initChannel(SocketChannel aChannel) throws Exception {
ChannelPipeline pipeline = aChannel.pipeline();
pipeline.addLast("encoder" , new HttpResponseEncoder());
pipeline.addLast("decoder" , new HttpRequestDecoder(4096, 8192, 8192, false));
pipeline.addLast("aggregator" , new HttpObjectAggregator(MAX_CONTENT_LENGTH)); // handle HttpContents
pipeline.addLast("chunked", new ChunkedWriteHandler());
// pipeline.addLast("handler" , new HttpServerHandler(requestListener));
pipeline.addLast("handler" , new HttpServerHandler(requestListener));
}
示例15: initChannel
import io.netty.channel.socket.SocketChannel; //導入方法依賴的package包/類
@Override
public void initChannel(SocketChannel ch) {
ChannelPipeline pipeline = ch.pipeline();
//pipeline.addLast("http-compressor", new HttpContentCompressor());
pipeline.addLast("http-codec", new HttpServerCodec());
pipeline.addLast("http-aggregator", new HttpObjectAggregator(65536));
pipeline.addLast("http-chunked", new ChunkedWriteHandler());
pipeline.addLast("http-handler", new HttpRedirectHandler());
}