use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project spring-boot-admin by codecentric.
the class StatusUpdateApplicationListenerTest method test_start_stop.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void test_start_stop() throws Exception {
StatusUpdater statusUpdater = mock(StatusUpdater.class);
ThreadPoolTaskScheduler scheduler = mock(ThreadPoolTaskScheduler.class);
StatusUpdateApplicationListener listener = new StatusUpdateApplicationListener(statusUpdater, scheduler);
ScheduledFuture task = mock(ScheduledFuture.class);
when(scheduler.scheduleAtFixedRate(isA(Runnable.class), eq(10_000L))).thenReturn(task);
listener.onApplicationReady(new ApplicationReadyEvent(mock(SpringApplication.class), null, mock(ConfigurableWebApplicationContext.class)));
verify(scheduler).scheduleAtFixedRate(isA(Runnable.class), eq(10_000L));
listener.onContextClosed(new ContextClosedEvent(mock(EmbeddedWebApplicationContext.class)));
verify(task).cancel(true);
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project Protocol-Adapter-OSLP by OSGP.
the class AutonomousDeviceRegisterConfig method deviceRegistrationTaskScheduler.
@Bean(destroyMethod = "shutdown")
public TaskScheduler deviceRegistrationTaskScheduler() {
final ThreadPoolTaskScheduler deviceRegistrationTaskScheduler = new ThreadPoolTaskScheduler();
deviceRegistrationTaskScheduler.setPoolSize(Integer.parseInt(this.environment.getRequiredProperty(PROPERTY_NAME_AUTONOMOUS_POOL_SIZE)));
deviceRegistrationTaskScheduler.setThreadNamePrefix(this.environment.getRequiredProperty(PROPERTY_NAME_AUTONOMOUS_THREAD_NAME_PREFIX));
deviceRegistrationTaskScheduler.setWaitForTasksToCompleteOnShutdown(false);
return deviceRegistrationTaskScheduler;
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project Protocol-Adapter-OSLP by OSGP.
the class EveningMorningBurnersLightSwitchingOffConfig method eveningMorningBurnerslightSwitchingOffTaskScheduler.
@Bean(destroyMethod = "shutdown")
public TaskScheduler eveningMorningBurnerslightSwitchingOffTaskScheduler() {
final ThreadPoolTaskScheduler eveningMorningBurnerslightSwitchingOffTaskScheduler = new ThreadPoolTaskScheduler();
eveningMorningBurnerslightSwitchingOffTaskScheduler.setPoolSize(Integer.parseInt(this.environment.getRequiredProperty(PROPERTY_NAME_AUTONOMOUS_EVENING_MORNING_BURNER_LIGHTSWITCHING_OFF_POOL_SIZE)));
eveningMorningBurnerslightSwitchingOffTaskScheduler.setThreadNamePrefix(this.environment.getRequiredProperty(PROPERTY_NAME_AUTONOMOUS_EVENING_MORNING_BURNER_LIGHTSWITCHING_OFF_THREAD_NAME_PREFIX));
eveningMorningBurnerslightSwitchingOffTaskScheduler.setWaitForTasksToCompleteOnShutdown(false);
return eveningMorningBurnerslightSwitchingOffTaskScheduler;
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project Protocol-Adapter-OSLP by OSGP.
the class TariffSwitchingHighConfig method tariffSwitchingHighTaskScheduler.
@Bean(destroyMethod = "shutdown")
public TaskScheduler tariffSwitchingHighTaskScheduler() {
final ThreadPoolTaskScheduler tariffSwitchingHighTaskScheduler = new ThreadPoolTaskScheduler();
tariffSwitchingHighTaskScheduler.setPoolSize(Integer.parseInt(this.environment.getRequiredProperty(PROPERTY_NAME_AUTONOMOUS_TARIFFSWITCHING_HIGH_POOL_SIZE)));
tariffSwitchingHighTaskScheduler.setThreadNamePrefix(this.environment.getRequiredProperty(PROPERTY_NAME_AUTONOMOUS_TARIFFSWITCHING_HIGH_THREAD_NAME_PREFIX));
tariffSwitchingHighTaskScheduler.setWaitForTasksToCompleteOnShutdown(false);
return tariffSwitchingHighTaskScheduler;
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project faf-java-server by FAForever.
the class SchedulerConfig method taskScheduler.
// Name is important in order to overwrite Spring's default taskScheduler
@Bean
public ThreadPoolTaskScheduler taskScheduler() {
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
taskScheduler.setPoolSize(1);
taskScheduler.initialize();
return taskScheduler;
}
Aggregations