public abstract class

AbstractSelector

extends Selector
java.lang.Object
   ↳ java.nio.channels.Selector
     ↳ java.nio.channels.spi.AbstractSelector

Class Overview

AbstractSelector is the base implementation class for selectors. It realizes the interruption of selection by begin and end. It also holds the cancellation and the deletion of the key set.

Summary

Protected Constructors
AbstractSelector(SelectorProvider selectorProvider)
Constructs a new AbstractSelector.
Public Methods
final void close()
Closes this selector.
final boolean isOpen()
Indicates whether this selector is open.
final SelectorProvider provider()
Gets this selector's provider.
Protected Methods
final void begin()
Indicates the beginning of a code section that includes an I/O operation that is potentially blocking.
final Set<SelectionKey> cancelledKeys()
Returns this channel's set of canceled selection keys.
final void deregister(AbstractSelectionKey key)
Deletes the key from the channel's key set.
final void end()
Indicates the end of a code section that has been started with begin() and that includes a potentially blocking I/O operation.
abstract void implCloseSelector()
Implements the closing of this channel.
abstract SelectionKey register(AbstractSelectableChannel channel, int operations, Object attachment)
Registers a channel with this selector.
[Expand]
Inherited Methods
From class java.nio.channels.Selector
From class java.lang.Object

Protected Constructors

protected AbstractSelector (SelectorProvider selectorProvider)

Since: API Level 1

Constructs a new AbstractSelector.

Parameters
selectorProvider the selector provider that creates this selector.

Public Methods

public final void close ()

Since: API Level 1

Closes this selector. This method does nothing if this selector is already closed. The actual closing must be implemented by subclasses in implCloseSelector().

Throws
IOException if an I/O error occurs.

public final boolean isOpen ()

Since: API Level 1

Indicates whether this selector is open.

Returns
  • true if this selector is not closed, false otherwise.

public final SelectorProvider provider ()

Since: API Level 1

Gets this selector's provider.

Returns
  • the provider of this selector.

Protected Methods

protected final void begin ()

Since: API Level 1

Indicates the beginning of a code section that includes an I/O operation that is potentially blocking. After this operation, the application should invoke the corresponding end(boolean) method.

protected final Set<SelectionKey> cancelledKeys ()

Since: API Level 1

Returns this channel's set of canceled selection keys.

Returns
  • the set of canceled selection keys.

protected final void deregister (AbstractSelectionKey key)

Since: API Level 1

Deletes the key from the channel's key set.

Parameters
key the key.

protected final void end ()

Since: API Level 1

Indicates the end of a code section that has been started with begin() and that includes a potentially blocking I/O operation.

protected abstract void implCloseSelector ()

Since: API Level 1

Implements the closing of this channel.

Throws
IOException if an I/O error occurs.

protected abstract SelectionKey register (AbstractSelectableChannel channel, int operations, Object attachment)

Since: API Level 1

Registers a channel with this selector.

Parameters
channel the channel to be registered.
operations the interest set of channel.
attachment the attachment for the selection key.
Returns
  • the key related to the channel and this selector.