Class JdkFutures
- java.lang.Object
-
- org.opendaylight.infrautils.utils.concurrent.JdkFutures
-
@Deprecated(forRemoval=true) public final class JdkFutures extends Object
Deprecated, for removal: This API element is subject to removal in a future version.This class is not used anywhere in OpenDaylight proper. Most of the functionality is available fromLoggingFutures
and Guava'sFutures
.Utility methods pertaining to the Java 5Future
interface.Use of JDK Future should generally be avoid, but is prevalent in ODL because the Java Bindings (v1) generated code uses them for all RPC return types.
Any new hand written code should never use the old Future interface anymore, but instead use either a Guava
ListenableFuture
, or a Java 8CompletionStage
.- Author:
- Michael Vorburger.ch
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <V> void
addErrorLogging(Future<V> future, org.slf4j.Logger logger, String message)
Deprecated, for removal: This API element is subject to removal in a future version.static <V> void
addErrorLogging(Future<V> future, org.slf4j.Logger logger, String format, Object arg)
Deprecated, for removal: This API element is subject to removal in a future version.static <V> void
addErrorLogging(Future<V> future, org.slf4j.Logger logger, String format, Object... args)
Deprecated, for removal: This API element is subject to removal in a future version.static <V> CompletionStage<V>
toCompletionStage(Future<V> future)
Deprecated, for removal: This API element is subject to removal in a future version.Converts a Java 5Future
to a Java 8CompletionStage
.static <V> com.google.common.util.concurrent.ListenableFuture<V>
toListenableFuture(Future<V> future)
Deprecated, for removal: This API element is subject to removal in a future version.Converts a Java 5Future
to a GuavaListenableFuture
.static <V> com.google.common.util.concurrent.ListenableFuture<V>
toListenableFuture(Future<V> future, Executor executor)
Deprecated, for removal: This API element is subject to removal in a future version.Converts a Java 5Future
to a GuavaListenableFuture
, using your own Executor.
-
-
-
Method Detail
-
toListenableFuture
public static <V> com.google.common.util.concurrent.ListenableFuture<V> toListenableFuture(Future<V> future)
Deprecated, for removal: This API element is subject to removal in a future version.Converts a Java 5Future
to a GuavaListenableFuture
.See also Guava's
JdkFutureAdapters
utility, which is used internally here (with an Executor that would log any possible issues, and which will be metric monitored).
-
toListenableFuture
public static <V> com.google.common.util.concurrent.ListenableFuture<V> toListenableFuture(Future<V> future, Executor executor)
Deprecated, for removal: This API element is subject to removal in a future version.Converts a Java 5Future
to a GuavaListenableFuture
, using your own Executor.It's typically a bad idea to pass a directExector here, because then the
ListenableFuture.addListener(Runnable, Executor)
will become blocking and one might as well just use the Future's blocking get() instead of this.
-
toCompletionStage
public static <V> CompletionStage<V> toCompletionStage(Future<V> future)
Deprecated, for removal: This API element is subject to removal in a future version.Converts a Java 5Future
to a Java 8CompletionStage
.
-
addErrorLogging
@Deprecated(forRemoval=true) public static <V> void addErrorLogging(Future<V> future, org.slf4j.Logger logger, String message)
Deprecated, for removal: This API element is subject to removal in a future version.Adds a callback to a Future which logs any failures.
-
addErrorLogging
@Deprecated(forRemoval=true) public static <V> void addErrorLogging(Future<V> future, org.slf4j.Logger logger, String format, Object arg)
Deprecated, for removal: This API element is subject to removal in a future version.Adds a callback to a Future which logs any failures.
-
addErrorLogging
@Deprecated(forRemoval=true) public static <V> void addErrorLogging(Future<V> future, org.slf4j.Logger logger, String format, Object... args)
Deprecated, for removal: This API element is subject to removal in a future version.Adds a callback to a Future which logs any failures.
-
-