java.nio.channels.spi
public
abstract
class
java.nio.channels.spi.AbstractSelectableChannel
Abstract class for selectable channels.
In this class, there are methods about registering/deregistering a channel,
about channel closing. It realize the multi-thread safe.
Known Direct Subclasses
| DatagramChannel |
A DatagramChannel is a selectable channel for part abstraction of datagram
socket. |
| Pipe.SinkChannel |
Writable sink channel for writing into. |
| Pipe.SourceChannel |
Readable source channel for reading from. |
| ServerSocketChannel |
A ServerSocketChannel is a partly abstracted stream-oriented listening socket
which is selectable. |
| SocketChannel |
A SocketChannel is a selectable channel for part abstraction of stream
connecting socket. |
Summary
Protected Constructors
Public Methods
Protected Methods
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
Protected Constructors
protected
AbstractSelectableChannel(SelectorProvider selectorProvider)
Constructor for this class.
Parameters
| selectorProvider
| A instance of SelectorProvider
|
Public Methods
public
final
Object
blockingLock()
Gets the blocking lock which synchronizes the configureBlocking and
register methods.
public
final
SelectableChannel
configureBlocking(boolean blockingMode)
Set the blocking mode of this channel.
Parameters
| blockingMode
| true for blocking mode; false
for non-blocking mode.
|
public
final
boolean
isBlocking()
Returns if channel is in blocking mode.
public
final
synchronized
boolean
isRegistered()
Returns if channel is registered.
public
final
synchronized
SelectionKey
keyFor(Selector selector)
Gets the selection key for the channel with the given selector.
Parameters
| selector
| the selector with which this channel may register |
Answer the SelectorProvider of this channel.
Returns
- The provider of this channel.
public
final
SelectionKey
register(Selector selector, int interestSet, Object attachment)
Realize the register function.
It registers current channel to the selector, then answer the selection
key. The channel must be open and the interest op set must be valid. If
the current channel is already registered to the selector, the method
only set the new interest op set; otherwise it will call the
register in selector, and add the relative
key to the key set of the current channel.
Parameters
| selector
| the selector with which this channel shall be registered |
| interestSet
| the interesting operation |
| attachment
| The attached object, which can be null |
Protected Methods
protected
final
synchronized
void
implCloseChannel()
Implement the closing function.
protected
abstract
void
implCloseSelectableChannel()
Implement the closing function of the SelectableChannel.
protected
abstract
void
implConfigureBlocking(boolean blockingMode)
Implement the setting of blocking mode.
Parameters
| blockingMode
| true for blocking mode; false
for non-blocking mode. |