scheduling.concurrent
package which is based on Java 5's java.util.concurrent.ExecutorService@Deprecated public class TimerTaskExecutor extends Object implements SchedulingTaskExecutor, BeanNameAware, InitializingBean, DisposableBean
TaskExecutor implementation that uses a
single Timer for executing all tasks, effectively resulting in
serialized asynchronous execution on a single thread.Timer| Modifier and Type | Field and Description |
|---|---|
protected Log |
logger
Deprecated.
|
TIMEOUT_IMMEDIATE, TIMEOUT_INDEFINITE| Constructor and Description |
|---|
TimerTaskExecutor()
Deprecated.
Create a new TimerTaskExecutor that needs to be further configured and initialized.
|
TimerTaskExecutor(Timer timer)
Deprecated.
Create a new TimerTaskExecutor for the given
Timer. |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet()
Deprecated.
Invoked by a BeanFactory after it has set all bean properties supplied
(and satisfied BeanFactoryAware and ApplicationContextAware).
|
protected Timer |
createTimer()
Deprecated.
Create a new
Timer instance. |
void |
destroy()
Deprecated.
Cancel the
Timer on bean factory shutdown, stopping all scheduled tasks. |
void |
execute(Runnable task)
Deprecated.
Schedules the given
Runnable on this executor's Timer instance,
wrapping it in a DelegatingTimerTask. |
void |
execute(Runnable task,
long startTimeout)
Deprecated.
Execute the given
task. |
protected Timer |
getTimer()
Deprecated.
Return the underlying Timer behind this TimerTaskExecutor.
|
boolean |
prefersShortLivedTasks()
Deprecated.
This task executor prefers short-lived work units.
|
void |
setBeanName(String beanName)
Deprecated.
Set the name of the bean in the bean factory that created this bean.
|
void |
setDelay(long delay)
Deprecated.
Set the delay to use for scheduling tasks passed into the plain
execute(Runnable) method. |
void |
setTimer(Timer timer)
Deprecated.
Set the
Timer to use for this TimerTaskExecutor, for example
a shared Timer instance defined by a TimerFactoryBean. |
<T> Future<T> |
submit(Callable<T> task)
Deprecated.
Submit a Callable task for execution, receiving a Future representing that task.
|
Future<?> |
submit(Runnable task)
Deprecated.
Submit a Runnable task for execution, receiving a Future representing that task.
|
protected final Log logger
public TimerTaskExecutor()
public void setTimer(Timer timer)
Timer to use for this TimerTaskExecutor, for example
a shared Timer instance defined by a TimerFactoryBean.
If not specified, a default internal Timer instance will be used.
timer - the Timer to use for this TimerTaskExecutorTimerFactoryBeanpublic void setDelay(long delay)
execute(Runnable) method. Default is 0.
Note that calls to execute(Runnable, long) will use the
given timeout as delay if it is lower than the general delay.
delay - the delay in milliseconds before the task is to be executedpublic void setBeanName(String beanName)
BeanNameAwareInvoked after population of normal bean properties but before an
init callback such as InitializingBean.afterPropertiesSet()
or a custom init-method.
setBeanName in interface BeanNameAwarebeanName - the name of the bean in the factory.
Note that this name is the actual bean name used in the factory, which may
differ from the originally specified name: in particular for inner bean
names, the actual bean name might have been made unique through appending
"#..." suffixes. Use the BeanFactoryUtils.originalBeanName(String)
method to extract the original bean name (without suffix), if desired.public void afterPropertiesSet()
InitializingBeanThis method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.
afterPropertiesSet in interface InitializingBeanprotected Timer createTimer()
protected final Timer getTimer()
public void execute(Runnable task)
Runnable on this executor's Timer instance,
wrapping it in a DelegatingTimerTask.execute in interface Executorexecute in interface TaskExecutortask - the task to be executedpublic void execute(Runnable task, long startTimeout)
AsyncTaskExecutortask.execute in interface AsyncTaskExecutortask - the Runnable to execute (never null)startTimeout - the time duration (milliseconds) within which the task is
supposed to start. This is intended as a hint to the executor, allowing for
preferred handling of immediate tasks. Typical values are AsyncTaskExecutor.TIMEOUT_IMMEDIATE
or AsyncTaskExecutor.TIMEOUT_INDEFINITE (the default as used by TaskExecutor.execute(Runnable)).public Future<?> submit(Runnable task)
AsyncTaskExecutornull result upon completion.submit in interface AsyncTaskExecutortask - the Runnable to execute (never null)public <T> Future<T> submit(Callable<T> task)
AsyncTaskExecutorsubmit in interface AsyncTaskExecutortask - the Callable to execute (never null)public boolean prefersShortLivedTasks()
prefersShortLivedTasks in interface SchedulingTaskExecutortrue if this TaskExecutor prefers
short-lived taskspublic void destroy()
Timer on bean factory shutdown, stopping all scheduled tasks.destroy in interface DisposableBeanTimer.cancel()