From 52d1d04cc129d6df7b54bd41e882e353add0e4ce Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 16 Oct 2017 00:57:29 +0300 Subject: web: move scheduler config to base web config --- .../juick/server/configuration/BaseWebConfiguration.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'juick-server-web/src/main/java/com/juick/server/configuration') diff --git a/juick-server-web/src/main/java/com/juick/server/configuration/BaseWebConfiguration.java b/juick-server-web/src/main/java/com/juick/server/configuration/BaseWebConfiguration.java index efbe66cb..abf8482c 100644 --- a/juick-server-web/src/main/java/com/juick/server/configuration/BaseWebConfiguration.java +++ b/juick-server-web/src/main/java/com/juick/server/configuration/BaseWebConfiguration.java @@ -29,19 +29,23 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.scheduling.annotation.SchedulingConfigurer; +import org.springframework.scheduling.config.ScheduledTaskRegistrar; import org.springframework.web.multipart.MultipartResolver; import org.springframework.web.multipart.commons.CommonsMultipartResolver; import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import java.util.List; +import java.util.concurrent.Executor; +import java.util.concurrent.Executors; /** * Created by vitalyster on 28.06.2016. */ @Import(DataConfiguration.class) @Configuration -public class BaseWebConfiguration implements WebMvcConfigurer { +public class BaseWebConfiguration implements WebMvcConfigurer, SchedulingConfigurer { @Override @@ -76,4 +80,13 @@ public class BaseWebConfiguration implements WebMvcConfigurer { public ImagesService imagesService() { return new ImagesServiceImpl(); } + @Override + public void configureTasks(ScheduledTaskRegistrar taskRegistrar) { + taskRegistrar.setScheduler(taskExecutor()); + } + + @Bean(destroyMethod="shutdown") + public Executor taskExecutor() { + return Executors.newScheduledThreadPool(100); + } } -- cgit v1.2.3