java.nio.channels.spi
Class SelectorProvider

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.nio.channels.spi.SelectorProvider

public abstract class SelectorProvider
extends Object sample code for java.lang.Object definition code for java.lang.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 system-wide default provider instance, which is returned by the provider sample code for java.nio.channels.spi.SelectorProvider.provider definition code for java.nio.channels.spi.SelectorProvider.provider method. The first invocation of that method will locate the default provider as specified below.

The system-wide default provider is used by the static open methods of the DatagramChannel sample code for java.nio.channels.DatagramChannel.open() definition code for java.nio.channels.DatagramChannel.open() , Pipe sample code for java.nio.channels.Pipe.open() definition code for java.nio.channels.Pipe.open() , Selector sample code for java.nio.channels.Selector.open() definition code for java.nio.channels.Selector.open() , ServerSocketChannel sample code for java.nio.channels.ServerSocketChannel.open() definition code for java.nio.channels.ServerSocketChannel.open() , and SocketChannel sample code for java.nio.channels.SocketChannel.open() definition code for java.nio.channels.SocketChannel.open() classes. It is also used by the System.inheritedChannel() sample code for java.lang.System.inheritedChannel() definition code for java.lang.System.inheritedChannel() method. A program may make use of a provider other than the default provider by instantiating that provider and then directly invoking the open methods defined in this class.

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

Since:
1.4

Constructor Summary
protected SelectorProvider sample code for java.nio.channels.spi.SelectorProvider.SelectorProvider() definition code for java.nio.channels.spi.SelectorProvider.SelectorProvider() ()
          Initializes a new instance of this class.
 
Method Summary
 Channel sample code for java.nio.channels.Channel definition code for java.nio.channels.Channel inheritedChannel sample code for java.nio.channels.spi.SelectorProvider.inheritedChannel() definition code for java.nio.channels.spi.SelectorProvider.inheritedChannel() ()
          Returns the channel inherited from the entity that created this Java virtual machine.
abstract  DatagramChannel sample code for java.nio.channels.DatagramChannel definition code for java.nio.channels.DatagramChannel openDatagramChannel sample code for java.nio.channels.spi.SelectorProvider.openDatagramChannel() definition code for java.nio.channels.spi.SelectorProvider.openDatagramChannel() ()
          Opens a datagram channel.
abstract  Pipe sample code for java.nio.channels.Pipe definition code for java.nio.channels.Pipe openPipe sample code for java.nio.channels.spi.SelectorProvider.openPipe() definition code for java.nio.channels.spi.SelectorProvider.openPipe() ()
          Opens a pipe.
abstract  AbstractSelector sample code for java.nio.channels.spi.AbstractSelector definition code for java.nio.channels.spi.AbstractSelector openSelector sample code for java.nio.channels.spi.SelectorProvider.openSelector() definition code for java.nio.channels.spi.SelectorProvider.openSelector() ()
          Opens a selector.
abstract  ServerSocketChannel sample code for java.nio.channels.ServerSocketChannel definition code for java.nio.channels.ServerSocketChannel openServerSocketChannel sample code for java.nio.channels.spi.SelectorProvider.openServerSocketChannel() definition code for java.nio.channels.spi.SelectorProvider.openServerSocketChannel() ()
          Opens a server-socket channel.
abstract  SocketChannel sample code for java.nio.channels.SocketChannel definition code for java.nio.channels.SocketChannel openSocketChannel sample code for java.nio.channels.spi.SelectorProvider.openSocketChannel() definition code for java.nio.channels.spi.SelectorProvider.openSocketChannel() ()
          Opens a socket channel.
static SelectorProvider sample code for java.nio.channels.spi.SelectorProvider definition code for java.nio.channels.spi.SelectorProvider provider sample code for java.nio.channels.spi.SelectorProvider.provider() definition code for java.nio.channels.spi.SelectorProvider.provider() ()
          Returns the system-wide default selector provider for this invocation of the Java virtual machine.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

SelectorProvider sample code for java.nio.channels.spi.SelectorProvider() definition code for java.nio.channels.spi.SelectorProvider()

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

Throws:
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - If a security manager has been installed and it denies RuntimePermission sample code for java.lang.RuntimePermission definition code for java.lang.RuntimePermission ("selectorProvider")
Method Detail

provider sample code for java.nio.channels.spi.SelectorProvider.provider() definition code for java.nio.channels.spi.SelectorProvider.provider()

