Class SynchronousTerminalListener

  • All Implemented Interfaces:
    TerminalListener

    public class SynchronousTerminalListener
    extends Object
    implements TerminalListener

    Helper class for handle synchronous method calls in the Terminal class. Used internally by the Terminal instance to provide synchronous behavior. TimApi users can though use this class as base for their own synchronous use of the TimApi by using asynchronous function calls only. Provides the user with the ability to work also with intermediate completed request data in contrary to the synchronous method calls provided by Terminal.

    The listener collects all response data received for all possible requests. The user can then examine those at a later time. The most recent request data is stored. TimEvent is not stored. Stores the last received TimException.

    To use the listener call it like this:

     
     SynchronousTerminalListener listener = new SynchronousTerminalListener();
     listener.prepareWait(RequestType.TRANSACTION);
     // run action potentially completing straight away
     listener.waitForRequestCompleted();
     // work with the result in listener
     
     

    Warning! Do not use instances of this class as monitor. Instances of this class use themselves as monitor in different ways including notify/wait calls. Trying to use it as monitor can result in unpredictable behavior.