package ru.yandex.market.graphouse.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.jdbc.core.JdbcTemplate;
import ru.yandex.market.graphouse.AutoHideService;
import ru.yandex.market.graphouse.monitoring.Monitoring;
import ru.yandex.market.graphouse.search.MetricSearch;

/**
 * @author Vlad Vinogradov <a href="mailto:vladvin@yandex-team.ru"></a> on 12.01.17
 */
@Configuration
@PropertySource(value = "classpath:graphouse-default.properties")
@PropertySource(
    value = {
        "file:${app.home}/conf/graphouse.properties",
        "file:${app.home}/conf/local-application.properties",
        "classpath:local-application.properties"
    },
    ignoreResourceNotFound = true
)
@Import({DbConfig.class, MetricsConfig.class, ServerConfig.class,
    StatisticsConfig.class, StatisticsCountersConfig.class})
public class GraphouseConfig {

    @Autowired
    private MetricSearch metricSearch;

    @Autowired
    private JdbcTemplate clickHouseJdbcTemplate;

    @Bean
    @Primary
    public Monitoring monitoring() {
        return new Monitoring();
    }

    @Bean
    public Monitoring ping(){
        return new Monitoring();
    }

    @Bean(initMethod = "startService")
    public AutoHideService autoHideService() {
        return new AutoHideService(clickHouseJdbcTemplate, metricSearch);
    }

    @Bean
    public static PropertySourcesPlaceholderConfigurer propertyConfigInDev() {
        return new PropertySourcesPlaceholderConfigurer();
    }

}

@@ -1368,16 +1368,24 @@
 Template
+Autohide
 ;%0A%0A    @
@@ -1517,16 +1517,17 @@
 g ping()
+ 
 %7B%0A      
@@ -1703,16 +1703,24 @@
 Template
+Autohide
 , metric

Fix JdbcTemplate injection in GraphouseConfig (#156)