java.lang.Object | |||
↳ | java.nio.channels.spi.AbstractInterruptibleChannel | ||
↳ | java.nio.channels.SelectableChannel | ||
↳ | java.nio.channels.spi.AbstractSelectableChannel |
Known Direct Subclasses |
AbstractSelectableChannel
is the base implementation class for
selectable channels. It declares methods for registering, unregistering and
closing selectable channels. It is thread-safe.
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Constructs a new
AbstractSelectableChannel
.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Gets the object used for the synchronization of
register
and
configureBlocking
.
|
||||||||||
|
Sets the blocking mode of this channel.
|
||||||||||
|
Indicates whether this channel is in blocking mode.
|
||||||||||
|
Indicates whether this channel is registered with one or more selectors.
|
||||||||||
|
Gets this channel's selection key for the specified selector.
|
||||||||||
|
Returns the selector provider that has created this channel.
|
||||||||||
|
Registers this channel with the specified selector for the specified
interest set.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Implements the channel closing behavior.
|
||||||||||
|
Implements the closing function of the SelectableChannel.
|
||||||||||
|
Implements the configuration of blocking/non-blocking mode.
|
[Expand]
Inherited Methods
|
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.nio.channels.SelectableChannel
|
|||||||||||
From class
java.nio.channels.spi.AbstractInterruptibleChannel
|
|||||||||||
From class
java.lang.Object
|
|||||||||||
From interface
java.io.Closeable
|
|||||||||||
From interface
java.lang.AutoCloseable
|
|||||||||||
From interface
java.nio.channels.Channel
|
|||||||||||
From interface
java.nio.channels.InterruptibleChannel
|
Constructs a new
AbstractSelectableChannel
.
selectorProvider | the selector provider that creates this channel. |
---|
Gets the object used for the synchronization of
register
and
configureBlocking
.
Sets the blocking mode of this channel. A call to this method blocks if
other calls to this method or to
register
are executing. The
actual setting of the mode is done by calling
implConfigureBlocking(boolean)
.
blockingMode |
true
for setting this channel's mode to blocking,
false
to set it to non-blocking.
|
---|
ClosedChannelException | if this channel is closed. |
---|---|
IllegalBlockingModeException |
if
block
is
true
and this channel has been
registered with at least one selector.
|
IOException | if an I/O error occurs. |
Indicates whether this channel is in blocking mode.
true
if this channel is blocking,
false
otherwise.
Indicates whether this channel is registered with one or more selectors.
true
if this channel is registered with a selector,
false
otherwise.
Gets this channel's selection key for the specified selector.
selector | the selector with which this channel has been registered. |
---|
null
if this channel
has not been registered with
selector
.
Returns the selector provider that has created this channel.
Registers this channel with the specified selector for the specified
interest set. If the channel is already registered with the selector, the
interest set
is updated to
interestSet
and
the corresponding selection key is returned. If the channel is not yet
registered, this method calls the
register
method of
selector
and adds the selection key to this channel's key set.
selector | the selector with which to register this channel. |
---|---|
interestSet |
this channel's
interest set
.
|
attachment |
the object to attach, can be
null
.
|
CancelledKeyException | if this channel is registered but its key has been canceled. |
---|---|
ClosedChannelException | if this channel is closed. |
IllegalArgumentException |
if
interestSet
is not supported by this channel.
|
IllegalBlockingModeException | if this channel is in blocking mode. |
IllegalSelectorException | if this channel does not have the same provider as the given selector. |
Implements the channel closing behavior. Calls
implCloseSelectableChannel()
first, then loops through the list
of selection keys and cancels them, which unregisters this channel from
all selectors it is registered with.
IOException | if a problem occurs while closing the channel. |
---|
Implements the closing function of the SelectableChannel. This method is
called from
implCloseChannel()
.
IOException | if an I/O exception occurs. |
---|
Implements the configuration of blocking/non-blocking mode.
blocking | true for blocking, false for non-blocking. |
---|
IOException | if an I/O error occurs. |
---|