Commit 1acffdf6 authored by Phillip Webb's avatar Phillip Webb

Polish

parent f3a40e03
/* /*
* Copyright 2014 the original author or authors. * Copyright 2012-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -28,6 +28,7 @@ import org.springframework.boot.actuate.health.RedisHealthIndicator; ...@@ -28,6 +28,7 @@ import org.springframework.boot.actuate.health.RedisHealthIndicator;
import org.springframework.boot.actuate.health.SimpleDataSourceHealthIndicator; import org.springframework.boot.actuate.health.SimpleDataSourceHealthIndicator;
import org.springframework.boot.actuate.health.VanillaHealthIndicator; import org.springframework.boot.actuate.health.VanillaHealthIndicator;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.jdbc.CommonsDataSourceConfiguration; import org.springframework.boot.autoconfigure.jdbc.CommonsDataSourceConfiguration;
...@@ -44,6 +45,8 @@ import org.springframework.data.mongodb.core.MongoTemplate; ...@@ -44,6 +45,8 @@ import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.connection.RedisConnectionFactory;
/** /**
* {@link EnableAutoConfiguration Auto-configuration} for {@link HealthIndicator}s.
*
* @author Christian Dupuis * @author Christian Dupuis
* @since 1.1.0 * @since 1.1.0
*/ */
...@@ -72,14 +75,14 @@ public class HealthIndicatorAutoConfiguration { ...@@ -72,14 +75,14 @@ public class HealthIndicatorAutoConfiguration {
@ConditionalOnMissingBean(name = "dbHealthIndicator") @ConditionalOnMissingBean(name = "dbHealthIndicator")
public HealthIndicator<? extends Object> dbHealthIndicator() { public HealthIndicator<? extends Object> dbHealthIndicator() {
if (this.dataSources.size() == 1) { if (this.dataSources.size() == 1) {
return new SimpleDataSourceHealthIndicator(this.dataSources.values().iterator() return new SimpleDataSourceHealthIndicator(this.dataSources.values()
.next()); .iterator().next());
} }
CompositeHealthIndicator composite = new CompositeHealthIndicator(); CompositeHealthIndicator composite = new CompositeHealthIndicator();
for (Map.Entry<String, DataSource> entry : this.dataSources.entrySet()) { for (Map.Entry<String, DataSource> entry : this.dataSources.entrySet()) {
composite.addHealthIndicator(entry.getKey(), new SimpleDataSourceHealthIndicator( composite.addHealthIndicator(entry.getKey(),
entry.getValue())); new SimpleDataSourceHealthIndicator(entry.getValue()));
} }
return composite; return composite;
} }
......
...@@ -59,9 +59,9 @@ public class HealthEndpoint extends AbstractEndpoint<Map<String, Object>> { ...@@ -59,9 +59,9 @@ public class HealthEndpoint extends AbstractEndpoint<Map<String, Object>> {
* Turns the bean name into a key that can be used in the map of health information. * Turns the bean name into a key that can be used in the map of health information.
*/ */
private String getKey(String name) { private String getKey(String name) {
int x = name.toLowerCase().indexOf("healthindicator"); int index = name.toLowerCase().indexOf("healthindicator");
if (x > 0) { if (index > 0) {
return name.substring(0, x); return name.substring(0, index);
} }
return name; return name;
} }
......
/* /*
* Copyright 2014 the original author or authors. * Copyright 2012-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -20,6 +20,7 @@ import java.util.HashMap; ...@@ -20,6 +20,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.util.Assert;
import com.mongodb.CommandResult; import com.mongodb.CommandResult;
...@@ -35,6 +36,7 @@ public class MongoHealthIndicator implements HealthIndicator<Map<String, Object> ...@@ -35,6 +36,7 @@ public class MongoHealthIndicator implements HealthIndicator<Map<String, Object>
private final MongoTemplate mongoTemplate; private final MongoTemplate mongoTemplate;
public MongoHealthIndicator(MongoTemplate mongoTemplate) { public MongoHealthIndicator(MongoTemplate mongoTemplate) {
Assert.notNull(mongoTemplate, "MongoTemplate must not be null");
this.mongoTemplate = mongoTemplate; this.mongoTemplate = mongoTemplate;
} }
......
/* /*
* Copyright 2014 the original author or authors. * Copyright 2012-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -23,6 +23,7 @@ import java.util.Properties; ...@@ -23,6 +23,7 @@ import java.util.Properties;
import org.springframework.data.redis.connection.RedisConnection; import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisConnectionUtils; import org.springframework.data.redis.core.RedisConnectionUtils;
import org.springframework.util.Assert;
/** /**
* Simple implementation of a {@link HealthIndicator} returning status information for * Simple implementation of a {@link HealthIndicator} returning status information for
...@@ -36,6 +37,7 @@ public class RedisHealthIndicator implements HealthIndicator<Map<String, Object> ...@@ -36,6 +37,7 @@ public class RedisHealthIndicator implements HealthIndicator<Map<String, Object>
private final RedisConnectionFactory redisConnectionFactory; private final RedisConnectionFactory redisConnectionFactory;
public RedisHealthIndicator(RedisConnectionFactory connectionFactory) { public RedisHealthIndicator(RedisConnectionFactory connectionFactory) {
Assert.notNull(connectionFactory, "ConnectionFactory must not be null");
this.redisConnectionFactory = connectionFactory; this.redisConnectionFactory = connectionFactory;
} }
......
/* /*
* Copyright 2014 the original author or authors. * Copyright 2012-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -120,7 +120,7 @@ public class HealthIndicatorAutoConfigurationTests { ...@@ -120,7 +120,7 @@ public class HealthIndicatorAutoConfigurationTests {
Map<String, HealthIndicator> beans = this.context Map<String, HealthIndicator> beans = this.context
.getBeansOfType(HealthIndicator.class); .getBeansOfType(HealthIndicator.class);
assertEquals(1, beans.size()); assertEquals(1, beans.size());
assertEquals(SimpleDataSourceHealthIndicator.class, beans.values().iterator().next() assertEquals(SimpleDataSourceHealthIndicator.class, beans.values().iterator()
.getClass()); .next().getClass());
} }
} }
/* /*
* Copyright 2014 the original author or authors. * Copyright 2012-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
......
/* /*
* Copyright 2014 the original author or authors. * Copyright 2012-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment