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
bee651fc
Commit
bee651fc
authored
Feb 24, 2016
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.3.x'
parents
852ba546
13971692
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
5 deletions
+39
-5
EndpointWebMvcHypermediaManagementContextConfiguration.java
...dpointWebMvcHypermediaManagementContextConfiguration.java
+25
-3
ConditionalOnEnabledEndpoint.java
.../boot/actuate/condition/ConditionalOnEnabledEndpoint.java
+2
-2
EndpointWebMvcAutoConfigurationTests.java
...e/autoconfigure/EndpointWebMvcAutoConfigurationTests.java
+12
-0
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcHypermediaManagementContextConfiguration.java
View file @
bee651fc
...
...
@@ -32,6 +32,8 @@ import com.fasterxml.jackson.annotation.JsonUnwrapped;
import
com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.actuate.autoconfigure.EndpointWebMvcHypermediaManagementContextConfiguration.EndpointHypermediaEnabledCondition
;
import
org.springframework.boot.actuate.condition.ConditionalOnEnabledEndpoint
;
import
org.springframework.boot.actuate.endpoint.mvc.DocsMvcEndpoint
;
import
org.springframework.boot.actuate.endpoint.mvc.HalBrowserMvcEndpoint
;
import
org.springframework.boot.actuate.endpoint.mvc.HalJsonMvcEndpoint
;
...
...
@@ -39,6 +41,7 @@ import org.springframework.boot.actuate.endpoint.mvc.HypermediaDisabled;
import
org.springframework.boot.actuate.endpoint.mvc.ManagementServletContext
;
import
org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint
;
import
org.springframework.boot.actuate.endpoint.mvc.MvcEndpoints
;
import
org.springframework.boot.autoconfigure.condition.AnyNestedCondition
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
...
...
@@ -50,6 +53,7 @@ import org.springframework.boot.autoconfigure.web.ResourceProperties;
import
org.springframework.boot.autoconfigure.web.ServerProperties
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Conditional
;
import
org.springframework.core.MethodParameter
;
import
org.springframework.core.annotation.AnnotationUtils
;
import
org.springframework.core.io.ResourceLoader
;
...
...
@@ -85,7 +89,7 @@ import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
@ConditionalOnClass
(
Link
.
class
)
@ConditionalOnWebApplication
@ConditionalOnBean
(
HttpMessageConverters
.
class
)
@Conditional
OnProperty
(
value
=
"endpoints.enabled"
,
matchIfMissing
=
true
)
@Conditional
(
EndpointHypermediaEnabledCondition
.
class
)
@EnableConfigurationProperties
(
ResourceProperties
.
class
)
public
class
EndpointWebMvcHypermediaManagementContextConfiguration
{
...
...
@@ -102,7 +106,7 @@ public class EndpointWebMvcHypermediaManagementContextConfiguration {
};
}
@ConditionalOn
Property
(
prefix
=
"endpoints.actuator"
,
name
=
"enabled"
,
matchIfMissing
=
true
)
@ConditionalOn
EnabledEndpoint
(
"actuator"
)
@Bean
public
HalJsonMvcEndpoint
halJsonMvcEndpoint
(
ManagementServletContext
managementServletContext
,
...
...
@@ -114,7 +118,7 @@ public class EndpointWebMvcHypermediaManagementContextConfiguration {
}
@Bean
@ConditionalOn
Property
(
prefix
=
"endpoints.docs"
,
name
=
"enabled"
,
matchIfMissing
=
true
)
@ConditionalOn
EnabledEndpoint
(
"docs"
)
@ConditionalOnResource
(
resources
=
"classpath:/META-INF/resources/spring-boot-actuator/docs/index.html"
)
public
DocsMvcEndpoint
docsMvcEndpoint
(
ManagementServletContext
managementServletContext
)
{
...
...
@@ -333,4 +337,22 @@ public class EndpointWebMvcHypermediaManagementContextConfiguration {
}
static
class
EndpointHypermediaEnabledCondition
extends
AnyNestedCondition
{
public
EndpointHypermediaEnabledCondition
()
{
super
(
ConfigurationPhase
.
REGISTER_BEAN
);
}
@ConditionalOnEnabledEndpoint
(
"actuator"
)
static
class
ActuatorEndpointEnabled
{
}
@ConditionalOnEnabledEndpoint
(
"docs"
)
static
class
DocsEndpointEnabled
{
}
}
}
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/condition/ConditionalOnEnabledEndpoint.java
View file @
bee651fc
/*
* Copyright 2012-201
5
the original author or authors.
* Copyright 2012-201
6
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -35,7 +35,7 @@ import org.springframework.context.annotation.Conditional;
*/
@Conditional
(
OnEnabledEndpointCondition
.
class
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Target
(
ElementType
.
METHOD
)
@Target
(
{
ElementType
.
METHOD
,
ElementType
.
TYPE
}
)
public
@interface
ConditionalOnEnabledEndpoint
{
/**
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfigurationTests.java
View file @
bee651fc
...
...
@@ -40,6 +40,7 @@ import org.springframework.boot.actuate.endpoint.Endpoint;
import
org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping
;
import
org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMappingCustomizer
;
import
org.springframework.boot.actuate.endpoint.mvc.EnvironmentMvcEndpoint
;
import
org.springframework.boot.actuate.endpoint.mvc.HalJsonMvcEndpoint
;
import
org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint
;
import
org.springframework.boot.actuate.endpoint.mvc.MetricsMvcEndpoint
;
import
org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint
;
...
...
@@ -451,6 +452,17 @@ public class EndpointWebMvcAutoConfigurationTests {
.
hasSize
(
1
);
}
@Test
public
void
actuatorEndpointEnabledIndividually
()
{
this
.
applicationContext
.
register
(
RootConfig
.
class
,
BaseConfiguration
.
class
,
ServerPortConfig
.
class
,
EndpointWebMvcAutoConfiguration
.
class
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
applicationContext
,
"endpoints.enabled:false"
,
"endpoints.actuator.enabled:true"
);
this
.
applicationContext
.
refresh
();
assertThat
(
this
.
applicationContext
.
getBeansOfType
(
HalJsonMvcEndpoint
.
class
))
.
hasSize
(
1
);
}
private
void
endpointDisabled
(
String
name
,
Class
<?
extends
MvcEndpoint
>
type
)
{
this
.
applicationContext
.
register
(
RootConfig
.
class
,
BaseConfiguration
.
class
,
ServerPortConfig
.
class
,
EndpointWebMvcAutoConfiguration
.
class
);
...
...
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