|
XNIO version 1.0.0.GA | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jboss.xnio.IoUtils
public final class IoUtils
General I/O utility methods.
Method Summary | ||
---|---|---|
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 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. |
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 <T extends Channel> IoHandler<T> nullHandler()
T
- the channel type
public static <T extends Channel> IoHandlerFactory<T> nullHandlerFactory()
T
- the channel type
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 close
|
XNIO version 1.0.0.GA | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |