本文整理汇总了Java中org.springframework.scheduling.config.ScheduledTaskRegistrar.setScheduler方法的典型用法代码示例。如果您正苦于以下问题:Java ScheduledTaskRegistrar.setScheduler方法的具体用法?Java ScheduledTaskRegistrar.setScheduler怎么用?Java ScheduledTaskRegistrar.setScheduler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.scheduling.config.ScheduledTaskRegistrar
的用法示例。
在下文中一共展示了ScheduledTaskRegistrar.setScheduler方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureTasks
import org.springframework.scheduling.config.ScheduledTaskRegistrar; //导入方法依赖的package包/类
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
if (properties.isEnabled()) {
TaskScheduler taskScheduler = null;
try {
taskScheduler = this.beanFactory.getBean(TaskScheduler.class);
} catch (NoUniqueBeanDefinitionException e) {
taskScheduler = this.beanFactory.getBean("taskScheduler", TaskScheduler.class);
} catch (NoSuchBeanDefinitionException ex) {
log.warn("'useExistingScheduler' was configured to 'true', but we did not find any bean.");
}
if (taskScheduler != null) {
log.info("register existing TaskScheduler");
taskRegistrar.setScheduler(taskScheduler);
} else {
throw new BeanCreationException("Expecting a 'ConcurrentTaskScheduler' injected, but was 'null'");
}
} else {
log.info("'CustomSchedulingConfiguration' is disabled, create a default - 'ConcurrentTaskScheduler'");
this.localExecutor = Executors.newSingleThreadScheduledExecutor();
taskRegistrar.setScheduler(new ConcurrentTaskScheduler(localExecutor));
}
}
示例2: configureTasks
import org.springframework.scheduling.config.ScheduledTaskRegistrar; //导入方法依赖的package包/类
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
taskRegistrar.setScheduler(taskScheduler());
taskRegistrar.addTriggerTask(
new Runnable() {
public void run() {
try {
scheduledTasks().calculateWinner();
} catch (MessagingException e) {
LOGGER.error("Fault while calculating winner!", e);
}
}
},
new CronTrigger(winnerCalculationCron)
);
}
示例3: configureTasks
import org.springframework.scheduling.config.ScheduledTaskRegistrar; //导入方法依赖的package包/类
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
taskRegistrar.setScheduler(taskExecutor());
}
示例4: configureTasks
import org.springframework.scheduling.config.ScheduledTaskRegistrar; //导入方法依赖的package包/类
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
taskRegistrar.setScheduler(taskExecutor());
}
示例5: configureTasks
import org.springframework.scheduling.config.ScheduledTaskRegistrar; //导入方法依赖的package包/类
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
taskRegistrar.setScheduler(taskScheduler());
taskRegistrar.addFixedRateTask(new IntervalTask(
new Runnable() {
@Override
public void run() {
worker().executedByThread = Thread.currentThread().getName();
}
},
10, 0));
}
示例6: configureTasks
import org.springframework.scheduling.config.ScheduledTaskRegistrar; //导入方法依赖的package包/类
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
taskRegistrar.setScheduler(taskScheduler());
}
示例7: configureTasks
import org.springframework.scheduling.config.ScheduledTaskRegistrar; //导入方法依赖的package包/类
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
taskRegistrar.setScheduler(Executors.newScheduledThreadPool(1));
}
示例8: configureTasks
import org.springframework.scheduling.config.ScheduledTaskRegistrar; //导入方法依赖的package包/类
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
taskRegistrar.setScheduler(taskScheduler());
}