|
XNIO version 1.2.0.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
|
attachmentClosingNotifier()
Get a notifier that closes the attachment. |
|
static void |
awaitAll(IoFuture<?>... futures)
|
|
static void |
awaitAllInterruptibly(IoFuture<?>... futures)
|
|
static CloseableExecutor |
closeableExecutor(ExecutorService executorService,
long timeout,
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,
Executor reconnectExecutor)
Create a persistent connection using a channel source. |
|
static Executor |
delayedExecutor(ScheduledExecutorService scheduledExecutorService,
long delay,
TimeUnit unit)
Create a delayed executor. |
|
static 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 Closeable |
nullCloseable()
Get the null closeable. |
|
static Executor |
nullExecutor()
Get the null executor. |
|
static
|
nullHandler()
Get the null handler. |
|
static
|
nullHandlerFactory()
Get the null handler factory. |
|
static void |
safeClose(Closeable resource)
Close a resource, logging an error if an error occurs. |
|
static void |
safeClose(DatagramSocket resource)
Close a resource, logging an error if an error occurs. |
|
static void |
safeClose(Handler resource)
Close a resource, logging an error if an error occurs. |
|
static void |
safeClose(Selector resource)
Close a resource, logging an error if an error occurs. |
|
static void |
safeClose(ServerSocket resource)
Close a resource, logging an error if an error occurs. |
|
static void |
safeClose(Socket resource)
Close a resource, logging an error if an error occurs. |
|
static void |
safeClose(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> Closeable createConnection(ChannelSource<T> channelSource,
IoHandler<? super T> handler,
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 Executor delayedExecutor(ScheduledExecutorService scheduledExecutorService,
long delay,
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 Executor directExecutor()
public static Executor nullExecutor()
public static CloseableExecutor closeableExecutor(ExecutorService executorService,
long timeout,
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 Closeable nullCloseable()
Closeable instance that does nothing when its close()
method is invoked.
public static <T extends Channel> IoHandler<T> nullHandler()
T - the channel type
public static <T extends Channel> IoHandlerFactory<T> nullHandlerFactory()
T - the channel type
public static <T extends Channel> IoHandlerFactory<T> singletonHandlerFactory(IoHandler<T> handler)
handler - the handler to return
public static void safeClose(Closeable resource)
resource - the resource to closepublic static void safeClose(Socket resource)
resource - the resource to closepublic static void safeClose(DatagramSocket resource)
resource - the resource to closepublic static void safeClose(Selector resource)
resource - the resource to closepublic static void safeClose(ServerSocket resource)
resource - the resource to closepublic static void safeClose(ZipFile resource)
resource - the resource to closepublic static void safeClose(Handler resource)
resource - the resource to closepublic static <T> IoFuture.Notifier<T,Closeable> attachmentClosingNotifier()
T - the future type (not used)
public static <T extends Closeable> IoFuture.Notifier<T,Void> closingNotifier()
T - the future type, which must be closeable
public static <T> 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 InterruptedException
InterruptedException
|
XNIO version 1.2.0.GA | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||