Class ServerChannelHandler
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- io.netty.channel.SimpleChannelInboundHandler<Object>
-
- org.apache.camel.component.netty.handlers.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
-
-
Constructor Summary
Constructors Constructor Description ServerChannelHandler(NettyConsumer consumer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbeforeProcess(org.apache.camel.Exchange exchange, io.netty.channel.ChannelHandlerContext ctx, Object message)Allows any custom logic before theExchangeis processed by the routing engine.voidchannelActive(io.netty.channel.ChannelHandlerContext ctx)voidchannelInactive(io.netty.channel.ChannelHandlerContext ctx)protected voidchannelRead0(io.netty.channel.ChannelHandlerContext ctx, Object msg)protected org.apache.camel.ExchangecreateExchange(io.netty.channel.ChannelHandlerContext ctx, Object message)protected io.netty.channel.ChannelFutureListenercreateResponseFutureListener(NettyConsumer consumer, org.apache.camel.Exchange exchange, SocketAddress remoteAddress)Creates theChannelFutureListenerto execute when writing the response is complete.voidexceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)protected ObjectgetResponseBody(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
-
-
-
-
Constructor Detail
-
ServerChannelHandler
public ServerChannelHandler(NettyConsumer consumer)
-
-
Method Detail
-
channelActive
public void channelActive(io.netty.channel.ChannelHandlerContext ctx) throws Exception- Specified by:
channelActivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelActivein classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
channelInactive
public void channelInactive(io.netty.channel.ChannelHandlerContext ctx) throws Exception- Specified by:
channelInactivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelInactivein classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
exceptionCaught
public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelHandler- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
exceptionCaughtin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
channelRead0
protected void channelRead0(io.netty.channel.ChannelHandlerContext ctx, Object msg) 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 theExchangeis processed by the routing engine.- Parameters:
exchange- the exchangectx- the channel handler contextmessage- 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 theChannelFutureListenerto execute when writing the response is complete.- Parameters:
consumer- the netty consumerexchange- the exchangeremoteAddress- the remote address of the message- Returns:
- the listener.
-
-