Class ActionHandler
- All Implemented Interfaces:
io.netty.channel.ChannelHandler
,io.netty.channel.ChannelInboundHandler
- Direct Known Subclasses:
EppActionHandler
,WebWhoisActionHandler
ChannelHandler
s placed at end of channel pipeline
ActionHandler
inherits from SimpleChannelInboundHandler
, as it should only be
passed in messages that implement the InboundMessageType
interface.
The ActionHandler
skeleton exists for a few main purposes. First, it returns a ChannelPromise
, which informs the ProbingAction
in charge that a response has been read.
Second, with any exception thrown, the connection is closed, and the ProbingAction governing this
channel is informed of the error. If the error is an instance of a FailureException
finished
is marked as a failure with cause FailureException
. If it is any other
type of error, it is treated as an UndeterminedStateException
and finished
set as
a failure with the same cause as what caused the exception. Lastly, if no error is thrown, we
know the action completed as a success, and, as such, we mark finished
as a success.
Subclasses specify further work to be done for specific kinds of channel pipelines.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable
-
Field Summary
Modifier and TypeFieldDescriptionprotected io.netty.channel.ChannelPromise
ChannelPromise
that informsProbingAction
if response has been received. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
channelRead0
(io.netty.channel.ChannelHandlerContext ctx, InboundMessageType inboundMessage) MarksChannelPromise
as successvoid
exceptionCaught
(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) Logs the channel and pipeline that caused error, closes channel, then informsProbingAction
listeners of error.io.netty.channel.ChannelFuture
Returns initializedChannelPromise
toProbingAction
.void
handlerAdded
(io.netty.channel.ChannelHandlerContext ctx) InitializesChannelPromise
Methods inherited from class io.netty.channel.SimpleChannelInboundHandler
acceptInboundMessage, channelRead
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerRemoved, isSharable
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.netty.channel.ChannelHandler
handlerRemoved
-
Field Details
-
finished
protected io.netty.channel.ChannelPromise finishedChannelPromise
that informsProbingAction
if response has been received.
-
-
Constructor Details
-
ActionHandler
public ActionHandler()
-
-
Method Details
-
getFinishedFuture
public io.netty.channel.ChannelFuture getFinishedFuture()Returns initializedChannelPromise
toProbingAction
. -
handlerAdded
public void handlerAdded(io.netty.channel.ChannelHandlerContext ctx) InitializesChannelPromise
- Specified by:
handlerAdded
in interfaceio.netty.channel.ChannelHandler
- Overrides:
handlerAdded
in classio.netty.channel.ChannelHandlerAdapter
-
channelRead0
public void channelRead0(io.netty.channel.ChannelHandlerContext ctx, InboundMessageType inboundMessage) throws FailureException, UndeterminedStateException MarksChannelPromise
as success- Specified by:
channelRead0
in classio.netty.channel.SimpleChannelInboundHandler<InboundMessageType>
- Throws:
FailureException
UndeterminedStateException
-
exceptionCaught
Logs the channel and pipeline that caused error, closes channel, then informsProbingAction
listeners of error.- Specified by:
exceptionCaught
in interfaceio.netty.channel.ChannelHandler
- Specified by:
exceptionCaught
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
exceptionCaught
in classio.netty.channel.ChannelInboundHandlerAdapter
-