Search in sources :

Example 1 with ListenableFutureTask

use of org.springframework.util.concurrent.ListenableFutureTask in project spring-framework by spring-projects.

the class ThreadPoolTaskScheduler method submitListenable.

@Override
public <T> ListenableFuture<T> submitListenable(Callable<T> task) {
    ExecutorService executor = getScheduledExecutor();
    try {
        ListenableFutureTask<T> future = new ListenableFutureTask<>(task);
        executor.execute(errorHandlingTask(future, false));
        return future;
    } catch (RejectedExecutionException ex) {
        throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
    }
}
Also used : TaskRejectedException(org.springframework.core.task.TaskRejectedException) ListenableFutureTask(org.springframework.util.concurrent.ListenableFutureTask) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ExecutorService(java.util.concurrent.ExecutorService) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 2 with ListenableFutureTask

use of org.springframework.util.concurrent.ListenableFutureTask in project spring-framework by spring-projects.

the class ThreadPoolTaskScheduler method submitListenable.

@Override
public ListenableFuture<?> submitListenable(Runnable task) {
    ExecutorService executor = getScheduledExecutor();
    try {
        ListenableFutureTask<Object> future = new ListenableFutureTask<>(task, null);
        executor.execute(errorHandlingTask(future, false));
        return future;
    } catch (RejectedExecutionException ex) {
        throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
    }
}
Also used : TaskRejectedException(org.springframework.core.task.TaskRejectedException) ListenableFutureTask(org.springframework.util.concurrent.ListenableFutureTask) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ExecutorService(java.util.concurrent.ExecutorService) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 3 with ListenableFutureTask

use of org.springframework.util.concurrent.ListenableFutureTask in project spring-framework by spring-projects.

the class ThreadPoolTaskExecutor method submitListenable.

@Override
public <T> ListenableFuture<T> submitListenable(Callable<T> task) {
    ExecutorService executor = getThreadPoolExecutor();
    try {
        ListenableFutureTask<T> future = new ListenableFutureTask<>(task);
        executor.execute(future);
        return future;
    } catch (RejectedExecutionException ex) {
        throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
    }
}
Also used : TaskRejectedException(org.springframework.core.task.TaskRejectedException) ListenableFutureTask(org.springframework.util.concurrent.ListenableFutureTask) ExecutorService(java.util.concurrent.ExecutorService) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 4 with ListenableFutureTask

use of org.springframework.util.concurrent.ListenableFutureTask in project spring-framework by spring-projects.

the class TaskExecutorAdapter method submitListenable.

@Override
public <T> ListenableFuture<T> submitListenable(Callable<T> task) {
    try {
        ListenableFutureTask<T> future = new ListenableFutureTask<>(task);
        doExecute(this.concurrentExecutor, this.taskDecorator, future);
        return future;
    } catch (RejectedExecutionException ex) {
        throw new TaskRejectedException("Executor [" + this.concurrentExecutor + "] did not accept task: " + task, ex);
    }
}
Also used : TaskRejectedException(org.springframework.core.task.TaskRejectedException) ListenableFutureTask(org.springframework.util.concurrent.ListenableFutureTask) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 5 with ListenableFutureTask

use of org.springframework.util.concurrent.ListenableFutureTask in project spring-framework by spring-projects.

the class ThreadPoolTaskExecutor method submitListenable.

@Override
public ListenableFuture<?> submitListenable(Runnable task) {
    ExecutorService executor = getThreadPoolExecutor();
    try {
        ListenableFutureTask<Object> future = new ListenableFutureTask<>(task, null);
        executor.execute(future);
        return future;
    } catch (RejectedExecutionException ex) {
        throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
    }
}
Also used : TaskRejectedException(org.springframework.core.task.TaskRejectedException) ListenableFutureTask(org.springframework.util.concurrent.ListenableFutureTask) ExecutorService(java.util.concurrent.ExecutorService) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Aggregations

ListenableFutureTask (org.springframework.util.concurrent.ListenableFutureTask)8 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)6 TaskRejectedException (org.springframework.core.task.TaskRejectedException)6 ExecutorService (java.util.concurrent.ExecutorService)4 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)2 WebSocketSession (org.springframework.web.socket.WebSocketSession)2 ClientEndpointConfig (jakarta.websocket.ClientEndpointConfig)1 Endpoint (jakarta.websocket.Endpoint)1 InetSocketAddress (java.net.InetSocketAddress)1 Principal (java.security.Principal)1 Future (java.util.concurrent.Future)1 ClientUpgradeRequest (org.eclipse.jetty.websocket.client.ClientUpgradeRequest)1 ListenableFuture (org.springframework.util.concurrent.ListenableFuture)1 WebSocketExtension (org.springframework.web.socket.WebSocketExtension)1 JettyWebSocketHandlerAdapter (org.springframework.web.socket.adapter.jetty.JettyWebSocketHandlerAdapter)1 JettyWebSocketSession (org.springframework.web.socket.adapter.jetty.JettyWebSocketSession)1 WebSocketToJettyExtensionConfigAdapter (org.springframework.web.socket.adapter.jetty.WebSocketToJettyExtensionConfigAdapter)1 StandardWebSocketHandlerAdapter (org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter)1 StandardWebSocketSession (org.springframework.web.socket.adapter.standard.StandardWebSocketSession)1