org.springframework.integration.scheduling
Class SimpleTaskScheduler
java.lang.Object
org.springframework.integration.scheduling.SimpleTaskScheduler
- All Implemented Interfaces:
- java.util.EventListener, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.DisposableBean, org.springframework.context.ApplicationListener, org.springframework.context.Lifecycle, TaskScheduler
public class SimpleTaskScheduler
- extends java.lang.Object
- implements TaskScheduler, org.springframework.beans.factory.BeanFactoryAware, org.springframework.context.ApplicationListener, org.springframework.beans.factory.DisposableBean
An implementation of TaskScheduler
that delegates to any instance
of TaskExecutor
.
This class implements ApplicationListener and provides an autoStartup
property. If true
, the scheduler will start automatically upon
receiving the ContextRefreshedEvent
. Otherwise, it will require an
explicit invocation of its start()
method. The default value is
true
. To require explicit startup, provide a value of
false
to the setAutoStartup(boolean)
method.
- Author:
- Mark Fisher, Marius Bogoevici
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SimpleTaskScheduler
public SimpleTaskScheduler(org.springframework.core.task.TaskExecutor executor)
setAutoStartup
public void setAutoStartup(boolean autoStartup)
setErrorHandler
public void setErrorHandler(ErrorHandler errorHandler)
setBeanFactory
public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
throws org.springframework.beans.BeansException
- Specified by:
setBeanFactory
in interface org.springframework.beans.factory.BeanFactoryAware
- Throws:
org.springframework.beans.BeansException
schedule
public final java.util.concurrent.ScheduledFuture<?> schedule(java.lang.Runnable task,
Trigger trigger)
- Description copied from interface:
TaskScheduler
- Schedules a task for multiple executions according to a Trigger.
- Specified by:
schedule
in interface TaskScheduler
- Parameters:
task
- Task to be run multiple timestrigger
- Trigger that determines at which times the task should be run
isRunning
public final boolean isRunning()
- Specified by:
isRunning
in interface org.springframework.context.Lifecycle
start
public final void start()
- Specified by:
start
in interface org.springframework.context.Lifecycle
stop
public final void stop()
- Specified by:
stop
in interface org.springframework.context.Lifecycle
onApplicationEvent
public final void onApplicationEvent(org.springframework.context.ApplicationEvent event)
- Specified by:
onApplicationEvent
in interface org.springframework.context.ApplicationListener
destroy
public void destroy()
throws java.lang.Exception
- Specified by:
destroy
in interface org.springframework.beans.factory.DisposableBean
- Throws:
java.lang.Exception
prefersShortLivedTasks
public boolean prefersShortLivedTasks()
execute
public void execute(java.lang.Runnable task)