Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
f9aeb6ae
Commit
f9aeb6ae
authored
May 22, 2014
by
Christian Dupuis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
344fb461
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
56 additions
and
45 deletions
+56
-45
EndpointWebMvcAutoConfiguration.java
...ctuate/autoconfigure/EndpointWebMvcAutoConfiguration.java
+26
-19
HealthMvcEndpointProperties.java
...ot/actuate/autoconfigure/HealthMvcEndpointProperties.java
+1
-1
HealthEndpoint.java
...springframework/boot/actuate/endpoint/HealthEndpoint.java
+2
-1
CompositeHealthIndicator.java
...amework/boot/actuate/health/CompositeHealthIndicator.java
+1
-1
Health.java
.../java/org/springframework/boot/actuate/health/Health.java
+4
-4
HealthAggregator.java
...springframework/boot/actuate/health/HealthAggregator.java
+3
-3
HealthIndicator.java
.../springframework/boot/actuate/health/HealthIndicator.java
+1
-1
MongoHealthIndicator.java
...ngframework/boot/actuate/health/MongoHealthIndicator.java
+1
-1
OrderedHealthAggregator.java
...ramework/boot/actuate/health/OrderedHealthAggregator.java
+6
-4
RabbitHealthIndicator.java
...gframework/boot/actuate/health/RabbitHealthIndicator.java
+1
-1
RedisHealthIndicator.java
...ngframework/boot/actuate/health/RedisHealthIndicator.java
+1
-1
SimpleDataSourceHealthIndicator.java
.../boot/actuate/health/SimpleDataSourceHealthIndicator.java
+5
-3
Status.java
.../java/org/springframework/boot/actuate/health/Status.java
+3
-3
VanillaHealthIndicator.java
...framework/boot/actuate/health/VanillaHealthIndicator.java
+1
-2
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.java
View file @
f9aeb6ae
...
...
@@ -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
<
ContextRefreshedEvent
>
{
...
...
@@ -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
<
ContextClosedEvent
>()
{
((
ConfigurableApplicationContext
)
this
.
applicationContext
)
.
addApplicationListener
(
new
ApplicationListener
<
ContextClosedEvent
>()
{
@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=<different>,
// 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
();
}
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/HealthMvcEndpointProperties.java
View file @
f9aeb6ae
...
...
@@ -25,7 +25,7 @@ import org.springframework.http.HttpStatus;
/**
* Configuration properties for the {@link HealthMvcEndpoint}.
*
*
* @author Christian Dupuis
* @since 1.1.0
*/
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/HealthEndpoint.java
View file @
f9aeb6ae
...
...
@@ -48,7 +48,8 @@ public class HealthEndpoint extends AbstractEndpoint<Health> {
if
(
healthIndicators
.
size
()
==
1
)
{
this
.
healthIndicator
=
healthIndicators
.
values
().
iterator
().
next
();
}
else
{
}
else
{
CompositeHealthIndicator
healthIndicator
=
new
CompositeHealthIndicator
(
healthAggregator
);
for
(
Map
.
Entry
<
String
,
HealthIndicator
>
h
:
healthIndicators
.
entrySet
())
{
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeHealthIndicator.java
View file @
f9aeb6ae
...
...
@@ -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
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/Health.java
View file @
f9aeb6ae
...
...
@@ -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.
*
*
* <p>
* {@link Health} contains a {@link Status} to express the state of a component or
* subsystem and some additional details to carry some contextual information.
*
*
* <p>
* {@link Health} has a fluent API to make it easy to construct instances. Typical usage
* in a {@link HealthIndicator} would be:
*
*
* <code>
* Health health = new Health();
* try {
...
...
@@ -52,7 +52,7 @@ import com.fasterxml.jackson.annotation.JsonUnwrapped;
* }
* return health;
* </code>
*
*
* @author Christian Dupuis
* @since 1.1.0
*/
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthAggregator.java
View file @
f9aeb6ae
...
...
@@ -21,18 +21,18 @@ import java.util.Map;
/**
* Strategy interface used by {@link CompositeHealthIndicator} to aggregate {@link Health}
* instances into a final one.
*
*
* <p>
* 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.
*
*
* <p>
* 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
*/
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthIndicator.java
View file @
f9aeb6ae
...
...
@@ -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
*/
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/MongoHealthIndicator.java
View file @
f9aeb6ae
...
...
@@ -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
*/
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/OrderedHealthAggregator.java
View file @
f9aeb6ae
...
...
@@ -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.
*
*
* <p>
* 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
())));
}
});
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/RabbitHealthIndicator.java
View file @
f9aeb6ae
...
...
@@ -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
*/
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/RedisHealthIndicator.java
View file @
f9aeb6ae
...
...
@@ -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
*/
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/SimpleDataSourceHealthIndicator.java
View file @
f9aeb6ae
...
...
@@ -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
);
}
}
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/Status.java
View file @
f9aeb6ae
...
...
@@ -25,14 +25,14 @@ import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Value object to express state of a component or subsystem.
*
*
* <p>
* Status provides convenient constants for commonly used states like {@link #UP},
* {@link #DOWN} or {@link #OUT_OF_SERVICE}.
*
*
* <p>
* Custom states can also be created and used throughout the Spring Boot Health subsystem.
*
*
* @author Christian Dupuis
* @since 1.1.0
*/
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/VanillaHealthIndicator.java
View file @
f9aeb6ae
...
...
@@ -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
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment