de.bund.bva.isyfact.ueberwachung.autoconfigure.IsyUeberwachungAutoConfiguration Maven / Gradle / Ivy
package de.bund.bva.isyfact.ueberwachung.autoconfigure;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletRegistration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import de.bund.bva.isyfact.ueberwachung.config.LoadbalancerSecurityConfiguration;
import de.bund.bva.isyfact.ueberwachung.config.LoadbalancerServletConfigurationProperties;
import de.bund.bva.isyfact.ueberwachung.service.loadbalancer.LoadbalancerServlet;
@Configuration
@EnableConfigurationProperties
@ConditionalOnClass(ServletRegistration.class)
@Import(LoadbalancerSecurityConfiguration.class)
public class IsyUeberwachungAutoConfiguration {
@Bean
@ConfigurationProperties(prefix = "isy.ueberwachung.loadbalancer")
public LoadbalancerServletConfigurationProperties loadbalancerServletConfigurationProperties() {
return new LoadbalancerServletConfigurationProperties();
}
@Bean
public ServletRegistrationBean loadbalancerservlet(
LoadbalancerServletConfigurationProperties properties) {
ServletRegistrationBean loadbalancerServlet =
new ServletRegistrationBean<>(new LoadbalancerServlet());
loadbalancerServlet.setLoadOnStartup(1);
loadbalancerServlet.addUrlMappings(LoadbalancerSecurityConfiguration.LOADBALANCER_SERVLET_PATH);
Map initParameters = new HashMap<>();
initParameters.put("isAliveFileLocation", properties.getIsAliveFileLocation());
loadbalancerServlet.setInitParameters(initParameters);
return loadbalancerServlet;
}
}