Class EventResult

  • All Implemented Interfaces:
    EventListener

    public class EventResult
    extends Object
    implements EventListener
    Utility class for Event retrieval with an EventListener.

    The getEventIterator(long) and getEvents(long) methods will block until an event is delivered and then return the events. Note, that only one of the methods can be called for an expected event delivery. Calling the 'other' method will block until the next events are delivered.

    • Constructor Detail

      • EventResult

        public EventResult​(PrintWriter log)
        Creates a new EventResult.
        Parameters:
        log - log messages are written to this Logger.
    • Method Detail

      • getEvents

        public Event[] getEvents​(long wait)
        Gets the events from the EventListener. Waits at most wait milliseconds for the events.

        If the events are not delivered within wait time an empty array is returned and a log message is written.

        Parameters:
        wait - time in milliseconds to wait at most for Events.
        Returns:
        Events.
      • getEventIterator

        public EventIterator getEventIterator​(long wait)
        Gets the events from the EventListener. Waits at most wait milliseconds for the events.

        If the events are not delivered within wait time null is returned and a log message is written.

        Parameters:
        wait - time in milliseconds to wait at most for EventIterator.
        Returns:
        EventIterator.
      • onEvent

        public void onEvent​(EventIterator events)
        Called when events are delivered.
        Specified by:
        onEvent in interface EventListener
        Parameters:
        events - the events.