Class ListenableFutureCallbackRegistry<T>
java.lang.Object
org.springframework.util.concurrent.ListenableFutureCallbackRegistry<T>
- Type Parameters:
T
- the callback result type
Helper class for
ListenableFuture
implementations that maintains a
of success and failure callbacks and helps to notify them.
Inspired by com.google.common.util.concurrent.ExecutionList
.
- Since:
- 4.0
- Author:
- Arjen Poutsma, Sebastien Deleuze, Rossen Stoyanchev
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCallback
(ListenableFutureCallback<? super T> callback) Add the given callback to this registry.void
addFailureCallback
(FailureCallback callback) Add the given failure callback to this registry.void
addSuccessCallback
(SuccessCallback<? super T> callback) Add the given success callback to this registry.void
Trigger aFailureCallback.onFailure(Throwable)
call on all added callbacks with the givenThrowable
.void
Trigger aSuccessCallback.onSuccess(Object)
call on all added callbacks with the given result.
-
Constructor Details
-
ListenableFutureCallbackRegistry
public ListenableFutureCallbackRegistry()
-
-
Method Details
-
addCallback
Add the given callback to this registry.- Parameters:
callback
- the callback to add
-
addSuccessCallback
Add the given success callback to this registry.- Parameters:
callback
- the success callback to add- Since:
- 4.1
-
addFailureCallback
Add the given failure callback to this registry.- Parameters:
callback
- the failure callback to add- Since:
- 4.1
-
success
Trigger aSuccessCallback.onSuccess(Object)
call on all added callbacks with the given result.- Parameters:
result
- the result to trigger the callbacks with
-
failure
Trigger aFailureCallback.onFailure(Throwable)
call on all added callbacks with the givenThrowable
.- Parameters:
ex
- the exception to trigger the callbacks with
-