Skip to content

Commit 4e85066

Browse files
lor6pivovarit
authored andcommitted
fix list endpoints actuator endpoint (eugenp#3348)
1 parent e039960 commit 4e85066

3 files changed

Lines changed: 46 additions & 6 deletions

File tree

‎spring-custom-aop/spring-custom-aop/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.baeldung</groupId>
5-
<artifactId>spring-boot</artifactId>
5+
<artifactId>spring-custom-aop</artifactId>
66
<version>0.0.1-SNAPSHOT</version>
77
<packaging>war</packaging>
88
<name>spring-boot</name>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package org.baeldung.endpoints;
2+
3+
public class EndpointDTO {
4+
private String id;
5+
private boolean enabled;
6+
private boolean sensitive;
7+
8+
public EndpointDTO(String id, boolean enabled, boolean sensitive) {
9+
super();
10+
this.id = id;
11+
this.enabled = enabled;
12+
this.sensitive = sensitive;
13+
}
14+
15+
public String getId() {
16+
return id;
17+
}
18+
19+
public void setId(String id) {
20+
this.id = id;
21+
}
22+
23+
public boolean isEnabled() {
24+
return enabled;
25+
}
26+
27+
public void setEnabled(boolean enabled) {
28+
this.enabled = enabled;
29+
}
30+
31+
public boolean isSensitive() {
32+
return sensitive;
33+
}
34+
35+
public void setSensitive(boolean sensitive) {
36+
this.sensitive = sensitive;
37+
}
38+
39+
}
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
package org.baeldung.endpoints;
22

33
import java.util.List;
4+
import java.util.stream.Collectors;
45

56
import org.springframework.beans.factory.annotation.Autowired;
67
import org.springframework.boot.actuate.endpoint.AbstractEndpoint;
78
import org.springframework.boot.actuate.endpoint.Endpoint;
89
import org.springframework.stereotype.Component;
910

1011
@Component
11-
public class ListEndpoints extends AbstractEndpoint<List<Endpoint>> {
12-
private List<Endpoint> endpoints;
12+
public class ListEndpoints extends AbstractEndpoint<List<EndpointDTO>> {
13+
private List<EndpointDTO> endpointDTOs;
1314

1415
@Autowired
1516
public ListEndpoints(List<Endpoint> endpoints) {
1617
super("listEndpoints");
17-
this.endpoints = endpoints;
18+
this.endpointDTOs = endpoints.stream().map(endpoint -> new EndpointDTO(endpoint.getId(), endpoint.isEnabled(), endpoint.isSensitive())).collect(Collectors.toList());
1819
}
1920

20-
public List<Endpoint> invoke() {
21-
return this.endpoints;
21+
public List<EndpointDTO> invoke() {
22+
return this.endpointDTOs;
2223
}
2324
}

0 commit comments

Comments
 (0)