package org.atlasapi.system;

import java.util.Collection;

import javax.annotation.PostConstruct;

import org.atlasapi.AtlasPersistenceModule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.codahale.metrics.MetricRegistry;
import com.google.common.collect.ImmutableList;
import com.metabroadcast.common.health.HealthProbe;
import com.metabroadcast.common.health.probes.MemoryInfoProbe;
import com.metabroadcast.common.persistence.cassandra.health.CassandraProbe;
import com.metabroadcast.common.webapp.health.HealthController;
import com.metabroadcast.common.webapp.health.probes.MetricsProbe;

@Configuration
public class HealthModule {

    private static final MetricRegistry metrics = new MetricRegistry();

    private @Autowired Collection<HealthProbe> probes;
    private @Autowired HealthController healthController;
    private @Autowired AtlasPersistenceModule persistenceModule;

    public @Bean HealthController healthController() {
        return new HealthController(ImmutableList.of(
                new MemoryInfoProbe()
        ));
    }

    public @Bean org.atlasapi.system.HealthController threadController() {
        return new org.atlasapi.system.HealthController(null);
    }

    public @Bean HealthProbe metricsProbe() {
        return new MetricsProbe("Metrics", metrics());
    }

    public @Bean MetricRegistry metrics() {
        return metrics;
    }

    @PostConstruct
    public void addProbes() {
        healthController.addProbes(ImmutableList.of(
                new CassandraProbe(persistenceModule.persistenceModule().getSession())
        ));
        healthController.addProbes(probes);
    }
}

@@ -97,52 +97,8 @@
 t;%0A%0A
-import org.atlasapi.AtlasPersistenceModule;%0A
 impo
@@ -156,16 +156,16 @@
 owired;%0A
+
 import o
@@ -481,85 +481,8 @@
 be;%0A
-import com.metabroadcast.common.persistence.cassandra.health.CassandraProbe;%0A
 impo
@@ -838,24 +838,113 @@
 troller;%0A   
+ // TODO There is a circular dependency here. Extract metrics to their own modules%0A    //
  private @Au
@@ -1533,24 +1533,26 @@
 dProbes() %7B%0A
+//
         heal
@@ -1584,32 +1584,34 @@
 mutableList.of(%0A
+//
                 
@@ -1681,16 +1681,18 @@
 sion())%0A
+//
         

Disable change due to circular dependency