Skip to content

Commit

Permalink
Update Actuator to use the new endpoint infrastructure
Browse files Browse the repository at this point in the history
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
  • Loading branch information
wilkinsona committed Aug 11, 2017
1 parent e92cb11 commit ee16332
Show file tree
Hide file tree
Showing 195 changed files with 7,760 additions and 11,961 deletions.
44 changes: 29 additions & 15 deletions spring-boot-actuator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,16 @@
<artifactId>flyway-core</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
Expand Down Expand Up @@ -183,6 +193,11 @@
<artifactId>spring-jdbc</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webflux</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
Expand Down Expand Up @@ -241,16 +256,6 @@
<artifactId>spring-integration-core</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.hateoas</groupId>
<artifactId>spring-hateoas</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
Expand All @@ -261,11 +266,6 @@
<artifactId>spring-security-config</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>hal-browser</artifactId>
<optional>true</optional>
</dependency>
<!-- Annotation processing -->
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -298,6 +298,10 @@
<artifactId>json-path</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor.ipc</groupId>
<artifactId>reactor-netty</artifactId>
</dependency>
<dependency>
<groupId>io.undertow</groupId>
<artifactId>undertow-core</artifactId>
Expand All @@ -324,6 +328,16 @@
<artifactId>hsqldb</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-spring3</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 2012-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.boot.actuate.autoconfigure;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.springframework.context.annotation.Conditional;

/**
* {@link Conditional} that matches based on the configuration of the management port.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE, ElementType.METHOD })
@Documented
@Conditional(OnManagementPortCondition.class)
public @interface ConditionalOnManagementPort {

/**
* The {@link ManagementPortType} to match.
* @return the port type
*/
ManagementPortType value();

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,17 @@
* limitations under the License.
*/

package org.springframework.boot.actuate.endpoint.mvc;
package org.springframework.boot.actuate.autoconfigure;

import org.springframework.context.annotation.Configuration;

/**
* Callback for customizing the {@link EndpointHandlerMapping} at configuration time.
* Configurtaion class used to enable configuration of a child management context.
*
* @author Dave Syer
* @since 1.2.0
* @author Andy Wilkinson
*/
@FunctionalInterface
public interface EndpointHandlerMappingCustomizer {

/**
* Customize the specified {@link EndpointHandlerMapping}.
* @param mapping the {@link EndpointHandlerMapping} to customize
*/
void customize(EndpointHandlerMapping mapping);
@Configuration
@EnableManagementContext(ManagementContextType.CHILD)
class EnableChildManagementContextConfiguration {

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,27 @@
* limitations under the License.
*/

package org.springframework.boot.actuate.endpoint.mvc;
package org.springframework.boot.actuate.autoconfigure;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.springframework.core.annotation.AliasFor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.context.annotation.Import;

/**
* Specialized {@link RequestMapping} for {@link RequestMethod#GET GET} requests that
* produce {@code application/json} or
* {@code application/vnd.spring-boot.actuator.v1+json} responses.
* Enables the management context.
*
* @author Andy Wilkinson
*/
@Target(ElementType.METHOD)
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@RequestMapping(method = RequestMethod.GET, produces = {
ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON_VALUE,
MediaType.APPLICATION_JSON_VALUE })
@interface ActuatorGetMapping {
@Import(ManagementContextConfigurationImportSelector.class)
@interface EnableManagementContext {

/**
* Alias for {@link RequestMapping#value}.
* @return the value
*/
@AliasFor(annotation = RequestMapping.class)
String[] value() default {};
ManagementContextType value();

}
Loading

0 comments on commit ee16332

Please sign in to comment.