package com.jasamedika.medifirst2000.task.schedule.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.web.client.RestTemplate;

/**
 * @author Salman
 * @since 12 Jul 2023
 */
@Configuration
@EnableScheduling
@ComponentScan("com.jasamedika.medifirst2000.task")
public class ScheduleTaskConfig {

	@Bean
	public TaskScheduler taskScheduler() {
		ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
		threadPoolTaskScheduler.setPoolSize(50);
		threadPoolTaskScheduler.setThreadNamePrefix("BridgingThreadPoolTaskScheduler");
		return threadPoolTaskScheduler;
	}

	@Bean
	public ObjectMapper objectMapper() {
		return new ObjectMapper();
	}

	@Bean
	public RestTemplate restTemplate() {
		return new RestTemplate();
	}
}
