|
XNIO API 2.0.2.GA | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jboss.xnio.IoUtils
public final class IoUtils

General I/O utility methods.
| Method Summary | ||
|---|---|---|
static IoFuture.Notifier<java.lang.Object,java.io.Closeable> |
attachmentClosingNotifier()
Get a notifier that closes the attachment. |
|
static void |
awaitAll(IoFuture<?>... futures)
Wait for all the futures to complete. |
|
static void |
awaitAllInterruptibly(IoFuture<?>... futures)
Wait for all the futures to complete. |
|
static
|
cast(IoFuture<I> parent,
java.lang.Class<O> type)
Create an IoFuture which wraps another IoFuture, but returns a different type. |
|
static
|
channelListenerNotifier()
Get the notifier that invokes the channel listener given as an attachment. |
|
static CloseableExecutor |
closeableExecutor(java.util.concurrent.ExecutorService executorService,
long timeout,
java.util.concurrent.TimeUnit unit)
Get a closeable executor wrapper for an ExecutorService. |
|
static Cancellable |
closingCancellable(java.io.Closeable c)
A cancellable which closes the given resource on cancel. |
|
static ChannelListener<java.nio.channels.Channel> |
closingChannelListener()
Get a channel listener which closes the channel when notified. |
|
static IoFuture.Notifier<java.io.Closeable,java.lang.Void> |
closingNotifier()
Get a notifier that closes the result. |
|
static java.util.concurrent.Executor |
directExecutor()
Get the direct executor. |
|
static
|
getChannelListenerTask(T channel,
ChannelListener<? super T> channelListener)
Get a task which invokes the given channel listener on the given channel. |
|
static
|
getFuture(IoFuture<T> ioFuture)
Get a java.util.concurrent-style Future instance wrapper for an IoFuture instance. |
|
static
|
getManagerNotifier()
Get a notifier which forwards the result to another IoFuture's manager. |
|
static
|
getRetryingChannelSource(ChannelSource<T> delegate,
int maxTries)
A channel source which tries to acquire a channel from a delegate channel source the given number of times before giving up. |
|
static
|
getSetter(java.util.concurrent.atomic.AtomicReference<ChannelListener<? super T>> atomicReference)
Get a setter based on an atomic reference. |
|
static
|
getSetter(C channel,
java.util.concurrent.atomic.AtomicReferenceFieldUpdater<C,ChannelListener> updater)
Get a setter based on an atomic reference field updater. |
|
static
|
invokeChannelListener(java.util.concurrent.Executor executor,
T channel,
ChannelListener<? super T> channelListener)
Invoke a channel listener on a given channel, logging any errors, using the given executor. |
|
static
|
invokeChannelListener(T channel,
ChannelListener<? super T> channelListener)
Invoke a channel listener on a given channel, logging any errors. |
|
static Cancellable |
nullCancellable()
Get the null cancellable. |
|
static ChannelListener<java.nio.channels.Channel> |
nullChannelListener()
Get a channel listener which does nothing. |
|
static java.io.Closeable |
nullCloseable()
Get the null closeable. |
|
static java.util.concurrent.Executor |
nullExecutor()
Get the null executor. |
|
static
|
nullSetter()
Get a channel listener setter which does nothing. |
|
static
|
resultNotifier()
Get the result notifier. |
|
static
|
runnableNotifier(java.lang.Runnable runnable)
Get a notifier that runs the supplied action. |
|
static void |
safeClose(java.io.Closeable resource)
Close a resource, logging an error if an error occurs. |
|
static void |
safeClose(java.net.DatagramSocket resource)
Close a resource, logging an error if an error occurs. |
|
static void |
safeClose(java.util.logging.Handler resource)
Close a resource, logging an error if an error occurs. |
|
static void |
safeClose(IoFuture<? extends java.io.Closeable> futureResource)
Close a future resource, logging an error if an error occurs. |
|
static void |
safeClose(java.nio.channels.Selector resource)
Close a resource, logging an error if an error occurs. |
|
static void |
safeClose(java.net.ServerSocket resource)
Close a resource, logging an error if an error occurs. |
|
static void |
safeClose(java.net.Socket resource)
Close a resource, logging an error if an error occurs. |
|
static void |
safeClose(java.util.zip.ZipFile resource)
Close a resource, logging an error if an error occurs. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static java.util.concurrent.Executor directExecutor()
public static java.util.concurrent.Executor nullExecutor()
public static CloseableExecutor closeableExecutor(java.util.concurrent.ExecutorService executorService,
long timeout,
java.util.concurrent.TimeUnit unit)
ExecutorService. The given timeout is used to determine how long
the close() method will wait for a clean shutdown before the executor is shut down forcefully.
executorService - the executor servicetimeout - the timeoutunit - the unit for the timeout
public static java.io.Closeable nullCloseable()
Closeable instance that does nothing when its close()
method is invoked.
public static void safeClose(java.io.Closeable resource)
resource - the resource to closepublic static void safeClose(java.net.Socket resource)
resource - the resource to closepublic static void safeClose(java.net.DatagramSocket resource)
resource - the resource to closepublic static void safeClose(java.nio.channels.Selector resource)
resource - the resource to closepublic static void safeClose(java.net.ServerSocket resource)
resource - the resource to closepublic static void safeClose(java.util.zip.ZipFile resource)
resource - the resource to closepublic static void safeClose(java.util.logging.Handler resource)
resource - the resource to closepublic static void safeClose(IoFuture<? extends java.io.Closeable> futureResource)
futureResource - the resource to closepublic static IoFuture.Notifier<java.lang.Object,java.io.Closeable> attachmentClosingNotifier()
public static IoFuture.Notifier<java.io.Closeable,java.lang.Void> closingNotifier()
public static <T> IoFuture.Notifier<T,java.lang.Void> runnableNotifier(java.lang.Runnable runnable)
T - the future type (not used)runnable - the notifier type
public static <T> IoFuture.Notifier<T,Result<T>> resultNotifier()
IoFuture to the attached
Result.
T - the result type
public static <T extends java.nio.channels.Channel> IoFuture.Notifier<T,ChannelListener<? super T>> channelListenerNotifier()
T - the channel type
public static <T> java.util.concurrent.Future<T> getFuture(IoFuture<T> ioFuture)
java.util.concurrent-style Future instance wrapper for an IoFuture instance.
ioFuture - the IoFuture to wrap
Futurepublic static void awaitAll(IoFuture<?>... futures)
futures - the futures to wait for
public static void awaitAllInterruptibly(IoFuture<?>... futures)
throws java.lang.InterruptedException
futures - the futures to wait for
java.lang.InterruptedException - if the current thread is interrupted while waiting
public static <I,O> IoFuture<? extends O> cast(IoFuture<I> parent,
java.lang.Class<O> type)
IoFuture which wraps another IoFuture, but returns a different type.
I - the type of the original resultO - the type of the wrapped resultparent - the original IoFuturetype - the class of the new IoFuture
IoFuture
public static <T extends java.nio.channels.Channel> boolean invokeChannelListener(T channel,
ChannelListener<? super T> channelListener)
T - the channel typechannel - the channelchannelListener - the channel listener
true if the handler completed successfully, or false if it failed
public static <T extends java.nio.channels.Channel> void invokeChannelListener(java.util.concurrent.Executor executor,
T channel,
ChannelListener<? super T> channelListener)
T - the channel typeexecutor - the executorchannel - the channelchannelListener - the channel listener
public static <T extends java.nio.channels.Channel> java.lang.Runnable getChannelListenerTask(T channel,
ChannelListener<? super T> channelListener)
T - the channel typechannel - the channelchannelListener - the channel listener
public static ChannelListener<java.nio.channels.Channel> closingChannelListener()
public static ChannelListener<java.nio.channels.Channel> nullChannelListener()
public static <T extends java.nio.channels.Channel,C> ChannelListener.Setter<T> getSetter(C channel,
java.util.concurrent.atomic.AtomicReferenceFieldUpdater<C,ChannelListener> updater)
T - the channel typeC - the holding classchannel - the channelupdater - the updater
public static <T extends java.nio.channels.Channel> ChannelListener.Setter<T> getSetter(java.util.concurrent.atomic.AtomicReference<ChannelListener<? super T>> atomicReference)
T - the channel typeatomicReference - the atomic reference
public static <T extends java.nio.channels.Channel> ChannelListener.Setter<T> nullSetter()
T - the channel type
public static <T> IoFuture.Notifier<T,FutureResult<T>> getManagerNotifier()
IoFuture's manager.
T - the channel type
public static <T extends java.nio.channels.Channel> ChannelSource<T> getRetryingChannelSource(ChannelSource<T> delegate,
int maxTries)
T - the channel typedelegate - the delegate channel sourcemaxTries - the number of times to retry
public static Cancellable closingCancellable(java.io.Closeable c)
c - the resource
public static Cancellable nullCancellable()
|
XNIO API 2.0.2.GA | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||