JavaTM 2 Platform
Std. Ed. v1.4.0

java.nio.channels.spi
Class SelectorProvider

java.lang.Object
  |
  +--java.nio.channels.spi.SelectorProvider

public abstract class SelectorProvider
extends Object

Service-provider class for selectors and selectable channels.

A selector provider is a concrete subclass of this class that has a zero-argument constructor and implements the abstract methods specified below. A given invocation of the Java virtual machine maintains a single provider instance, which is returned by the provider method. The first invocation of that method will locate the provider object as specified below.

All of the methods in this class are safe for use by multiple concurrent threads.

Since:
1.4

Constructor Summary
protected SelectorProvider()
          Initializes a new instance of this class.
 
Method Summary
abstract  DatagramChannel openDatagramChannel()
          Opens a datagram channel.
abstract  Pipe openPipe()
          Opens a pipe.
abstract  AbstractSelector openSelector()
          Opens a selector.
abstract  ServerSocketChannel openServerSocketChannel()
          Opens a server-socket channel.
abstract  SocketChannel openSocketChannel()
          Opens a socket channel.
static SelectorProvider provider()
          Returns the selector provider for this invocation of the Java virtual machine.
static void setProvider(SelectorProvider provider)
          Sets the system-wide selector provider.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SelectorProvider

protected SelectorProvider()
Initializes a new instance of this class.

Method Detail

setProvider

public static void setProvider(SelectorProvider provider)
Sets the system-wide selector provider.

Parameters:
provider - The provider to be used; must not be null
Throws:
IllegalStateException - If a provider for this invocation of the Java virtual machine has already been determined
SecurityException - If a security manager has been installed and it denies RuntimePermission("selectorProvider")

provider

public static SelectorProvider provider()
Returns the selector provider for this invocation of the Java virtual machine.

The first invocation of this method locates the system-wide provider object as follows:

  1. If the setProvider method has been succesfully invoked then the supplied provider is returned.

  2. If the system property java.nio.spi.SelectorProvider is defined then it is taken to be the fully-qualified name of a concrete provider class. The class is loaded and instantiated; if this process fails then an unspecified error is thrown.

  3. If a provider class has been installed in a jar file that is visible to the system class loader, and that jar file contains a provider-configuration file named java.nio.spi.SelectorProvider in the resource directory META-INF/services, then the first class name specified in that file is taken. The class is loaded and instantiated; if this process fails then an unspecified error is thrown.

  4. Finally, if no provider has been specified by any of the above means then the system-default provider class is instantiated and the result is returned.

Subsequent invocations of this method return the provider that was returned by the first invocation.

Returns:
The system-wide selector provider

openDatagramChannel

public abstract DatagramChannel openDatagramChannel()
                                             throws IOException
Opens a datagram channel.

Returns:
The new channel
IOException

openPipe

public abstract Pipe openPipe()
                       throws IOException
Opens a pipe.

Returns:
The new pipe
IOException

openSelector

public abstract AbstractSelector openSelector()
                                       throws IOException
Opens a selector.

Returns:
The new selector
IOException

openServerSocketChannel

public abstract ServerSocketChannel openServerSocketChannel()
                                                     throws IOException
Opens a server-socket channel.

Returns:
The new channel
IOException

openSocketChannel

public abstract SocketChannel openSocketChannel()
                                         throws IOException
Opens a socket channel.

Returns:
The new channel
IOException

JavaTM 2 Platform
Std. Ed. v1.4.0

Submit a bug or feature
For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-2001 Sun Microsystems, Inc. 901 San Antonio Road
Palo Alto, California, 94303, U.S.A. All Rights Reserved.