public abstract class AbstractChannel extends io.netty.util.DefaultAttributeMap implements Channel
Channel implementation.| Modifier and Type | Class and Description |
|---|---|
protected class |
AbstractChannel.AbstractUnsafe
Unsafe implementation which sub-classes must extend and use. |
Channel.Unsafe| Modifier | Constructor and Description |
|---|---|
protected |
AbstractChannel(Channel parent)
Creates a new instance.
|
protected |
AbstractChannel(Channel parent,
ChannelId id)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
ChannelFuture |
closeFuture()
Returns the
ChannelFuture which will be notified when this
channel is closed. |
int |
compareTo(Channel o) |
protected abstract void |
doBeginRead()
Schedule a read operation.
|
protected abstract void |
doBind(SocketAddress localAddress)
Bind the
Channel to the SocketAddress |
protected abstract void |
doClose()
Close the
Channel |
protected void |
doDeregister()
|
protected abstract void |
doDisconnect()
Disconnect this
Channel from its remote peer |
protected void |
doRegister()
Deprecated.
|
protected void |
doRegister(ChannelPromise promise)
|
protected void |
doShutdownOutput()
Called when conditions justify shutting down the output portion of the channel.
|
protected abstract void |
doWrite(ChannelOutboundBuffer in)
Flush the content of the given buffer to the remote peer.
|
boolean |
equals(Object o)
Returns
true if and only if the specified object is identical
with this channel (i.e: this == o). |
EventLoop |
eventLoop()
|
protected Object |
filterOutboundMessage(Object msg)
Invoked when a new message is added to a
ChannelOutboundBuffer of this AbstractChannel, so that
the Channel implementation converts the message to another. |
int |
hashCode()
Returns the ID of this channel.
|
ChannelId |
id()
Returns the globally unique identifier of this
Channel. |
protected void |
invalidateLocalAddress()
Deprecated.
no use-case for this.
|
protected void |
invalidateRemoteAddress()
Deprecated.
no use-case for this.
|
protected abstract boolean |
isCompatible(EventLoop loop)
Return
true if the given EventLoop is compatible with this instance. |
boolean |
isRegistered()
|
SocketAddress |
localAddress()
Returns the local address where this channel is bound to.
|
protected abstract SocketAddress |
localAddress0()
Returns the
SocketAddress which is bound locally. |
protected int |
maxMessagesPerWrite() |
protected DefaultChannelPipeline |
newChannelPipeline()
Returns a new
DefaultChannelPipeline instance. |
protected ChannelId |
newId()
Returns a new
DefaultChannelId instance. |
protected abstract AbstractChannel.AbstractUnsafe |
newUnsafe()
Create a new
AbstractChannel.AbstractUnsafe instance which will be used for the life-time of the Channel |
Channel |
parent()
Returns the parent of this channel.
|
ChannelPipeline |
pipeline()
Return the assigned
ChannelPipeline. |
SocketAddress |
remoteAddress()
Returns the remote address where this channel is connected to.
|
protected abstract SocketAddress |
remoteAddress0()
Return the
SocketAddress which the Channel is connected to. |
String |
toString()
Returns the
String representation of this channel. |
Channel.Unsafe |
unsafe()
Returns an internal-use-only object that provides unsafe operations.
|
protected void |
validateFileRegion(DefaultFileRegion region,
long position) |
ChannelPromise |
voidPromise()
Return a special ChannelPromise which can be reused for different operations.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitalloc, 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, writeAndFlushprotected AbstractChannel(Channel parent)
parent - the parent of this channel. null if there's no parent.protected final int maxMessagesPerWrite()
public final ChannelId id()
ChannelChannel.protected ChannelId newId()
DefaultChannelId instance. Subclasses may override this method to assign custom
ChannelIds to Channels that use the AbstractChannel(Channel) constructor.protected DefaultChannelPipeline newChannelPipeline()
DefaultChannelPipeline instance.public Channel parent()
Channelpublic ChannelPipeline pipeline()
ChannelChannelPipeline.public SocketAddress localAddress()
ChannelSocketAddress is supposed to be down-cast into more concrete
type such as InetSocketAddress to retrieve the detailed
information.localAddress in interface Channelnull if this channel is not bound.@Deprecated protected void invalidateLocalAddress()
public SocketAddress remoteAddress()
ChannelSocketAddress is supposed to be down-cast into more
concrete type such as InetSocketAddress to retrieve the detailed
information.remoteAddress in interface Channelnull if this channel is not connected.
If this channel is not connected but it can receive messages
from arbitrary remote addresses (e.g. DatagramChannel,
use DefaultAddressedEnvelope.recipient() to determine
the origination of the received message as this method will
return null.@Deprecated protected void invalidateRemoteAddress()
public boolean isRegistered()
ChannelisRegistered in interface Channelpublic ChannelFuture closeFuture()
ChannelChannelFuture which will be notified when this
channel is closed. This method always returns the same future instance.closeFuture in interface Channelpublic Channel.Unsafe unsafe()
Channelprotected abstract AbstractChannel.AbstractUnsafe newUnsafe()
AbstractChannel.AbstractUnsafe instance which will be used for the life-time of the Channelpublic final int hashCode()
public final boolean equals(Object o)
true if and only if the specified object is identical
with this channel (i.e: this == o).public final int compareTo(Channel o)
compareTo in interface Comparable<Channel>public String toString()
String representation of this channel. The returned
string contains the ID, local address,
and remote address of this channel for
easier identification.public final ChannelPromise voidPromise()
ChannelOutboundInvoker
It's only supported to use
it for ChannelOutboundInvoker.write(Object, ChannelPromise).
Be aware that the returned ChannelPromise will 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 call
ChannelPipeline.fireExceptionCaught(Throwable) in this case.
voidPromise in interface ChannelvoidPromise in interface ChannelOutboundInvokerprotected abstract boolean isCompatible(EventLoop loop)
true if the given EventLoop is compatible with this instance.protected abstract SocketAddress localAddress0()
SocketAddress which is bound locally.protected abstract SocketAddress remoteAddress0()
SocketAddress which the Channel is connected to.@Deprecated protected void doRegister() throws Exception
doRegister(ChannelPromise)Channel is registered with its EventLoop as part of the register process.
Subclasses may override this methodExceptionprotected void doRegister(ChannelPromise promise)
Channel is registered with its EventLoop as part of the register process.
Subclasses may override this methodpromise - ChannelPromise that must be notified once done to continue the registration.protected abstract void doBind(SocketAddress localAddress) throws Exception
Channel to the SocketAddressExceptionprotected abstract void doDisconnect()
throws Exception
Channel from its remote peerExceptionprotected void doShutdownOutput()
throws Exception
Exceptionprotected abstract void doBeginRead()
throws Exception
Exceptionprotected abstract void doWrite(ChannelOutboundBuffer in) throws Exception
Exceptionprotected Object filterOutboundMessage(Object msg) throws Exception
ChannelOutboundBuffer of this AbstractChannel, so that
the Channel implementation converts the message to another. (e.g. heap buffer -> direct buffer)Exceptionprotected void validateFileRegion(DefaultFileRegion region, long position) throws IOException
IOExceptionCopyright © 2008–2025 The Netty Project. All rights reserved.