Package jadex.commons.future
Class TerminableDelegationFuture<E>
- java.lang.Object
-
- jadex.commons.future.Future<E>
-
- jadex.commons.future.TerminableDelegationFuture<E>
-
- All Implemented Interfaces:
IBackwardCommandFuture,IForwardCommandFuture,IFuture<E>,ITerminableFuture<E>
public class TerminableDelegationFuture<E> extends Future<E> implements ITerminableFuture<E>
A terminable delegation future can be used when a termination future should be delegated. This kind of future needs to be connected to the termination source (another delegation or a real future). Termination calls are forwarded to the termination source. The future remembers when terminate() was called in unconnected state and forwards the request as soon as the connection is established.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jadex.commons.future.IForwardCommandFuture
IForwardCommandFuture.Type
-
-
Field Summary
Fields Modifier and Type Field Description protected booleannotifiedFlag if source has been notified.protected booleannotifyFlag if source has to be notified.protected java.lang.ExceptionreasonException used for notification.protected ITerminableFuture<?>srcThe termination source.protected java.util.List<java.lang.Object>storedinfosThe list of stored infos, to be sent when src is connected.-
Fields inherited from class jadex.commons.future.Future
CALLER_QUEUED, CALLER_RESUMED, CALLER_SUSPENDED, callers, creation, DEBUG, exception, first, listener, listeners, NO_STACK_COMPACTION, NONE, notcommand, notifications, result, resultavailable, STACK, undone, UNSET
-
-
Constructor Summary
Constructors Constructor Description TerminableDelegationFuture()Create a new future.TerminableDelegationFuture(ITerminableFuture<?> src)Create a new future.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidsendBackwardCommand(java.lang.Object info)Send a backward command in direction of the source.voidsetTerminationSource(ITerminableFuture<?> src)Set the termination source.voidterminate()Terminate the future.voidterminate(java.lang.Exception reason)Terminate the future and supply a custom reason.-
Methods inherited from class jadex.commons.future.Future
abortGet, acceptEither, addResultListener, addResultListener, addResultListener, applyToEither, delegate, doSetException, doSetResult, exceptionally, exceptionally, exceptionally, executeNotification, get, get, get, get, get, getEmptyFuture, getException, getFuture, getNotificationCommand, hasResultListener, isDone, notifyListener, notifyListener, resume, scheduleNotification, scheduleNotification, scheduleNotification, sendForwardCommand, setException, setExceptionIfUndone, setResult, setResultIfUndone, startScheduledNotifications, thenAccept, thenAccept, thenApply, thenApply, thenCombine, thenCompose, thenCompose
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jadex.commons.future.IFuture
acceptEither, addResultListener, addResultListener, addResultListener, applyToEither, delegate, exceptionally, exceptionally, exceptionally, get, get, get, get, get, getException, isDone, thenAccept, thenAccept, thenApply, thenApply, thenCombine, thenCompose, thenCompose
-
-
-
-
Field Detail
-
src
protected ITerminableFuture<?> src
The termination source.
-
notify
protected boolean notify
Flag if source has to be notified.
-
notified
protected boolean notified
Flag if source has been notified.
-
reason
protected java.lang.Exception reason
Exception used for notification.
-
storedinfos
protected java.util.List<java.lang.Object> storedinfos
The list of stored infos, to be sent when src is connected.
-
-
Constructor Detail
-
TerminableDelegationFuture
public TerminableDelegationFuture()
Create a new future.
-
TerminableDelegationFuture
public TerminableDelegationFuture(ITerminableFuture<?> src)
Create a new future.
-
-
Method Detail
-
setTerminationSource
public void setTerminationSource(ITerminableFuture<?> src)
Set the termination source.
-
terminate
public void terminate()
Terminate the future. The exception will be set to FutureTerminatedException.- Specified by:
terminatein interfaceITerminableFuture<E>
-
terminate
public void terminate(java.lang.Exception reason)
Terminate the future and supply a custom reason.- Specified by:
terminatein interfaceITerminableFuture<E>
-
sendBackwardCommand
public void sendBackwardCommand(java.lang.Object info)
Send a backward command in direction of the source.- Specified by:
sendBackwardCommandin interfaceIBackwardCommandFuture- Parameters:
info- The command info.
-
-