Top Description Inners Fields Constructors Methods
org.springframework.util.concurrent

public abstract Class FutureAdapter<T, S>

extends Object
implements Future<T>
Class Inheritance
All Implemented Interfaces
java.util.concurrent.Future
Known Direct Subclasses
org.springframework.util.concurrent.ListenableFutureAdapter
Annotations
@Deprecated
since:6.0
Type Parameters
<T>
the type of this Future
<S>
the type of the adaptee's Future
Imports
java.util.concurrent.ExecutionException, .Future, .TimeUnit, .TimeoutException, org.springframework.lang.Nullable, org.springframework.util.Assert

Deprecated

since 6.0.

as of 6.0, with no concrete replacement

Abstract class that adapts a Future parameterized over S into a Future parameterized over T. All methods are delegated to the adaptee, where get() and get(long, TimeUnit) call adapt(Object) on the adaptee's result.
Author
Arjen Poutsma
Since
4.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum

Field Summary

Modifier and TypeField and Description
private final Future<S>
private final Object
private Object
private FutureAdapter.State

Constructor Summary

AccessConstructor and Description
protected
FutureAdapter(Future<S>
the future to delegate to
adaptee
)

Constructs a new FutureAdapter with the given adaptee.

Method Summary

Modifier and TypeMethod and Description
protected abstract T

Returns:

the adapted result
adapt
(S adapteeResult)

Adapts the given adaptee's result into T.

pack-priv final T
adaptInternal(S adapteeResult)

public boolean
cancel(boolean
true if the thread executing this task should be interrupted (if the thread is known to the implementation); otherwise, in-progress tasks are allowed to complete
mayInterruptIfRunning
)

Implements java.util.concurrent.Future.cancel.

Attempts to cancel execution of this task.

public T
get()

Implements java.util.concurrent.Future.get.

Waits if necessary for the computation to complete, and then retrieves its result.

public T
get(long
the maximum time to wait
timeout
,
TimeUnit
the time unit of the timeout argument
unit
)

Implements java.util.concurrent.Future.get.

Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.

protected Future<S>
getAdaptee()

Returns the adaptee.

public boolean
isCancelled()

Implements java.util.concurrent.Future.isCancelled.

Returns true if this task was cancelled before it completed normally.

public boolean
isDone()

Implements java.util.concurrent.Future.isDone.

Returns true if this task completed.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

adapteeback to summary
private final Future<S> adaptee
mutexback to summary
private final Object mutex
resultback to summary
private Object result
Annotations
@Nullable
stateback to summary
private FutureAdapter.State state

Constructor Detail

FutureAdapterback to summary
protected FutureAdapter(Future<S> adaptee)

Constructs a new FutureAdapter with the given adaptee.

Parameters
adaptee:Future<S>

the future to delegate to

Method Detail

adaptback to summary
protected abstract T adapt(S adapteeResult) throws ExecutionException

Adapts the given adaptee's result into T.

Returns:T

the adapted result

Annotations
@Nullable
adaptInternalback to summary
pack-priv final T adaptInternal(S adapteeResult) throws ExecutionException
Annotations
@SuppressWarnings:unchecked
@Nullable
cancelback to summary
public boolean cancel(boolean mayInterruptIfRunning)

Implements java.util.concurrent.Future.cancel.

Doc from java.util.concurrent.Future.cancel.

Attempts to cancel execution of this task. This method has no effect if the task is already completed or cancelled, or could not be cancelled for some other reason. Otherwise, if this task has not started when cancel is called, this task should never run. If the task has already started, then the mayInterruptIfRunning parameter determines whether the thread executing this task (when known by the implementation) is interrupted in an attempt to stop the task.

The return value from this method does not necessarily indicate whether the task is now cancelled; use isCancelled.

Parameters
mayInterruptIfRunning:boolean

true if the thread executing this task should be interrupted (if the thread is known to the implementation); otherwise, in-progress tasks are allowed to complete

Returns:boolean

false if the task could not be cancelled, typically because it has already completed; true otherwise. If two or more threads cause a task to be cancelled, then at least one of them returns true. Implementations may provide stronger guarantees.

Annotations
@Override
getback to summary
public T get() throws InterruptedException, ExecutionException

Implements java.util.concurrent.Future.get.

Doc from java.util.concurrent.Future.get.

Waits if necessary for the computation to complete, and then retrieves its result.

Returns:T

the computed result

Annotations
@Override
@Nullable
Exceptions
InterruptedException:
if the current thread was interrupted while waiting
ExecutionException:
if the computation threw an exception
getback to summary
public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException

Implements java.util.concurrent.Future.get.

Doc from java.util.concurrent.Future.get.

Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.

Parameters
timeout:long

the maximum time to wait

unit:TimeUnit

the time unit of the timeout argument

Returns:T

the computed result

Annotations
@Override
@Nullable
Exceptions
InterruptedException:
if the current thread was interrupted while waiting
ExecutionException:
if the computation threw an exception
TimeoutException:
if the wait timed out
getAdapteeback to summary
protected Future<S> getAdaptee()

Returns the adaptee.

isCancelledback to summary
public boolean isCancelled()

Implements java.util.concurrent.Future.isCancelled.

Doc from java.util.concurrent.Future.isCancelled.

Returns true if this task was cancelled before it completed normally.

Returns:boolean

true if this task was cancelled before it completed

Annotations
@Override
isDoneback to summary
public boolean isDone()

Implements java.util.concurrent.Future.isDone.

Doc from java.util.concurrent.Future.isDone.

Returns true if this task completed. Completion may be due to normal termination, an exception, or cancellation -- in all of these cases, this method will return true.

Returns:boolean

true if this task completed

Annotations
@Override
org.springframework.util.concurrent back to summary

private final Enum FutureAdapter.State

extends Enum<FutureAdapter.State>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final FutureAdapter.State
public static final FutureAdapter.State
public static final FutureAdapter.State

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static FutureAdapter.State
public static FutureAdapter.State[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

FAILUREback to summary
public static final FutureAdapter.State FAILURE
NEWback to summary
public static final FutureAdapter.State NEW
SUCCESSback to summary
public static final FutureAdapter.State SUCCESS

Constructor Detail

Stateback to summary
private State()

Method Detail

valueOfback to summary
public static FutureAdapter.State valueOf(String name)
valuesback to summary
public static FutureAdapter.State[] values()