public static SelectorProvider sample code for java.nio.channels.spi.SelectorProvider definition code for java.nio.channels.spi.SelectorProvider  provider()
Returns the system-wide default selector provider for this invocation of the Java virtual machine.

The first invocation of this method locates the default provider object as follows:

  1. If the system property java.nio.channels.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.

  2. 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.channels.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.

  3. 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 default selector provider

openDatagramChannel sample code for java.nio.channels.spi.SelectorProvider.openDatagramChannel() definition code for java.nio.channels.spi.SelectorProvider.openDatagramChannel()

public abstract DatagramChannel sample code for java.nio.channels.DatagramChannel definition code for java.nio.channels.DatagramChannel  openDatagramChannel()
                                             throws IOException sample code for java.io.IOException definition code for java.io.IOException 
Opens a datagram channel.

Returns:
The new channel
Throws:
IOException sample code for java.io.IOException definition code for java.io.IOException

openPipe sample code for java.nio.channels.spi.SelectorProvider.openPipe() definition code for java.nio.channels.spi.SelectorProvider.openPipe()

public abstract Pipe sample code for java.nio.channels.Pipe definition code for java.nio.channels.Pipe  openPipe()
                       throws IOException sample code for java.io.IOException definition code for java.io.IOException 
Opens a pipe.

Returns:
The new pipe
Throws:
IOException sample code for java.io.IOException definition code for java.io.IOException

openSelector sample code for java.nio.channels.spi.SelectorProvider.openSelector() definition code for java.nio.channels.spi.SelectorProvider.openSelector()

public abstract AbstractSelector sample code for java.nio.channels.spi.AbstractSelector definition code for java.nio.channels.spi.AbstractSelector  openSelector()
                                       throws IOException sample code for java.io.IOException definition code for java.io.IOException 
Opens a selector.

Returns:
The new selector
Throws:
IOException sample code for java.io.IOException definition code for java.io.IOException

openServerSocketChannel sample code for java.nio.channels.spi.SelectorProvider.openServerSocketChannel() definition code for java.nio.channels.spi.SelectorProvider.openServerSocketChannel()

public abstract ServerSocketChannel sample code for java.nio.channels.ServerSocketChannel definition code for java.nio.channels.ServerSocketChannel  openServerSocketChannel()
                                                     throws IOException sample code for java.io.IOException definition code for java.io.IOException 
Opens a server-socket channel.

Returns:
The new channel
Throws:
IOException sample code for java.io.IOException definition code for java.io.IOException

openSocketChannel sample code for java.nio.channels.spi.SelectorProvider.openSocketChannel() definition code for java.nio.channels.spi.SelectorProvider.openSocketChannel()

public abstract SocketChannel sample code for java.nio.channels.SocketChannel definition code for java.nio.channels.SocketChannel  openSocketChannel()
                                         throws IOException sample code for java.io.IOException definition code for java.io.IOException 
Opens a socket channel.

Returns:
The new channel
Throws:
IOException sample code for java.io.IOException definition code for java.io.IOException

inheritedChannel sample code for java.nio.channels.spi.SelectorProvider.inheritedChannel() definition code for java.nio.channels.spi.SelectorProvider.inheritedChannel()

public Channel sample code for java.nio.channels.Channel definition code for java.nio.channels.Channel  inheritedChannel()
                         throws IOException sample code for java.io.IOException definition code for java.io.IOException 
Returns the channel inherited from the entity that created this Java virtual machine.

On many operating systems a process, such as a Java virtual machine, can be started in a manner that allows the process to inherit a channel from the entity that created the process. The manner in which this is done is system dependent, as are the possible entities to which the channel may be connected. For example, on UNIX systems, the Internet services daemon (inetd) is used to start programs to service requests when a request arrives on an associated network port. In this example, the process that is started, inherits a channel representing a network socket.

In cases where the inherited channel represents a network socket then the Channel sample code for java.nio.channels.Channel definition code for java.nio.channels.Channel type returned by this method is determined as follows:

In addition to the network-oriented channels described, this method may return other kinds of channels in the future.

The first invocation of this method creates the channel that is returned. Subsequent invocations of this method return the same channel.

Returns:
The inherited channel, if any, otherwise null.
Throws:
IOException sample code for java.io.IOException definition code for java.io.IOException - If an I/O error occurs
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - If a security manager has been installed and it denies RuntimePermission sample code for java.lang.RuntimePermission definition code for java.lang.RuntimePermission ("inheritedChannel")
Since:
1.5