Class IoUtil

java.lang.Object
org.apache.mina.core.IoUtil

public final class IoUtil extends Object
A utility class that provides various convenience methods related with IoSession and IoFuture.
  • Field Details

    • EMPTY_SESSIONS

      private static final IoSession[] EMPTY_SESSIONS
  • Constructor Details

    • IoUtil

      private IoUtil()
  • Method Details

    • broadcast

      public static List<WriteFuture> broadcast(Object message, Collection<IoSession> sessions)
      Writes the specified message to the specified sessions. If the specified message is an IoBuffer, the buffer is automatically duplicated using IoBuffer.duplicate().
      Parameters:
      message - The message to broadcast
      sessions - The sessions that will receive the message
      Returns:
      The list of WriteFuture created for each broadcasted message
    • broadcast

      public static List<WriteFuture> broadcast(Object message, Iterable<IoSession> sessions)
      Writes the specified message to the specified sessions. If the specified message is an IoBuffer, the buffer is automatically duplicated using IoBuffer.duplicate().
      Parameters:
      message - The message to broadcast
      sessions - The sessions that will receive the message
      Returns:
      The list of WriteFuture created for each broadcasted message
    • broadcast

      public static List<WriteFuture> broadcast(Object message, Iterator<IoSession> sessions)
      Writes the specified message to the specified sessions. If the specified message is an IoBuffer, the buffer is automatically duplicated using IoBuffer.duplicate().
      Parameters:
      message - The message to write
      sessions - The sessions the message has to be written to
      Returns:
      The list of WriteFuture for the written messages
    • broadcast

      public static List<WriteFuture> broadcast(Object message, IoSession... sessions)
      Writes the specified message to the specified sessions. If the specified message is an IoBuffer, the buffer is automatically duplicated using IoBuffer.duplicate().
      Parameters:
      message - The message to write
      sessions - The sessions the message has to be written to
      Returns:
      The list of WriteFuture for the written messages
    • broadcast

      private static void broadcast(Object message, Iterator<IoSession> sessions, Collection<WriteFuture> answer)
    • await

      public static void await(Iterable<? extends IoFuture> futures) throws InterruptedException
      Wait on all the IoFutures we get, or until one of the IoFutures is interrupted
      Parameters:
      futures - The IoFutures we are waiting on
      Throws:
      InterruptedException - If one of the IoFuture is interrupted
    • awaitUninterruptably

      public static void awaitUninterruptably(Iterable<? extends IoFuture> futures)
      Wait on all the IoFutures we get. This can't get interrupted.
      Parameters:
      futures - The IoFutures we are waiting on
    • await

      public static boolean await(Iterable<? extends IoFuture> futures, long timeout, TimeUnit unit) throws InterruptedException
      Wait on all the IoFutures we get, or until one of the IoFutures is interrupted
      Parameters:
      futures - The IoFutures we are waiting on
      timeout - The maximum time we wait for the IoFutures to complete
      unit - The Time unit to use for the timeout
      Returns:
      TRUE if all the IoFuture have been completed, FALSE if at least one IoFuture has been interrupted
      Throws:
      InterruptedException - If one of the IoFuture is interrupted
    • await

      public static boolean await(Iterable<? extends IoFuture> futures, long timeoutMillis) throws InterruptedException
      Wait on all the IoFutures we get, or until one of the IoFutures is interrupted
      Parameters:
      futures - The IoFutures we are waiting on
      timeoutMillis - The maximum milliseconds we wait for the IoFutures to complete
      Returns:
      TRUE if all the IoFuture have been completed, FALSE if at least one IoFuture has been interrupted
      Throws:
      InterruptedException - If one of the IoFuture is interrupted
    • awaitUninterruptibly

      public static boolean awaitUninterruptibly(Iterable<? extends IoFuture> futures, long timeout, TimeUnit unit)
      Wait on all the IoFutures we get.
      Parameters:
      futures - The IoFutures we are waiting on
      timeout - The maximum time we wait for the IoFutures to complete
      unit - The Time unit to use for the timeout
      Returns:
      TRUE if all the IoFuture have been completed, FALSE if at least one IoFuture has been interrupted
    • awaitUninterruptibly

      public static boolean awaitUninterruptibly(Iterable<? extends IoFuture> futures, long timeoutMillis)
      Wait on all the IoFutures we get.
      Parameters:
      futures - The IoFutures we are waiting on
      timeoutMillis - The maximum milliseconds we wait for the IoFutures to complete
      Returns:
      TRUE if all the IoFuture have been completed, FALSE if at least one IoFuture has been interrupted
    • await0

      private static boolean await0(Iterable<? extends IoFuture> futures, long timeoutMillis, boolean interruptable) throws InterruptedException
      Throws:
      InterruptedException