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.
该类是一个抽象基类,为DatagramChannel, Pipe, Selector , ServerSocketChannel, and SocketChannel提供SelectorProvider实例。该类的所有方法均是线程安全的。
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.
Provider实例可以通过系统属性或者jar文件中的一个配置文件;如果这两种方式下没有provider可用,那么该类返回一个系统默认的provider。
Summary
Protected Constructors
SelectorProvider()
Constructs a new SelectorProvider.
构造一个新的SelectorProvider.
Public Methods
Channel inheritedChannel()
Returns the channel inherited from the instance that created this virtual machine.
返回一个继承自创建该虚拟机的实例的channel。
abstract DatagramChannel openDatagramChannel()
Creates a new open DatagramChannel.
创建一个新的DatagramChannel。
abstract Pipe openPipe()
Creates a new Pipe.
创建一个新的Pipe.
abstract AbstractSelector openSelector()
Creates a new selector.
创建一个新的selector.
abstract ServerSocketChannel openServerSocketChannel()
Creates a new open ServerSocketChannel.
创建一个新的打开的ServerSocketChannel。
abstract SocketChannel openSocketChannel()
Create a new open SocketChannel.
创建一个新的打开的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.
第一次调用该方法时执行以下操作,返回一个SelectorProvider:
如果系统属性"java.nio.channels.spi.SelectorProvider"设置了,那么该属性的值就是返回的provider的类名。
如果在META-INF/services中的一个jar文件中存在一个"java.nio.channels.spi.SelectorProvider"provider配置文件在系统的类装载器中是有效的,那么配置文件中第一个类名就是provider的类名。
否则,返回一个系统默认的provider。
[Expand]
Inherited Methods
From class java.lang.Object
Protected Constructors
protected SelectorProvider ()
Since: API Level 1
Constructs a new SelectorProvider.
Throws
SecurityException if there is a security manager installed that does not permit the runtime permission labeled "selectorProvider".
安全管理员不允许"selectorProvider"运行权限。
Public Methods
public Channel inheritedChannel ()
Since: API Level 1
Returns the channel inherited from the instance that created this virtual machine.
Returns
the channel.
Throws
IOException if an I/O error occurs.
SecurityException if there is a security manager installed that does not permit the runtime permission labeled "selectorProvider".
public abstract DatagramChannel openDatagramChannel ()
Since: API Level 1
Creates a new open DatagramChannel.
Returns
the new channel.
Throws
IOException if an I/O error occurs.
public abstract Pipe openPipe ()
Since: API Level 1
Creates a new Pipe.
Returns
the new pipe.
Throws
IOException if an I/O error occurs.
public abstract AbstractSelector openSelector ()
Since: API Level 1
Creates a new selector.
Returns
the new selector.
Throws
IOException if an I/O error occurs.
public abstract ServerSocketChannel openServerSocketChannel ()
Since: API Level 1
Creates a new open ServerSocketChannel.
Returns
the new channel.
Throws
IOException if an I/O error occurs.
public abstract SocketChannel openSocketChannel ()
Since: 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 ()
Since: 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.
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.
该类是一个抽象基类,为DatagramChannel, Pipe, Selector , ServerSocketChannel, and SocketChannel提供SelectorProvider实例。该类的所有方法均是线程安全的。
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.
Provider实例可以通过系统属性或者jar文件中的一个配置文件;如果这两种方式下没有provider可用,那么该类返回一个系统默认的provider。
Summary
Protected Constructors
SelectorProvider()
Constructs a new SelectorProvider.
构造一个新的SelectorProvider.
Public Methods
Channel inheritedChannel()
Returns the channel inherited from the instance that created this virtual machine.
返回一个继承自创建该虚拟机的实例的channel。
abstract DatagramChannel openDatagramChannel()
Creates a new open DatagramChannel.
创建一个新的DatagramChannel。
abstract Pipe openPipe()
Creates a new Pipe.
创建一个新的Pipe.
abstract AbstractSelector openSelector()
Creates a new selector.
创建一个新的selector.
abstract ServerSocketChannel openServerSocketChannel()
Creates a new open ServerSocketChannel.
创建一个新的打开的ServerSocketChannel。
abstract SocketChannel openSocketChannel()
Create a new open SocketChannel.
创建一个新的打开的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.
第一次调用该方法时执行以下操作,返回一个SelectorProvider:
如果系统属性"java.nio.channels.spi.SelectorProvider"设置了,那么该属性的值就是返回的provider的类名。
如果在META-INF/services中的一个jar文件中存在一个"java.nio.channels.spi.SelectorProvider"provider配置文件在系统的类装载器中是有效的,那么配置文件中第一个类名就是provider的类名。
否则,返回一个系统默认的provider。
[Expand]
Inherited Methods
From class java.lang.Object
Protected Constructors
protected SelectorProvider ()
Since: API Level 1
Constructs a new SelectorProvider.
Throws
SecurityException if there is a security manager installed that does not permit the runtime permission labeled "selectorProvider".
安全管理员不允许"selectorProvider"运行权限。
Public Methods
public Channel inheritedChannel ()
Since: API Level 1
Returns the channel inherited from the instance that created this virtual machine.
Returns
the channel.
Throws
IOException if an I/O error occurs.
SecurityException if there is a security manager installed that does not permit the runtime permission labeled "selectorProvider".
public abstract DatagramChannel openDatagramChannel ()
Since: API Level 1
Creates a new open DatagramChannel.
Returns
the new channel.
Throws
IOException if an I/O error occurs.
public abstract Pipe openPipe ()
Since: API Level 1
Creates a new Pipe.
Returns
the new pipe.
Throws
IOException if an I/O error occurs.
public abstract AbstractSelector openSelector ()
Since: API Level 1
Creates a new selector.
Returns
the new selector.
Throws
IOException if an I/O error occurs.
public abstract ServerSocketChannel openServerSocketChannel ()
Since: API Level 1
Creates a new open ServerSocketChannel.
Returns
the new channel.
Throws
IOException if an I/O error occurs.
public abstract SocketChannel openSocketChannel ()
Since: 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 ()
Since: 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.