- 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 protected
DelegatingChannelHandlerContext(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 givenSocketAddress
and notify theFuture
once the operation completes, either because the operation was successful or because of an error.BufferAllocator
bufferAllocator()
Return the assignedBufferAllocator
which will be used to allocateBuffer
s.Channel
channel()
Return theChannel
which is bound to theChannelHandlerContext
.Future<Void>
close()
Future<Void>
connect(SocketAddress remoteAddress)
Request to connect to the givenSocketAddress
and notify theFuture
once 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 givenSocketAddress
while bind to the localAddress and notify theFuture
once the operation completes, either because the operation was successful or because of an error.ChannelHandlerContext
delegatingCtx()
Future<Void>
deregister()
Request to deregister from the previous assignedEventExecutor
and notify theFuture
once 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 theFuture
once the operation completes, either because the operation was successful or because of an error.EventExecutor
executor()
Returns theEventExecutor
that is used to execute the operations of thisChannelOutboundInvoker
.ChannelHandlerContext
fireChannelActive()
AChannel
is active now, which means it is connected.ChannelHandlerContext
fireChannelExceptionCaught(Throwable cause)
ChannelHandlerContext
fireChannelInactive()
AChannel
is inactive now, which means it is closed.ChannelHandlerContext
fireChannelInboundEvent(Object evt)
AChannel
received a custom defined inbound event.ChannelHandlerContext
fireChannelRead(Object msg)
AChannel
received a message.ChannelHandlerContext
fireChannelReadComplete()
Triggers anChannelHandler.channelReadComplete(ChannelHandlerContext)
event to the nextChannelHandler
in theChannelPipeline
.ChannelHandlerContext
fireChannelRegistered()
ChannelHandlerContext
fireChannelShutdown(ChannelShutdownDirection direction)
AChannel
was shutdown in a specific direction.ChannelHandlerContext
fireChannelUnregistered()
ChannelHandlerContext
fireChannelWritabilityChanged()
Triggers anChannelHandler.channelWritabilityChanged(ChannelHandlerContext)
event to the nextChannelHandler
in theChannelPipeline
.ChannelHandlerContext
flush()
Request to flush all pending messages via this ChannelOutboundInvoker.ChannelHandler
handler()
TheChannelHandler
that is bound thisChannelHandlerContext
.boolean
isRemoved()
Returntrue
if theChannelHandler
which belongs to this context was removed from theChannelPipeline
.String
name()
The unique name of theChannelHandlerContext
.The name was used when thenChannelHandler
was added to theChannelPipeline
.<V> Future<V>
newFailedFuture(Throwable cause)
Create a newFuture
which is marked as failed already.<V> Promise<V>
newPromise()
Return a newPromise
.Future<Void>
newSucceededFuture()
Create a newFuture
which is marked as succeeded already.<V> Future<V>
newSucceededFuture(V value)
Create a newFuture
which is marked as succeeded already.ChannelPipeline
pipeline()
Return the assignedChannelPipeline
ChannelHandlerContext
read()
Request to Read data from theChannel
into the first inbound buffer, triggers anChannelHandler.channelRead(ChannelHandlerContext, Object)
event if data was read, and triggers achannelReadComplete
event so the handler can decide to continue reading.Future<Void>
register()
Request to register on theEventExecutor
for I/O processing.Future<Void>
sendOutboundEvent(Object event)
Send a custom outbound event via thisChannelOutboundInvoker
through theChannelPipeline
.Future<Void>
shutdown(ChannelShutdownDirection direction)
Future<Void>
write(Object msg)
Request to write a message via thisChannelHandlerContext
through 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:ChannelHandlerContext
Return theChannel
which is bound to theChannelHandlerContext
.- Specified by:
channel
in interfaceChannelHandlerContext
-
executor
public EventExecutor executor()
Description copied from interface:ChannelOutboundInvoker
Returns theEventExecutor
that is used to execute the operations of thisChannelOutboundInvoker
.- Specified by:
executor
in interfaceChannelOutboundInvoker
- Returns:
- the executor.
-
name
public String name()
Description copied from interface:ChannelHandlerContext
The unique name of theChannelHandlerContext
.The name was used when thenChannelHandler
was added to theChannelPipeline
. This name can also be used to access the registeredChannelHandler
from theChannelPipeline
.- Specified by:
name
in interfaceChannelHandlerContext
-
handler
public ChannelHandler handler()
Description copied from interface:ChannelHandlerContext
TheChannelHandler
that is bound thisChannelHandlerContext
.- Specified by:
handler
in interfaceChannelHandlerContext
-
isRemoved
public boolean isRemoved()
Description copied from interface:ChannelHandlerContext
Returntrue
if theChannelHandler
which belongs to this context was removed from theChannelPipeline
.- Specified by:
isRemoved
in interfaceChannelHandlerContext
-
fireChannelRegistered
public ChannelHandlerContext fireChannelRegistered()
Description copied from interface:ChannelInboundInvoker
AChannel
was registered to itsEventLoop
. This will result in having theChannelHandler.channelRegistered(ChannelHandlerContext)
method called of the nextChannelHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
fireChannelRegistered
in interfaceChannelHandlerContext
- Specified by:
fireChannelRegistered
in interfaceChannelInboundInvoker
-
fireChannelUnregistered
public ChannelHandlerContext fireChannelUnregistered()
Description copied from interface:ChannelInboundInvoker
AChannel
was unregistered from itsEventLoop
. This will result in having theChannelHandler.channelUnregistered(ChannelHandlerContext)
method called of the nextChannelHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
fireChannelUnregistered
in interfaceChannelHandlerContext
- Specified by:
fireChannelUnregistered
in interfaceChannelInboundInvoker
-
fireChannelActive
public ChannelHandlerContext fireChannelActive()
Description copied from interface:ChannelInboundInvoker
AChannel
is active now, which means it is connected. This will result in having theChannelHandler.channelActive(ChannelHandlerContext)
method called of the nextChannelHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
fireChannelActive
in interfaceChannelHandlerContext
- Specified by:
fireChannelActive
in interfaceChannelInboundInvoker
-
fireChannelInactive
public ChannelHandlerContext fireChannelInactive()
Description copied from interface:ChannelInboundInvoker
AChannel
is inactive now, which means it is closed. This will result in having theChannelHandler.channelInactive(ChannelHandlerContext)
method called of the nextChannelHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
fireChannelInactive
in interfaceChannelHandlerContext
- Specified by:
fireChannelInactive
in interfaceChannelInboundInvoker
-
fireChannelShutdown
public ChannelHandlerContext fireChannelShutdown(ChannelShutdownDirection direction)
Description copied from interface:ChannelInboundInvoker
AChannel
was shutdown in a specific direction. This will result in having theChannelHandler.channelShutdown(ChannelHandlerContext, ChannelShutdownDirection)
method called of the nextChannelHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
fireChannelShutdown
in interfaceChannelHandlerContext
- Specified by:
fireChannelShutdown
in interfaceChannelInboundInvoker
-
fireChannelExceptionCaught
public ChannelHandlerContext fireChannelExceptionCaught(Throwable cause)
Description copied from interface:ChannelInboundInvoker
AChannel
received anThrowable
in one of its inbound operations. This will result in having theChannelHandler.channelExceptionCaught(ChannelHandlerContext, Throwable)
method called of the nextChannelHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
fireChannelExceptionCaught
in interfaceChannelHandlerContext
- Specified by:
fireChannelExceptionCaught
in interfaceChannelInboundInvoker
-
fireChannelInboundEvent
public ChannelHandlerContext fireChannelInboundEvent(Object evt)
Description copied from interface:ChannelInboundInvoker
AChannel
received a custom defined inbound event. This will result in having theChannelHandler.channelInboundEvent(ChannelHandlerContext, Object)
method called of the nextChannelHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
fireChannelInboundEvent
in interfaceChannelHandlerContext
- Specified by:
fireChannelInboundEvent
in interfaceChannelInboundInvoker
-
fireChannelRead
public ChannelHandlerContext fireChannelRead(Object msg)
Description copied from interface:ChannelInboundInvoker
AChannel
received a message. This will result in having theChannelHandler.channelRead(ChannelHandlerContext, Object)
method called of the nextChannelHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
fireChannelRead
in interfaceChannelHandlerContext
- Specified by:
fireChannelRead
in interfaceChannelInboundInvoker
-
fireChannelReadComplete
public ChannelHandlerContext fireChannelReadComplete()
Description copied from interface:ChannelInboundInvoker
Triggers anChannelHandler.channelReadComplete(ChannelHandlerContext)
event to the nextChannelHandler
in theChannelPipeline
.- Specified by:
fireChannelReadComplete
in interfaceChannelHandlerContext
- Specified by:
fireChannelReadComplete
in interfaceChannelInboundInvoker
-
fireChannelWritabilityChanged
public ChannelHandlerContext fireChannelWritabilityChanged()
Description copied from interface:ChannelInboundInvoker
Triggers anChannelHandler.channelWritabilityChanged(ChannelHandlerContext)
event to the nextChannelHandler
in theChannelPipeline
.- Specified by:
fireChannelWritabilityChanged
in interfaceChannelHandlerContext
- Specified by:
fireChannelWritabilityChanged
in interfaceChannelInboundInvoker
-
read
public ChannelHandlerContext read()
Description copied from interface:ChannelOutboundInvoker
Request to Read data from theChannel
into the first inbound buffer, triggers anChannelHandler.channelRead(ChannelHandlerContext, Object)
event if data was read, and triggers achannelReadComplete
event 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 nextChannelHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
read
in interfaceChannelHandlerContext
- Specified by:
read
in interfaceChannelOutboundInvoker
-
flush
public ChannelHandlerContext flush()
Description copied from interface:ChannelOutboundInvoker
Request to flush all pending messages via this ChannelOutboundInvoker.- Specified by:
flush
in interfaceChannelHandlerContext
- Specified by:
flush
in interfaceChannelOutboundInvoker
-
sendOutboundEvent
public Future<Void> sendOutboundEvent(Object event)
Description copied from interface:ChannelOutboundInvoker
Send a custom outbound event via thisChannelOutboundInvoker
through theChannelPipeline
.This will result in having the
ChannelHandler.sendOutboundEvent(ChannelHandlerContext, Object)
method called of the nextChannelHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
sendOutboundEvent
in interfaceChannelOutboundInvoker
-
pipeline
public ChannelPipeline pipeline()
Description copied from interface:ChannelHandlerContext
Return the assignedChannelPipeline
- Specified by:
pipeline
in interfaceChannelHandlerContext
-
bufferAllocator
public BufferAllocator bufferAllocator()
Description copied from interface:ChannelHandlerContext
Return the assignedBufferAllocator
which will be used to allocateBuffer
s.- Specified by:
bufferAllocator
in interfaceChannelHandlerContext
-
bind
public Future<Void> bind(SocketAddress localAddress)
Description copied from interface:ChannelOutboundInvoker
Request to bind to the givenSocketAddress
and notify theFuture
once 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 nextChannelHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
bind
in interfaceChannelOutboundInvoker
-
connect
public Future<Void> connect(SocketAddress remoteAddress)
Description copied from interface:ChannelOutboundInvoker
Request to connect to the givenSocketAddress
and notify theFuture
once the operation completes, either because the operation was successful or because of an error.If the connection fails because of a connection timeout, the
Future
will get failed with aConnectTimeoutException
. If it fails because of connection refused aConnectException
will be used.This will result in having the
ChannelHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress)
method called of the nextChannelHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
connect
in interfaceChannelOutboundInvoker
-
connect
public Future<Void> connect(SocketAddress remoteAddress, SocketAddress localAddress)
Description copied from interface:ChannelOutboundInvoker
Request to connect to the givenSocketAddress
while bind to the localAddress and notify theFuture
once 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 nextChannelHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
connect
in interfaceChannelOutboundInvoker
-
disconnect
public Future<Void> disconnect()
Description copied from interface:ChannelOutboundInvoker
Request to disconnect from the remote peer and notify theFuture
once 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 nextChannelHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
disconnect
in interfaceChannelOutboundInvoker
-
close
public Future<Void> close()
Description copied from interface:ChannelOutboundInvoker
Request to close theChannel
and notify theFuture
once 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 nextChannelHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
close
in interfaceChannelOutboundInvoker
-
shutdown
public Future<Void> shutdown(ChannelShutdownDirection direction)
Description copied from interface:ChannelOutboundInvoker
Request shutdown one direction of theChannel
and notify theFuture
once 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.Outbound
orChannelShutdownDirection.Inbound
might also result in data transferred over the network. Like for example in case of TCP shutting down theChannelShutdownDirection.Outbound
will result in aFIN
that 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 nextChannelHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
shutdown
in interfaceChannelOutboundInvoker
-
deregister
public Future<Void> deregister()
Description copied from interface:ChannelOutboundInvoker
Request to deregister from the previous assignedEventExecutor
and notify theFuture
once 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 nextChannelHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
deregister
in interfaceChannelOutboundInvoker
-
register
public Future<Void> register()
Description copied from interface:ChannelOutboundInvoker
Request to register on theEventExecutor
for I/O processing.Future
once 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 nextChannelHandler
contained in theChannelPipeline
of theChannel
.- Specified by:
register
in interfaceChannelOutboundInvoker
-
write
public Future<Void> write(Object msg)
Description copied from interface:ChannelOutboundInvoker
Request to write a message via thisChannelHandlerContext
through 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:
write
in interfaceChannelOutboundInvoker
-
writeAndFlush
public Future<Void> writeAndFlush(Object msg)
Description copied from interface:ChannelOutboundInvoker
Shortcut for callChannelOutboundInvoker.write(Object)
andChannelOutboundInvoker.flush()
.- Specified by:
writeAndFlush
in interfaceChannelOutboundInvoker
-
newPromise
public <V> Promise<V> newPromise()
Description copied from interface:FuturePromiseFactory
Return a newPromise
.- Specified by:
newPromise
in interfaceChannelOutboundInvoker
- Specified by:
newPromise
in interfaceFuturePromiseFactory
-
newSucceededFuture
public Future<Void> newSucceededFuture()
Description copied from interface:FuturePromiseFactory
Create a newFuture
which is marked as succeeded already. SoAsynchronousResult.isSuccess()
will returntrue
. AllFutureListener
added to it will be notified directly. Also every call of blocking methods will just return without blocking.- Specified by:
newSucceededFuture
in interfaceChannelOutboundInvoker
- Specified by:
newSucceededFuture
in interfaceFuturePromiseFactory
-
newFailedFuture
public <V> Future<V> newFailedFuture(Throwable cause)
Description copied from interface:FuturePromiseFactory
Create a newFuture
which is marked as failed already. SoAsynchronousResult.isSuccess()
will returnfalse
. AllFutureListener
added to it will be notified directly. Also every call of blocking methods will just return without blocking.- Specified by:
newFailedFuture
in interfaceChannelOutboundInvoker
- Specified by:
newFailedFuture
in interfaceFuturePromiseFactory
-
newSucceededFuture
public <V> Future<V> newSucceededFuture(V value)
Description copied from interface:FuturePromiseFactory
Create a newFuture
which is marked as succeeded already. SoAsynchronousResult.isSuccess()
will returntrue
. AllFutureListener
added to it will be notified directly. Also every call of blocking methods will just return without blocking.- Specified by:
newSucceededFuture
in interfaceChannelOutboundInvoker
- Specified by:
newSucceededFuture
in interfaceFuturePromiseFactory
-
-