Class EventManger<K,R,E extends Exception>

java.lang.Object
org.jivesoftware.smack.util.EventManger<K,R,E>
Type Parameters:
K - the event key.
R - the event result.
E - the exception which could be thrown by the action.

public class EventManger<K,R,E extends Exception> extends Object
The event manager class is used to perform actions and wait for an event, which is usually caused by the action (or maybe never occurs).

Events are distinguished by an unique event key. They can produce an event result, which can simply be null.

The action is able to throw an exception.

  • Constructor Details

  • Method Details

    • performActionAndWaitForEvent

      public R performActionAndWaitForEvent(K eventKey, long timeout, EventManger.Callback<E> action) throws InterruptedException, E
      Perform an action and wait for an event.

      The event is signaled with signalEvent(Object, Object).

      Parameters:
      eventKey - the event key, must not be null.
      timeout - the timeout to wait for the event in milliseconds.
      action - the action to perform prior waiting for the event, must not be null.
      Returns:
      the event value, may be null.
      Throws:
      InterruptedException - if interrupted while waiting for the event.
      E - depending on the concrete use case.
    • signalEvent

      public boolean signalEvent(K eventKey, R eventResult)
      Signal an event and the event result.

      This method will return false if the event was not created with performActionAndWaitForEvent(Object, long, Callback).

      Parameters:
      eventKey - the event key, must not be null.
      eventResult - the event result, may be null.
      Returns:
      true if the event was found and signaled, false otherwise.