Class CombinedChannelDuplexHandler.DelegatingChannelHandlerContext
- java.lang.Object
-
- io.netty.channel.CombinedChannelDuplexHandler.DelegatingChannelHandlerContext
-
- All Implemented Interfaces:
ChannelHandlerContext,ChannelInboundInvoker,ChannelOutboundInvoker,AttributeMap
- Enclosing class:
- CombinedChannelDuplexHandler<I extends ChannelInboundHandler,O extends ChannelOutboundHandler>
private static class CombinedChannelDuplexHandler.DelegatingChannelHandlerContext extends java.lang.Object implements ChannelHandlerContext
-
-
Field Summary
Fields Modifier and Type Field Description private ChannelHandlerContextctxprivate ChannelHandlerhandler(package private) booleanremoved
-
Constructor Summary
Constructors Constructor Description DelegatingChannelHandlerContext(ChannelHandlerContext ctx, ChannelHandler handler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ByteBufAllocatoralloc()Return the assignedByteBufAllocatorwhich will be used to allocateByteBufs.<T> Attribute<T>attr(AttributeKey<T> key)Get theAttributefor the givenAttributeKey.ChannelFuturebind(java.net.SocketAddress localAddress)Request to bind to the givenSocketAddressand notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.ChannelFuturebind(java.net.SocketAddress localAddress, ChannelPromise promise)Request to bind to the givenSocketAddressand notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.Channelchannel()Return theChannelwhich is bound to theChannelHandlerContext.ChannelFutureclose()Request to close theChanneland notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.ChannelFutureclose(ChannelPromise promise)Request to close theChanneland notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.ChannelFutureconnect(java.net.SocketAddress remoteAddress)Request to connect to the givenSocketAddressand notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.ChannelFutureconnect(java.net.SocketAddress remoteAddress, ChannelPromise promise)Request to connect to the givenSocketAddressand notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.ChannelFutureconnect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress)Request to connect to the givenSocketAddresswhile bind to the localAddress and notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.ChannelFutureconnect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress, ChannelPromise promise)Request to connect to the givenSocketAddresswhile bind to the localAddress and notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.ChannelFuturederegister()Request to deregister from the previous assignedEventExecutorand notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.ChannelFuturederegister(ChannelPromise promise)Request to deregister from the previous assignedEventExecutorand notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.ChannelFuturedisconnect()Request to disconnect from the remote peer and notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.ChannelFuturedisconnect(ChannelPromise promise)Request to disconnect from the remote peer and notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.EventExecutorexecutor()Returns theEventExecutorwhich is used to execute an arbitrary task.ChannelHandlerContextfireChannelActive()AChannelis active now, which means it is connected.ChannelHandlerContextfireChannelInactive()AChannelis inactive now, which means it is closed.ChannelHandlerContextfireChannelRead(java.lang.Object msg)AChannelreceived a message.ChannelHandlerContextfireChannelReadComplete()Triggers anChannelInboundHandler.channelReadComplete(ChannelHandlerContext)event to the nextChannelInboundHandlerin theChannelPipeline.ChannelHandlerContextfireChannelRegistered()ChannelHandlerContextfireChannelUnregistered()ChannelHandlerContextfireChannelWritabilityChanged()Triggers anChannelInboundHandler.channelWritabilityChanged(ChannelHandlerContext)event to the nextChannelInboundHandlerin theChannelPipeline.ChannelHandlerContextfireExceptionCaught(java.lang.Throwable cause)AChannelreceived anThrowablein one of its inbound operations.ChannelHandlerContextfireUserEventTriggered(java.lang.Object event)AChannelreceived an user defined event.ChannelHandlerContextflush()Request to flush all pending messages via this ChannelOutboundInvoker.ChannelHandlerhandler()TheChannelHandlerthat is bound thisChannelHandlerContext.<T> booleanhasAttr(AttributeKey<T> key)booleanisRemoved()Returntrueif theChannelHandlerwhich belongs to this context was removed from theChannelPipeline.java.lang.Stringname()The unique name of theChannelHandlerContext.The name was used when thenChannelHandlerwas added to theChannelPipeline.ChannelFuturenewFailedFuture(java.lang.Throwable cause)Create a newChannelFuturewhich is marked as failed already.ChannelProgressivePromisenewProgressivePromise()Return an newChannelProgressivePromiseChannelPromisenewPromise()Return a newChannelPromise.ChannelFuturenewSucceededFuture()Create a newChannelFuturewhich is marked as succeeded already.ChannelPipelinepipeline()Return the assignedChannelPipelineChannelHandlerContextread()Request to Read data from theChannelinto the first inbound buffer, triggers anChannelInboundHandler.channelRead(ChannelHandlerContext, Object)event if data was read, and triggers achannelReadCompleteevent so the handler can decide to continue reading.(package private) voidremove()private voidremove0()ChannelPromisevoidPromise()Return a special ChannelPromise which can be reused for different operations.ChannelFuturewrite(java.lang.Object msg)Request to write a message via thisChannelHandlerContextthrough theChannelPipeline.ChannelFuturewrite(java.lang.Object msg, ChannelPromise promise)Request to write a message via thisChannelHandlerContextthrough theChannelPipeline.ChannelFuturewriteAndFlush(java.lang.Object msg)Shortcut for callChannelOutboundInvoker.write(Object)andChannelOutboundInvoker.flush().ChannelFuturewriteAndFlush(java.lang.Object msg, ChannelPromise promise)Shortcut for callChannelOutboundInvoker.write(Object, ChannelPromise)andChannelOutboundInvoker.flush().
-
-
-
Field Detail
-
ctx
private final ChannelHandlerContext ctx
-
handler
private final ChannelHandler handler
-
removed
boolean removed
-
-
Constructor Detail
-
DelegatingChannelHandlerContext
DelegatingChannelHandlerContext(ChannelHandlerContext ctx, ChannelHandler handler)
-
-
Method Detail
-
channel
public Channel channel()
Description copied from interface:ChannelHandlerContextReturn theChannelwhich is bound to theChannelHandlerContext.- Specified by:
channelin interfaceChannelHandlerContext
-
executor
public EventExecutor executor()
Description copied from interface:ChannelHandlerContextReturns theEventExecutorwhich is used to execute an arbitrary task.- Specified by:
executorin interfaceChannelHandlerContext
-
name
public java.lang.String name()
Description copied from interface:ChannelHandlerContextThe unique name of theChannelHandlerContext.The name was used when thenChannelHandlerwas added to theChannelPipeline. This name can also be used to access the registeredChannelHandlerfrom theChannelPipeline.- Specified by:
namein interfaceChannelHandlerContext
-
handler
public ChannelHandler handler()
Description copied from interface:ChannelHandlerContextTheChannelHandlerthat is bound thisChannelHandlerContext.- Specified by:
handlerin interfaceChannelHandlerContext
-
isRemoved
public boolean isRemoved()
Description copied from interface:ChannelHandlerContextReturntrueif theChannelHandlerwhich belongs to this context was removed from theChannelPipeline. Note that this method is only meant to be called from with in theEventLoop.- Specified by:
isRemovedin interfaceChannelHandlerContext
-
fireChannelRegistered
public ChannelHandlerContext fireChannelRegistered()
Description copied from interface:ChannelInboundInvokerAChannelwas registered to itsEventLoop. This will result in having theChannelInboundHandler.channelRegistered(ChannelHandlerContext)method called of the nextChannelInboundHandlercontained in theChannelPipelineof theChannel.- Specified by:
fireChannelRegisteredin interfaceChannelHandlerContext- Specified by:
fireChannelRegisteredin interfaceChannelInboundInvoker
-
fireChannelUnregistered
public ChannelHandlerContext fireChannelUnregistered()
Description copied from interface:ChannelInboundInvokerAChannelwas unregistered from itsEventLoop. This will result in having theChannelInboundHandler.channelUnregistered(ChannelHandlerContext)method called of the nextChannelInboundHandlercontained in theChannelPipelineof theChannel.- Specified by:
fireChannelUnregisteredin interfaceChannelHandlerContext- Specified by:
fireChannelUnregisteredin interfaceChannelInboundInvoker
-
fireChannelActive
public ChannelHandlerContext fireChannelActive()
Description copied from interface:ChannelInboundInvokerAChannelis active now, which means it is connected. This will result in having theChannelInboundHandler.channelActive(ChannelHandlerContext)method called of the nextChannelInboundHandlercontained in theChannelPipelineof theChannel.- Specified by:
fireChannelActivein interfaceChannelHandlerContext- Specified by:
fireChannelActivein interfaceChannelInboundInvoker
-
fireChannelInactive
public ChannelHandlerContext fireChannelInactive()
Description copied from interface:ChannelInboundInvokerAChannelis inactive now, which means it is closed. This will result in having theChannelInboundHandler.channelInactive(ChannelHandlerContext)method called of the nextChannelInboundHandlercontained in theChannelPipelineof theChannel.- Specified by:
fireChannelInactivein interfaceChannelHandlerContext- Specified by:
fireChannelInactivein interfaceChannelInboundInvoker
-
fireExceptionCaught
public ChannelHandlerContext fireExceptionCaught(java.lang.Throwable cause)
Description copied from interface:ChannelInboundInvokerAChannelreceived anThrowablein one of its inbound operations. This will result in having theChannelInboundHandler.exceptionCaught(ChannelHandlerContext, Throwable)method called of the nextChannelInboundHandlercontained in theChannelPipelineof theChannel.- Specified by:
fireExceptionCaughtin interfaceChannelHandlerContext- Specified by:
fireExceptionCaughtin interfaceChannelInboundInvoker
-
fireUserEventTriggered
public ChannelHandlerContext fireUserEventTriggered(java.lang.Object event)
Description copied from interface:ChannelInboundInvokerAChannelreceived an user defined event. This will result in having theChannelInboundHandler.userEventTriggered(ChannelHandlerContext, Object)method called of the nextChannelInboundHandlercontained in theChannelPipelineof theChannel.- Specified by:
fireUserEventTriggeredin interfaceChannelHandlerContext- Specified by:
fireUserEventTriggeredin interfaceChannelInboundInvoker
-
fireChannelRead
public ChannelHandlerContext fireChannelRead(java.lang.Object msg)
Description copied from interface:ChannelInboundInvokerAChannelreceived a message. This will result in having theChannelInboundHandler.channelRead(ChannelHandlerContext, Object)method called of the nextChannelInboundHandlercontained in theChannelPipelineof theChannel.- Specified by:
fireChannelReadin interfaceChannelHandlerContext- Specified by:
fireChannelReadin interfaceChannelInboundInvoker
-
fireChannelReadComplete
public ChannelHandlerContext fireChannelReadComplete()
Description copied from interface:ChannelInboundInvokerTriggers anChannelInboundHandler.channelReadComplete(ChannelHandlerContext)event to the nextChannelInboundHandlerin theChannelPipeline.- Specified by:
fireChannelReadCompletein interfaceChannelHandlerContext- Specified by:
fireChannelReadCompletein interfaceChannelInboundInvoker
-
fireChannelWritabilityChanged
public ChannelHandlerContext fireChannelWritabilityChanged()
Description copied from interface:ChannelInboundInvokerTriggers anChannelInboundHandler.channelWritabilityChanged(ChannelHandlerContext)event to the nextChannelInboundHandlerin theChannelPipeline.- Specified by:
fireChannelWritabilityChangedin interfaceChannelHandlerContext- Specified by:
fireChannelWritabilityChangedin interfaceChannelInboundInvoker
-
bind
public ChannelFuture bind(java.net.SocketAddress localAddress)
Description copied from interface:ChannelOutboundInvokerRequest to bind to the givenSocketAddressand notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.This will result in having the
ChannelOutboundHandler.bind(ChannelHandlerContext, SocketAddress, ChannelPromise)method called of the nextChannelOutboundHandlercontained in theChannelPipelineof theChannel.- Specified by:
bindin interfaceChannelOutboundInvoker
-
connect
public ChannelFuture connect(java.net.SocketAddress remoteAddress)
Description copied from interface:ChannelOutboundInvokerRequest to connect to the givenSocketAddressand notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.If the connection fails because of a connection timeout, the
ChannelFuturewill get failed with aConnectTimeoutException. If it fails because of connection refused aConnectExceptionwill be used.This will result in having the
ChannelOutboundHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)method called of the nextChannelOutboundHandlercontained in theChannelPipelineof theChannel.- Specified by:
connectin interfaceChannelOutboundInvoker
-
connect
public ChannelFuture connect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress)
Description copied from interface:ChannelOutboundInvokerRequest to connect to the givenSocketAddresswhile bind to the localAddress and notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.This will result in having the
ChannelOutboundHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)method called of the nextChannelOutboundHandlercontained in theChannelPipelineof theChannel.- Specified by:
connectin interfaceChannelOutboundInvoker
-
disconnect
public ChannelFuture disconnect()
Description copied from interface:ChannelOutboundInvokerRequest to disconnect from the remote peer and notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.This will result in having the
ChannelOutboundHandler.disconnect(ChannelHandlerContext, ChannelPromise)method called of the nextChannelOutboundHandlercontained in theChannelPipelineof theChannel.- Specified by:
disconnectin interfaceChannelOutboundInvoker
-
close
public ChannelFuture close()
Description copied from interface:ChannelOutboundInvokerRequest to close theChanneland notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error. After it is closed it is not possible to reuse it again.This will result in having the
ChannelOutboundHandler.close(ChannelHandlerContext, ChannelPromise)method called of the nextChannelOutboundHandlercontained in theChannelPipelineof theChannel.- Specified by:
closein interfaceChannelOutboundInvoker
-
deregister
public ChannelFuture deregister()
Description copied from interface:ChannelOutboundInvokerRequest to deregister from the previous assignedEventExecutorand notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.This will result in having the
ChannelOutboundHandler.deregister(ChannelHandlerContext, ChannelPromise)method called of the nextChannelOutboundHandlercontained in theChannelPipelineof theChannel.- Specified by:
deregisterin interfaceChannelOutboundInvoker
-
bind
public ChannelFuture bind(java.net.SocketAddress localAddress, ChannelPromise promise)
Description copied from interface:ChannelOutboundInvokerRequest to bind to the givenSocketAddressand notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error. The givenChannelPromisewill be notified.This will result in having the
ChannelOutboundHandler.bind(ChannelHandlerContext, SocketAddress, ChannelPromise)method called of the nextChannelOutboundHandlercontained in theChannelPipelineof theChannel.- Specified by:
bindin interfaceChannelOutboundInvoker
-
connect
public ChannelFuture connect(java.net.SocketAddress remoteAddress, ChannelPromise promise)
Description copied from interface:ChannelOutboundInvokerRequest to connect to the givenSocketAddressand notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error. The givenChannelFuturewill be notified.If the connection fails because of a connection timeout, the
ChannelFuturewill get failed with aConnectTimeoutException. If it fails because of connection refused aConnectExceptionwill be used.This will result in having the
ChannelOutboundHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)method called of the nextChannelOutboundHandlercontained in theChannelPipelineof theChannel.- Specified by:
connectin interfaceChannelOutboundInvoker
-
connect
public ChannelFuture connect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress, ChannelPromise promise)
Description copied from interface:ChannelOutboundInvokerRequest to connect to the givenSocketAddresswhile bind to the localAddress and notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error. The givenChannelPromisewill be notified and also returned.This will result in having the
ChannelOutboundHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)method called of the nextChannelOutboundHandlercontained in theChannelPipelineof theChannel.- Specified by:
connectin interfaceChannelOutboundInvoker
-
disconnect
public ChannelFuture disconnect(ChannelPromise promise)
Description copied from interface:ChannelOutboundInvokerRequest to disconnect from the remote peer and notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error. The givenChannelPromisewill be notified.This will result in having the
ChannelOutboundHandler.disconnect(ChannelHandlerContext, ChannelPromise)method called of the nextChannelOutboundHandlercontained in theChannelPipelineof theChannel.- Specified by:
disconnectin interfaceChannelOutboundInvoker
-
close
public ChannelFuture close(ChannelPromise promise)
Description copied from interface:ChannelOutboundInvokerRequest to close theChanneland notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error. After it is closed it is not possible to reuse it again. The givenChannelPromisewill be notified.This will result in having the
ChannelOutboundHandler.close(ChannelHandlerContext, ChannelPromise)method called of the nextChannelOutboundHandlercontained in theChannelPipelineof theChannel.- Specified by:
closein interfaceChannelOutboundInvoker
-
deregister
public ChannelFuture deregister(ChannelPromise promise)
Description copied from interface:ChannelOutboundInvokerRequest to deregister from the previous assignedEventExecutorand notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error. The givenChannelPromisewill be notified.This will result in having the
ChannelOutboundHandler.deregister(ChannelHandlerContext, ChannelPromise)method called of the nextChannelOutboundHandlercontained in theChannelPipelineof theChannel.- Specified by:
deregisterin interfaceChannelOutboundInvoker
-
read
public ChannelHandlerContext read()
Description copied from interface:ChannelOutboundInvokerRequest to Read data from theChannelinto the first inbound buffer, triggers anChannelInboundHandler.channelRead(ChannelHandlerContext, Object)event if data was read, and triggers achannelReadCompleteevent so the handler can decide to continue reading. If there's a pending read operation already, this method does nothing.This will result in having the
ChannelOutboundHandler.read(ChannelHandlerContext)method called of the nextChannelOutboundHandlercontained in theChannelPipelineof theChannel.- Specified by:
readin interfaceChannelHandlerContext- Specified by:
readin interfaceChannelOutboundInvoker
-
write
public ChannelFuture write(java.lang.Object msg)
Description copied from interface:ChannelOutboundInvokerRequest to write a message via thisChannelHandlerContextthrough theChannelPipeline. This method will not request to actual flush, so be sure to callChannelOutboundInvoker.flush()once you want to request to flush all pending data to the actual transport.- Specified by:
writein interfaceChannelOutboundInvoker
-
write
public ChannelFuture write(java.lang.Object msg, ChannelPromise promise)
Description copied from interface:ChannelOutboundInvokerRequest to write a message via thisChannelHandlerContextthrough theChannelPipeline. This method will not request to actual flush, so be sure to callChannelOutboundInvoker.flush()once you want to request to flush all pending data to the actual transport.- Specified by:
writein interfaceChannelOutboundInvoker
-
flush
public ChannelHandlerContext flush()
Description copied from interface:ChannelOutboundInvokerRequest to flush all pending messages via this ChannelOutboundInvoker.- Specified by:
flushin interfaceChannelHandlerContext- Specified by:
flushin interfaceChannelOutboundInvoker
-
writeAndFlush
public ChannelFuture writeAndFlush(java.lang.Object msg, ChannelPromise promise)
Description copied from interface:ChannelOutboundInvokerShortcut for callChannelOutboundInvoker.write(Object, ChannelPromise)andChannelOutboundInvoker.flush().- Specified by:
writeAndFlushin interfaceChannelOutboundInvoker
-
writeAndFlush
public ChannelFuture writeAndFlush(java.lang.Object msg)
Description copied from interface:ChannelOutboundInvokerShortcut for callChannelOutboundInvoker.write(Object)andChannelOutboundInvoker.flush().- Specified by:
writeAndFlushin interfaceChannelOutboundInvoker
-
pipeline
public ChannelPipeline pipeline()
Description copied from interface:ChannelHandlerContextReturn the assignedChannelPipeline- Specified by:
pipelinein interfaceChannelHandlerContext
-
alloc
public ByteBufAllocator alloc()
Description copied from interface:ChannelHandlerContextReturn the assignedByteBufAllocatorwhich will be used to allocateByteBufs.- Specified by:
allocin interfaceChannelHandlerContext
-
newPromise
public ChannelPromise newPromise()
Description copied from interface:ChannelOutboundInvokerReturn a newChannelPromise.- Specified by:
newPromisein interfaceChannelOutboundInvoker
-
newProgressivePromise
public ChannelProgressivePromise newProgressivePromise()
Description copied from interface:ChannelOutboundInvokerReturn an newChannelProgressivePromise- Specified by:
newProgressivePromisein interfaceChannelOutboundInvoker
-
newSucceededFuture
public ChannelFuture newSucceededFuture()
Description copied from interface:ChannelOutboundInvokerCreate a newChannelFuturewhich is marked as succeeded already. SoFuture.isSuccess()will returntrue. AllFutureListeneradded to it will be notified directly. Also every call of blocking methods will just return without blocking.- Specified by:
newSucceededFuturein interfaceChannelOutboundInvoker
-
newFailedFuture
public ChannelFuture newFailedFuture(java.lang.Throwable cause)
Description copied from interface:ChannelOutboundInvokerCreate a newChannelFuturewhich is marked as failed already. SoFuture.isSuccess()will returnfalse. AllFutureListeneradded to it will be notified directly. Also every call of blocking methods will just return without blocking.- Specified by:
newFailedFuturein interfaceChannelOutboundInvoker
-
voidPromise
public ChannelPromise voidPromise()
Description copied from interface:ChannelOutboundInvokerReturn a special ChannelPromise which can be reused for different operations.It's only supported to use it for
ChannelOutboundInvoker.write(Object, ChannelPromise).Be aware that the returned
Be aware this is an expert feature and should be used with care!ChannelPromisewill not support most operations and should only be used if you want to save an object allocation for every write operation. You will not be able to detect if the operation was complete, only if it failed as the implementation will callChannelPipeline.fireExceptionCaught(Throwable)in this case.- Specified by:
voidPromisein interfaceChannelOutboundInvoker
-
attr
public <T> Attribute<T> attr(AttributeKey<T> key)
Description copied from interface:AttributeMapGet theAttributefor the givenAttributeKey. This method will never return null, but may return anAttributewhich does not have a value set yet.- Specified by:
attrin interfaceAttributeMap- Specified by:
attrin interfaceChannelHandlerContext
-
hasAttr
public <T> boolean hasAttr(AttributeKey<T> key)
Description copied from interface:AttributeMap- Specified by:
hasAttrin interfaceAttributeMap- Specified by:
hasAttrin interfaceChannelHandlerContext
-
remove
final void remove()
-
remove0
private void remove0()
-
-