diff --git a/spring-context/src/main/java/org/springframework/scheduling/concurrent/ExecutorConfigurationSupport.java b/spring-context/src/main/java/org/springframework/scheduling/concurrent/ExecutorConfigurationSupport.java index c80030647beaa84060a6e966c49e7e0adcbde7c8..fa2ae75206cd527ce29fc867b9ba9cb404991aec 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/concurrent/ExecutorConfigurationSupport.java +++ b/spring-context/src/main/java/org/springframework/scheduling/concurrent/ExecutorConfigurationSupport.java @@ -63,8 +63,8 @@ public abstract class ExecutorConfigurationSupport extends CustomizableThreadFac /** - * Set the ThreadFactory to use for the ThreadPoolExecutor's thread pool. - * Default is the ThreadPoolExecutor's default thread factory. + * Set the ThreadFactory to use for the ExecutorService's thread pool. + * Default is the underlying ExecutorService's default thread factory. *

In a Java EE 7 or other managed environment with JSR-236 support, * consider specifying a JNDI-located ManagedThreadFactory: by default, * to be found at "java:comp/env/concurrent/tf/DefaultThreadFactory". @@ -83,8 +83,8 @@ public abstract class ExecutorConfigurationSupport extends CustomizableThreadFac } /** - * Set the RejectedExecutionHandler to use for the ThreadPoolExecutor. - * Default is the ThreadPoolExecutor's default abort policy. + * Set the RejectedExecutionHandler to use for the ExecutorService. + * Default is the ExecutorService's default abort policy. * @see java.util.concurrent.ThreadPoolExecutor.AbortPolicy */ public void setRejectedExecutionHandler(RejectedExecutionHandler rejectedExecutionHandler) { @@ -189,7 +189,7 @@ public abstract class ExecutorConfigurationSupport extends CustomizableThreadFac } /** - * Perform a shutdown on the ThreadPoolExecutor. + * Perform a shutdown on the underlying ExecutorService. * @see java.util.concurrent.ExecutorService#shutdown() * @see java.util.concurrent.ExecutorService#shutdownNow() * @see #awaitTerminationIfNecessary() diff --git a/spring-context/src/main/java/org/springframework/scheduling/concurrent/ScheduledExecutorFactoryBean.java b/spring-context/src/main/java/org/springframework/scheduling/concurrent/ScheduledExecutorFactoryBean.java index 4b5e4b6a2595fb4be211050acdafb3b4bf06642c..507349e8fcce1c90ab4e94756769de9a569235b0 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/concurrent/ScheduledExecutorFactoryBean.java +++ b/spring-context/src/main/java/org/springframework/scheduling/concurrent/ScheduledExecutorFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,9 +37,10 @@ import org.springframework.util.ObjectUtils; * *

Allows for registration of {@link ScheduledExecutorTask ScheduledExecutorTasks}, * automatically starting the {@link ScheduledExecutorService} on initialization and - * cancelling it on destruction of the context. In scenarios that just require static + * cancelling it on destruction of the context. In scenarios that only require static * registration of tasks at startup, there is no need to access the - * {@link ScheduledExecutorService} instance itself in application code. + * {@link ScheduledExecutorService} instance itself in application code at all; + * ScheduledExecutorFactoryBean is then just being used for lifecycle integration. * *

Note that {@link java.util.concurrent.ScheduledExecutorService} * uses a {@link Runnable} instance that is shared between repeated executions, @@ -92,7 +93,7 @@ public class ScheduledExecutorFactoryBean extends ExecutorConfigurationSupport * @see java.util.concurrent.ScheduledExecutorService#scheduleWithFixedDelay(java.lang.Runnable, long, long, java.util.concurrent.TimeUnit) * @see java.util.concurrent.ScheduledExecutorService#scheduleAtFixedRate(java.lang.Runnable, long, long, java.util.concurrent.TimeUnit) */ - public void setScheduledExecutorTasks(ScheduledExecutorTask[] scheduledExecutorTasks) { + public void setScheduledExecutorTasks(ScheduledExecutorTask... scheduledExecutorTasks) { this.scheduledExecutorTasks = scheduledExecutorTasks; } @@ -193,9 +194,9 @@ public class ScheduledExecutorFactoryBean extends ExecutorConfigurationSupport * @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); + return (this.continueScheduledExecutionAfterException ? + new DelegatingErrorHandlingRunnable(task.getRunnable(), TaskUtils.LOG_AND_SUPPRESS_ERROR_HANDLER) : + new DelegatingErrorHandlingRunnable(task.getRunnable(), TaskUtils.LOG_AND_PROPAGATE_ERROR_HANDLER)); } diff --git a/spring-context/src/main/java/org/springframework/scheduling/concurrent/ThreadPoolExecutorFactoryBean.java b/spring-context/src/main/java/org/springframework/scheduling/concurrent/ThreadPoolExecutorFactoryBean.java index b8912e8143de6b284332f73c48b0e7373f78d72f..a3addbd27e8c8416242561a68ba019de901d79b6 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/concurrent/ThreadPoolExecutorFactoryBean.java +++ b/spring-context/src/main/java/org/springframework/scheduling/concurrent/ThreadPoolExecutorFactoryBean.java @@ -71,7 +71,6 @@ public class ThreadPoolExecutorFactoryBean extends ExecutorConfigurationSupport /** * Set the ThreadPoolExecutor's core pool size. * Default is 1. - *

This setting can be modified at runtime, for example through JMX. */ public void setCorePoolSize(int corePoolSize) { this.corePoolSize = corePoolSize; @@ -80,7 +79,6 @@ public class ThreadPoolExecutorFactoryBean extends ExecutorConfigurationSupport /** * Set the ThreadPoolExecutor's maximum pool size. * Default is {@code Integer.MAX_VALUE}. - *

This setting can be modified at runtime, for example through JMX. */ public void setMaxPoolSize(int maxPoolSize) { this.maxPoolSize = maxPoolSize; @@ -89,7 +87,6 @@ public class ThreadPoolExecutorFactoryBean extends ExecutorConfigurationSupport /** * Set the ThreadPoolExecutor's keep-alive seconds. * Default is 60. - *

This setting can be modified at runtime, for example through JMX. */ public void setKeepAliveSeconds(int keepAliveSeconds) { this.keepAliveSeconds = keepAliveSeconds; @@ -99,9 +96,7 @@ public class ThreadPoolExecutorFactoryBean extends ExecutorConfigurationSupport * Specify whether to allow core threads to time out. This enables dynamic * growing and shrinking even in combination with a non-zero queue (since * the max pool size will only grow once the queue is full). - *

Default is "false". Note that this feature is only available on Java 6 - * or above. On Java 5, consider switching to the backport-concurrent - * version of ThreadPoolTaskExecutor which also supports this feature. + *

Default is "false". * @see java.util.concurrent.ThreadPoolExecutor#allowCoreThreadTimeOut(boolean) */ public void setAllowCoreThreadTimeOut(boolean allowCoreThreadTimeOut) {