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

OZG-6280 cleanup async configuration - centre it for test/prod

parent b81c4113
No related tags found
No related merge requests found
...@@ -25,17 +25,11 @@ package de.ozgcloud.alfa; ...@@ -25,17 +25,11 @@ package de.ozgcloud.alfa;
import java.util.TimeZone; import java.util.TimeZone;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.security.concurrent.DelegatingSecurityContextRunnable;
import org.springframework.web.filter.ForwardedHeaderFilter;
@SpringBootApplication @SpringBootApplication
@EnableAsync @EnableAsync
...@@ -48,29 +42,4 @@ public class AlfaServerApplication { ...@@ -48,29 +42,4 @@ public class AlfaServerApplication {
SpringApplication.run(AlfaServerApplication.class, args); SpringApplication.run(AlfaServerApplication.class, args);
} }
@Bean
FilterRegistrationBean<ForwardedHeaderFilter> forwardedHeaderFilter() {
FilterRegistrationBean<ForwardedHeaderFilter> bean = new FilterRegistrationBean<>();
bean.setFilter(new ForwardedHeaderFilter());
return bean;
}
@Bean
ThreadPoolTaskExecutor threadPoolTaskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setThreadNamePrefix("async-");
executor.setTaskDecorator(DelegatingSecurityContextRunnable::new);
return executor;
}
@Bean
CallScope callScope() {
return new CallScope();
}
@Bean
BeanFactoryPostProcessor beanFactoryPostProcessor(CallScope callScope) {
return new CallBeanFactoryPostProcessor(callScope);
}
} }
\ No newline at end of file
...@@ -25,21 +25,11 @@ package de.ozgcloud.alfa; ...@@ -25,21 +25,11 @@ package de.ozgcloud.alfa;
import java.util.TimeZone; import java.util.TimeZone;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.task.ThreadPoolTaskExecutorBuilder;
import org.springframework.boot.task.ThreadPoolTaskExecutorCustomizer;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.Primary;
import org.springframework.core.task.TaskExecutor;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.security.concurrent.DelegatingSecurityContextRunnable;
import org.springframework.web.filter.ForwardedHeaderFilter;
@SpringBootApplication @SpringBootApplication
@EnableAsync @EnableAsync
...@@ -52,46 +42,4 @@ public class AlfaServerApplication { ...@@ -52,46 +42,4 @@ public class AlfaServerApplication {
SpringApplication.run(AlfaServerApplication.class, args); SpringApplication.run(AlfaServerApplication.class, args);
} }
@Bean
ThreadPoolTaskExecutorCustomizer addSecurityContextCustomizer() {
return customizer -> customizer.setTaskDecorator(DelegatingSecurityContextRunnable::new);
}
@Bean
ThreadPoolTaskExecutorCustomizer setThreadName() {
return customizer -> customizer.setThreadNamePrefix("ozgtask-");
}
@Bean("taskExecutor")
@Primary
TaskExecutor taskExecutor(ThreadPoolTaskExecutorBuilder builder) {
return builder.build();
}
// @Bean
FilterRegistrationBean<ForwardedHeaderFilter> forwardedHeaderFilter() {
FilterRegistrationBean<ForwardedHeaderFilter> bean = new FilterRegistrationBean<>();
bean.setFilter(new ForwardedHeaderFilter());
return bean;
}
// @Bean
ThreadPoolTaskExecutor threadPoolTaskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setThreadNamePrefix("async-");
executor.setTaskDecorator(DelegatingSecurityContextRunnable::new);
return executor;
}
@Bean
CallScope callScope() {
return new CallScope();
}
@Bean
BeanFactoryPostProcessor beanFactoryPostProcessor(CallScope callScope) {
return new CallBeanFactoryPostProcessor(callScope);
}
} }
\ No newline at end of file
package de.ozgcloud.alfa;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.boot.task.ThreadPoolTaskExecutorBuilder;
import org.springframework.boot.task.ThreadPoolTaskExecutorCustomizer;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.security.concurrent.DelegatingSecurityContextRunnable;
import org.springframework.web.filter.ForwardedHeaderFilter;
@Configuration
class AsyncConfiguration {
@Bean
ThreadPoolTaskExecutorCustomizer addSecurityContextCustomizer() {
return customizer -> customizer.setTaskDecorator(DelegatingSecurityContextRunnable::new);
}
@Bean
ThreadPoolTaskExecutorCustomizer setThreadName() {
return customizer -> customizer.setThreadNamePrefix("ozgtask-");
}
@Bean("taskExecutor")
@Primary
AsyncTaskExecutor taskExecutor(ThreadPoolTaskExecutorBuilder builder) {
return builder.build();
}
// @Bean
FilterRegistrationBean<ForwardedHeaderFilter> forwardedHeaderFilter() {
FilterRegistrationBean<ForwardedHeaderFilter> bean = new FilterRegistrationBean<>();
bean.setFilter(new ForwardedHeaderFilter());
return bean;
}
// @Bean
ThreadPoolTaskExecutor threadPoolTaskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setThreadNamePrefix("async-");
executor.setTaskDecorator(DelegatingSecurityContextRunnable::new);
return executor;
}
@Bean
CallScope callScope() {
return new CallScope();
}
@Bean
BeanFactoryPostProcessor beanFactoryPostProcessor(CallScope callScope) {
return new CallBeanFactoryPostProcessor(callScope);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment