package org.holer.server.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;

@Configuration
public class SchedulerConfig
  implements SchedulingConfigurer
{
  private final int HOLER_POOL_SIZE = 5;
  private final String HOLER_NAME_PREFIX = "Holer-Task-";

  public void configureTasks(ScheduledTaskRegistrar registrar) {
    ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
    taskScheduler.setPoolSize(HOLER_POOL_SIZE);
    taskScheduler.setThreadNamePrefix(HOLER_NAME_PREFIX);
    taskScheduler.initialize();
    registrar.setTaskScheduler(taskScheduler);
  }
}
