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 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.
|
void |
closeInbound()
Closes inbound.
|
void |
closeOutbound()
Closes outbound.
|
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 |
onClose()
Template method that is called when the socket channel closed.
|
int |
read(ByteBuffer dst)
This method will be removed from the Channel in the near future.
|
SocketAddress |
remoteSocketAddress() |
Socket |
socket() |
SocketChannel |
socketChannel() |
int |
write(ByteBuffer src)
This method will be removed from the Channel in the near future.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
flush, lastReadTimeMillis, lastWriteTimeMillis, write
protected final SocketChannel socketChannel
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 int read(ByteBuffer dst) throws IOException
Channel
read
in interface Channel
IOException
SocketChannel.read(ByteBuffer)
public int write(ByteBuffer src) throws IOException
Channel
write
in interface Channel
IOException
SocketChannel.write(ByteBuffer)
public void closeInbound() throws IOException
Channel
Not thread safe. Should be called in channel reader thread.
Method will be removed once the TLS integration doesn't rely on subclassing this channel.closeInbound
in interface Channel
IOException
public void closeOutbound() throws IOException
Channel
Not thread safe. Should be called in channel writer thread.
Method will be removed once the TLS integration doesn't rely on subclassing this channel.closeOutbound
in interface Channel
IOException
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 onClose() throws IOException
socketChannel
is closed.
It will be called only once.IOException
public void addCloseListener(ChannelCloseListener listener)
Channel
addCloseListener
in interface Channel
listener
- the listener to register.Copyright © 2018 Hazelcast, Inc.. All Rights Reserved.