public abstract class AbstractChannel extends Object implements Channel
Channel
implementation. This class is a pure implementation
detail, the fact that it exposes some functionality like access to the socket
channel is because the current Channel implementations need the SocketChannel.Modifier and Type | Field and Description |
---|---|
protected ILogger |
logger |
protected SocketChannel |
socketChannel |
Constructor and Description |
---|
AbstractChannel(SocketChannel socketChannel,
boolean clientMode) |
Modifier and Type | Method and Description |
---|---|
void |
addCloseListener(ChannelCloseListener listener)
Adds a ChannelCloseListener.
|
ConcurrentMap |
attributeMap()
Returns the attribute map.
|
void |
close()
Closes the Channel.
|
protected void |
close0()
Template method that is called when the Channel is closed.
|
void |
connect(InetSocketAddress address,
int timeoutMillis)
Connects the channel.
|
boolean |
isClientMode()
Checks if this side is the Channel is in client mode or server mode.
|
boolean |
isClosed()
Checks if this Channel is closed.
|
SocketAddress |
localSocketAddress() |
protected void |
notifyCloseListeners() |
protected void |
onConnect()
Template method that can be implemented when the
connect(InetSocketAddress, int)
has completed. |
SocketAddress |
remoteSocketAddress() |
Socket |
socket() |
SocketChannel |
socketChannel() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
bytesRead, bytesWritten, inboundPipeline, lastReadTimeMillis, lastWriteTimeMillis, options, outboundPipeline, start, write
protected final SocketChannel socketChannel
protected final ILogger logger
public AbstractChannel(SocketChannel socketChannel, boolean clientMode)
public boolean isClientMode()
Channel
isClientMode
in interface Channel
SSLEngine.getUseClientMode()
public ConcurrentMap attributeMap()
Channel
attributeMap
in interface Channel
public Socket socket()
socket
in interface Channel
This method will be removed from the interface. Only an explicit cast to NioChannel
will expose the Socket.
It is very important that the socket isn't closed directly; but one goes through the
{@link #close()} method so that interal administration of the channel is in sync with
that of the socket.
public SocketChannel socketChannel()
public SocketAddress remoteSocketAddress()
remoteSocketAddress
in interface Channel
public SocketAddress localSocketAddress()
localSocketAddress
in interface Channel
public void connect(InetSocketAddress address, int timeoutMillis) throws IOException
Channel
connect
in interface Channel
address
- the address to connect to.timeoutMillis
- the timeout in millis, or 0 if waiting indefinitely.IOException
- if connecting fails.protected void onConnect()
connect(InetSocketAddress, int)
has completed.public boolean isClosed()
Channel
public void close() throws IOException
Channel
close
in interface Channel
close
in interface Closeable
close
in interface AutoCloseable
IOException
protected void close0() throws IOException
IOException
public void addCloseListener(ChannelCloseListener listener)
Channel
addCloseListener
in interface Channel
listener
- the listener to register.protected final void notifyCloseListeners()
Copyright © 2020 Hazelcast, Inc.. All Rights Reserved.