From f9aeb6aefe6773ab958b86e9965cf956ac0995b0 Mon Sep 17 00:00:00 2001 From: Christian Dupuis Date: Thu, 22 May 2014 17:31:31 +0200 Subject: [PATCH] Polish --- .../EndpointWebMvcAutoConfiguration.java | 45 +++++++++++-------- .../HealthMvcEndpointProperties.java | 2 +- .../boot/actuate/endpoint/HealthEndpoint.java | 3 +- .../health/CompositeHealthIndicator.java | 2 +- .../boot/actuate/health/Health.java | 8 ++-- .../boot/actuate/health/HealthAggregator.java | 6 +-- .../boot/actuate/health/HealthIndicator.java | 2 +- .../actuate/health/MongoHealthIndicator.java | 2 +- .../health/OrderedHealthAggregator.java | 10 +++-- .../actuate/health/RabbitHealthIndicator.java | 2 +- .../actuate/health/RedisHealthIndicator.java | 2 +- .../SimpleDataSourceHealthIndicator.java | 8 ++-- .../boot/actuate/health/Status.java | 6 +-- .../health/VanillaHealthIndicator.java | 3 +- 14 files changed, 56 insertions(+), 45 deletions(-) diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.java index 7517c9a0b31..af58b432d38 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.java @@ -75,7 +75,7 @@ import org.springframework.web.servlet.DispatcherServlet; * different port to {@link ServerProperties} a new child context is created, otherwise it * is assumed that endpoint requests will be mapped and handled via an already registered * {@link DispatcherServlet}. - * + * * @author Dave Syer * @author Phillip Webb * @author Christian Dupuis @@ -84,8 +84,8 @@ import org.springframework.web.servlet.DispatcherServlet; @ConditionalOnClass({ Servlet.class, DispatcherServlet.class }) @ConditionalOnWebApplication @AutoConfigureAfter({ PropertyPlaceholderAutoConfiguration.class, - EmbeddedServletContainerAutoConfiguration.class, WebMvcAutoConfiguration.class, - ManagementServerPropertiesAutoConfiguration.class }) + EmbeddedServletContainerAutoConfiguration.class, WebMvcAutoConfiguration.class, + ManagementServerPropertiesAutoConfiguration.class }) @EnableConfigurationProperties(HealthMvcEndpointProperties.class) public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware, ApplicationListener { @@ -109,8 +109,8 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware, @Bean @ConditionalOnMissingBean public EndpointHandlerMapping endpointHandlerMapping() { - EndpointHandlerMapping mapping = new EndpointHandlerMapping( - mvcEndpoints().getEndpoints()); + EndpointHandlerMapping mapping = new EndpointHandlerMapping(mvcEndpoints() + .getEndpoints()); boolean disabled = ManagementServerPort.get(this.applicationContext) != ManagementServerPort.SAME; mapping.setDisabled(disabled); if (!disabled) { @@ -169,7 +169,8 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware, public HealthMvcEndpoint healthMvcEndpoint(HealthEndpoint delegate) { HealthMvcEndpoint healthMvcEndpoint = new HealthMvcEndpoint(delegate); if (this.healthMvcEndpointProperties.getMapping() != null) { - healthMvcEndpoint.setStatusMapping(this.healthMvcEndpointProperties.getMapping()); + healthMvcEndpoint.setStatusMapping(this.healthMvcEndpointProperties + .getMapping()); } return healthMvcEndpoint; } @@ -205,25 +206,28 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware, // Ensure close on the parent also closes the child if (this.applicationContext instanceof ConfigurableApplicationContext) { - ((ConfigurableApplicationContext) this.applicationContext).addApplicationListener(new ApplicationListener() { + ((ConfigurableApplicationContext) this.applicationContext) + .addApplicationListener(new ApplicationListener() { - @Override - public void onApplicationEvent(ContextClosedEvent event) { - if (event.getApplicationContext() == EndpointWebMvcAutoConfiguration.this.applicationContext) { - childContext.close(); - } - } - }); + @Override + public void onApplicationEvent(ContextClosedEvent event) { + if (event.getApplicationContext() == EndpointWebMvcAutoConfiguration.this.applicationContext) { + childContext.close(); + } + } + }); } try { childContext.refresh(); - } catch (RuntimeException ex) { + } + catch (RuntimeException ex) { // No support currently for deploying a war with management.port=, // and this is the signature of that happening if (ex instanceof EmbeddedServletContainerException || ex.getCause() instanceof EmbeddedServletContainerException) { logger.warn("Could not start embedded container (management endpoints are still available through JMX)"); - } else { + } + else { throw ex; } } @@ -238,14 +242,17 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware, ServerProperties serverProperties; try { serverProperties = beanFactory.getBean(ServerProperties.class); - } catch (NoSuchBeanDefinitionException ex) { + } + catch (NoSuchBeanDefinitionException ex) { serverProperties = new ServerProperties(); } ManagementServerProperties managementServerProperties; try { - managementServerProperties = beanFactory.getBean(ManagementServerProperties.class); - } catch (NoSuchBeanDefinitionException ex) { + managementServerProperties = beanFactory + .getBean(ManagementServerProperties.class); + } + catch (NoSuchBeanDefinitionException ex) { managementServerProperties = new ManagementServerProperties(); } diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/HealthMvcEndpointProperties.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/HealthMvcEndpointProperties.java index 7b147adac97..6b1fa9077b8 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/HealthMvcEndpointProperties.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/HealthMvcEndpointProperties.java @@ -25,7 +25,7 @@ import org.springframework.http.HttpStatus; /** * Configuration properties for the {@link HealthMvcEndpoint}. - * + * * @author Christian Dupuis * @since 1.1.0 */ diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/HealthEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/HealthEndpoint.java index bfaf672e8c4..1bcecedc452 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/HealthEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/HealthEndpoint.java @@ -48,7 +48,8 @@ public class HealthEndpoint extends AbstractEndpoint { if (healthIndicators.size() == 1) { this.healthIndicator = healthIndicators.values().iterator().next(); - } else { + } + else { CompositeHealthIndicator healthIndicator = new CompositeHealthIndicator( healthAggregator); for (Map.Entry h : healthIndicators.entrySet()) { diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeHealthIndicator.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeHealthIndicator.java index 4de09d72283..616f8dec082 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeHealthIndicator.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeHealthIndicator.java @@ -23,7 +23,7 @@ import org.springframework.util.Assert; /** * {@link HealthIndicator} that returns health indications from all registered delegates. - * + * * @author Tyler J. Frederick * @author Phillip Webb * @author Christian Dupuis diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/Health.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/Health.java index e9540c7c422..53314304c8c 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/Health.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/Health.java @@ -31,15 +31,15 @@ import com.fasterxml.jackson.annotation.JsonUnwrapped; /** * Value object used to carry information about the health information of a component or * subsystem. - * + * *

* {@link Health} contains a {@link Status} to express the state of a component or * subsystem and some additional details to carry some contextual information. - * + * *

* {@link Health} has a fluent API to make it easy to construct instances. Typical usage * in a {@link HealthIndicator} would be: - * + * * * Health health = new Health(); * try { @@ -52,7 +52,7 @@ import com.fasterxml.jackson.annotation.JsonUnwrapped; * } * return health; * - * + * * @author Christian Dupuis * @since 1.1.0 */ diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthAggregator.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthAggregator.java index 0a0283d4cc8..3bfc7ba9944 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthAggregator.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthAggregator.java @@ -21,18 +21,18 @@ import java.util.Map; /** * Strategy interface used by {@link CompositeHealthIndicator} to aggregate {@link Health} * instances into a final one. - * + * *

* This is especially useful to combine subsystem states expressed through * {@link Health#getStatus()} into one state for the entire system. The default * implementation {@link OrderedHealthAggregator} sorts {@link Status} instances based on * a priority list. - * + * *

* It is possible to add more complex {@link Status} types to the system. In that case * either the {@link OrderedHealthAggregator} needs to be properly configured or users * need to register a custom {@link HealthAggregator} as bean. - * + * * @author Christian Dupuis * @since 1.1.0 */ diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthIndicator.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthIndicator.java index a39f5724984..5f5e7060f9e 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthIndicator.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthIndicator.java @@ -18,7 +18,7 @@ package org.springframework.boot.actuate.health; /** * Strategy interface used to provide an indication of application health. - * + * * @author Dave Syer * @see VanillaHealthIndicator */ diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/MongoHealthIndicator.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/MongoHealthIndicator.java index e6364923fa6..729ff1ce52e 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/MongoHealthIndicator.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/MongoHealthIndicator.java @@ -24,7 +24,7 @@ import com.mongodb.CommandResult; /** * Simple implementation of a {@link HealthIndicator} returning status information for * Mongo data stores. - * + * * @author Christian Dupuis * @since 1.1.0 */ diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/OrderedHealthAggregator.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/OrderedHealthAggregator.java index db37ecebf95..0ca86f4b54a 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/OrderedHealthAggregator.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/OrderedHealthAggregator.java @@ -26,11 +26,11 @@ import java.util.Map; /** * Default {@link HealthAggregator} implementation that aggregates {@link Health} * instances and determines the final system state based on a simple ordered list. - * + * *

* If a different order is required or a new {@link Status} type will be used, the order * can be set by calling {@link #setStatusOrder(List)}. - * + * * @author Christian Dupuis * @since 1.1.0 */ @@ -67,8 +67,10 @@ public class OrderedHealthAggregator implements HealthAggregator { @Override public int compare(Status s1, Status s2) { return Integer.valueOf( - OrderedHealthAggregator.this.statusOrder.indexOf(s1.getCode())).compareTo( - Integer.valueOf(OrderedHealthAggregator.this.statusOrder.indexOf(s2.getCode()))); + OrderedHealthAggregator.this.statusOrder.indexOf(s1.getCode())) + .compareTo( + Integer.valueOf(OrderedHealthAggregator.this.statusOrder + .indexOf(s2.getCode()))); } }); diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/RabbitHealthIndicator.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/RabbitHealthIndicator.java index 771d8563985..366475cd4ca 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/RabbitHealthIndicator.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/RabbitHealthIndicator.java @@ -27,7 +27,7 @@ import com.rabbitmq.client.Channel; /** * Simple implementation of a {@link HealthIndicator} returning status information for the * RabbitMQ messaging system. - * + * * @author Christian Dupuis * @since 1.1.0 */ diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/RedisHealthIndicator.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/RedisHealthIndicator.java index 86d529fe916..ce44e574f2f 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/RedisHealthIndicator.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/RedisHealthIndicator.java @@ -26,7 +26,7 @@ import org.springframework.util.Assert; /** * Simple implementation of a {@link HealthIndicator} returning status information for * Redis data stores. - * + * * @author Christian Dupuis * @since 1.1.0 */ diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/SimpleDataSourceHealthIndicator.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/SimpleDataSourceHealthIndicator.java index 0e4ddaddc5b..d61615a820b 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/SimpleDataSourceHealthIndicator.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/SimpleDataSourceHealthIndicator.java @@ -31,7 +31,7 @@ import org.springframework.util.StringUtils; /** * Simple implementation of {@link HealthIndicator} that returns a status and also * attempts a simple database test. - * + * * @author Dave Syer * @author Christian Dupuis */ @@ -88,7 +88,8 @@ public class SimpleDataSourceHealthIndicator implements HealthIndicator { } }); health.withDetail("database", product); - } catch (DataAccessException ex) { + } + catch (DataAccessException ex) { health.down().withException(ex); } String query = detectQuery(product); @@ -96,7 +97,8 @@ public class SimpleDataSourceHealthIndicator implements HealthIndicator { try { health.withDetail("hello", this.jdbcTemplate.queryForObject(query, Object.class)); - } catch (Exception ex) { + } + catch (Exception ex) { health.down().withException(ex); } } diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/Status.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/Status.java index d5a9443d199..34566edbc51 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/Status.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/Status.java @@ -25,14 +25,14 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** * Value object to express state of a component or subsystem. - * + * *

* Status provides convenient constants for commonly used states like {@link #UP}, * {@link #DOWN} or {@link #OUT_OF_SERVICE}. - * + * *

* Custom states can also be created and used throughout the Spring Boot Health subsystem. - * + * * @author Christian Dupuis * @since 1.1.0 */ diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/VanillaHealthIndicator.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/VanillaHealthIndicator.java index d2370a18c7a..aa042d42c36 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/VanillaHealthIndicator.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/VanillaHealthIndicator.java @@ -16,10 +16,9 @@ package org.springframework.boot.actuate.health; - /** * Default implementation of {@link HealthIndicator} that simply returns {@literal "ok"}. - * + * * @author Dave Syer * @author Christian Dupuis */