|
Build 1.0_r1 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.nio.channels.spi.AbstractInterruptibleChannel
java.nio.channels.SelectableChannel
java.nio.channels.spi.AbstractSelectableChannel
public abstract class 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.
| Constructor Summary | |
|---|---|
protected |
AbstractSelectableChannel(SelectorProvider selectorProvider)
Constructor for this class. |
| Method Summary | |
|---|---|
Object |
blockingLock()
Gets the blocking lock which synchronizes the configureBlocking and register methods. |
SelectableChannel |
configureBlocking(boolean blockingMode)
Set the blocking mode of this channel. |
protected void |
implCloseChannel()
Implement the closing function. |
protected abstract void |
implCloseSelectableChannel()
Implement the closing function of the SelectableChannel. |
protected abstract void |
implConfigureBlocking(boolean flag)
|
boolean |
isBlocking()
Returns if channel is in blocking mode. |
boolean |
isRegistered()
Returns if channel is registered. |
SelectionKey |
keyFor(Selector selector)
Gets the selection key for the channel with the given selector. |
SelectorProvider |
provider()
Answer the SelectorProvider of this channel. |
SelectionKey |
register(Selector selector,
int interestSet,
Object attachment)
Realize the register function. |
| Methods inherited from class java.nio.channels.SelectableChannel |
|---|
register, validOps |
| Methods inherited from class java.nio.channels.spi.AbstractInterruptibleChannel |
|---|
begin, close, end, isOpen |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.nio.channels.Channel |
|---|
close, isOpen |
| Constructor Detail |
|---|
protected AbstractSelectableChannel(SelectorProvider selectorProvider)
selectorProvider - A instance of SelectorProvider| Method Detail |
|---|
public final SelectorProvider provider()
provider in class SelectableChannelprovider()public final boolean isRegistered()
isRegistered in class SelectableChannelisRegistered()public final SelectionKey keyFor(Selector selector)
keyFor in class SelectableChannelselector - the selector with which this channel may register
keyFor(java.nio.channels.Selector)
public final SelectionKey register(Selector selector,
int interestSet,
Object attachment)
throws ClosedChannelException
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.
register in class SelectableChannelselector - the selector with which this channel shall be registeredinterestSet - the interesting operationattachment - The attached object, which can be null
ClosedChannelExceptionregister(java.nio.channels.Selector, int, java.lang.Object)
protected final void implCloseChannel()
throws IOException
implCloseChannel in class AbstractInterruptibleChannelIOExceptionimplCloseChannel()
protected abstract void implCloseSelectableChannel()
throws IOException
IOException - If some I/O exception occurred.public final boolean isBlocking()
isBlocking in class SelectableChannelisBlocking()public final Object blockingLock()
blockingLock in class SelectableChannelblockingLock()
public final SelectableChannel configureBlocking(boolean blockingMode)
throws IOException
configureBlocking in class SelectableChannelblockingMode - true for blocking mode; false
for non-blocking mode.
IOExceptionconfigureBlocking(boolean)
protected abstract void implConfigureBlocking(boolean flag)
throws IOException
IOException
|
Build 1.0_r1 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||