Skip to content

Commit ee16332

Browse files
committed
Update Actuator to use the new endpoint infrastructure
This commit migrates the Actuator onto the new endpoint infrastruture. In addition to the existing support for accessing the endpoints via JMX and HTTP using Spring MVC, support for access via HTTP using Jersey and WebFlux has been added. This includes using a separate management port where we now spin up an additional, appropriately configured servlet or reactive web server to expose the management context on a different HTTP port to the main application. Closes gh-2921 Closes gh-5389 Closes gh-9796
1 parent e92cb11 commit ee16332

File tree

195 files changed

+7760
-11961
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

195 files changed

+7760
-11961
lines changed

spring-boot-actuator/pom.xml

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,16 @@
153153
<artifactId>flyway-core</artifactId>
154154
<optional>true</optional>
155155
</dependency>
156+
<dependency>
157+
<groupId>org.glassfish.jersey.core</groupId>
158+
<artifactId>jersey-server</artifactId>
159+
<optional>true</optional>
160+
</dependency>
161+
<dependency>
162+
<groupId>org.glassfish.jersey.containers</groupId>
163+
<artifactId>jersey-container-servlet-core</artifactId>
164+
<optional>true</optional>
165+
</dependency>
156166
<dependency>
157167
<groupId>org.hibernate</groupId>
158168
<artifactId>hibernate-validator</artifactId>
@@ -183,6 +193,11 @@
183193
<artifactId>spring-jdbc</artifactId>
184194
<optional>true</optional>
185195
</dependency>
196+
<dependency>
197+
<groupId>org.springframework</groupId>
198+
<artifactId>spring-webflux</artifactId>
199+
<optional>true</optional>
200+
</dependency>
186201
<dependency>
187202
<groupId>org.springframework</groupId>
188203
<artifactId>spring-webmvc</artifactId>
@@ -241,16 +256,6 @@
241256
<artifactId>spring-integration-core</artifactId>
242257
<optional>true</optional>
243258
</dependency>
244-
<dependency>
245-
<groupId>org.springframework.hateoas</groupId>
246-
<artifactId>spring-hateoas</artifactId>
247-
<optional>true</optional>
248-
</dependency>
249-
<dependency>
250-
<groupId>org.springframework.plugin</groupId>
251-
<artifactId>spring-plugin-core</artifactId>
252-
<optional>true</optional>
253-
</dependency>
254259
<dependency>
255260
<groupId>org.springframework.security</groupId>
256261
<artifactId>spring-security-web</artifactId>
@@ -261,11 +266,6 @@
261266
<artifactId>spring-security-config</artifactId>
262267
<optional>true</optional>
263268
</dependency>
264-
<dependency>
265-
<groupId>org.webjars</groupId>
266-
<artifactId>hal-browser</artifactId>
267-
<optional>true</optional>
268-
</dependency>
269269
<!-- Annotation processing -->
270270
<dependency>
271271
<groupId>org.springframework.boot</groupId>
@@ -298,6 +298,10 @@
298298
<artifactId>json-path</artifactId>
299299
<scope>test</scope>
300300
</dependency>
301+
<dependency>
302+
<groupId>io.projectreactor.ipc</groupId>
303+
<artifactId>reactor-netty</artifactId>
304+
</dependency>
301305
<dependency>
302306
<groupId>io.undertow</groupId>
303307
<artifactId>undertow-core</artifactId>
@@ -324,6 +328,16 @@
324328
<artifactId>hsqldb</artifactId>
325329
<scope>test</scope>
326330
</dependency>
331+
<dependency>
332+
<groupId>org.glassfish.jersey.media</groupId>
333+
<artifactId>jersey-media-json-jackson</artifactId>
334+
<scope>test</scope>
335+
</dependency>
336+
<dependency>
337+
<groupId>org.glassfish.jersey.ext</groupId>
338+
<artifactId>jersey-spring3</artifactId>
339+
<scope>test</scope>
340+
</dependency>
327341
<dependency>
328342
<groupId>org.skyscreamer</groupId>
329343
<artifactId>jsonassert</artifactId>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2012-2017 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.actuate.autoconfigure;
18+
19+
import java.lang.annotation.Documented;
20+
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
25+
import org.springframework.context.annotation.Conditional;
26+
27+
/**
28+
* {@link Conditional} that matches based on the configuration of the management port.
29+
*/
30+
@Retention(RetentionPolicy.RUNTIME)
31+
@Target({ ElementType.TYPE, ElementType.METHOD })
32+
@Documented
33+
@Conditional(OnManagementPortCondition.class)
34+
public @interface ConditionalOnManagementPort {
35+
36+
/**
37+
* The {@link ManagementPortType} to match.
38+
* @return the port type
39+
*/
40+
ManagementPortType value();
41+
42+
}
Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,17 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.actuate.endpoint.mvc;
17+
package org.springframework.boot.actuate.autoconfigure;
18+
19+
import org.springframework.context.annotation.Configuration;
1820

1921
/**
20-
* Callback for customizing the {@link EndpointHandlerMapping} at configuration time.
22+
* Configurtaion class used to enable configuration of a child management context.
2123
*
22-
* @author Dave Syer
23-
* @since 1.2.0
24+
* @author Andy Wilkinson
2425
*/
25-
@FunctionalInterface
26-
public interface EndpointHandlerMappingCustomizer {
27-
28-
/**
29-
* Customize the specified {@link EndpointHandlerMapping}.
30-
* @param mapping the {@link EndpointHandlerMapping} to customize
31-
*/
32-
void customize(EndpointHandlerMapping mapping);
26+
@Configuration
27+
@EnableManagementContext(ManagementContextType.CHILD)
28+
class EnableChildManagementContextConfiguration {
3329

3430
}

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/ActuatorGetMapping.java renamed to spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EnableManagementContext.java

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,27 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.actuate.endpoint.mvc;
17+
package org.springframework.boot.actuate.autoconfigure;
1818

1919
import java.lang.annotation.Documented;
2020
import java.lang.annotation.ElementType;
2121
import java.lang.annotation.Retention;
2222
import java.lang.annotation.RetentionPolicy;
2323
import java.lang.annotation.Target;
2424

25-
import org.springframework.core.annotation.AliasFor;
26-
import org.springframework.http.MediaType;
27-
import org.springframework.web.bind.annotation.RequestMapping;
28-
import org.springframework.web.bind.annotation.RequestMethod;
25+
import org.springframework.context.annotation.Import;
2926

3027
/**
31-
* Specialized {@link RequestMapping} for {@link RequestMethod#GET GET} requests that
32-
* produce {@code application/json} or
33-
* {@code application/vnd.spring-boot.actuator.v1+json} responses.
28+
* Enables the management context.
3429
*
3530
* @author Andy Wilkinson
3631
*/
37-
@Target(ElementType.METHOD)
32+
@Target(ElementType.TYPE)
3833
@Retention(RetentionPolicy.RUNTIME)
3934
@Documented
40-
@RequestMapping(method = RequestMethod.GET, produces = {
41-
ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON_VALUE,
42-
MediaType.APPLICATION_JSON_VALUE })
43-
@interface ActuatorGetMapping {
35+
@Import(ManagementContextConfigurationImportSelector.class)
36+
@interface EnableManagementContext {
4437

45-
/**
46-
* Alias for {@link RequestMapping#value}.
47-
* @return the value
48-
*/
49-
@AliasFor(annotation = RequestMapping.class)
50-
String[] value() default {};
38+
ManagementContextType value();
5139

5240
}

0 commit comments

Comments
 (0)