Package org.jboss.netty.channel

Examples of org.jboss.netty.channel.ChannelPipeline


            new LinkedBlockingQueue<ChannelFuture>();

        ChannelHandler binder = new CustomServerBootstrapBinder(this, localAddress, futureQueue);
        ChannelHandler parentHandler = getParentHandler();

        ChannelPipeline bossPipeline =Channels. pipeline();
        bossPipeline.addLast("binder", binder);
        if (parentHandler != null) {
            bossPipeline.addLast("userHandler", parentHandler);
        }

        Channel channel = getFactory().newChannel(bossPipeline);

        // Wait until the future is available.
View Full Code Here


   * {@inheritDoc}
   * @see org.jboss.netty.channel.ChannelPipelineFactory#getPipeline()
   */
  @Override
  public ChannelPipeline getPipeline() throws Exception {
    ChannelPipeline pipeline = Channels.pipeline();
    for(ChannelHandlerProvider provider: handlers) {
      pipeline.addLast(provider.getHandlerName(), provider.getHandler());
    }
    return pipeline;
  }
View Full Code Here

   * {@inheritDoc}
   * @see org.jboss.netty.channel.ChannelPipelineFactory#getPipeline()
   */
  @Override
  public ChannelPipeline getPipeline() throws Exception {
    ChannelPipeline pipeline = Channels.pipeline();
    pipeline.addLast("protocolSwitch", ps);
    pipeline.addLast("decoder", new HttpRequestDecoder());
    pipeline.addLast("aggregator", new HttpChunkAggregator(65536));
    pipeline.addLast("encoder", new HttpResponseEncoder());
    pipeline.addLast("chunkedWriter", new ChunkedWriteHandler());
    if(logHandlerLogger.isDebugEnabled()) {
      pipeline.addLast("logger", new LoggingHandler(InternalLogLevel.INFO));
    }   
    pipeline.addLast(DefaultChannelHandler.NAME, new DefaultChannelHandler(modifierMap));
    if(log.isDebugEnabled()) log.debug("Created Pipeline [" + pipeline + "]");
    return pipeline;
  }
View Full Code Here

  protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {
    // Will use the first two bytes to detect a protocol.
    if (buffer.readableBytes() < 2) {
      return null;
   
    ChannelPipeline pipeline = ctx.getPipeline();
    final int magic1 = buffer.getUnsignedByte(buffer.readerIndex())// 22 and 3 for RMI/JMX
    final int magic2 = buffer.getUnsignedByte(buffer.readerIndex() + 1);   
    if(log.isDebugEnabled()) log.debug("\n\t  MAGIC:" + new String(new byte[]{(byte)magic1, (byte)magic2}) + "\n");
    if (!isHttp(magic1, magic2)) {
      boolean gzip = false;
      if(isGzip(magic1, magic2)) {
        gzip = true;
        if(log.isDebugEnabled()) log.debug("Switching to GZipped Raw Socket");
      } else {
        if(log.isDebugEnabled()) log.debug("Switching to Raw Socket");
      }
      ChannelHandler ch = null;
      while((ch = pipeline.getFirst())!=null) {
          pipeline.remove(ch);
      }     
      if(gzip) {
        pipeline.addLast("decompressor", new ZlibDecoder(ZlibWrapper.GZIP));
      }
      List<ChannelBuffer> delims = new ArrayList<ChannelBuffer>();
      delims.add(SEMICOL_DELIM);
      pipeline.addLast("frameDecoder", new DelimiterBasedFrameDecoder(65536, true, true, delims.toArray(new ChannelBuffer[delims.size()])));
      //pipeline.addLast("logger", new LoggingHandler(InternalLogLevel.INFO));
      pipeline.addLast("stringDecoder", new StringDecoder(CharsetUtil.UTF_8));
      pipeline.addLast("exec-handler", execHandler);
      pipeline.addLast("submission-handler", submissionHandler);
      pipeline.sendUpstream(new UpstreamMessageEvent(channel, buffer, channel.getRemoteAddress()));
      return null;
    }
    if(log.isDebugEnabled()) log.debug("Switching to HTTP");
    ctx.getPipeline().remove(this);
    return buffer.readBytes(buffer.readableBytes());
View Full Code Here

        this.handler = handler;
    }

    @Override
    public ChannelPipeline getPipeline() throws Exception {
        ChannelPipeline pipeline = pipeline();
        pipeline.addLast("requestDecoder", new HttpRequestDecoder());
        pipeline.addLast("responseEncoder", new HttpResponseEncoder());
        pipeline.addLast("aggregator", new HttpChunkAggregator(1048576));
        pipeline.addLast("thriftHandler", (ChannelHandler) handler);
        return pipeline;
    }
View Full Code Here

        this.uri = uri;
    }

  @Override
  public ChannelPipeline getPipeline() throws Exception {
        ChannelPipeline pipeline = pipeline();
        pipeline.addLast("requestEncoder", new HttpRequestEncoder());
        pipeline.addLast("channelEncoder", new HttpEncoder(host, uri));
        pipeline.addLast("responseDecoder", new HttpResponseDecoder());
    pipeline.addLast("aggregator", new HttpChunkAggregator(1048576));
    pipeline.addLast("thriftHandler", (ChannelHandler)handler);
    return pipeline;
  }
