org.springframework.util.concurrent.CompletableToListenableFutureAdapter Java Examples
The following examples show how to use
org.springframework.util.concurrent.CompletableToListenableFutureAdapter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultFlywayDataSourceContext.java From embedded-database-spring-test with Apache License 2.0 | 6 votes |
@Override public synchronized ListenableFuture<DataSource> reload(Flyway flyway) { Executor executor = bootstrapExecutor != null ? bootstrapExecutor : Runnable::run; CompletableFuture<DataSource> reloadFuture = dataSourceFuture.thenApplyAsync(x -> { for (int current = 1; current <= maxAttempts; current++) { try { FlywayDatabasePreparer databasePreparer = new FlywayDatabasePreparer(flyway); return databaseProvider.getDatabase(databasePreparer, databaseDescriptor); } catch (Exception e) { if (ExceptionUtils.indexOfType(e, IOException.class) == -1 || current == maxAttempts) { throw new CompletionException(e); } } } throw new IllegalStateException("maxAttempts parameter must be greater or equal to 1"); }, executor); // main data source future must never fail, otherwise all following tests will fail dataSourceFuture = reloadFuture.exceptionally(throwable -> null); return new CompletableToListenableFutureAdapter<>(reloadFuture); }
Example #2
Source File: CompletableFutureReturnValueHandler.java From spring-analysis-note with MIT License | 4 votes |
@Override @SuppressWarnings("unchecked") public ListenableFuture<?> toListenableFuture(Object returnValue, MethodParameter returnType) { return new CompletableToListenableFutureAdapter<>((CompletionStage<Object>) returnValue); }
Example #3
Source File: CompletableFutureReturnValueHandler.java From java-technology-stack with MIT License | 4 votes |
@Override @SuppressWarnings("unchecked") public ListenableFuture<?> toListenableFuture(Object returnValue, MethodParameter returnType) { return new CompletableToListenableFutureAdapter<>((CompletionStage<Object>) returnValue); }
Example #4
Source File: CseAsyncClientHttpRequest.java From servicecomb-java-chassis with Apache License 2.0 | 4 votes |
private ListenableFuture<ClientHttpResponse> invoke(Map<String, Object> swaggerArguments) { Invocation invocation = prepareInvocation(swaggerArguments); invocation.getHandlerContext().put(RestConst.CONSUMER_HEADER, this.getHeaders()); CompletableFuture<ClientHttpResponse> clientHttpResponseCompletableFuture = doAsyncInvoke(invocation); return new CompletableToListenableFutureAdapter<ClientHttpResponse>(clientHttpResponseCompletableFuture); }
Example #5
Source File: CompletableFutureReturnValueHandler.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override @SuppressWarnings("unchecked") public ListenableFuture<?> toListenableFuture(Object returnValue, MethodParameter returnType) { return new CompletableToListenableFutureAdapter<Object>((CompletableFuture<Object>) returnValue); }