Class ServerChannelHandler

  • All Implemented Interfaces:
    io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler

    public class ServerChannelHandler
    extends io.netty.channel.SimpleChannelInboundHandler<Object>
    Server handler which cannot be shared
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

        io.netty.channel.ChannelHandler.Sharable
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void beforeProcess​(org.apache.camel.Exchange exchange, io.netty.channel.ChannelHandlerContext ctx, Object message)
      Allows any custom logic before the Exchange is processed by the routing engine.
      void channelActive​(io.netty.channel.ChannelHandlerContext ctx)  
      void channelInactive​(io.netty.channel.ChannelHandlerContext ctx)  
      protected void channelRead0​(io.netty.channel.ChannelHandlerContext ctx, Object msg)  
      protected org.apache.camel.Exchange createExchange​(io.netty.channel.ChannelHandlerContext ctx, Object message)  
      protected io.netty.channel.ChannelFutureListener createResponseFutureListener​(NettyConsumer consumer, org.apache.camel.Exchange exchange, SocketAddress remoteAddress)
      Creates the ChannelFutureListener to execute when writing the response is complete.
      void exceptionCaught​(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)  
      protected Object getResponseBody​(org.apache.camel.Exchange exchange)
      Gets the object we want to use as the response object for sending to netty.
      • Methods inherited from class io.netty.channel.SimpleChannelInboundHandler

        acceptInboundMessage, channelRead
      • Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

        channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered
      • Methods inherited from class io.netty.channel.ChannelHandlerAdapter

        ensureNotSharable, handlerAdded, handlerRemoved, isSharable
      • Methods inherited from interface io.netty.channel.ChannelHandler

        handlerAdded, handlerRemoved
    • Constructor Detail

      • ServerChannelHandler

        public ServerChannelHandler​(NettyConsumer consumer)
    • Method Detail

      • channelActive

        public void channelActive​(io.netty.channel.ChannelHandlerContext ctx)
                           throws Exception
        Specified by:
        channelActive in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        channelActive in class io.netty.channel.ChannelInboundHandlerAdapter
        Throws:
        Exception
      • channelInactive

        public void channelInactive​(io.netty.channel.ChannelHandlerContext ctx)
                             throws Exception
        Specified by:
        channelInactive in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        channelInactive in class io.netty.channel.ChannelInboundHandlerAdapter
        Throws:
        Exception
      • exceptionCaught

        public void exceptionCaught​(io.netty.channel.ChannelHandlerContext ctx,
                                    Throwable cause)
                             throws Exception
        Specified by:
        exceptionCaught in interface io.netty.channel.ChannelHandler
        Specified by:
        exceptionCaught in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        exceptionCaught in class io.netty.channel.ChannelInboundHandlerAdapter
        Throws:
        Exception
      • channelRead0

        protected void channelRead0​(io.netty.channel.ChannelHandlerContext ctx,
                                    Object msg)
                             throws Exception
        Specified by:
        channelRead0 in class io.netty.channel.SimpleChannelInboundHandler<Object>
        Throws:
        Exception
      • createExchange

        protected org.apache.camel.Exchange createExchange​(io.netty.channel.ChannelHandlerContext ctx,
                                                           Object message)
                                                    throws Exception
        Throws:
        Exception
      • beforeProcess

        protected void beforeProcess​(org.apache.camel.Exchange exchange,
                                     io.netty.channel.ChannelHandlerContext ctx,
                                     Object message)
        Allows any custom logic before the Exchange is processed by the routing engine.
        Parameters:
        exchange - the exchange
        ctx - the channel handler context
        message - the message which needs to be sent
      • getResponseBody

        protected Object getResponseBody​(org.apache.camel.Exchange exchange)
                                  throws Exception
        Gets the object we want to use as the response object for sending to netty.
        Parameters:
        exchange - the exchange
        Returns:
        the object to use as response
        Throws:
        Exception - is thrown if error getting the response body
      • createResponseFutureListener

        protected io.netty.channel.ChannelFutureListener createResponseFutureListener​(NettyConsumer consumer,
                                                                                      org.apache.camel.Exchange exchange,
                                                                                      SocketAddress remoteAddress)
        Creates the ChannelFutureListener to execute when writing the response is complete.
        Parameters:
        consumer - the netty consumer
        exchange - the exchange
        remoteAddress - the remote address of the message
        Returns:
        the listener.