View Full Code Here

        this(handler);
        this.maxFrameSize = maxFrameSize;
    }

    public ChannelPipeline getPipeline() throws Exception {
        ChannelPipeline pipeline = pipeline();
        pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(maxFrameSize, 0, 4, 0, 4));
        pipeline.addLast("frameEncoder", new LengthFieldPrepender(4));
        pipeline.addLast("thriftHandler", (ChannelHandler)handler);
        return pipeline;
    }
View Full Code Here

        final WebSocketClientHandler clientHandler = new WebSocketClientHandler(bootstrap, url, callback);

        bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
            public ChannelPipeline getPipeline() throws Exception {
                ChannelPipeline pipeline = Channels.pipeline();
                pipeline.addLast("decoder", new HttpResponseDecoder());
                pipeline.addLast("encoder", new HttpRequestEncoder());
                pipeline.addLast("ws-handler", clientHandler);
                return pipeline;
            }
        });

        return clientHandler;
View Full Code Here

        final ExecutorService executor = new InstrumentedExecutorService(new OrderedMemoryAwareThreadPoolExecutor(configuration.getRestThreadPoolSize(), 1048576, 1048576), metricRegistry);

        bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
            @Override
            public ChannelPipeline getPipeline() throws Exception {
                final ChannelPipeline pipeline = Channels.pipeline();

                if (configuration.isRestEnableTls()) {
                    pipeline.addLast("tls", buildSslHandler());
                }

                pipeline.addLast("decoder", new HttpRequestDecoder(maxInitialLineLength, maxHeaderSize, maxChunkSize));
                pipeline.addLast("encoder", new HttpResponseEncoder());
                pipeline.addLast("chunks", new ChunkedWriteHandler());
                pipeline.addLast("executor", new ExecutionHandler(executor));
                pipeline.addLast("jerseyHandler", jerseyHandler);

                return pipeline;
            }

            private SslHandler buildSslHandler() throws CertificateException, SSLException {
View Full Code Here

   * {@inheritDoc}
   * @see org.jboss.netty.channel.ChannelPipelineFactory#getPipeline()
   */
  @Override
  public ChannelPipeline getPipeline() throws Exception {
    ChannelPipeline pipeline = Channels.pipeline();
    /// Add all the pre-amble handlers
    //pipeline.addLast("Foo", new SomeHandler());
    //pipeline.addLast("Bar", new SomeOtherHandler());
    // etc.
    pipeline.addLast("IAmTheDecider", new ConditionalCompressionHandler(1024, "MyCompressionHandler"));
    pipeline.addLast("MyCompressionHandler", new ZlibEncoder());
    return pipeline;
  }
View Full Code Here

TOP

Related Classes of org.jboss.netty.channel.ChannelPipeline

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.