Package jadex.bridge

Class TimeoutResultListener<E>

  • All Implemented Interfaces:
    jadex.commons.future.IFutureCommandResultListener<E>, jadex.commons.future.IResultListener<E>, jadex.commons.future.IUndoneResultListener<E>
    Direct Known Subclasses:
    TimeoutIntermediateResultListener

    public class TimeoutResultListener<E>
    extends java.lang.Object
    implements jadex.commons.future.IResultListener<E>, jadex.commons.future.IUndoneResultListener<E>, jadex.commons.future.IFutureCommandResultListener<E>
    Listener that allows to automatically trigger a timeout when no result (or exception) was received after some timeout interval.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected IExternalAccess exta
      The external access.
      protected jadex.commons.future.IResultListener<E> listener
      The delegation listener.
      protected java.lang.Object message
      The timeout message.
      protected boolean notified
      The timeout occurred flag.
      protected boolean realtime
      The realtime flag.
      protected long timeout
      The timeout.
      protected java.lang.Object timer
      The timer.
      protected boolean undone
      Flag if undone methods should be used.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void cancel()
      Cancel the timeout.
      void commandAvailable​(java.lang.Object command)
      Called when a command is available.
      protected java.util.TimerTask createTimerTask​(java.lang.Exception debug)  
      void exceptionOccurred​(java.lang.Exception exception)
      Called when an exception occurred.
      void exceptionOccurredIfUndone​(java.lang.Exception exception)
      Called when an exception occurred.
      protected void initTimer()  
      void resultAvailable​(E result)
      Called when the result is available.
      void resultAvailableIfUndone​(E result)
      Called when the result is available.
      void timeoutOccurred​(jadex.commons.TimeoutException te)
      Can be overridden, e.g.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • listener

        protected jadex.commons.future.IResultListener<E> listener
        The delegation listener.
      • notified

        protected boolean notified
        The timeout occurred flag.
      • timer

        protected java.lang.Object timer
        The timer.
      • timeout

        protected long timeout
        The timeout.
      • realtime

        protected boolean realtime
        The realtime flag.
      • message

        protected java.lang.Object message
        The timeout message.
      • undone

        protected boolean undone
        Flag if undone methods should be used.
    • Constructor Detail

      • TimeoutResultListener

        public TimeoutResultListener​(long timeout,
                                     IExternalAccess exta)
        Create a new listener.
      • TimeoutResultListener

        public TimeoutResultListener​(long timeout,
                                     IExternalAccess exta,
                                     jadex.commons.future.IResultListener<E> listener)
        Create a new listener.
      • TimeoutResultListener

        public TimeoutResultListener​(long timeout,
                                     IExternalAccess exta,
                                     boolean realtime,
                                     java.lang.Object message,
                                     jadex.commons.future.IResultListener<E> listener)
        Create a new listener.
    • Method Detail

      • resultAvailable

        public void resultAvailable​(E result)
        Called when the result is available.
        Specified by:
        resultAvailable in interface jadex.commons.future.IResultListener<E>
        Parameters:
        result - The result.
      • exceptionOccurred

        public void exceptionOccurred​(java.lang.Exception exception)
        Called when an exception occurred.
        Specified by:
        exceptionOccurred in interface jadex.commons.future.IResultListener<E>
        Parameters:
        exception - The exception.
      • resultAvailableIfUndone

        public void resultAvailableIfUndone​(E result)
        Called when the result is available.
        Specified by:
        resultAvailableIfUndone in interface jadex.commons.future.IUndoneResultListener<E>
        Parameters:
        result - The result.
      • exceptionOccurredIfUndone

        public void exceptionOccurredIfUndone​(java.lang.Exception exception)
        Called when an exception occurred.
        Specified by:
        exceptionOccurredIfUndone in interface jadex.commons.future.IUndoneResultListener<E>
        Parameters:
        exception - The exception.
      • cancel

        public void cancel()
        Cancel the timeout.
      • initTimer

        protected void initTimer()
      • createTimerTask

        protected java.util.TimerTask createTimerTask​(java.lang.Exception debug)
      • commandAvailable

        public void commandAvailable​(java.lang.Object command)
        Called when a command is available.
        Specified by:
        commandAvailable in interface jadex.commons.future.IFutureCommandResultListener<E>
      • timeoutOccurred

        public void timeoutOccurred​(jadex.commons.TimeoutException te)
        Can be overridden, e.g. when no listener is used.