XNIO API 3.0.7.GA

org.xnio
Class Xnio

java.lang.Object
  extended by org.xnio.Xnio

public abstract class Xnio
extends Object

The XNIO provider class.


Constructor Summary
protected Xnio(String name)
          Construct an XNIO provider instance.
 
Method Summary
static boolean allowBlocking(boolean newSetting)
          Allow (or disallow) blocking I/O on the current thread.
static void checkBlockingAllowed()
          Perform a check for whether blocking is allowed on the current thread.
 XnioWorker createWorker(OptionMap optionMap)
          Construct a new XNIO worker.
 XnioWorker createWorker(ThreadGroup threadGroup, OptionMap optionMap)
          Construct a new XNIO worker.
abstract  XnioWorker createWorker(ThreadGroup threadGroup, OptionMap optionMap, Runnable terminationTask)
          Construct a new XNIO worker.
static Xnio getInstance()
          Get an XNIO provider instance from XNIO's class loader.
static Xnio getInstance(ClassLoader classLoader)
          Get an XNIO provider instance.
static Xnio getInstance(String provider)
          Get a specific XNIO provider instance from XNIO's class loader.
static Xnio getInstance(String provider, ClassLoader classLoader)
          Get a specific XNIO provider instance.
 String getName()
          Get the name of this XNIO provider.
protected  String getProperty(String name)
          Get an XNIO property.
protected  String getProperty(String name, String defaultValue)
          Get an XNIO property.
 XnioSsl getSslProvider(KeyManager[] keyManagers, TrustManager[] trustManagers, OptionMap optionMap)
          Get an SSL provider for this XNIO provider.
 XnioSsl getSslProvider(OptionMap optionMap)
          Get an SSL provider for this XNIO provider.
static boolean isBlockingAllowed()
          Determine whether blocking I/O is allowed from the current thread.
 FileChannel openFile(File file, FileAccess access)
          Open a file on the filesystem.
 FileChannel openFile(File file, OptionMap options)
          Open a file on the filesystem.
 FileChannel openFile(String fileName, FileAccess access)
          Open a file on the filesystem.
 FileChannel openFile(String fileName, OptionMap options)
          Open a file on the filesystem.
 String toString()
          Get a string representation of this XNIO provider.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Xnio

protected Xnio(String name)
Construct an XNIO provider instance. Used by implementors only. To get an XNIO instance, use one of the getInstance() methods.

Parameters:
name - the provider name
Method Detail

allowBlocking

public static boolean allowBlocking(boolean newSetting)
                             throws SecurityException
Allow (or disallow) blocking I/O on the current thread. Requires the changeThreadBlockingSetting RuntimePermission.

Parameters:
newSetting - true to allow blocking I/O, false to disallow it
Returns:
the previous setting
Throws:
SecurityException - if a security manager is present and disallows changing the changeThreadBlockingSetting RuntimePermission

isBlockingAllowed

public static boolean isBlockingAllowed()
Determine whether blocking I/O is allowed from the current thread.

Returns:
true if blocking I/O is allowed, false otherwise

checkBlockingAllowed

public static void checkBlockingAllowed()
                                 throws IllegalStateException
Perform a check for whether blocking is allowed on the current thread.

Throws:
IllegalStateException - if blocking is not allowed on the current thread

getInstance

public static Xnio getInstance(ClassLoader classLoader)
Get an XNIO provider instance. If multiple providers are available, use the first one encountered.

Parameters:
classLoader - the class loader to search in
Returns:
the XNIO provider instance
Since:
3.0

getInstance

public static Xnio getInstance()
Get an XNIO provider instance from XNIO's class loader. If multiple providers are available, use the first one encountered.

Returns:
the XNIO provider instance
Since:
3.0

getInstance

public static Xnio getInstance(String provider,
                               ClassLoader classLoader)
Get a specific XNIO provider instance.

Parameters:
provider - the provider name, or null for the first available
classLoader - the class loader to search in
Returns:
the XNIO provider instance
Since:
3.0

getInstance

public static Xnio getInstance(String provider)
Get a specific XNIO provider instance from XNIO's class loader.

Parameters:
provider - the provider name, or null for the first available
Returns:
the XNIO provider instance
Since:
3.0

getSslProvider

public XnioSsl getSslProvider(OptionMap optionMap)
                       throws GeneralSecurityException
Get an SSL provider for this XNIO provider.

Parameters:
optionMap - the option map to use for configuring SSL
Returns:
the SSL provider
Throws:
GeneralSecurityException - if an exception occurred configuring the SSL provider

getSslProvider

public XnioSsl getSslProvider(KeyManager[] keyManagers,
                              TrustManager[] trustManagers,
                              OptionMap optionMap)
                       throws GeneralSecurityException
Get an SSL provider for this XNIO provider.

Parameters:
optionMap - the option map to use for configuring SSL
keyManagers - the key managers to use, or null to configure from the option map
trustManagers - the trust managers to use, or null to configure from the option map
Returns:
the SSL provider
Throws:
GeneralSecurityException - if an exception occurred configuring the SSL provider

openFile

public FileChannel openFile(File file,
                            OptionMap options)
                     throws IOException
Open a file on the filesystem.

Parameters:
file - the file to open
options - the file-open options
Returns:
the file channel
Throws:
IOException - if an I/O error occurs

openFile

public FileChannel openFile(String fileName,
                            OptionMap options)
                     throws IOException
Open a file on the filesystem.

Parameters:
fileName - the file name of the file to open
options - the file-open options
Returns:
the file channel
Throws:
IOException - if an I/O error occurs

openFile

public FileChannel openFile(File file,
                            FileAccess access)
                     throws IOException
Open a file on the filesystem.

Parameters:
file - the file to open
access - the file access level to use
Returns:
the file channel
Throws:
IOException - if an I/O error occurs

openFile

public FileChannel openFile(String fileName,
                            FileAccess access)
                     throws IOException
Open a file on the filesystem.

Parameters:
fileName - the file name of the file to open
access - the file access level to use
Returns:
the file channel
Throws:
IOException - if an I/O error occurs

createWorker

public XnioWorker createWorker(OptionMap optionMap)
                        throws IOException,
                               IllegalArgumentException
Construct a new XNIO worker.

Parameters:
optionMap - the options to use to configure the worker
Returns:
the new worker
Throws:
IOException - if the worker failed to be opened
IllegalArgumentException - if an option value is invalid for this worker

createWorker

public XnioWorker createWorker(ThreadGroup threadGroup,
                               OptionMap optionMap)
                        throws IOException,
                               IllegalArgumentException
Construct a new XNIO worker.

Parameters:
threadGroup - the thread group for worker threads
optionMap - the options to use to configure the worker
Returns:
the new worker
Throws:
IOException - if the worker failed to be opened
IllegalArgumentException - if an option value is invalid for this worker

createWorker

public abstract XnioWorker createWorker(ThreadGroup threadGroup,
                                        OptionMap optionMap,
                                        Runnable terminationTask)
                                 throws IOException,
                                        IllegalArgumentException
Construct a new XNIO worker.

Parameters:
threadGroup - the thread group for worker threads
optionMap - the options to use to configure the worker
terminationTask - the task to run after the worker has shut down
Returns:
the new worker
Throws:
IOException - if the worker failed to be opened
IllegalArgumentException - if an option value is invalid for this worker

getName

public final String getName()
Get the name of this XNIO provider.

Returns:
the name

toString

public final String toString()
Get a string representation of this XNIO provider.

Overrides:
toString in class Object
Returns:
the string representation

getProperty

protected String getProperty(String name)
Get an XNIO property. The property name must start with "xnio.".

Parameters:
name - the property name
Returns:
the property value, or null if it wasn't found
Since:
1.2

getProperty

protected String getProperty(String name,
                             String defaultValue)
Get an XNIO property. The property name must start with "xnio.".

Parameters:
name - the property name
defaultValue - the default value
Returns:
the property value, or defaultValue if it wasn't found
Since:
1.2

XNIO API 3.0.7.GA

Copyright © 2010 JBoss, a division of Red Hat, Inc.