Package jadex.bridge
Class TimeoutResultListener<E>
- java.lang.Object
-
- jadex.bridge.TimeoutResultListener<E>
-
- All Implemented Interfaces:
IFunctionalExceptionListener
,IFunctionalResultListener<E>
,IFutureCommandResultListener<E>
,IResultListener<E>
,IUndoneResultListener<E>
- Direct Known Subclasses:
TimeoutIntermediateResultListener
public class TimeoutResultListener<E> extends java.lang.Object implements IResultListener<E>, IUndoneResultListener<E>, 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 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.
-
Constructor Summary
Constructors Constructor Description TimeoutResultListener(long timeout, IExternalAccess exta)
Create a new listener.TimeoutResultListener(long timeout, IExternalAccess exta, boolean realtime, java.lang.Object message, IResultListener<E> listener)
Create a new listener.TimeoutResultListener(long timeout, IExternalAccess exta, IResultListener<E> listener)
Create a new listener.
-
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(TimeoutException te)
Can be overridden, e.g.
-
-
-
Field Detail
-
listener
protected IResultListener<E> listener
The delegation listener.
-
exta
protected IExternalAccess exta
The external access.
-
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, IResultListener<E> listener)
Create a new listener.
-
TimeoutResultListener
public TimeoutResultListener(long timeout, IExternalAccess exta, boolean realtime, java.lang.Object message, 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 interfaceIFunctionalResultListener<E>
- Parameters:
result
- The result.
-
exceptionOccurred
public void exceptionOccurred(java.lang.Exception exception)
Called when an exception occurred.- Specified by:
exceptionOccurred
in interfaceIFunctionalExceptionListener
- Parameters:
exception
- The exception.
-
resultAvailableIfUndone
public void resultAvailableIfUndone(E result)
Called when the result is available.- Specified by:
resultAvailableIfUndone
in interfaceIUndoneResultListener<E>
- Parameters:
result
- The result.
-
exceptionOccurredIfUndone
public void exceptionOccurredIfUndone(java.lang.Exception exception)
Called when an exception occurred.- Specified by:
exceptionOccurredIfUndone
in interfaceIUndoneResultListener<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 interfaceIFutureCommandResultListener<E>
-
timeoutOccurred
public void timeoutOccurred(TimeoutException te)
Can be overridden, e.g. when no listener is used.
-
-