Example usage for org.springframework.core.task TaskRejectedException TaskRejectedException

List of usage examples for org.springframework.core.task TaskRejectedException TaskRejectedException

Introduction

In this page you can find the example usage for org.springframework.core.task TaskRejectedException TaskRejectedException.

Prototype

public TaskRejectedException(String msg, Throwable cause) 

Source Link

Document

Create a new TaskRejectedException with the specified detail message and the given root cause.

Usage

From source file:org.d4rxh4wx.thread.executor.ListeningThreadPoolTaskExecutor.java

@Override
public Future<?> submit(Runnable task) {
    ListeningExecutorService executor = MoreExecutors.listeningDecorator(getThreadPoolExecutor());

    try {/*from  ww w  . j  a va2 s  .  com*/
        return executor.submit(task);
    } catch (RejectedExecutionException ex) {
        throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
    }
}

From source file:org.d4rxh4wx.thread.executor.ListeningThreadPoolTaskExecutor.java

@Override
public <T> Future<T> submit(Callable<T> task) {
    ListeningExecutorService executor = MoreExecutors.listeningDecorator(getThreadPoolExecutor());

    try {//from w w w.  java  2 s . c  om
        return executor.submit(task);
    } catch (RejectedExecutionException ex) {
        throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
    }
}

From source file:be.vlaanderen.sesam.monitor.internal.util.ThreadPoolTaskScheduler.java

public void execute(Runnable task) {
    Executor executor = getScheduledExecutor();
    try {/*from w  w  w .j av a  2 s  . c o m*/
        executor.execute(errorHandlingTask(task, false));
    } catch (RejectedExecutionException ex) {
        throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
    }
}

From source file:be.vlaanderen.sesam.monitor.internal.util.ThreadPoolTaskScheduler.java

public Future<?> submit(Runnable task) {
    ExecutorService executor = getScheduledExecutor();
    try {//w w  w .  j  av a2s. c  o m
        return executor.submit(errorHandlingTask(task, false));
    } catch (RejectedExecutionException ex) {
        throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
    }
}

From source file:be.vlaanderen.sesam.monitor.internal.util.ThreadPoolTaskScheduler.java

public <T> Future<T> submit(Callable<T> task) {
    ExecutorService executor = getScheduledExecutor();
    try {//from w w w.jav a 2  s.co  m
        if (this.errorHandler != null) {
            task = new DelegatingErrorHandlingCallable<T>(task, this.errorHandler);
        }
        return executor.submit(task);
    } catch (RejectedExecutionException ex) {
        throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
    }
}

From source file:be.vlaanderen.sesam.monitor.internal.util.ThreadPoolTaskScheduler.java

public ScheduledFuture schedule(Runnable task, Trigger trigger) {
    ScheduledExecutorService executor = getScheduledExecutor();
    try {//from ww w.j  a  v a2s.  c  o  m
        ErrorHandler errorHandler = this.errorHandler != null ? this.errorHandler
                : TaskUtils.getDefaultErrorHandler(true);
        return new ReschedulingRunnable(task, trigger, executor, errorHandler).schedule();
    } catch (RejectedExecutionException ex) {
        throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
    }
}

From source file:be.vlaanderen.sesam.monitor.internal.util.ThreadPoolTaskScheduler.java

public ScheduledFuture schedule(Runnable task, Date startTime) {
    ScheduledExecutorService executor = getScheduledExecutor();
    long initialDelay = startTime.getTime() - System.currentTimeMillis();
    try {//  w  ww.  j  av  a  2  s. c om
        return executor.schedule(errorHandlingTask(task, false), initialDelay, TimeUnit.MILLISECONDS);
    } catch (RejectedExecutionException ex) {
        throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
    }
}

From source file:org.green.code.async.executor.ThreadPoolTaskExecutor.java

public void execute(Runnable task) {
    Executor executor = getThreadPoolExecutor();
    try {//from   ww  w.j  a v a2  s . co m
        executor.execute(task);
    } catch (RejectedExecutionException ex) {
        throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
    }
}

From source file:be.vlaanderen.sesam.monitor.internal.util.ThreadPoolTaskScheduler.java

public ScheduledFuture scheduleAtFixedRate(Runnable task, Date startTime, long period) {
    ScheduledExecutorService executor = getScheduledExecutor();
    long initialDelay = startTime.getTime() - System.currentTimeMillis();
    try {//from w ww  .j a  va  2  s .  c  om
        return executor.scheduleAtFixedRate(errorHandlingTask(task, true), initialDelay, period,
                TimeUnit.MILLISECONDS);
    } catch (RejectedExecutionException ex) {
        throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
    }
}

From source file:org.green.code.async.executor.ThreadPoolTaskExecutor.java

public Future<?> submit(Runnable task) {
    ExecutorService executor = getThreadPoolExecutor();
    try {/*  ww w .  java 2 s  . c  o  m*/
        return executor.submit(task);
    } catch (RejectedExecutionException ex) {
        throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
    }
}