to top
Android APIs
public abstract class

SelectorProvider

extends Object
java.lang.Object
   ↳ java.nio.channels.spi.SelectorProvider

Class Overview

SelectorProvider is an abstract base class that declares methods for providing instances of DatagramChannel, Pipe, Selector , ServerSocketChannel, and SocketChannel. All the methods of this class are thread-safe.

A provider instance can be retrieved through a system property or the configuration file in a jar file; if no provider is available that way then the system default provider is returned.

Summary

Protected Constructors
SelectorProvider()
Constructs a new SelectorProvider.
Public Methods
Channel inheritedChannel()
Returns the channel inherited from the process that created this VM.
abstract DatagramChannel openDatagramChannel()
Creates a new open DatagramChannel.
abstract Pipe openPipe()
Creates a new Pipe.
abstract AbstractSelector openSelector()
Creates a new selector.
abstract ServerSocketChannel openServerSocketChannel()
Creates a new open ServerSocketChannel.
abstract SocketChannel openSocketChannel()
Create a new open SocketChannel.
synchronized static SelectorProvider provider()
Gets a provider instance by executing the following steps when called for the first time:
  • if the system property "java.nio.channels.spi.SelectorProvider" is set, the value of this property is the class name of the provider returned;
  • if there is a provider-configuration file named "java.nio.channels.spi.SelectorProvider" in META-INF/services of a jar file valid in the system class loader, the first class name is the provider's class name;
  • otherwise, a system default provider will be returned.
[Expand]
Inherited Methods
From class java.lang.Object

Protected Constructors

protected SelectorProvider ()

Added in API level 1

Constructs a new SelectorProvider.

Public Methods

public Channel inheritedChannel ()

Added in API level 1

Returns the channel inherited from the process that created this VM. On Android, this method always returns null because stdin and stdout are never connected to a socket.

Returns
  • the channel.
Throws
IOException if an I/O error occurs.

public abstract DatagramChannel openDatagramChannel ()

Added in API level 1

Creates a new open DatagramChannel.

Returns
  • the new channel.
Throws
IOException if an I/O error occurs.

public abstract Pipe openPipe ()

Added in API level 1

Creates a new Pipe.

Returns
  • the new pipe.
Throws
IOException if an I/O error occurs.

public abstract AbstractSelector openSelector ()

Added in API level 1

Creates a new selector.

Returns
  • the new selector.
Throws
IOException if an I/O error occurs.

public abstract ServerSocketChannel openServerSocketChannel ()

Added in API level 1

Creates a new open ServerSocketChannel.

Returns
  • the new channel.
Throws
IOException if an I/O error occurs.

public abstract SocketChannel openSocketChannel ()

Added in API level 1

Create a new open SocketChannel.

Returns
  • the new channel.
Throws
IOException if an I/O error occurs.

public static synchronized SelectorProvider provider ()

Added in API level 1

Gets a provider instance by executing the following steps when called for the first time:

  • if the system property "java.nio.channels.spi.SelectorProvider" is set, the value of this property is the class name of the provider returned;
  • if there is a provider-configuration file named "java.nio.channels.spi.SelectorProvider" in META-INF/services of a jar file valid in the system class loader, the first class name is the provider's class name;
  • otherwise, a system default provider will be returned.

Returns
  • the provider.
No examples for this method.
Frequently called with: [Clear]
Portions of this page are reproduced from work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License. The original page is available here.