Part 24 Custom Endpoints

Опубликовано: 17 Июнь 2026
на канале: JavaAnatomy
138
0

Spring Boot Actuator provides the option to create your own endpoints.

Just annotate a class with @Endpoint
Then you can annotate methods of a class
With the following:

@ReadOperation (handling GET requests)
@WriteOperation (handling POST requests)
@DeleteOperation (handling DELETE requests)

@Selector annotation can be used in methods to indicate that a parameter can be used to filter the data in question.

@ReadOperation
public Object read(@Selector String name)

@Endpoint
Exposes the endpoint over both HTTP and JMX

If only JMX protocol is desired then the @Endpoint annotation should be replaced with a specialized one for JMX: @JmxEndpoint.

If only HTTP access is required then the @Endpoint annotation should be replaced with its specialization for HTTP: @WebEndpoint

@Endpoint, @WebEndpoint, and @JmxEndpoint declare two attributes: id, the identifier of the endpoint (and is mandatory), enableByDefault, not mandatory but is true by default. This last attribute can enable or disable the endpoint.