Package jadex.commons.future
Class TerminableIntermediateFuture<E>
- java.lang.Object
-
- jadex.commons.future.Future<java.util.Collection<E>>
-
- jadex.commons.future.IntermediateFuture<E>
-
- jadex.commons.future.TerminableIntermediateFuture<E>
-
- All Implemented Interfaces:
IBackwardCommandFuture
,IForwardCommandFuture
,IFuture<java.util.Collection<E>>
,IIntermediateFuture<E>
,ITerminableFuture<java.util.Collection<E>>
,ITerminableIntermediateFuture<E>
- Direct Known Subclasses:
PullIntermediateFuture
,SubscriptionIntermediateFuture
public class TerminableIntermediateFuture<E> extends IntermediateFuture<E> implements ITerminableIntermediateFuture<E>
Intermediate future that can be terminated from caller side. A termination request leads to setException() being called with a FutureTerminatedException. The future can be supplied with a command that gets executed if terminate is called.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jadex.commons.future.IForwardCommandFuture
IForwardCommandFuture.Type
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<ICommand<java.lang.Object>,IFilter<java.lang.Object>>
bcommands
The list of backward commands.protected ITerminationCommand
terminate
The termination code.-
Fields inherited from class jadex.commons.future.IntermediateFuture
icallers, indices, intermediate, notcommand, results
-
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, notifications, result, resultavailable, STACK, undone, UNSET
-
Fields inherited from interface jadex.commons.future.IIntermediateFuture
DONE
-
-
Constructor Summary
Constructors Constructor Description TerminableIntermediateFuture()
Create a new future.TerminableIntermediateFuture(ITerminationCommand terminate)
Create a new future.TerminableIntermediateFuture(java.lang.Exception exception)
Create a future that is already done (failed).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addBackwardCommand(IFilter<java.lang.Object> filter, ICommand<java.lang.Object> command)
Add a backward command with a filter.ITerminationCommand
getTerminationCommand()
Get the terminate.void
removeBackwardCommand(ICommand<java.lang.Object> command)
Add a command with a filter.void
sendBackwardCommand(java.lang.Object info)
Send a backward command in direction of the source.void
setTerminationCommand(ITerminationCommand terminate)
Set the terminate.void
terminate()
Terminate the future.void
terminate(java.lang.Exception reason)
Terminate the future and supply a custom reason.-
Methods inherited from class jadex.commons.future.IntermediateFuture
addIntermediateResult, addIntermediateResultIfUndone, addIntermediateResultListener, addIntermediateResultListener, addIntermediateResultListener, addIntermediateResultListener, addIntermediateResultListener, addResultListener, doAddIntermediateResult, doGetNextIntermediateResult, doSetFinished, doSetResult, flatMapAsync, getIntermediateResults, getNextIntermediateResult, getNextIntermediateResult, getNextIntermediateResult, getNotificationCommand, hasNextIntermediateResult, hasNextIntermediateResult, mapAsync, mapAsync, notifyIntermediateResult, resume, resumeIntermediate, setFinished, setFinishedIfUndone, storeResult
-
Methods inherited from class jadex.commons.future.Future
abortGet, acceptEither, addResultListener, addResultListener, applyToEither, delegate, doSetException, exceptionally, exceptionally, exceptionally, executeNotification, get, get, get, get, get, getEmptyFuture, getException, getFuture, hasResultListener, isDone, notifyListener, notifyListener, 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
-
Methods inherited from interface jadex.commons.future.IIntermediateFuture
addIntermediateResultListener, addIntermediateResultListener, addIntermediateResultListener, addIntermediateResultListener, addIntermediateResultListener, flatMapAsync, getIntermediateResults, getNextIntermediateResult, getNextIntermediateResult, hasNextIntermediateResult, hasNextIntermediateResult, mapAsync, mapAsync
-
-
-
-
Field Detail
-
terminate
protected ITerminationCommand terminate
The termination code.
-
-
Constructor Detail
-
TerminableIntermediateFuture
public TerminableIntermediateFuture()
Create a new future.
-
TerminableIntermediateFuture
public TerminableIntermediateFuture(java.lang.Exception exception)
Create a future that is already done (failed).- Parameters:
exception
- The exception.
-
TerminableIntermediateFuture
public TerminableIntermediateFuture(ITerminationCommand terminate)
Create a new future.- Parameters:
terminate
- The runnable to be executed in case of termination.
-
-
Method Detail
-
terminate
public void terminate()
Terminate the future. The exception will be set to FutureTerminatedException.- Specified by:
terminate
in interfaceITerminableFuture<E>
-
terminate
public void terminate(java.lang.Exception reason)
Terminate the future and supply a custom reason.- Specified by:
terminate
in interfaceITerminableFuture<E>
-
getTerminationCommand
public ITerminationCommand getTerminationCommand()
Get the terminate.- Returns:
- The terminate.
-
setTerminationCommand
public void setTerminationCommand(ITerminationCommand terminate)
Set the terminate.- Parameters:
terminate
- The terminate to set.
-
sendBackwardCommand
public void sendBackwardCommand(java.lang.Object info)
Send a backward command in direction of the source.- Specified by:
sendBackwardCommand
in interfaceIBackwardCommandFuture
- Parameters:
info
- The command info.
-
addBackwardCommand
public void addBackwardCommand(IFilter<java.lang.Object> filter, ICommand<java.lang.Object> command)
Add a backward command with a filter. Whenever the future receives an info it will check all registered filters.
-
removeBackwardCommand
public void removeBackwardCommand(ICommand<java.lang.Object> command)
Add a command with a filter. Whenever the future receives an info it will check all registered filters.
-
-