|
|||||||||
| 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
|
attachmentClosingNotifier()
Get a notifier that closes the attachment. |
|
static void |
awaitAll(IoFuture<?>... futures)
|
|
static void |
awaitAllInterruptibly(IoFuture<?>... futures)
|
|
static CloseableExecutor |
closeableExecutor(java.util.concurrent.ExecutorService executorService,
long timeout,
java.util.concurrent.TimeUnit unit)
Get a closeable executor wrapper for an ExecutorService. |
|
static
|
closingNotifier()
Get a notifier that closes the result. |
|
static
|
createConnection(ChannelSource<T> channelSource,
IoHandler<? super T> handler,
java.util.concurrent.Executor reconnectExecutor)
Create a persistent connection using a channel source. |
|
static java.util.concurrent.Executor |
delayedExecutor(java.util.concurrent.ScheduledExecutorService scheduledExecutorService,
long delay,
java.util.concurrent.TimeUnit unit)
Create a delayed executor. |
|
static java.util.concurrent.Executor |
directExecutor()
Get the direct executor. |
|
static
|
getFuture(IoFuture<T> ioFuture)
Get a java.util.concurrent-style Future instance wrapper for an IoFuture instance. |
|
static java.io.Closeable |
nullCloseable()
Get the null closeable. |
|
static java.util.concurrent.Executor |
nullExecutor()
Get the null executor. |
|
static
|
nullHandler()
Get the null handler. |
|
static
|
nullHandlerFactory()
Get the null handler factory. |
|
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(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. |
|
static
|
singletonHandlerFactory(IoHandler<T> handler)
Get a singleton handler factory that returns the given handler one time only. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static <T extends StreamChannel> java.io.Closeable createConnection(ChannelSource<T> channelSource,
IoHandler<? super T> handler,
java.util.concurrent.Executor reconnectExecutor)
reconnectExecutor will
be used to execute a reconnect task in the event that the connection fails or is lost or terminated. If you wish
to impose a time delay on reconnect, use the delayedExecutor() method
to create a delayed executor. If you do not want to auto-reconnect use the nullExecutor() method to
create a null executor. If you want auto-reconnect to take place immediately, use the directExecutor() method
to create a direct executor.
T - the channel typechannelSource - the client to connect onhandler - the handler for the connectionreconnectExecutor - the executor that should execute the reconnect task
public static java.util.concurrent.Executor delayedExecutor(java.util.concurrent.ScheduledExecutorService scheduledExecutorService,
long delay,
java.util.concurrent.TimeUnit unit)
ScheduledExecutorService. To get an executor for this method, use one of the methods on the
Executors class.
scheduledExecutorService - the executor service to use to schedule the taskdelay - the time delay before reconnectunit - the unit of time to use
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 <T extends java.nio.channels.Channel> IoHandler<T> nullHandler()
T - the channel type
public static <T extends java.nio.channels.Channel> IoHandlerFactory<T> nullHandlerFactory()
T - the channel type
public static <T extends java.nio.channels.Channel> IoHandlerFactory<T> singletonHandlerFactory(IoHandler<T> handler)
handler - the handler to return
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 <T> IoFuture.Notifier<T,java.io.Closeable> attachmentClosingNotifier()
T - the future type (not used)
public static <T extends java.io.Closeable> IoFuture.Notifier<T,java.lang.Void> closingNotifier()
T - the future type, which must be closeable
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)
public static void awaitAllInterruptibly(IoFuture<?>... futures)
throws java.lang.InterruptedException
java.lang.InterruptedException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||