Save This Page
Home » openjdk-7 » java » nio » channels » spi » [javadoc | source]
java.nio.channels.spi
abstract public class: AbstractSelectableChannel [javadoc | source]
java.lang.Object
   java.nio.channels.spi.AbstractInterruptibleChannel
      java.nio.channels.SelectableChannel
         java.nio.channels.spi.AbstractSelectableChannel

All Implemented Interfaces:
    Channel, InterruptibleChannel

Direct Known Subclasses:
    ServerSocketChannel, SinkChannel, SourceChannel, DatagramChannel, SocketChannel

Base implementation class for selectable channels.

This class defines methods that handle the mechanics of channel registration, deregistration, and closing. It maintains the current blocking mode of this channel as well as its current set of selection keys. It performs all of the synchronization required to implement the java.nio.channels.SelectableChannel specification. Implementations of the abstract protected methods defined in this class need not synchronize against other threads that might be engaged in the same operations.

Field Summary
 boolean blocking     
Constructor:
 protected AbstractSelectableChannel(SelectorProvider provider) 
    Initializes a new instance of this class.
Method from java.nio.channels.spi.AbstractSelectableChannel Summary:
blockingLock,   configureBlocking,   implCloseChannel,   implCloseSelectableChannel,   implConfigureBlocking,   isBlocking,   isRegistered,   keyFor,   provider,   register,   removeKey
Methods from java.nio.channels.SelectableChannel:
blockingLock,   configureBlocking,   isBlocking,   isRegistered,   keyFor,   provider,   register,   register,   validOps
Methods from java.nio.channels.spi.AbstractInterruptibleChannel:
begin,   blockedOn,   close,   end,   implCloseChannel,   isOpen
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from java.nio.channels.spi.AbstractSelectableChannel Detail:
 public final Object blockingLock() 
 public final SelectableChannel configureBlocking(boolean block) throws IOException 
    Adjusts this channel's blocking mode.

    If the given blocking mode is different from the current blocking mode then this method invokes the implConfigureBlocking method, while holding the appropriate locks, in order to change the mode.

 protected final  void implCloseChannel() throws IOException 
 abstract protected  void implCloseSelectableChannel() throws IOException
    Closes this selectable channel.

    This method is invoked by the close method in order to perform the actual work of closing the channel. This method is only invoked if the channel has not yet been closed, and it is never invoked more than once.

    An implementation of this method must arrange for any other thread that is blocked in an I/O operation upon this channel to return immediately, either by throwing an exception or by returning normally.

 abstract protected  void implConfigureBlocking(boolean block) throws IOException
    Adjusts this channel's blocking mode.

    This method is invoked by the configureBlocking method in order to perform the actual work of changing the blocking mode. This method is only invoked if the new mode is different from the current mode.

 public final boolean isBlocking() 
 public final boolean isRegistered() 
 public final SelectionKey keyFor(Selector sel) 
 public final SelectorProvider provider() 
    Returns the provider that created this channel.
 public final SelectionKey register(Selector sel,
    int ops,
    Object att) throws ClosedChannelException 
    Registers this channel with the given selector, returning a selection key.

    This method first verifies that this channel is open and that the given initial interest set is valid.

    If this channel is already registered with the given selector then the selection key representing that registration is returned after setting its interest set to the given value.

    Otherwise this channel has not yet been registered with the given selector, so the register method of the selector is invoked while holding the appropriate locks. The resulting key is added to this channel's key set before being returned.

  void removeKey(SelectionKey k)