BT

New Early adopter or innovator? InfoQ has been working on some new features for you. Learn more

Spring Boot 2.0 Will Feature Improved Actuator Endpoints

| by Michael Redlich Follow 5 Followers on Aug 31, 2017. Estimated reading time: 3 minutes |

The upcoming release of Spring Boot 2.0.0 M4 will feature an improved actuator endpoint infrastructure. The most significant changes include:

  • Support for Jersey RESTful web services
  • Support for WebFlux reactive-based web apps
  • New endpoint mapping
  • Simplified creation of user-defined endpoints
  • Improved endpoint security

Spring Boot’s actuator endpoints allow for monitoring and interaction with web applications. Previously, these endpoints were only supported by Spring MVC and creating user-defined endpoints required writing a significant amount of additional code and configuration.

Endpoint Mapping

Built-in endpoints, such as /beans, /health, etc., are now mapped to the /application root context, by default. This means, for example, that /beans in previous versions of Spring Boot is now accessed via /application/beans.

Creating User-Defined Endpoints

The new @Enpoint annotation has simplified the process of creating user-defined endpoints. The example below creates an endpoint named person. (The entire sample application can be found on GitHub.)

    
@Endpoint(id = "person")
@Component
public class PersonEndpoint {

    private final Map people = new HashMap<>();

    PersonEndpoint() {
        this.people.put("mike", new Person("Michael Redlich"));
        this.people.put("rowena", new Person("Rowena Redlich"));
        this.people.put("barry", new Person("Barry Burd"));
    }

    @ReadOperation
    public List getAll() {
        return new ArrayList<>(this.people.values());
    }

    @ReadOperation
    public Person getPerson(@Selector String person) {
        return this.people.get(person);
    }

    @WriteOperation
    public void updatePerson(@Selector String name, String person) {
        this.people.put(name, new Person(person));
    }

    public static class Person {
        private String name;

        Person(String name) {
            this.name = name;
        }

        public String getName() {
            return this.name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }
}
    

This endpoint exposes the three methods defined with the @ReadOperation and @WriteOperation annotations. No additional source code is necessary and the endpoint is accessed via /application/person and /application/person/{name}. This endpoint is also automatically deployed as a JMX MBean and may be accessed by a JMX-client such as JConsole.

Improved Endpoint Security

Spring Boot 2.0 takes a slightly different approach to ensuring that web endpoints are secure by default. Web endpoints are now disabled by default and the management.security.enabled property has been removed. Individual endpoints may be enabled via configuration in the application.properties file. For example:

    
endpoints.info.enabled=true
endpoints.beans.enabled=true
    

It is possible, however, expose all of the actuator and user-defined endpoints by setting the endpoints.default.web.enabled property equal to true.

Stéphane Nicoll, principal software engineer at Pivotal, spoke to InfoQ about actuator endpoints.

InfoQ: How would you describe your experience in upgrading actuator endpoints to include support for Jersey and WebFlux?

Stéphane Nicoll: Supporting both traditional servlet-based environments and reactive-based web apps is a challenge, especially when dealing with extensive feature sets.

InfoQ: Spring is famous for supplying a tight and well thought-out API. How was this refactoring handled?

Nicoll: We've seen several initiatives in the framework team with “spring-webmvc” and “spring-webflux” sharing a great deal of features from “spring-web.” Building abstractions that work is hard and I am quite happy we're doing it again at another level.

InfoQ: What were the driving architectural principles?

Nicoll: Spring Boot 2.0 is mainly about setting up firm foundations and a good base to build on: we believe this new endpoint infrastructure is going in the right direction for production-ready features and we are looking forward to feedback from the community.

InfoQ: When is the anticipated release of Spring Boot 2.0 GA?

Nicoll: Things are still a bit in flux (pun intended) but our current plan is to release Spring Boot 2.0 GA at the end of this year.

Resources

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT