Package org.xnio
Class Xnio
java.lang.Object
org.xnio.Xnio
The XNIO provider class.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanA flag indicating the presence of NIO.2 (JDK 7). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanallowBlocking(boolean newSetting) Allow (or disallow) blocking I/O on the current thread.protected abstract XnioWorkerbuild(XnioWorker.Builder builder) Construct an XNIO worker from a builder.static voidPerform a check for whether blocking is allowed on the current thread.createFileSystemWatcher(String name, OptionMap options) Creates a file system watcher, that can be used to monitor file system changes.createWorker(ThreadGroup threadGroup, OptionMap optionMap) Construct a new XNIO worker.createWorker(ThreadGroup threadGroup, OptionMap optionMap, Runnable terminationTask) Construct a new XNIO worker.createWorker(OptionMap optionMap) Construct a new XNIO worker.Create a new worker builder.static XnioGet an XNIO provider instance from XNIO's class loader.static XniogetInstance(ClassLoader classLoader) Get an XNIO provider instance.static XniogetInstance(String provider) Get a specific XNIO provider instance from XNIO's class loader.static XniogetInstance(String provider, ClassLoader classLoader) Get a specific XNIO provider instance.final StringgetName()Get the name of this XNIO provider.protected static StringgetProperty(String name) Get an XNIO property.protected static StringgetProperty(String name, String defaultValue) Get an XNIO property.getSslProvider(KeyManager[] keyManagers, TrustManager[] trustManagers, OptionMap optionMap) Get an SSL provider for this XNIO provider.getSslProvider(OptionMap optionMap) Get an SSL provider for this XNIO provider.protected voidImplement tasks that will be executed on thread exits if a task worker thread is initialized throughXnioWorker$WorkerThreadFactory.static booleanDetermine whether blocking I/O is allowed from the current thread.openFile(File file, FileAccess access) Open a file on the filesystem.Open a file on the filesystem.openFile(String fileName, FileAccess access) Open a file on the filesystem.Open a file on the filesystem.protected static Closeableregister(XnioProviderMXBean providerMXBean) Register an MBean.protected static Closeableregister(XnioServerMXBean serverMXBean) Register an MBean.protected static Closeableregister(XnioWorkerMXBean workerMXBean) Register an MBean.final StringtoString()Get a string representation of this XNIO provider.protected FileChannelUnwrap an XNIO-wrapped file channel.
-
Field Details
-
NIO2
public static final boolean NIO2A flag indicating the presence of NIO.2 (JDK 7). Alwaystrueas of XNIO version 3.5.0, which requires Java 8.- See Also:
-
-
Constructor Details
-
Xnio
Construct an XNIO provider instance. Used by implementors only. To get an XNIO instance, use one of thegetInstance()methods.- Parameters:
name- the provider name
-
-
Method Details
-
allowBlocking
Allow (or disallow) blocking I/O on the current thread. Requires thechangeThreadBlockingSettingRuntimePermission.- Parameters:
newSetting-trueto allow blocking I/O,falseto disallow it- Returns:
- the previous setting
- Throws:
SecurityException- if a security manager is present and disallows changing thechangeThreadBlockingSettingRuntimePermission
-
isBlockingAllowed
public static boolean isBlockingAllowed()Determine whether blocking I/O is allowed from the current thread.- Returns:
trueif blocking I/O is allowed,falseotherwise
-
checkBlockingAllowed
Perform a check for whether blocking is allowed on the current thread.- Throws:
IllegalStateException- if blocking is not allowed on the current thread
-
getInstance
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
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
Get a specific XNIO provider instance.- Parameters:
provider- the provider name, ornullfor the first availableclassLoader- the class loader to search in- Returns:
- the XNIO provider instance
- Since:
- 3.0
-
getInstance
Get a specific XNIO provider instance from XNIO's class loader.- Parameters:
provider- the provider name, ornullfor the first available- Returns:
- the XNIO provider instance
- Since:
- 3.0
-
getSslProvider
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 SSLkeyManagers- the key managers to use, ornullto configure from the option maptrustManagers- the trust managers to use, ornullto configure from the option map- Returns:
- the SSL provider
- Throws:
GeneralSecurityException- if an exception occurred configuring the SSL provider
-
openFile
Open a file on the filesystem.- Parameters:
file- the file to openoptions- the file-open options- Returns:
- the file channel
- Throws:
IOException- if an I/O error occurs
-
openFile
Open a file on the filesystem.- Parameters:
fileName- the file name of the file to openoptions- the file-open options- Returns:
- the file channel
- Throws:
IOException- if an I/O error occurs
-
openFile
Open a file on the filesystem.- Parameters:
file- the file to openaccess- the file access level to use- Returns:
- the file channel
- Throws:
IOException- if an I/O error occurs
-
openFile
Open a file on the filesystem.- Parameters:
fileName- the file name of the file to openaccess- the file access level to use- Returns:
- the file channel
- Throws:
IOException- if an I/O error occurs
-
unwrapFileChannel
Unwrap an XNIO-wrapped file channel. For use by providers.- Parameters:
src- the possibly wrapped file channel- Returns:
- the unwrapped file channel
-
createWorkerBuilder
Create a new worker builder.- Returns:
- the worker builder (not
null)
-
build
Construct an XNIO worker from a builder.- Parameters:
builder- the builder (must not benull)- Returns:
- the constructed worker
-
createWorker
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 openedIllegalArgumentException- 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 threadsoptionMap- the options to use to configure the worker- Returns:
- the new worker
- Throws:
IOException- if the worker failed to be openedIllegalArgumentException- if an option value is invalid for this worker
-
createWorker
public XnioWorker createWorker(ThreadGroup threadGroup, OptionMap optionMap, Runnable terminationTask) throws IOException, IllegalArgumentException Construct a new XNIO worker.- Parameters:
threadGroup- the thread group for worker threadsoptionMap- the options to use to configure the workerterminationTask- the task to run after the worker has shut down- Returns:
- the new worker
- Throws:
IOException- if the worker failed to be openedIllegalArgumentException- if an option value is invalid for this worker
-
createFileSystemWatcher
Creates a file system watcher, that can be used to monitor file system changes.- Parameters:
name- The watcher nameoptions- The options to use to create the watcher- Returns:
- The file system watcher
-
handleThreadExit
protected void handleThreadExit()Implement tasks that will be executed on thread exits if a task worker thread is initialized throughXnioWorker$WorkerThreadFactory. -
getName
Get the name of this XNIO provider.- Returns:
- the name
-
toString
Get a string representation of this XNIO provider. -
getProperty
Get an XNIO property. The property name must start with"xnio.".- Parameters:
name- the property name- Returns:
- the property value, or
nullif it wasn't found - Since:
- 1.2
-
getProperty
Get an XNIO property. The property name must start with"xnio.".- Parameters:
name- the property namedefaultValue- the default value- Returns:
- the property value, or
defaultValueif it wasn't found - Since:
- 1.2
-
register
Register an MBean. If the MBean cannot be registered, this method will simply return.- Parameters:
providerMXBean- the provider MBean to register- Returns:
- a handle which may be used to remove the registration
-
register
Register an MBean. If the MBean cannot be registered, this method will simply return.- Parameters:
workerMXBean- the worker MBean to register- Returns:
- a handle which may be used to remove the registration
-
register
Register an MBean. If the MBean cannot be registered, this method will simply return.- Parameters:
serverMXBean- the server MBean to register- Returns:
- a handle which may be used to remove the registration
-