Top Description Inners Fields Constructors Methods
org.xnio

public abstract Class Xnio

extends Object
Class Inheritance
Annotations
@SuppressWarnings:unused
Imports
java.io.Closeable, .File, .FileNotFoundException, .IOException, java.lang.management.ManagementFactory, java.net.InetSocketAddress, java.nio.channels.FileChannel, java.nio.file.NoSuchFileException, .Path, .StandardOpenOption, java.security.AccessController, .GeneralSecurityException, .PrivilegedAction, java.util.EnumMap, .EnumSet, .Iterator, .ServiceLoader, java.util.concurrent.atomic.AtomicBoolean, javax.management.MBeanServer, .ObjectName, org.osgi.framework.Bundle, .BundleContext, .FrameworkUtil, .ServiceReference, org.xnio.management.XnioProviderMXBean, .XnioServerMXBean, .XnioWorkerMXBean, org.xnio.ssl.JsseSslUtils, .JsseXnioSsl, .XnioSsl, javax.net.ssl.KeyManager, .TrustManager

The XNIO provider class.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class
pack-priv static class

Field Summary

Modifier and TypeField and Description
private static final RuntimePermission
pack-priv static final InetSocketAddress
pack-priv static final LocalSocketAddress
private static final ThreadLocal<Boolean>
private static final EnumMap<FileAccess, OptionMap>
private final String
name

The name of this provider instance.

public static final boolean
NIO2

A flag indicating the presence of NIO.2 (JDK 7).

Constructor Summary

AccessConstructor and Description
protected
Xnio(String
the provider name
name
)

Construct an XNIO provider instance.

Method Summary

Modifier and TypeMethod and Description
public static boolean

Returns:

the previous setting
allowBlocking
(boolean
true to allow blocking I/O, false to disallow it
newSetting
)

Allow (or disallow) blocking I/O on the current thread.

protected abstract XnioWorker

Returns:

the constructed worker
build
(XnioWorker.Builder
the builder (must not be null)
builder
)

Construct an XNIO worker from a builder.

public static void
checkBlockingAllowed()

Perform a check for whether blocking is allowed on the current thread.

public FileSystemWatcher

Returns:

The file system watcher
createFileSystemWatcher
(final String
The watcher name
name
,
final OptionMap
The options to use to create the watcher
options
)

Creates a file system watcher, that can be used to monitor file system changes.

public XnioWorker

Returns:

the new worker
createWorker
(OptionMap
the options to use to configure the worker
optionMap
)

Construct a new XNIO worker.

public XnioWorker

Returns:

the new worker
createWorker
(ThreadGroup
the thread group for worker threads
threadGroup
,
OptionMap
the options to use to configure the worker
optionMap
)

Construct a new XNIO worker.

public XnioWorker

Returns:

the new worker
createWorker
(ThreadGroup
the thread group for worker threads
threadGroup
,
OptionMap
the options to use to configure the worker
optionMap
,
Runnable
the task to run after the worker has shut down
terminationTask
)

Construct a new XNIO worker.

public XnioWorker.Builder

Returns:

the worker builder (not null)
createWorkerBuilder
()

Create a new worker builder.

private static synchronized Xnio
doGetInstance(final String provider, final ServiceLoader<XnioProvider> serviceLoader)

public static Xnio

Returns:

the XNIO provider instance
getInstance
(final ClassLoader
the class loader to search in
classLoader
)

Get an XNIO provider instance.

public static Xnio

Returns:

the XNIO provider instance
getInstance
()

Get an XNIO provider instance from XNIO's class loader.

public static Xnio

Returns:

the XNIO provider instance
getInstance
(String
the provider name, or null for the first available
provider
,
final ClassLoader
the class loader to search in
classLoader
)

Get a specific XNIO provider instance.

public static Xnio

Returns:

the XNIO provider instance
getInstance
(String
the provider name, or null for the first available
provider
)

Get a specific XNIO provider instance from XNIO's class loader.

public final String

Returns:

the name
getName
()

Get the name of this XNIO provider.

protected static String

Returns:

the property value, or null if it wasn't found
getProperty
(final String
the property name
name
)

Get an XNIO property.

protected static String

Returns:

the property value, or defaultValue if it wasn't found
getProperty
(final String
the property name
name
,
final String
the default value
defaultValue
)

Get an XNIO property.

public XnioSsl

Returns:

the SSL provider
getSslProvider
(final OptionMap
the option map to use for configuring SSL
optionMap
)

Get an SSL provider for this XNIO provider.

public XnioSsl

Returns:

the SSL provider
getSslProvider
(final KeyManager[]
the key managers to use, or null to configure from the option map
keyManagers
,
final TrustManager[]
the trust managers to use, or null to configure from the option map
trustManagers
,
final OptionMap
the option map to use for configuring SSL
optionMap
)

Get an SSL provider for this XNIO provider.

protected void
handleThreadExit()

Implement tasks that will be executed on thread exits if a task worker thread is initialized through XnioWorker$WorkerThreadFactory.

public static boolean

Returns:

true if blocking I/O is allowed, false otherwise
isBlockingAllowed
()

Determine whether blocking I/O is allowed from the current thread.

public FileChannel

Returns:

the file channel
openFile
(File
the file to open
file
,
OptionMap
the file-open options
options
)

Open a file on the filesystem.

public FileChannel

Returns:

the file channel
openFile
(String
the file name of the file to open
fileName
,
OptionMap
the file-open options
options
)

Open a file on the filesystem.

public FileChannel

Returns:

the file channel
openFile
(File
the file to open
file
,
FileAccess
the file access level to use
access
)

Open a file on the filesystem.

public FileChannel

Returns:

the file channel
openFile
(String
the file name of the file to open
fileName
,
FileAccess
the file access level to use
access
)

Open a file on the filesystem.

protected static Closeable

Returns:

a handle which may be used to remove the registration
register
(XnioProviderMXBean
the provider MBean to register
providerMXBean
)

Register an MBean.

protected static Closeable

Returns:

a handle which may be used to remove the registration
register
(XnioWorkerMXBean
the worker MBean to register
workerMXBean
)

Register an MBean.

protected static Closeable

Returns:

a handle which may be used to remove the registration
register
(XnioServerMXBean
the server MBean to register
serverMXBean
)

Register an MBean.

public final String

Returns:

the string representation
toString
()

Overrides java.lang.Object.toString.

Get a string representation of this XNIO provider.

protected FileChannel

Returns:

the unwrapped file channel
unwrapFileChannel
(FileChannel
the possibly wrapped file channel
src
)

Unwrap an XNIO-wrapped file channel.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

ALLOW_BLOCKING_SETTINGback to summary
private static final RuntimePermission ALLOW_BLOCKING_SETTING
ANY_INET_ADDRESSback to summary
pack-priv static final InetSocketAddress ANY_INET_ADDRESS
ANY_LOCAL_ADDRESSback to summary
pack-priv static final LocalSocketAddress ANY_LOCAL_ADDRESS
BLOCKINGback to summary
private static final ThreadLocal<Boolean> BLOCKING
FILE_ACCESS_OPTION_MAPSback to summary
private static final EnumMap<FileAccess, OptionMap> FILE_ACCESS_OPTION_MAPS
nameback to summary
private final String name

The name of this provider instance.

NIO2back to summary
public static final boolean NIO2

A flag indicating the presence of NIO.2 (JDK 7). Always true as of XNIO version 3.5.0, which requires Java 8.

Constructor Detail

Xnioback to summary
protected Xnio(String name)

Construct an XNIO provider instance. Used by implementors only. To get an XNIO instance, use one of the org.xnio.Xnio#getInstance() methods.

Parameters
name:String

the provider name

Method Detail

allowBlockingback to summary
public static boolean allowBlocking(boolean newSetting) throws SecurityException

Allow (or disallow) blocking I/O on the current thread. Requires the changeThreadBlockingSetting RuntimePermission.

Parameters
newSetting:boolean

true to allow blocking I/O, false to disallow it

Returns:boolean

the previous setting

Exceptions
SecurityException:
if a security manager is present and disallows changing the changeThreadBlockingSetting RuntimePermission
buildback to summary
protected abstract XnioWorker build(XnioWorker.Builder builder)

Construct an XNIO worker from a builder.

Parameters
builder:XnioWorker.Builder

the builder (must not be null)

Returns:XnioWorker

the constructed worker

checkBlockingAllowedback to summary
public static void checkBlockingAllowed() throws IllegalStateException

Perform a check for whether blocking is allowed on the current thread.

Exceptions
IllegalStateException:
if blocking is not allowed on the current thread
createFileSystemWatcherback to summary
public FileSystemWatcher createFileSystemWatcher(final String name, final OptionMap options)

Creates a file system watcher, that can be used to monitor file system changes.

