- java.lang.Object
-
- io.netty5.channel.internal.DelegatingChannelHandlerContext
-
- All Implemented Interfaces:
ChannelHandlerContext,ChannelInboundInvoker,ChannelOutboundInvoker,FuturePromiseFactory
public abstract class DelegatingChannelHandlerContext extends Object implements ChannelHandlerContext
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDelegatingChannelHandlerContext(ChannelHandlerContext ctx)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Future<Void>bind(SocketAddress localAddress)Request to bind to the givenSocketAddressand notify theFutureonce the operation completes, either because the operation was successful or because of an error.BufferAllocatorbufferAllocator()Return the assignedBufferAllocatorwhich will be used to allocateBuffers.Channelchannel()Return theChannelwhich is bound to theChannelHandlerContext.Future<Void>close()Future<Void>connect(SocketAddress remoteAddress)Request to connect to the givenSocketAddressand notify theFutureonce the operation completes, either because the operation was successful or because of an error.Future<Void>connect(SocketAddress remoteAddress, SocketAddress localAddress)Request to connect to the givenSocketAddresswhile bind to the localAddress and notify theFutureonce the operation completes, either because the operation was successful or because of an error.ChannelHandlerContextdelegatingCtx()Future<Void>deregister()Request to deregister from the previous assignedEventExecutorand notify theFutureonce the operation completes, either because the operation was successful or because of an error.Future<Void>disconnect()Request to disconnect from the remote peer and notify theFutureonce the operation completes, either because the operation was successful or because of an error.EventExecutorexecutor()Returns theEventExecutorthat is used to execute the operations of thisChannelOutboundInvoker.ChannelHandlerContextfireChannelActive()AChannelis active now, which means it is connected.ChannelHandlerContextfireChannelExceptionCaught(Throwable cause)ChannelHandlerContextfireChannelInactive()AChannelis inactive now, which means it is closed.ChannelHandlerContextfireChannelInboundEvent(Object evt)AChannelreceived a custom defined inbound event.ChannelHandlerContextfireChannelRead(Object msg)AChannelreceived a message.ChannelHandlerContextfireChannelReadComplete()Triggers anChannelHandler.channelReadComplete(ChannelHandlerContext)event to the nextChannelHandlerin theChannelPipeline.ChannelHandlerContextfireChannelRegistered()ChannelHandlerContextfireChannelShutdown(ChannelShutdownDirection direction)AChannelwas shutdown in a specific direction.ChannelHandlerContextfireChannelUnregistered()ChannelHandlerContextfireChannelWritabilityChanged()Triggers anChannelHandler.channelWritabilityChanged(ChannelHandlerContext)event to the nextChannelHandlerin theChannelPipeline.ChannelHandlerContextflush()Request to flush all pending messages via this ChannelOutboundInvoker.ChannelHandlerhandler()TheChannelHandlerthat is bound thisChannelHandlerContext.booleanisRemoved()Returntrueif theChannelHandlerwhich belongs to this context was removed from theChannelPipeline.Stringname()The unique name of theChannelHandlerContext.The name was used when thenChannelHandlerwas added to theChannelPipeline.<V> Future<V>newFailedFuture(Throwable cause)Create a newFuturewhich is marked as failed already.<V> Promise<V>newPromise()Return a newPromise.Future<Void>newSucceededFuture()Create a newFuturewhich is marked as succeeded already.<V> Future<V>newSucceededFuture(V value)Create a newFuturewhich is marked as succeeded already.ChannelPipelinepipeline()Return the assignedChannelPipelineChannelHandlerContextread()Request to Read data from theChannelinto the first inbound buffer, triggers anChannelHandler.channelRead(ChannelHandlerContext, Object)event if data was read, and triggers achannelReadCompleteevent so the handler can decide to continue reading.Future<Void>register()Request to register on theEventExecutorfor I/O processing.Future<Void>sendOutboundEvent(Object event)Send a custom outbound event via thisChannelOutboundInvokerthrough theChannelPipeline.Future<Void>shutdown(ChannelShutdownDirection direction)Future<Void>write(Object msg)Request to write a message via thisChannelHandlerContextthrough theChannelPipeline.Future<Void>writeAndFlush(Object msg)Shortcut for callChannelOutboundInvoker.write(Object)andChannelOutboundInvoker.flush().
-
-
-
Constructor Detail
-
DelegatingChannelHandlerContext
protected DelegatingChannelHandlerContext(ChannelHandlerContext ctx)
-
-
Method Detail
-
delegatingCtx
public final ChannelHandlerContext delegatingCtx()
-
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:ChannelOutboundInvokerReturns theEventExecutorthat is used to execute the operations of thisChannelOutboundInvoker.- Specified by:
executorin interfaceChannelOutboundInvoker- Returns:
- the executor.
-
name
public 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.- Specified by:
isRemovedin interfaceChannelHandlerContext
-
fireChannelRegistered
public ChannelHandlerContext fireChannelRegistered()
Description copied from interface:ChannelInboundInvokerAChannelwas registered to itsEventLoop. This will result in having theChannelHandler.channelRegistered(ChannelHandlerContext)method called of the nextChannelHandlercontained 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 theChannelHandler.channelUnregistered(ChannelHandlerContext)method called of the nextChannelHandlercontained 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 theChannelHandler.channelActive(ChannelHandlerContext)method called of the nextChannelHandlercontained 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 theChannelHandler.channelInactive(ChannelHandlerContext)method called of the nextChannelHandlercontained in theChannelPipelineof theChannel.- Specified by:
fireChannelInactivein interfaceChannelHandlerContext- Specified by:
fireChannelInactivein interfaceChannelInboundInvoker
-
fireChannelShutdown
public ChannelHandlerContext fireChannelShutdown(ChannelShutdownDirection direction)
Description copied from interface:ChannelInboundInvokerAChannelwas shutdown in a specific direction. This will result in having theChannelHandler.channelShutdown(ChannelHandlerContext, ChannelShutdownDirection)method called of the nextChannelHandlercontained in theChannelPipelineof theChannel.- Specified by:
fireChannelShutdownin interfaceChannelHandlerContext- Specified by:
fireChannelShutdownin interfaceChannelInboundInvoker
-
fireChannelExceptionCaught
public ChannelHandlerContext fireChannelExceptionCaught(Throwable cause)
Description copied from interface:ChannelInboundInvokerAChannelreceived anThrowablein one of its inbound operations. This will result in having theChannelHandler.channelExceptionCaught(ChannelHandlerContext, Throwable)method called of the nextChannelHandlercontained in theChannelPipelineof theChannel.- Specified by:
fireChannelExceptionCaughtin interfaceChannelHandlerContext- Specified by:
fireChannelExceptionCaughtin interfaceChannelInboundInvoker
-
fireChannelInboundEvent
public ChannelHandlerContext fireChannelInboundEvent(Object evt)
Description copied from interface:ChannelInboundInvokerAChannelreceived a custom defined inbound event. This will result in having theChannelHandler.channelInboundEvent(ChannelHandlerContext, Object)method called of the nextChannelHandlercontained in theChannelPipelineof theChannel.- Specified by:
fireChannelInboundEventin interfaceChannelHandlerContext- Specified by:
fireChannelInboundEventin interfaceChannelInboundInvoker
-
fireChannelRead
public ChannelHandlerContext fireChannelRead(Object msg)
Description copied from interface:ChannelInboundInvokerAChannelreceived a message. This will result in having theChannelHandler.channelRead(ChannelHandlerContext, Object)method called of the nextChannelHandlercontained in theChannelPipelineof theChannel.- Specified by:
fireChannelReadin interfaceChannelHandlerContext- Specified by:
fireChannelReadin interfaceChannelInboundInvoker
-
fireChannelReadComplete
public ChannelHandlerContext fireChannelReadComplete()
Description copied from interface:ChannelInboundInvokerTriggers anChannelHandler.channelReadComplete(ChannelHandlerContext)event to the nextChannelHandlerin theChannelPipeline.- Specified by:
fireChannelReadCompletein interfaceChannelHandlerContext- Specified by:
fireChannelReadCompletein interfaceChannelInboundInvoker
-
fireChannelWritabilityChanged
public ChannelHandlerContext fireChannelWritabilityChanged()
Description copied from interface:ChannelInboundInvokerTriggers anChannelHandler.channelWritabilityChanged(ChannelHandlerContext)event to the nextChannelHandlerin theChannelPipeline.- Specified by:
fireChannelWritabilityChangedin interfaceChannelHandlerContext- Specified by:
fireChannelWritabilityChangedin interfaceChannelInboundInvoker
-
read
public ChannelHandlerContext read()
Description copied from interface:ChannelOutboundInvokerRequest to Read data from theChannelinto the first inbound buffer, triggers anChannelHandler.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
ChannelHandler.read(ChannelHandlerContext)method called of the nextChannelHandlercontained in theChannelPipelineof theChannel.- Specified by:
readin interfaceChannelHandlerContext- Specified by:
readin 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
-
sendOutboundEvent
public Future<Void> sendOutboundEvent(Object event)
Description copied from interface:ChannelOutboundInvokerSend a custom outbound event via thisChannelOutboundInvokerthrough theChannelPipeline.This will result in having the
ChannelHandler.sendOutboundEvent(ChannelHandlerContext, Object)method called of the nextChannelHandlercontained in theChannelPipelineof theChannel.- Specified by:
sendOutboundEventin interfaceChannelOutboundInvoker
-
pipeline
public ChannelPipeline pipeline()
Description copied from interface:ChannelHandlerContextReturn the assignedChannelPipeline- Specified by:
pipelinein interfaceChannelHandlerContext
-
bufferAllocator
public BufferAllocator bufferAllocator()
Description copied from interface:ChannelHandlerContextReturn the assignedBufferAllocatorwhich will be used to allocateBuffers.- Specified by:
bufferAllocatorin interfaceChannelHandlerContext
-
bind
public Future<Void> bind(SocketAddress localAddress)
Description copied from interface:ChannelOutboundInvokerRequest to bind to the givenSocketAddressand notify theFutureonce the operation completes, either because the operation was successful or because of an error.This will result in having the
ChannelHandler.bind(ChannelHandlerContext, SocketAddress)method called of the nextChannelHandlercontained in theChannelPipelineof theChannel.- Specified by:
bindin interfaceChannelOutboundInvoker
-
connect
public Future<Void> connect(SocketAddress remoteAddress)
Description copied from interface:ChannelOutboundInvokerRequest to connect to the givenSocketAddressand notify theFutureonce the operation completes, either because the operation was successful or because of an error.If the connection fails because of a connection timeout, the
Futurewill get failed with aConnectTimeoutException. If it fails because of connection refused aConnectExceptionwill be used.This will result in having the
ChannelHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress)method called of the nextChannelHandlercontained in theChannelPipelineof theChannel.- Specified by:
connectin interfaceChannelOutboundInvoker
-
connect
public Future<Void> connect(SocketAddress remoteAddress, SocketAddress localAddress)
Description copied from interface:ChannelOutboundInvokerRequest to connect to the givenSocketAddresswhile bind to the localAddress and notify theFutureonce the operation completes, either because the operation was successful or because of an error.This will result in having the
ChannelHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress)method called of the nextChannelHandlercontained in theChannelPipelineof theChannel.- Specified by:
connectin interfaceChannelOutboundInvoker
-
disconnect
public Future<Void> disconnect()
Description copied from interface:ChannelOutboundInvokerRequest to disconnect from the remote peer and notify theFutureonce the operation completes, either because the operation was successful or because of an error.This will result in having the
ChannelHandler.disconnect(ChannelHandlerContext)method called of the nextChannelHandlercontained in theChannelPipelineof theChannel.- Specified by:
disconnectin interfaceChannelOutboundInvoker
-
close
public Future<Void> close()
Description copied from interface:ChannelOutboundInvokerRequest to close theChanneland notify theFutureonce 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
ChannelHandler.close(ChannelHandlerContext)method called of the nextChannelHandlercontained in theChannelPipelineof theChannel.- Specified by:
closein interfaceChannelOutboundInvoker
-
shutdown
public Future<Void> shutdown(ChannelShutdownDirection direction)
Description copied from interface:ChannelOutboundInvokerRequest shutdown one direction of theChanneland notify theFutureonce the operation completes, either because the operation was successful or because of an error.When completed, the channel will either not produce any inbound data anymore, or it will not be possible to write data anymore, depending on the given
ChannelShutdownDirection.Depending on the transport implementation shutting down the
ChannelShutdownDirection.OutboundorChannelShutdownDirection.Inboundmight also result in data transferred over the network. Like for example in case of TCP shutting down theChannelShutdownDirection.Outboundwill result in aFINthat is transmitted to the remote peer that will as a result shutdownChannelShutdownDirection.Inbound.This will result in having the
ChannelHandler.shutdown(ChannelHandlerContext, ChannelShutdownDirection). method called of the nextChannelHandlercontained in theChannelPipelineof theChannel.- Specified by:
shutdownin interfaceChannelOutboundInvoker
-
deregister
public Future<Void> deregister()
Description copied from interface:ChannelOutboundInvokerRequest to deregister from the previous assignedEventExecutorand notify theFutureonce the operation completes, either because the operation was successful or because of an error.This will result in having the
ChannelHandler.deregister(ChannelHandlerContext)method called of the nextChannelHandlercontained in theChannelPipelineof theChannel.- Specified by:
deregisterin interfaceChannelOutboundInvoker
-
register
public Future<Void> register()
Description copied from interface:ChannelOutboundInvokerRequest to register on theEventExecutorfor I/O processing.Futureonce the operation completes, either because the operation was successful or because of an error.This will result in having the
ChannelHandler.register(ChannelHandlerContext)method called of the nextChannelHandlercontained in theChannelPipelineof theChannel.- Specified by:
registerin interfaceChannelOutboundInvoker
-
write
public Future<Void> write(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
-
writeAndFlush
public Future<Void> writeAndFlush(Object msg)
Description copied from interface:ChannelOutboundInvokerShortcut for callChannelOutboundInvoker.write(Object)andChannelOutboundInvoker.flush().- Specified by:
writeAndFlushin interfaceChannelOutboundInvoker
-
newPromise
public <V> Promise<V> newPromise()
Description copied from interface:FuturePromiseFactoryReturn a newPromise.- Specified by:
newPromisein interfaceChannelOutboundInvoker- Specified by:
newPromisein interfaceFuturePromiseFactory
-
newSucceededFuture
public Future<Void> newSucceededFuture()
Description copied from interface:FuturePromiseFactoryCreate a newFuturewhich is marked as succeeded already. SoAsynchronousResult.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- Specified by:
newSucceededFuturein interfaceFuturePromiseFactory
-
newFailedFuture
public <V> Future<V> newFailedFuture(Throwable cause)
Description copied from interface:FuturePromiseFactoryCreate a newFuturewhich is marked as failed already. SoAsynchronousResult.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- Specified by:
newFailedFuturein interfaceFuturePromiseFactory
-
newSucceededFuture
public <V> Future<V> newSucceededFuture(V value)
Description copied from interface:FuturePromiseFactoryCreate a newFuturewhich is marked as succeeded already. SoAsynchronousResult.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- Specified by:
newSucceededFuturein interfaceFuturePromiseFactory
-
-