Java Code Examples for org.springframework.scheduling.config.ScheduledTaskRegistrar#setScheduler()

The following examples show how to use org.springframework.scheduling.config.ScheduledTaskRegistrar#setScheduler() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomSchedulingConfiguration.java    From booties with Apache License 2.0 6 votes vote down vote up
@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));
    }
}
 
Example 2
Source File: EnableSchedulingTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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));
}
 
Example 3
Source File: ScheduledConfig2.java    From SpringBoot2.0 with Apache License 2.0 5 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
    taskRegistrar.setScheduler(taskExecutor());
    taskRegistrar.addTriggerTask(
            () -> myTask().work(),
            new CustomTrigger()
    );
}
 
Example 4
Source File: EnableSchedulingTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@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));
}
 
Example 5
Source File: AsyncConfiguration.java    From tutorials with MIT License 4 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
    taskRegistrar.setScheduler(scheduledTaskExecutor());
}
 
Example 6
Source File: TestConfiguration.java    From bugsnag-java with MIT License 4 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
    taskRegistrar.setScheduler(scheduler());
}
 
Example 7
Source File: AsyncConfiguration.java    From tutorials with MIT License 4 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
    taskRegistrar.setScheduler(scheduledTaskExecutor());
}
 
Example 8
Source File: Application.java    From ic with MIT License 4 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
    taskRegistrar.setScheduler(taskExecutor());
}
 
Example 9
Source File: SchedulingConfig.java    From OneBlog with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
    // 指定使用自定义的调度器
    scheduledTaskRegistrar.setScheduler(newExecutors());
}
 
Example 10
Source File: AsyncConfiguration.java    From okta-jhipster-microservices-oauth-example with Apache License 2.0 4 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
    taskRegistrar.setScheduler(scheduledTaskExecutor());
}
 
Example 11
Source File: AsyncConfiguration.java    From okta-jhipster-microservices-oauth-example with Apache License 2.0 4 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
    taskRegistrar.setScheduler(scheduledTaskExecutor());
}
 
Example 12
Source File: EnableSchedulingTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
	taskRegistrar.setScheduler(taskScheduler2());
}
 
Example 13
Source File: EnableSchedulingTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
	taskRegistrar.setScheduler(taskScheduler1());
}
 
Example 14
Source File: TaskConfig.java    From spring-boot-demo with MIT License 4 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
    taskRegistrar.setScheduler(taskExecutor());
}
 
Example 15
Source File: EnableSchedulingTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
	taskRegistrar.setScheduler(taskScheduler1());
}
 
Example 16
Source File: ScheduleConfig.java    From rocketmq-exporter with Apache License 2.0 4 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
    taskRegistrar.setScheduler(taskExecutor());
}
 
Example 17
Source File: ThreadConfig.java    From tutorials with MIT License 4 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
    scheduledTaskRegistrar.setScheduler(schedulingExecutor());
}
 
Example 18
Source File: AsyncConfiguration.java    From tutorials with MIT License 4 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
    taskRegistrar.setScheduler(scheduledTaskExecutor());
}
 
Example 19
Source File: EnableSchedulingTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
	taskRegistrar.setScheduler(taskScheduler2());
}
 
Example 20
Source File: AsyncConfiguration.java    From e-commerce-microservice with Apache License 2.0 4 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
    taskRegistrar.setScheduler(scheduledTaskExecutor());
}