Parameters
name:String

The watcher name

options:OptionMap

The options to use to create the watcher

Returns:FileSystemWatcher

The file system watcher

createWorkerback to summary
public XnioWorker createWorker(OptionMap optionMap) throws IOException, IllegalArgumentException

Construct a new XNIO worker.

Parameters
optionMap:OptionMap

the options to use to configure the worker

Returns:XnioWorker

the new worker

Exceptions
IOException:
if the worker failed to be opened
IllegalArgumentException:
if an option value is invalid for this worker
createWorkerback to summary
public XnioWorker createWorker(ThreadGroup threadGroup, OptionMap optionMap) throws IOException, IllegalArgumentException

Construct a new XNIO worker.

Parameters
threadGroup:ThreadGroup

the thread group for worker threads

optionMap:OptionMap

the options to use to configure the worker

Returns:XnioWorker

the new worker

Exceptions
IOException:
if the worker failed to be opened
IllegalArgumentException:
if an option value is invalid for this worker
createWorkerback to summary
public XnioWorker createWorker(ThreadGroup threadGroup, OptionMap optionMap, Runnable terminationTask) throws IOException, IllegalArgumentException

Construct a new XNIO worker.

Parameters
threadGroup:ThreadGroup

the thread group for worker threads

optionMap:OptionMap

the options to use to configure the worker

terminationTask:Runnable

the task to run after the worker has shut down

Returns:XnioWorker

the new worker

Exceptions
IOException:
if the worker failed to be opened
IllegalArgumentException:
if an option value is invalid for this worker
createWorkerBuilderback to summary
public XnioWorker.Builder createWorkerBuilder()

Create a new worker builder.

Returns:XnioWorker.Builder

the worker builder (not null)

doGetInstanceback to summary
private static synchronized Xnio doGetInstance(final String provider, final ServiceLoader<XnioProvider> serviceLoader)
getInstanceback to summary
public static Xnio getInstance(final ClassLoader classLoader)

Get an XNIO provider instance. If multiple providers are available, use the first one encountered.

Parameters
classLoader:ClassLoader

the class loader to search in

Returns:Xnio

the XNIO provider instance

Since
3.0
getInstanceback to summary
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:Xnio

the XNIO provider instance

Since
3.0
getInstanceback to summary
public static Xnio getInstance(String provider, final ClassLoader classLoader)

Get a specific XNIO provider instance.

Parameters
provider:String

the provider name, or null for the first available

classLoader:ClassLoader

the class loader to search in

Returns:Xnio

the XNIO provider instance

Since
3.0
getInstanceback to summary
public static Xnio getInstance(String provider)

Get a specific XNIO provider instance from XNIO's class loader.

Parameters
provider:String

the provider name, or null for the first available

Returns:Xnio

the XNIO provider instance

Since
3.0
getNameback to summary
public final String getName()

Get the name of this XNIO provider.

Returns:String

the name

getPropertyback to summary
protected static String getProperty(final String name)

Get an XNIO property. The property name must start with "xnio.".

Parameters
name:String

the property name

Returns:String

the property value, or null if it wasn't found

Since
1.2
getPropertyback to summary
protected static String getProperty(final String name, final String defaultValue)

Get an XNIO property. The property name must start with "xnio.".

Parameters
name:String

the property name

defaultValue:String

the default value

Returns:String

the property value, or defaultValue if it wasn't found

Since
1.2
getSslProviderback to summary
public XnioSsl getSslProvider(final OptionMap optionMap) throws GeneralSecurityException

Get an SSL provider for this XNIO provider.

Parameters
optionMap:OptionMap

the option map to use for configuring SSL

Returns:XnioSsl

the SSL provider

Exceptions
GeneralSecurityException:
if an exception occurred configuring the SSL provider
getSslProviderback to summary
public XnioSsl getSslProvider(final KeyManager[] keyManagers, final TrustManager[] trustManagers, final OptionMap optionMap) throws GeneralSecurityException

Get an SSL provider for this XNIO provider.

Parameters
keyManagers:KeyManager[]

the key managers to use, or null to configure from the option map

trustManagers:TrustManager[]

the trust managers to use, or null to configure from the option map

optionMap:OptionMap

the option map to use for configuring SSL

Returns:XnioSsl

the SSL provider

Exceptions
GeneralSecurityException:
if an exception occurred configuring the SSL provider
handleThreadExitback to summary
protected void handleThreadExit()

Implement tasks that will be executed on thread exits if a task worker thread is initialized through XnioWorker$WorkerThreadFactory.

isBlockingAllowedback to summary
public static boolean isBlockingAllowed()

Determine whether blocking I/O is allowed from the current thread.

Returns:boolean

true if blocking I/O is allowed, false otherwise

openFileback to summary
public FileChannel openFile(File file, OptionMap options) throws IOException

Open a file on the filesystem.

Parameters
file:File

the file to open

options:OptionMap

the file-open options

Returns:FileChannel

the file channel

Exceptions
IOException:
if an I/O error occurs
openFileback to summary
public FileChannel openFile(String fileName, OptionMap options) throws IOException

Open a file on the filesystem.

Parameters
fileName:String

the file name of the file to open

options:OptionMap

the file-open options

Returns:FileChannel

the file channel

Exceptions
IOException:
if an I/O error occurs
openFileback to summary
public FileChannel openFile(File file, FileAccess access) throws IOException

Open a file on the filesystem.

Parameters
file:File

the file to open

access:FileAccess

the file access level to use

Returns:FileChannel

the file channel

Exceptions
IOException:
if an I/O error occurs
openFileback to summary
public FileChannel openFile(String fileName, FileAccess access) throws IOException

Open a file on the filesystem.

Parameters
fileName:String

the file name of the file to open

access:FileAccess

the file access level to use

Returns:FileChannel

the file channel

Exceptions
IOException:
if an I/O error occurs
registerback to summary
protected static Closeable register(XnioProviderMXBean providerMXBean)

Register an MBean. If the MBean cannot be registered, this method will simply return.

Parameters
providerMXBean:XnioProviderMXBean

the provider MBean to register

Returns:Closeable

a handle which may be used to remove the registration

registerback to summary
protected static Closeable register(XnioWorkerMXBean workerMXBean)

Register an MBean. If the MBean cannot be registered, this method will simply return.

Parameters
workerMXBean:XnioWorkerMXBean

the worker MBean to register

Returns:Closeable

a handle which may be used to remove the registration

registerback to summary
protected static Closeable register(XnioServerMXBean serverMXBean)

Register an MBean. If the MBean cannot be registered, this method will simply return.

Parameters
serverMXBean:XnioServerMXBean

the server MBean to register

Returns:Closeable

a handle which may be used to remove the registration

toStringback to summary
public final String toString()

Overrides java.lang.Object.toString.

Get a string representation of this XNIO provider.

Returns:String

the string representation

unwrapFileChannelback to summary
protected FileChannel unwrapFileChannel(FileChannel src)

Unwrap an XNIO-wrapped file channel. For use by providers.

Parameters
src:FileChannel

the possibly wrapped file channel

Returns:FileChannel

the unwrapped file channel

org.xnio back to summary

pack-priv Class Xnio.MBeanCloseable

extends AtomicBoolean
implements Closeable
Class Inheritance
All Implemented Interfaces
java.io.Closeable, java.lang.AutoCloseable

Field Summary

Modifier and TypeField and Description
private final ObjectName

Constructor Summary

AccessConstructor and Description
pack-priv
MBeanCloseable(final ObjectName objectName)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.

Inherited from java.util.concurrent.atomic.AtomicBoolean:
compareAndExchangecompareAndExchangeAcquirecompareAndExchangeReleasecompareAndSetgetgetAcquiregetAndSetgetOpaquegetPlainlazySetsetsetOpaquesetPlainsetReleasetoStringweakCompareAndSetweakCompareAndSetAcquireweakCompareAndSetPlainweakCompareAndSetReleaseweakCompareAndSetVolatile

Field Detail

objectNameback to summary
private final ObjectName objectName

Constructor Detail

MBeanCloseableback to summary
pack-priv MBeanCloseable(final ObjectName objectName)

Method Detail

closeback to summary
public void close()

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

org.xnio back to summary

pack-priv final Class Xnio.MBeanHolder

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final MBeanServer

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

MBEAN_SERVERback to summary
private static final MBeanServer MBEAN_SERVER

Constructor Detail

MBeanHolderback to summary
pack-priv MBeanHolder()
org.xnio back to summary

pack-priv Class Xnio.OsgiSupport

extends Object
Class Inheritance

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv static Xnio
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

OsgiSupportback to summary
pack-priv OsgiSupport()

Method Detail

doGetOsgiServiceback to summary
pack-priv static Xnio doGetOsgiService()