fix list endpoints actuator endpoint (#3348)
This commit is contained in:
parent
e039960365
commit
4e85066523
@ -2,7 +2,7 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>spring-boot</artifactId>
|
<artifactId>spring-custom-aop</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<name>spring-boot</name>
|
<name>spring-boot</name>
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
package org.baeldung.endpoints;
|
||||||
|
|
||||||
|
public class EndpointDTO {
|
||||||
|
private String id;
|
||||||
|
private boolean enabled;
|
||||||
|
private boolean sensitive;
|
||||||
|
|
||||||
|
public EndpointDTO(String id, boolean enabled, boolean sensitive) {
|
||||||
|
super();
|
||||||
|
this.id = id;
|
||||||
|
this.enabled = enabled;
|
||||||
|
this.sensitive = sensitive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnabled(boolean enabled) {
|
||||||
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSensitive() {
|
||||||
|
return sensitive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSensitive(boolean sensitive) {
|
||||||
|
this.sensitive = sensitive;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package org.baeldung.endpoints;
|
package org.baeldung.endpoints;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.actuate.endpoint.AbstractEndpoint;
|
import org.springframework.boot.actuate.endpoint.AbstractEndpoint;
|
||||||
@ -8,16 +9,16 @@ import org.springframework.boot.actuate.endpoint.Endpoint;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class ListEndpoints extends AbstractEndpoint<List<Endpoint>> {
|
public class ListEndpoints extends AbstractEndpoint<List<EndpointDTO>> {
|
||||||
private List<Endpoint> endpoints;
|
private List<EndpointDTO> endpointDTOs;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public ListEndpoints(List<Endpoint> endpoints) {
|
public ListEndpoints(List<Endpoint> endpoints) {
|
||||||
super("listEndpoints");
|
super("listEndpoints");
|
||||||
this.endpoints = endpoints;
|
this.endpointDTOs = endpoints.stream().map(endpoint -> new EndpointDTO(endpoint.getId(), endpoint.isEnabled(), endpoint.isSensitive())).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Endpoint> invoke() {
|
public List<EndpointDTO> invoke() {
|
||||||
return this.endpoints;
|
return this.endpointDTOs;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user