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 IExternalAccessextaThe external access.protected IResultListener<E>listenerThe delegation listener.protected java.lang.ObjectmessageThe timeout message.protected booleannotifiedThe timeout occurred flag.protected booleanrealtimeThe realtime flag.protected longtimeoutThe timeout.protected java.lang.ObjecttimerThe timer.protected booleanundoneFlag 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 voidcancel()Cancel the timeout.voidcommandAvailable(java.lang.Object command)Called when a command is available.voidexceptionOccurred(java.lang.Exception exception)Called when an exception occurred.voidexceptionOccurredIfUndone(java.lang.Exception exception)Called when an exception occurred.protected voidinitTimer()voidresultAvailable(E result)Called when the result is available.voidresultAvailableIfUndone(E result)Called when the result is available.voidtimeoutOccurred(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:
resultAvailablein interfaceIFunctionalResultListener<E>- Parameters:
result- The result.
-
exceptionOccurred
public void exceptionOccurred(java.lang.Exception exception)
Called when an exception occurred.- Specified by:
exceptionOccurredin interfaceIFunctionalExceptionListener- Parameters:
exception- The exception.
-
resultAvailableIfUndone
public void resultAvailableIfUndone(E result)
Called when the result is available.- Specified by:
resultAvailableIfUndonein interfaceIUndoneResultListener<E>- Parameters:
result- The result.
-
exceptionOccurredIfUndone
public void exceptionOccurredIfUndone(java.lang.Exception exception)
Called when an exception occurred.- Specified by:
exceptionOccurredIfUndonein interfaceIUndoneResultListener<E>- Parameters:
exception- The exception.
-
cancel
public void cancel()
Cancel the timeout.
-
initTimer
protected void initTimer()
-
commandAvailable
public void commandAvailable(java.lang.Object command)
Called when a command is available.- Specified by:
commandAvailablein interfaceIFutureCommandResultListener<E>
-
timeoutOccurred
public void timeoutOccurred(TimeoutException te)
Can be overridden, e.g. when no listener is used.
-
-