Skip to content
Snippets Groups Projects
Commit d6841e7a authored by OZGCloud's avatar OZGCloud
Browse files

fix configuration of async task executor for web request handling

parent 1e3af466
No related branches found
No related tags found
No related merge requests found
...@@ -26,9 +26,12 @@ package de.ozgcloud.alfa; ...@@ -26,9 +26,12 @@ package de.ozgcloud.alfa;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.http.CacheControl; import org.springframework.http.CacheControl;
import org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.resource.PathResourceResolver; import org.springframework.web.servlet.resource.PathResourceResolver;
...@@ -40,6 +43,9 @@ public class WebConfig implements WebMvcConfigurer { ...@@ -40,6 +43,9 @@ public class WebConfig implements WebMvcConfigurer {
private static final String RESOURCE_LOCATION = "classpath:/META-INF/resources/"; private static final String RESOURCE_LOCATION = "classpath:/META-INF/resources/";
@Autowired
private AsyncTaskExecutor threadPoolTaskExecutor;
@Override @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) { public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/*.js", "/*.css", "/*.ttf", "/*.woff", "/*.woff2", "/*.eot", registry.addResourceHandler("/*.js", "/*.css", "/*.ttf", "/*.woff", "/*.woff2", "/*.eot",
...@@ -57,6 +63,11 @@ public class WebConfig implements WebMvcConfigurer { ...@@ -57,6 +63,11 @@ public class WebConfig implements WebMvcConfigurer {
.addResolver(new OzgCloudPathResourceResolver()); .addResolver(new OzgCloudPathResourceResolver());
} }
@Override
public void configureAsyncSupport(AsyncSupportConfigurer configurer) {
configurer.setTaskExecutor(threadPoolTaskExecutor);
}
@NoArgsConstructor @NoArgsConstructor
static class OzgCloudPathResourceResolver extends PathResourceResolver { static class OzgCloudPathResourceResolver extends PathResourceResolver {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment