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 void
beforeProcess(org.apache.camel.Exchange exchange, io.netty.channel.ChannelHandlerContext ctx, Object message)
Allows any custom logic before theExchange
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 theChannelFutureListener
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
-
-
-
-
Constructor Detail
-
ServerChannelHandler
public ServerChannelHandler(NettyConsumer consumer)
-
-
Method Detail
-
channelActive
public void channelActive(io.netty.channel.ChannelHandlerContext ctx) throws Exception
- Specified by:
channelActive
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelActive
in classio.netty.channel.ChannelInboundHandlerAdapter
- Throws:
Exception
-
channelInactive
public void channelInactive(io.netty.channel.ChannelHandlerContext ctx) throws Exception
- Specified by:
channelInactive
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelInactive
in classio.netty.channel.ChannelInboundHandlerAdapter
- Throws:
Exception
-
exceptionCaught
public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception
- Specified by:
exceptionCaught
in interfaceio.netty.channel.ChannelHandler
- Specified by:
exceptionCaught
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
exceptionCaught
in 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 theExchange
is 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 theChannelFutureListener
to execute when writing the response is complete.- Parameters:
consumer
- the netty consumerexchange
- the exchangeremoteAddress
- the remote address of the message- Returns:
- the listener.
-
-