Class AbstractChannel
java.lang.Object
io.netty.util.DefaultAttributeMap
io.netty.channel.AbstractChannel
- All Implemented Interfaces:
Channel, ChannelOutboundInvoker, AttributeMap, Comparable<Channel>
- Direct Known Subclasses:
AbstractEpollServerChannel, AbstractEpollStreamChannel, AbstractKQueueServerChannel, AbstractKQueueStreamChannel, AbstractNioChannel, AbstractOioChannel, AbstractServerChannel, EmbeddedChannel, EpollDatagramChannel, EpollDomainDatagramChannel, IoUringDatagramChannel, IoUringDomainSocketChannel, IoUringServerDomainSocketChannel, IoUringServerSocketChannel, IoUringSocketChannel, KQueueDatagramChannel, KQueueDomainDatagramChannel, LocalChannel
A skeletal
Channel implementation.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classChannel.Unsafeimplementation which sub-classes must extend and use.Nested classes/interfaces inherited from interface Channel
Channel.Unsafe -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractChannel(Channel parent) Creates a new instance.protectedAbstractChannel(Channel parent, ChannelId id) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionReturns theChannelFuturewhich will be notified when this channel is closed.final intprotected abstract voidSchedule a read operation.protected abstract voiddoBind(SocketAddress localAddress) Bind theChannelto theSocketAddressprotected abstract voiddoClose()Close theChannelprotected voidprotected abstract voidDisconnect thisChannelfrom its remote peerprotected voidDeprecated.protected voiddoRegister(ChannelPromise promise) protected voidCalled when conditions justify shutting down the output portion of the channel.protected abstract voidFlush the content of the given buffer to the remote peer.final booleanReturnstrueif and only if the specified object is identical with this channel (i.e:this == o).protected ObjectInvoked when a new message is added to aChannelOutboundBufferof thisAbstractChannel, so that theChannelimplementation converts the message to another.final inthashCode()Returns the ID of this channel.final ChannelIdid()Returns the globally unique identifier of thisChannel.protected voidDeprecated.no use-case for this.protected voidDeprecated.no use-case for this.protected abstract booleanisCompatible(EventLoop loop) Returntrueif the givenEventLoopis compatible with this instance.booleanReturns the local address where this channel is bound to.protected abstract SocketAddressReturns theSocketAddresswhich is bound locally.protected final intprotected DefaultChannelPipelineReturns a newDefaultChannelPipelineinstance.protected ChannelIdnewId()Returns a newDefaultChannelIdinstance.protected abstract AbstractChannel.AbstractUnsafeCreate a newAbstractChannel.AbstractUnsafeinstance which will be used for the life-time of theChannelparent()Returns the parent of this channel.pipeline()Return the assignedChannelPipeline.Returns the remote address where this channel is connected to.protected abstract SocketAddressReturn theSocketAddresswhich theChannelis connected to.toString()Returns theStringrepresentation of this channel.unsafe()Returns an internal-use-only object that provides unsafe operations.protected voidvalidateFileRegion(DefaultFileRegion region, long position) final ChannelPromiseReturn a special ChannelPromise which can be reused for different operations.Methods inherited from class DefaultAttributeMap
attr, hasAttrMethods inherited from interface AttributeMap
attr, hasAttrMethods inherited from interface Channel
alloc, bind, bind, bytesBeforeUnwritable, bytesBeforeWritable, close, close, config, connect, connect, connect, connect, deregister, deregister, disconnect, disconnect, flush, getOption, isActive, isOpen, isWritable, metadata, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture, read, setOption, write, write, writeAndFlush, writeAndFlush
-
Constructor Details
-
AbstractChannel
Creates a new instance.- Parameters:
parent- the parent of this channel.nullif there's no parent.
-
AbstractChannel
-
-
Method Details
-
maxMessagesPerWrite
protected final int maxMessagesPerWrite() -
id
-
newId
Returns a newDefaultChannelIdinstance. Subclasses may override this method to assign customChannelIds toChannels that use theAbstractChannel(Channel)constructor. -
newChannelPipeline
Returns a newDefaultChannelPipelineinstance. -
parent
-
pipeline
Description copied from interface:ChannelReturn the assignedChannelPipeline. -
eventLoop
-
localAddress
Description copied from interface:ChannelReturns the local address where this channel is bound to. The returnedSocketAddressis supposed to be down-cast into more concrete type such asInetSocketAddressto retrieve the detailed information.- Specified by:
localAddressin interfaceChannel- Returns:
- the local address of this channel.
nullif this channel is not bound.
-
invalidateLocalAddress
Deprecated.no use-case for this. -
remoteAddress
Description copied from interface:ChannelReturns the remote address where this channel is connected to. The returnedSocketAddressis supposed to be down-cast into more concrete type such asInetSocketAddressto retrieve the detailed information.- Specified by:
remoteAddressin interfaceChannel- Returns:
- the remote address of this channel.
nullif this channel is not connected. If this channel is not connected but it can receive messages from arbitrary remote addresses (e.g.DatagramChannel, useDefaultAddressedEnvelope.recipient()to determine the origination of the received message as this method will returnnull.
-
invalidateRemoteAddress
Deprecated.no use-case for this. -
isRegistered
public boolean isRegistered()Description copied from interface:Channel- Specified by:
isRegisteredin interfaceChannel
-
closeFuture
Description copied from interface:ChannelReturns theChannelFuturewhich will be notified when this channel is closed. This method always returns the same future instance.- Specified by:
closeFuturein interfaceChannel
-
unsafe
Description copied from interface:ChannelReturns an internal-use-only object that provides unsafe operations. -
newUnsafe
Create a newAbstractChannel.AbstractUnsafeinstance which will be used for the life-time of theChannel -
hashCode
-
equals
-
compareTo
- Specified by:
compareToin interfaceComparable<Channel>
-
toString
Returns theStringrepresentation of this channel. The returned string contains the ID, local address, and remote address of this channel for easier identification. -
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 interfaceChannel- Specified by:
voidPromisein interfaceChannelOutboundInvoker
-
isCompatible
-
localAddress0
Returns theSocketAddresswhich is bound locally. -
remoteAddress0
Return theSocketAddresswhich theChannelis connected to. -
doRegister
-
doRegister
Is called after theChannelis registered with itsEventLoopas part of the register process. Subclasses may override this method- Parameters:
promise-ChannelPromisethat must be notified once done to continue the registration.
-
doBind
Bind theChannelto theSocketAddress- Throws:
Exception
-
doDisconnect
-
doClose
-
doShutdownOutput
-
doDeregister
-
doBeginRead
-
doWrite
Flush the content of the given buffer to the remote peer.- Throws:
Exception
-
filterOutboundMessage
Invoked when a new message is added to aChannelOutboundBufferof thisAbstractChannel, so that theChannelimplementation converts the message to another. (e.g. heap buffer -> direct buffer)- Throws:
Exception
-
validateFileRegion
- Throws:
IOException
-
doRegister(ChannelPromise)