The java.nio.channels.spi Package


The java.nio.channels.spi package contains various service-provider classes and methods to create a new selector provider class.

Note  

To learn more about java.nio.channels.spi package, see: http://java.sun.com/j2se/1.4.2/docs/api/java/nio/channels/spi/package-summary.html

The commonly used classes in the java.nio.channels.spi package are:

  • SelectProvider

  • AbstractSelectot

SelectorProvider

The SelectorProvider class defines various methods to create datagram channel, socket channel, and selectable channels. The most commonly used methods in the SelectorProvider class are:

  • openDatagramChannel() : Returns an object of the DatagramChannel class. The openDatagramChannel() method opens a datagram channel. The datagram channel is a type of channel that connects the selector to a stream-oriented socket using User Datagram Protocol (UDP).

  • openSelectors() : Returns an object of the AbstractSelector class. The openSelectors() method opens a selector.

  • openSocketChannel() : Returns an object of the SocketChannel class. The openSocketChannel() method opens a socket channel.

  • provider() : Returns an object of the SelectorProvider class that contains a default selector provider. The provider() method is a static method.

AbstractSelector

The AbstractSelector class works as a base implementation class for selectors. The AbstractSelector class defines methods that work with selectors. The most commonly used methods in the AbstractSelector class are:

  • begin() : Identifies the beginning of the input/output operation.

  • end() :Identifies the end of the input/output operation.

  • isOpen() : Returns a Boolean value that indicates whether the selector is open or close. The isOpen() method returns true if the selector is open .

  • provider() : Returns an object of the SelectorProvider class that creates the channel.

  • register() : Returns an object of the SelectionKey class. The register() method registers the given channel with the selector.




Java InstantCode. Developing Applications Using Java NIO
Java InstantCode. Developing Applications Using Java NIO
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 55

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net