Package org.jboss.netty.channel

Examples of org.jboss.netty.channel.ChannelHandler


  /* (non-Javadoc)
   * @see org.jboss.netty.channel.ChannelPipeline#addAfter(java.lang.String, java.lang.String, org.jboss.netty.channel.ChannelHandler)
   */
  public void addAfter(String arg0, String arg1, ChannelHandler arg2)
  {
    ChannelHandler handler1 = getHandlerOrDie(arg0);
    checkDuplicateName(arg1);
    _handlersMap.put(arg1, arg2);
    int i = _handlersList.indexOf(handler1);
    _handlersList.add(i+1, arg2);
    _namesList.add(i+1, arg1);
View Full Code Here


    _namesList.add(i+1, arg1);
  }

  private ChannelHandler getHandlerOrDie(String arg0)
  {
    ChannelHandler result = _handlersMap.get(arg0);
    if (result == null)
      throw new NoSuchElementException(arg0);
    return result;
  }
View Full Code Here

   * @see org.jboss.netty.channel.ChannelPipeline#addBefore(java.lang.String, java.lang.String, org.jboss.netty.channel.ChannelHandler)
   */
 
  public void addBefore(String arg0, String arg1, ChannelHandler arg2)
  {
    ChannelHandler handler1 = getHandlerOrDie(arg0);
    checkDuplicateName(arg1);
    _handlersMap.put(arg1, arg2);
    int i = _handlersList.indexOf(handler1);
    _handlersList.add(i, arg2);
    _namesList.add(i, arg1);
View Full Code Here

  public void mixin(ChannelPipeline pipeline)
  {
    _channel = pipeline.getChannel();
    for (int i = 0; i<_namesList.size(); i++)
    {
      ChannelHandler handler = _handlersList.get(i);
      String  name = _namesList.get(i);
      pipeline.addLast(name, handler);
    }
  }
View Full Code Here

public class StopablePipeline extends DefaultChannelPipeline
{
  public void stop()
  {
    ChannelHandler handler = this.getFirst();
    while (handler != null)
    {
      if (handler instanceof StopableHandler)
      {
        StopableHandler stopableHandler = (StopableHandler) handler;
View Full Code Here

            new LinkedBlockingQueue<ChannelFuture>();

        ChannelPipeline bossPipeline = pipeline();
        bossPipeline.addLast("binder", new Binder(localAddress, futureQueue));

        ChannelHandler parentHandler = getParentHandler();
        if (parentHandler != null) {
            bossPipeline.addLast("userHandler", parentHandler);
        }

        Channel channel = getFactory().newChannel(bossPipeline);
View Full Code Here

        }

        final BlockingQueue<ChannelFuture> futureQueue =
            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);
View Full Code Here

        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));
View Full Code Here

        if (LOG.isTraceEnabled()) {
            LOG.trace("Message received: {}", messageEvent);
        }

        if (producer.getConfiguration().getRequestTimeout() > 0) {
            ChannelHandler handler = ctx.getPipeline().get("timeout");
            if (handler != null) {
                LOG.trace("Removing timeout channel as we received message");
                ctx.getPipeline().remove(handler);
            }
        }
View Full Code Here

            addToPipeline("ssl", channelPipeline, sslHandler);
        }

        List<ChannelHandler> decoders = producer.getConfiguration().getDecoders();
        for (int x = 0; x < decoders.size(); x++) {
            ChannelHandler decoder = decoders.get(x);
            if (decoder instanceof ChannelHandlerFactory) {
                // use the factory to create a new instance of the channel as it may not be shareable
                decoder = ((ChannelHandlerFactory) decoder).newChannelHandler();
            }
            addToPipeline("decoder-" + x, channelPipeline, decoder);
        }

        List<ChannelHandler> encoders = producer.getConfiguration().getEncoders();
        for (int x = 0; x < encoders.size(); x++) {
            ChannelHandler encoder = encoders.get(x);
            if (encoder instanceof ChannelHandlerFactory) {
                // use the factory to create a new instance of the channel as it may not be shareable
                encoder = ((ChannelHandlerFactory) encoder).newChannelHandler();
            }
            addToPipeline("encoder-" + x, channelPipeline, encoder);
        }

        // do we use request timeout?
        if (producer.getConfiguration().getRequestTimeout() > 0) {
            if (LOG.isTraceEnabled()) {
                LOG.trace("Using request timeout {} millis", producer.getConfiguration().getRequestTimeout());
            }
            ChannelHandler timeout = new ReadTimeoutHandler(NettyComponent.getTimer(), producer.getConfiguration().getRequestTimeout(), TimeUnit.MILLISECONDS);
            addToPipeline("timeout", channelPipeline, timeout);
        }

        // our handler must be added last
        addToPipeline("handler", channelPipeline, new ClientChannelHandler(producer));
View Full Code Here

TOP

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

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.