org.springframework.scheduling.support.TaskUtils Java Examples
The following examples show how to use
org.springframework.scheduling.support.TaskUtils.
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: ConcurrentTaskScheduler.java From spring-analysis-note with MIT License | 6 votes |
@Override @Nullable public ScheduledFuture<?> schedule(Runnable task, Trigger trigger) { try { if (this.enterpriseConcurrentScheduler) { return new EnterpriseConcurrentTriggerScheduler().schedule(decorateTask(task, true), trigger); } else { ErrorHandler errorHandler = (this.errorHandler != null ? this.errorHandler : TaskUtils.getDefaultErrorHandler(true)); return new ReschedulingRunnable(task, trigger, this.scheduledExecutor, errorHandler).schedule(); } } catch (RejectedExecutionException ex) { throw new TaskRejectedException("Executor [" + this.scheduledExecutor + "] did not accept task: " + task, ex); } }
Example #2
Source File: ConcurrentTaskScheduler.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public ScheduledFuture<?> schedule(Runnable task, Trigger trigger) { try { if (this.enterpriseConcurrentScheduler) { return new EnterpriseConcurrentTriggerScheduler().schedule(decorateTask(task, true), trigger); } else { ErrorHandler errorHandler = (this.errorHandler != null ? this.errorHandler : TaskUtils.getDefaultErrorHandler(true)); return new ReschedulingRunnable(task, trigger, this.scheduledExecutor, errorHandler).schedule(); } } catch (RejectedExecutionException ex) { throw new TaskRejectedException("Executor [" + this.scheduledExecutor + "] did not accept task: " + task, ex); } }
Example #3
Source File: ConcurrentTaskScheduler.java From java-technology-stack with MIT License | 6 votes |
@Override @Nullable public ScheduledFuture<?> schedule(Runnable task, Trigger trigger) { try { if (this.enterpriseConcurrentScheduler) { return new EnterpriseConcurrentTriggerScheduler().schedule(decorateTask(task, true), trigger); } else { ErrorHandler errorHandler = (this.errorHandler != null ? this.errorHandler : TaskUtils.getDefaultErrorHandler(true)); return new ReschedulingRunnable(task, trigger, this.scheduledExecutor, errorHandler).schedule(); } } catch (RejectedExecutionException ex) { throw new TaskRejectedException("Executor [" + this.scheduledExecutor + "] did not accept task: " + task, ex); } }
Example #4
Source File: ApplicationContextEventTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void simpleApplicationEventMulticasterWithErrorHandler() { @SuppressWarnings("unchecked") ApplicationListener<ApplicationEvent> listener = mock(ApplicationListener.class); ApplicationEvent evt = new ContextClosedEvent(new StaticApplicationContext()); SimpleApplicationEventMulticaster smc = new SimpleApplicationEventMulticaster(); smc.setErrorHandler(TaskUtils.LOG_AND_SUPPRESS_ERROR_HANDLER); smc.addApplicationListener(listener); willThrow(new RuntimeException()).given(listener).onApplicationEvent(evt); smc.multicastEvent(evt); }
Example #5
Source File: ApplicationContextEventTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void simpleApplicationEventMulticasterWithErrorHandler() { @SuppressWarnings("unchecked") ApplicationListener<ApplicationEvent> listener = mock(ApplicationListener.class); ApplicationEvent evt = new ContextClosedEvent(new StaticApplicationContext()); SimpleApplicationEventMulticaster smc = new SimpleApplicationEventMulticaster(); smc.setErrorHandler(TaskUtils.LOG_AND_SUPPRESS_ERROR_HANDLER); smc.addApplicationListener(listener); willThrow(new RuntimeException()).given(listener).onApplicationEvent(evt); smc.multicastEvent(evt); }
Example #6
Source File: ThreadPoolTaskScheduler.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public ScheduledFuture<?> schedule(Runnable task, Trigger trigger) { ScheduledExecutorService executor = getScheduledExecutor(); try { 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); } }
Example #7
Source File: ConcurrentTaskScheduler.java From spring4-understanding with Apache License 2.0 | 5 votes |
private Runnable decorateTask(Runnable task, boolean isRepeatingTask) { Runnable result = TaskUtils.decorateTaskWithErrorHandler(task, this.errorHandler, isRepeatingTask); if (this.enterpriseConcurrentScheduler) { result = ManagedTaskBuilder.buildManagedTask(result, task.toString()); } return result; }
Example #8
Source File: ConcurrentTaskScheduler.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public ScheduledFuture<?> schedule(Runnable task, Trigger trigger) { try { if (this.enterpriseConcurrentScheduler) { return new EnterpriseConcurrentTriggerScheduler().schedule(decorateTask(task, true), trigger); } else { ErrorHandler errorHandler = (this.errorHandler != null ? this.errorHandler : TaskUtils.getDefaultErrorHandler(true)); return new ReschedulingRunnable(task, trigger, this.scheduledExecutor, errorHandler).schedule(); } } catch (RejectedExecutionException ex) { throw new TaskRejectedException("Executor [" + this.scheduledExecutor + "] did not accept task: " + task, ex); } }
Example #9
Source File: ThreadPoolTaskScheduler.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public ScheduledFuture<?> schedule(Runnable task, Trigger trigger) { ScheduledExecutorService executor = getScheduledExecutor(); try { 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); } }
Example #10
Source File: ConcurrentTaskScheduler.java From lams with GNU General Public License v2.0 | 5 votes |
private Runnable decorateTask(Runnable task, boolean isRepeatingTask) { Runnable result = TaskUtils.decorateTaskWithErrorHandler(task, this.errorHandler, isRepeatingTask); if (this.enterpriseConcurrentScheduler) { result = ManagedTaskBuilder.buildManagedTask(result, task.toString()); } return result; }
Example #11
Source File: DecoratedThreadPoolTaskExecutorTests.java From java-technology-stack with MIT License | 5 votes |
@Override protected AsyncListenableTaskExecutor buildExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setTaskDecorator(runnable -> new DelegatingErrorHandlingRunnable(runnable, TaskUtils.LOG_AND_PROPAGATE_ERROR_HANDLER)); executor.setThreadNamePrefix(THREAD_NAME_PREFIX); executor.setMaxPoolSize(1); executor.afterPropertiesSet(); return executor; }
Example #12
Source File: ConcurrentTaskScheduler.java From java-technology-stack with MIT License | 5 votes |
private Runnable decorateTask(Runnable task, boolean isRepeatingTask) { Runnable result = TaskUtils.decorateTaskWithErrorHandler(task, this.errorHandler, isRepeatingTask); if (this.enterpriseConcurrentScheduler) { result = ManagedTaskBuilder.buildManagedTask(result, task.toString()); } return result; }
Example #13
Source File: ConcurrentTaskScheduler.java From spring-analysis-note with MIT License | 5 votes |
private Runnable decorateTask(Runnable task, boolean isRepeatingTask) { Runnable result = TaskUtils.decorateTaskWithErrorHandler(task, this.errorHandler, isRepeatingTask); if (this.enterpriseConcurrentScheduler) { result = ManagedTaskBuilder.buildManagedTask(result, task.toString()); } return result; }
Example #14
Source File: ThreadPoolTaskScheduler.java From spring-analysis-note with MIT License | 5 votes |
@Override @Nullable public ScheduledFuture<?> schedule(Runnable task, Trigger trigger) { ScheduledExecutorService executor = getScheduledExecutor(); try { ErrorHandler errorHandler = this.errorHandler; if (errorHandler == null) { 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); } }
Example #15
Source File: DecoratedThreadPoolTaskExecutorTests.java From spring-analysis-note with MIT License | 5 votes |
@Override protected AsyncListenableTaskExecutor buildExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setTaskDecorator(runnable -> new DelegatingErrorHandlingRunnable(runnable, TaskUtils.LOG_AND_PROPAGATE_ERROR_HANDLER)); executor.setThreadNamePrefix(THREAD_NAME_PREFIX); executor.setMaxPoolSize(1); executor.afterPropertiesSet(); return executor; }
Example #16
Source File: ApplicationContextEventTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void simpleApplicationEventMulticasterWithErrorHandler() { @SuppressWarnings("unchecked") ApplicationListener<ApplicationEvent> listener = mock(ApplicationListener.class); ApplicationEvent evt = new ContextClosedEvent(new StaticApplicationContext()); SimpleApplicationEventMulticaster smc = new SimpleApplicationEventMulticaster(); smc.setErrorHandler(TaskUtils.LOG_AND_SUPPRESS_ERROR_HANDLER); smc.addApplicationListener(listener); willThrow(new RuntimeException()).given(listener).onApplicationEvent(evt); smc.multicastEvent(evt); }
Example #17
Source File: ThreadPoolTaskScheduler.java From java-technology-stack with MIT License | 5 votes |
@Override @Nullable public ScheduledFuture<?> schedule(Runnable task, Trigger trigger) { ScheduledExecutorService executor = getScheduledExecutor(); try { ErrorHandler errorHandler = this.errorHandler; if (errorHandler == null) { 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); } }
Example #18
Source File: ThreadPoolTaskScheduler.java From lams with GNU General Public License v2.0 | 4 votes |
private Runnable errorHandlingTask(Runnable task, boolean isRepeatingTask) { return TaskUtils.decorateTaskWithErrorHandler(task, this.errorHandler, isRepeatingTask); }
Example #19
Source File: TimerManagerTaskScheduler.java From spring4-understanding with Apache License 2.0 | 4 votes |
private Runnable errorHandlingTask(Runnable delegate, boolean isRepeatingTask) { return TaskUtils.decorateTaskWithErrorHandler(delegate, this.errorHandler, isRepeatingTask); }
Example #20
Source File: ThreadPoolTaskScheduler.java From spring4-understanding with Apache License 2.0 | 4 votes |
private Runnable errorHandlingTask(Runnable task, boolean isRepeatingTask) { return TaskUtils.decorateTaskWithErrorHandler(task, this.errorHandler, isRepeatingTask); }
Example #21
Source File: ThreadPoolTaskScheduler.java From spring-analysis-note with MIT License | 4 votes |
private Runnable errorHandlingTask(Runnable task, boolean isRepeatingTask) { return TaskUtils.decorateTaskWithErrorHandler(task, this.errorHandler, isRepeatingTask); }
Example #22
Source File: TimerManagerTaskScheduler.java From lams with GNU General Public License v2.0 | 4 votes |
private Runnable errorHandlingTask(Runnable delegate, boolean isRepeatingTask) { return TaskUtils.decorateTaskWithErrorHandler(delegate, this.errorHandler, isRepeatingTask); }
Example #23
Source File: TimerManagerTaskScheduler.java From spring-analysis-note with MIT License | 4 votes |
private Runnable errorHandlingTask(Runnable delegate, boolean isRepeatingTask) { return TaskUtils.decorateTaskWithErrorHandler(delegate, this.errorHandler, isRepeatingTask); }
Example #24
Source File: TimerManagerTaskScheduler.java From java-technology-stack with MIT License | 4 votes |
private Runnable errorHandlingTask(Runnable delegate, boolean isRepeatingTask) { return TaskUtils.decorateTaskWithErrorHandler(delegate, this.errorHandler, isRepeatingTask); }
Example #25
Source File: ThreadPoolTaskScheduler.java From java-technology-stack with MIT License | 4 votes |
private Runnable errorHandlingTask(Runnable task, boolean isRepeatingTask) { return TaskUtils.decorateTaskWithErrorHandler(task, this.errorHandler, isRepeatingTask); }
Example #26
Source File: ScheduledExecutorFactoryBean.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * Determine the actual Runnable to schedule for the given task. * <p>Wraps the task's Runnable in a * {@link org.springframework.scheduling.support.DelegatingErrorHandlingRunnable} * that will catch and log the Exception. If necessary, it will suppress the * Exception according to the * {@link #setContinueScheduledExecutionAfterException "continueScheduledExecutionAfterException"} * flag. * @param task the ScheduledExecutorTask to schedule * @return the actual Runnable to schedule (may be a decorator) */ protected Runnable getRunnableToSchedule(ScheduledExecutorTask task) { return (this.continueScheduledExecutionAfterException ? new DelegatingErrorHandlingRunnable(task.getRunnable(), TaskUtils.LOG_AND_SUPPRESS_ERROR_HANDLER) : new DelegatingErrorHandlingRunnable(task.getRunnable(), TaskUtils.LOG_AND_PROPAGATE_ERROR_HANDLER)); }
Example #27
Source File: ScheduledExecutorFactoryBean.java From java-technology-stack with MIT License | 2 votes |
/** * Determine the actual Runnable to schedule for the given task. * <p>Wraps the task's Runnable in a * {@link org.springframework.scheduling.support.DelegatingErrorHandlingRunnable} * that will catch and log the Exception. If necessary, it will suppress the * Exception according to the * {@link #setContinueScheduledExecutionAfterException "continueScheduledExecutionAfterException"} * flag. * @param task the ScheduledExecutorTask to schedule * @return the actual Runnable to schedule (may be a decorator) */ protected Runnable getRunnableToSchedule(ScheduledExecutorTask task) { return (this.continueScheduledExecutionAfterException ? new DelegatingErrorHandlingRunnable(task.getRunnable(), TaskUtils.LOG_AND_SUPPRESS_ERROR_HANDLER) : new DelegatingErrorHandlingRunnable(task.getRunnable(), TaskUtils.LOG_AND_PROPAGATE_ERROR_HANDLER)); }
Example #28
Source File: ScheduledExecutorFactoryBean.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Determine the actual Runnable to schedule for the given task. * <p>Wraps the task's Runnable in a * {@link org.springframework.scheduling.support.DelegatingErrorHandlingRunnable} * that will catch and log the Exception. If necessary, it will suppress the * Exception according to the * {@link #setContinueScheduledExecutionAfterException "continueScheduledExecutionAfterException"} * flag. * @param task the ScheduledExecutorTask to schedule * @return the actual Runnable to schedule (may be a decorator) */ protected Runnable getRunnableToSchedule(ScheduledExecutorTask task) { return (this.continueScheduledExecutionAfterException ? new DelegatingErrorHandlingRunnable(task.getRunnable(), TaskUtils.LOG_AND_SUPPRESS_ERROR_HANDLER) : new DelegatingErrorHandlingRunnable(task.getRunnable(), TaskUtils.LOG_AND_PROPAGATE_ERROR_HANDLER)); }
Example #29
Source File: ScheduledExecutorFactoryBean.java From spring-analysis-note with MIT License | 2 votes |
/** * Determine the actual Runnable to schedule for the given task. * <p>Wraps the task's Runnable in a * {@link org.springframework.scheduling.support.DelegatingErrorHandlingRunnable} * that will catch and log the Exception. If necessary, it will suppress the * Exception according to the * {@link #setContinueScheduledExecutionAfterException "continueScheduledExecutionAfterException"} * flag. * @param task the ScheduledExecutorTask to schedule * @return the actual Runnable to schedule (may be a decorator) */ protected Runnable getRunnableToSchedule(ScheduledExecutorTask task) { return (this.continueScheduledExecutionAfterException ? new DelegatingErrorHandlingRunnable(task.getRunnable(), TaskUtils.LOG_AND_SUPPRESS_ERROR_HANDLER) : new DelegatingErrorHandlingRunnable(task.getRunnable(), TaskUtils.LOG_AND_PROPAGATE_ERROR_HANDLER)); }