All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.bund.bva.isyfact.ueberwachung.autoconfigure.IsyUeberwachungAutoConfiguration Maven / Gradle / Ivy

There is a newer version: 3.2.1
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy