Java in a Nutshell, 5th Edition [Electronic resources]

نسخه متنی -صفحه : 1191/ 466
نمايش فراداده

SelectorProviderjava.nio.channels.spi

Java 1.4

This class is the central service-provider class for the channels and selectors of the java.nio.channels API. A concrete subclass of SelectorProvider implements factory methods that return open socket channels, server socket channels, datagram channels, pipes (with their two internal channels) and Selector objects. There is one default SelectorProvider object per JVM: this object can be obtained with the static SelectorProvider.provider( ) method.

You can specify a custom SelectorProvider implementation by setting its class name as the value of the system property java.nio.channels.spi.SelectorProvider. Or, you can put the class name in a file named

META-INF/services/java.nio.channels.spi.SelectorProvider , in your application's JAR file. The provider( ) method first looks for the system property, then looks for the JAR file entry. If it finds neither, it instantiates the implementation's default SelectorProvider.

Applications are not required to use the default SelectorProvider exclusively. It is legal to instantiate other SelectorProvider objects and explictly invoke their open( ) methods to create channels in that way.

public abstract class

SelectorProvider { // Protected Constructors protected

SelectorProvider ( ); // Public Class Methods public static SelectorProvider

provider ( ); // Public Instance Methods

5.0 public java.nio.channels.Channel

inheritedChannel ( ) throws java.io. IOException; constant public abstract java.nio.channels.DatagramChannel

openDatagramChannel ( ) throws java.io.IOException; public abstract java.nio.channels.Pipe

openPipe ( ) throws java.io.IOException; public abstract AbstractSelector

openSelector ( ) throws java.io.IOException; public abstract java.nio.channels.ServerSocketChannel

openServerSocketChannel ( ) throws java.io.IOException; public abstract java.nio.channels.SocketChannel

openSocketChannel ( ) throws java.io.IOException; }

Passed To

java.nio.channels.DatagramChannel.DatagramChannel( ), java.nio.channels.Pipe.SinkChannel.SinkChannel( ), java.nio.channels.Pipe.SourceChannel.SourceChannel( ), java.nio.channels.ServerSocketChannel.ServerSocketChannel( ), java.nio.channels.SocketChannel.SocketChannel( ), AbstractSelectableChannel.AbstractSelectableChannel( ), AbstractSelector.AbstractSelector( )

Returned By

java.nio.channels.SelectableChannel.provider( ), java.nio.channels.Selector.provider( ), AbstractSelectableChannel.provider( ), AbstractSelector.provider( )