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

io.hawt.springboot.HawtioAutoConfiguration Maven / Gradle / Ivy

There is a newer version: 4.2.0
Show newest version
package io.hawt.springboot;

import java.util.HashMap;
import java.util.Map;

import org.springframework.boot.actuate.autoconfigure.ManagementServerProperties;
import org.springframework.boot.actuate.condition.ConditionalOnEnabledEndpoint;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import io.hawt.system.ConfigManager;

/**
 * Configuration for hawtio on Spring Boot.
 */
@Configuration
@ConditionalOnWebApplication
@ConditionalOnEnabledEndpoint("hawtio")
@PropertySource("classpath:/io/hawt/springboot/application.properties")
@EnableConfigurationProperties
public class HawtioAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public HawtioEndpoint hawtioEndpoint(
            final ManagementServerProperties managementServerProperties) {
        return new HawtioEndpoint(managementServerProperties.getContextPath());
    }

    @Bean
    public ConfigManager hawtioConfigManager(
            final HawtioProperties hawtioProperties) {
        return new ConfigManager(hawtioProperties.get()::get);
    }

    @Bean
    public HawtioProperties hawtioProperties() {
        return new HawtioProperties(hawtioConfigurationProperties().getHawtio());
    }

    @Bean
    @ConfigurationProperties
    protected HawtioConfigurationProperties hawtioConfigurationProperties() {
        return new HawtioConfigurationProperties();
    }

    protected static class HawtioConfigurationProperties {

        private final Map hawtio = new HashMap<>();

        public Map getHawtio() {
            return hawtio;
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy