|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.scheduling.timer.TimerTaskExecutor
public class TimerTaskExecutor
TaskExecutor
implementation that uses a
single Timer
for executing all tasks, effectively resulting in
serialized asynchronous execution on a single thread.
Timer
Field Summary | |
---|---|
protected Log |
logger
|
Constructor Summary | |
---|---|
TimerTaskExecutor()
Create a new TimerTaskExecutor that needs to be further configured and initialized. |
|
TimerTaskExecutor(Timer timer)
Create a new TimerTaskExecutor for the given Timer . |
Method Summary | |
---|---|
void |
afterPropertiesSet()
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware). |
protected Timer |
createTimer()
Create a new Timer instance. |
void |
destroy()
Cancel the Timer on bean factory shutdown, stopping all scheduled tasks. |
void |
execute(Runnable task)
Schedules the given Runnable on this executor's Timer instance,
wrapping it in a DelegatingTimerTask . |
boolean |
prefersShortLivedTasks()
This task executor prefers short-lived work units. |
void |
setDelay(int delay)
Set the delay to use for scheduling tasks passed into the execute method. |
void |
setTimer(Timer timer)
Set the Timer to use for this TimerTaskExecutor , for example
a shared Timer instance defined by a TimerFactoryBean . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final Log logger
Constructor Detail |
---|
public TimerTaskExecutor()
setTimer(java.util.Timer)
,
afterPropertiesSet()
public TimerTaskExecutor(Timer timer)
Timer
.
timer
- the Timer
to wrapMethod Detail |
---|
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 TimerTaskExecutor
TimerFactoryBean
public void setDelay(int delay)
execute
method. Default is 0.
delay
- the delay in milliseconds before the task is to be executedpublic void afterPropertiesSet()
InitializingBean
This 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 InitializingBean
protected Timer createTimer()
Timer
instance. Called by afterPropertiesSet
if no Timer
has been specified explicitly.
The default implementation creates a plain daemon Timer
.
If overridden, subclasses must take care to ensure that a non-null
Timer
is returned from the execution of this method.
afterPropertiesSet()
,
Timer.Timer(boolean)
public void execute(Runnable task)
Runnable
on this executor's Timer
instance,
wrapping it in a DelegatingTimerTask
.
execute
in interface TaskExecutor
task
- the task to be executedpublic boolean prefersShortLivedTasks()
prefersShortLivedTasks
in interface SchedulingTaskExecutor
true
if this TaskExecutor
prefers
short-lived taskspublic void destroy()
Timer
on bean factory shutdown, stopping all scheduled tasks.
destroy
in interface DisposableBean
Timer.cancel()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |