Package io.netty.channel
Class CombinedChannelDuplexHandler<I extends ChannelInboundHandler,O extends ChannelOutboundHandler>
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
io.netty.channel.CombinedChannelDuplexHandler<I,O>
- All Implemented Interfaces:
ChannelHandler
,ChannelInboundHandler
,ChannelOutboundHandler
- Direct Known Subclasses:
BinaryMemcacheClientCodec
,BinaryMemcacheServerCodec
,HttpClientCodec
,HttpServerCodec
,SpdyHttpCodec
public class CombinedChannelDuplexHandler<I extends ChannelInboundHandler,O extends ChannelOutboundHandler>
extends ChannelDuplexHandler
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private I
private static final InternalLogger
private O
Fields inherited from class io.netty.channel.ChannelHandlerAdapter
added
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Creates a new uninitialized instance.CombinedChannelDuplexHandler
(I inboundHandler, O outboundHandler) Creates a new instance that combines the specified two handlers into one. -
Method Summary
Modifier and TypeMethodDescriptionvoid
bind
(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) CallsChannelOutboundInvoker.bind(SocketAddress, ChannelPromise)
to forward to the nextChannelOutboundHandler
in theChannelPipeline
.void
CallsChannelHandlerContext.fireChannelActive()
to forward to the nextChannelInboundHandler
in theChannelPipeline
.void
CallsChannelHandlerContext.fireChannelInactive()
to forward to the nextChannelInboundHandler
in theChannelPipeline
.void
channelRead
(ChannelHandlerContext ctx, Object msg) CallsChannelHandlerContext.fireChannelRead(Object)
to forward to the nextChannelInboundHandler
in theChannelPipeline
.void
CallsChannelHandlerContext.fireChannelReadComplete()
to forward to the nextChannelInboundHandler
in theChannelPipeline
.void
CallsChannelHandlerContext.fireChannelRegistered()
to forward to the nextChannelInboundHandler
in theChannelPipeline
.void
CallsChannelHandlerContext.fireChannelUnregistered()
to forward to the nextChannelInboundHandler
in theChannelPipeline
.void
CallsChannelHandlerContext.fireChannelWritabilityChanged()
to forward to the nextChannelInboundHandler
in theChannelPipeline
.private void
void
close
(ChannelHandlerContext ctx, ChannelPromise promise) CallsChannelOutboundInvoker.close(ChannelPromise)
to forward to the nextChannelOutboundHandler
in theChannelPipeline
.void
connect
(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) CallsChannelOutboundInvoker.connect(SocketAddress, SocketAddress, ChannelPromise)
to forward to the nextChannelOutboundHandler
in theChannelPipeline
.void
deregister
(ChannelHandlerContext ctx, ChannelPromise promise) CallsChannelOutboundInvoker.deregister(ChannelPromise)
to forward to the nextChannelOutboundHandler
in theChannelPipeline
.void
disconnect
(ChannelHandlerContext ctx, ChannelPromise promise) CallsChannelOutboundInvoker.disconnect(ChannelPromise)
to forward to the nextChannelOutboundHandler
in theChannelPipeline
.void
exceptionCaught
(ChannelHandlerContext ctx, Throwable cause) CallsChannelHandlerContext.fireExceptionCaught(Throwable)
to forward to the nextChannelHandler
in theChannelPipeline
.void
CallsChannelHandlerContext.flush()
to forward to the nextChannelOutboundHandler
in theChannelPipeline
.void
Do nothing by default, sub-classes may override this method.void
Do nothing by default, sub-classes may override this method.protected final I
protected final void
Initialized this handler with the specified handlers.protected final O
void
CallsChannelHandlerContext.read()
to forward to the nextChannelOutboundHandler
in theChannelPipeline
.final void
Removes theChannelInboundHandler
that was combined in thisCombinedChannelDuplexHandler
.final void
Removes theChannelOutboundHandler
that was combined in thisCombinedChannelDuplexHandler
.void
userEventTriggered
(ChannelHandlerContext ctx, Object evt) CallsChannelHandlerContext.fireUserEventTriggered(Object)
to forward to the nextChannelInboundHandler
in theChannelPipeline
.private void
void
write
(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) CallsChannelOutboundInvoker.write(Object, ChannelPromise)
to forward to the nextChannelOutboundHandler
in theChannelPipeline
.Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, isSharable
-
Field Details
-
logger
-
inboundCtx
-
outboundCtx
-
handlerAdded
private volatile boolean handlerAdded -
inboundHandler
-
outboundHandler
-
-
Constructor Details
-
CombinedChannelDuplexHandler
protected CombinedChannelDuplexHandler()Creates a new uninitialized instance. A class that extends this handler must invokeinit(ChannelInboundHandler, ChannelOutboundHandler)
before adding this handler into aChannelPipeline
. -
CombinedChannelDuplexHandler
Creates a new instance that combines the specified two handlers into one.
-
-
Method Details
-
init
Initialized this handler with the specified handlers.- Throws:
IllegalStateException
- if this handler was not constructed via the default constructor or if this handler does not implement all required handler interfacesIllegalArgumentException
- if the specified handlers cannot be combined into one due to a conflict in the type hierarchy
-
validate
-
inboundHandler
-
outboundHandler
-
checkAdded
private void checkAdded() -
removeInboundHandler
public final void removeInboundHandler()Removes theChannelInboundHandler
that was combined in thisCombinedChannelDuplexHandler
. -
removeOutboundHandler
public final void removeOutboundHandler()Removes theChannelOutboundHandler
that was combined in thisCombinedChannelDuplexHandler
. -
handlerAdded
Description copied from class:ChannelHandlerAdapter
Do nothing by default, sub-classes may override this method.- Specified by:
handlerAdded
in interfaceChannelHandler
- Overrides:
handlerAdded
in classChannelHandlerAdapter
- Throws:
Exception
-
handlerRemoved
Description copied from class:ChannelHandlerAdapter
Do nothing by default, sub-classes may override this method.- Specified by:
handlerRemoved
in interfaceChannelHandler
- Overrides:
handlerRemoved
in classChannelHandlerAdapter
- Throws:
Exception
-
channelRegistered
Description copied from class:ChannelInboundHandlerAdapter
CallsChannelHandlerContext.fireChannelRegistered()
to forward to the nextChannelInboundHandler
in theChannelPipeline
. Sub-classes may override this method to change behavior.- Specified by:
channelRegistered
in interfaceChannelInboundHandler
- Overrides:
channelRegistered
in classChannelInboundHandlerAdapter
- Throws:
Exception
-
channelUnregistered
Description copied from class:ChannelInboundHandlerAdapter
CallsChannelHandlerContext.fireChannelUnregistered()
to forward to the nextChannelInboundHandler
in theChannelPipeline
. Sub-classes may override this method to change behavior.- Specified by:
channelUnregistered
in interfaceChannelInboundHandler
- Overrides:
channelUnregistered
in classChannelInboundHandlerAdapter
- Throws:
Exception
-
channelActive
Description copied from class:ChannelInboundHandlerAdapter
CallsChannelHandlerContext.fireChannelActive()
to forward to the nextChannelInboundHandler
in theChannelPipeline
. Sub-classes may override this method to change behavior.- Specified by:
channelActive
in interfaceChannelInboundHandler
- Overrides:
channelActive
in classChannelInboundHandlerAdapter
- Throws:
Exception
-
channelInactive
Description copied from class:ChannelInboundHandlerAdapter
CallsChannelHandlerContext.fireChannelInactive()
to forward to the nextChannelInboundHandler
in theChannelPipeline
. Sub-classes may override this method to change behavior.- Specified by:
channelInactive
in interfaceChannelInboundHandler
- Overrides:
channelInactive
in classChannelInboundHandlerAdapter
- Throws:
Exception
-
exceptionCaught
Description copied from class:ChannelInboundHandlerAdapter
CallsChannelHandlerContext.fireExceptionCaught(Throwable)
to forward to the nextChannelHandler
in theChannelPipeline
. Sub-classes may override this method to change behavior.- Specified by:
exceptionCaught
in interfaceChannelHandler
- Specified by:
exceptionCaught
in interfaceChannelInboundHandler
- Overrides:
exceptionCaught
in classChannelInboundHandlerAdapter
- Throws:
Exception
-
userEventTriggered
Description copied from class:ChannelInboundHandlerAdapter
CallsChannelHandlerContext.fireUserEventTriggered(Object)
to forward to the nextChannelInboundHandler
in theChannelPipeline
. Sub-classes may override this method to change behavior.- Specified by:
userEventTriggered
in interfaceChannelInboundHandler
- Overrides:
userEventTriggered
in classChannelInboundHandlerAdapter
- Throws:
Exception
-
channelRead
Description copied from class:ChannelInboundHandlerAdapter
CallsChannelHandlerContext.fireChannelRead(Object)
to forward to the nextChannelInboundHandler
in theChannelPipeline
. Sub-classes may override this method to change behavior.- Specified by:
channelRead
in interfaceChannelInboundHandler
- Overrides:
channelRead
in classChannelInboundHandlerAdapter
- Throws:
Exception
-
channelReadComplete
Description copied from class:ChannelInboundHandlerAdapter
CallsChannelHandlerContext.fireChannelReadComplete()
to forward to the nextChannelInboundHandler
in theChannelPipeline
. Sub-classes may override this method to change behavior.- Specified by:
channelReadComplete
in interfaceChannelInboundHandler
- Overrides:
channelReadComplete
in classChannelInboundHandlerAdapter
- Throws:
Exception
-
channelWritabilityChanged
Description copied from class:ChannelInboundHandlerAdapter
CallsChannelHandlerContext.fireChannelWritabilityChanged()
to forward to the nextChannelInboundHandler
in theChannelPipeline
. Sub-classes may override this method to change behavior.- Specified by:
channelWritabilityChanged
in interfaceChannelInboundHandler
- Overrides:
channelWritabilityChanged
in classChannelInboundHandlerAdapter
- Throws:
Exception
-
bind
public void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) throws Exception Description copied from class:ChannelDuplexHandler
CallsChannelOutboundInvoker.bind(SocketAddress, ChannelPromise)
to forward to the nextChannelOutboundHandler
in theChannelPipeline
. Sub-classes may override this method to change behavior.- Specified by:
bind
in interfaceChannelOutboundHandler
- Overrides:
bind
in classChannelDuplexHandler
- Parameters:
ctx
- theChannelHandlerContext
for which the bind operation is madelocalAddress
- theSocketAddress
to which it should boundpromise
- theChannelPromise
to notify once the operation completes- Throws:
Exception
- thrown if an error occurs
-
connect
public void connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) throws Exception Description copied from class:ChannelDuplexHandler
CallsChannelOutboundInvoker.connect(SocketAddress, SocketAddress, ChannelPromise)
to forward to the nextChannelOutboundHandler
in theChannelPipeline
. Sub-classes may override this method to change behavior.- Specified by:
connect
in interfaceChannelOutboundHandler
- Overrides:
connect
in classChannelDuplexHandler
- Parameters:
ctx
- theChannelHandlerContext
for which the connect operation is maderemoteAddress
- theSocketAddress
to which it should connectlocalAddress
- theSocketAddress
which is used as source on connectpromise
- theChannelPromise
to notify once the operation completes- Throws:
Exception
- thrown if an error occurs
-
disconnect
Description copied from class:ChannelDuplexHandler
CallsChannelOutboundInvoker.disconnect(ChannelPromise)
to forward to the nextChannelOutboundHandler
in theChannelPipeline
. Sub-classes may override this method to change behavior.- Specified by:
disconnect
in interfaceChannelOutboundHandler
- Overrides:
disconnect
in classChannelDuplexHandler
- Parameters:
ctx
- theChannelHandlerContext
for which the disconnect operation is madepromise
- theChannelPromise
to notify once the operation completes- Throws:
Exception
- thrown if an error occurs
-
close
Description copied from class:ChannelDuplexHandler
CallsChannelOutboundInvoker.close(ChannelPromise)
to forward to the nextChannelOutboundHandler
in theChannelPipeline
. Sub-classes may override this method to change behavior.- Specified by:
close
in interfaceChannelOutboundHandler
- Overrides:
close
in classChannelDuplexHandler
- Parameters:
ctx
- theChannelHandlerContext
for which the close operation is madepromise
- theChannelPromise
to notify once the operation completes- Throws:
Exception
- thrown if an error occurs
-
deregister
Description copied from class:ChannelDuplexHandler
CallsChannelOutboundInvoker.deregister(ChannelPromise)
to forward to the nextChannelOutboundHandler
in theChannelPipeline
. Sub-classes may override this method to change behavior.- Specified by:
deregister
in interfaceChannelOutboundHandler
- Overrides:
deregister
in classChannelDuplexHandler
- Parameters:
ctx
- theChannelHandlerContext
for which the close operation is madepromise
- theChannelPromise
to notify once the operation completes- Throws:
Exception
- thrown if an error occurs
-
read
Description copied from class:ChannelDuplexHandler
CallsChannelHandlerContext.read()
to forward to the nextChannelOutboundHandler
in theChannelPipeline
. Sub-classes may override this method to change behavior.- Specified by:
read
in interfaceChannelOutboundHandler
- Overrides:
read
in classChannelDuplexHandler
- Throws:
Exception
-
write
Description copied from class:ChannelDuplexHandler
CallsChannelOutboundInvoker.write(Object, ChannelPromise)
to forward to the nextChannelOutboundHandler
in theChannelPipeline
. Sub-classes may override this method to change behavior.- Specified by:
write
in interfaceChannelOutboundHandler
- Overrides:
write
in classChannelDuplexHandler
- Parameters:
ctx
- theChannelHandlerContext
for which the write operation is mademsg
- the message to writepromise
- theChannelPromise
to notify once the operation completes- Throws:
Exception
- thrown if an error occurs
-
flush
Description copied from class:ChannelDuplexHandler
CallsChannelHandlerContext.flush()
to forward to the nextChannelOutboundHandler
in theChannelPipeline
. Sub-classes may override this method to change behavior.- Specified by:
flush
in interfaceChannelOutboundHandler
- Overrides:
flush
in classChannelDuplexHandler
- Parameters:
ctx
- theChannelHandlerContext
for which the flush operation is made- Throws:
Exception
- thrown if an error occurs
-