001/* 002 * Copyright 2002-2018 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.core.task; 018 019import java.util.concurrent.Callable; 020 021import org.springframework.util.concurrent.ListenableFuture; 022 023/** 024 * Extension of the {@link AsyncTaskExecutor} interface, adding the capability to submit 025 * tasks for {@link ListenableFuture ListenableFutures}. 026 * 027 * @author Arjen Poutsma 028 * @since 4.0 029 * @see ListenableFuture 030 */ 031public interface AsyncListenableTaskExecutor extends AsyncTaskExecutor { 032 033 /** 034 * Submit a {@code Runnable} task for execution, receiving a {@code ListenableFuture} 035 * representing that task. The Future will return a {@code null} result upon completion. 036 * @param task the {@code Runnable} to execute (never {@code null}) 037 * @return a {@code ListenableFuture} representing pending completion of the task 038 * @throws TaskRejectedException if the given task was not accepted 039 */ 040 ListenableFuture<?> submitListenable(Runnable task); 041 042 /** 043 * Submit a {@code Callable} task for execution, receiving a {@code ListenableFuture} 044 * representing that task. The Future will return the Callable's result upon 045 * completion. 046 * @param task the {@code Callable} to execute (never {@code null}) 047 * @return a {@code ListenableFuture} representing pending completion of the task 048 * @throws TaskRejectedException if the given task was not accepted 049 */ 050 <T> ListenableFuture<T> submitListenable(Callable<T> task); 051 052}