|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2012-2022 the original author or authors. |
|
|
|
* Copyright 2012-2023 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -16,11 +16,17 @@ |
|
|
|
|
|
|
|
|
|
|
|
package org.springframework.boot.actuate.endpoint.web.jersey; |
|
|
|
package org.springframework.boot.actuate.endpoint.web.jersey; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
import java.util.Collection; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
import java.util.stream.Stream; |
|
|
|
|
|
|
|
|
|
|
|
import org.glassfish.jersey.server.model.Resource; |
|
|
|
import org.glassfish.jersey.server.model.Resource; |
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.boot.actuate.endpoint.web.EndpointMapping; |
|
|
|
import org.springframework.boot.actuate.endpoint.web.EndpointMapping; |
|
|
|
|
|
|
|
import org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint; |
|
|
|
import org.springframework.boot.actuate.endpoint.web.WebOperation; |
|
|
|
import org.springframework.boot.actuate.endpoint.web.WebOperation; |
|
|
|
import org.springframework.boot.actuate.endpoint.web.WebOperationRequestPredicate; |
|
|
|
import org.springframework.boot.actuate.endpoint.web.WebOperationRequestPredicate; |
|
|
|
import org.springframework.boot.actuate.endpoint.web.WebServerNamespace; |
|
|
|
import org.springframework.boot.actuate.endpoint.web.WebServerNamespace; |
|
|
|
@ -35,7 +41,9 @@ import org.springframework.boot.actuate.health.HealthEndpointGroups; |
|
|
|
* @author Madhura Bhave |
|
|
|
* @author Madhura Bhave |
|
|
|
* @since 2.6.0 |
|
|
|
* @since 2.6.0 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class JerseyHealthEndpointAdditionalPathResourceFactory extends JerseyEndpointResourceFactory { |
|
|
|
public final class JerseyHealthEndpointAdditionalPathResourceFactory { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final JerseyEndpointResourceFactory delegate = new JerseyEndpointResourceFactory(); |
|
|
|
|
|
|
|
|
|
|
|
private final Set<HealthEndpointGroup> groups; |
|
|
|
private final Set<HealthEndpointGroup> groups; |
|
|
|
|
|
|
|
|
|
|
|
@ -47,20 +55,30 @@ public class JerseyHealthEndpointAdditionalPathResourceFactory extends JerseyEnd |
|
|
|
this.groups = groups.getAllWithAdditionalPath(serverNamespace); |
|
|
|
this.groups = groups.getAllWithAdditionalPath(serverNamespace); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public Collection<Resource> createEndpointResources(EndpointMapping endpointMapping, |
|
|
|
protected Resource createResource(EndpointMapping endpointMapping, WebOperation operation) { |
|
|
|
Collection<ExposableWebEndpoint> endpoints) { |
|
|
|
|
|
|
|
return endpoints.stream() |
|
|
|
|
|
|
|
.flatMap((endpoint) -> endpoint.getOperations().stream()) |
|
|
|
|
|
|
|
.flatMap((operation) -> createResources(endpointMapping, operation)) |
|
|
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Stream<Resource> createResources(EndpointMapping endpointMapping, WebOperation operation) { |
|
|
|
WebOperationRequestPredicate requestPredicate = operation.getRequestPredicate(); |
|
|
|
WebOperationRequestPredicate requestPredicate = operation.getRequestPredicate(); |
|
|
|
String matchAllRemainingPathSegmentsVariable = requestPredicate.getMatchAllRemainingPathSegmentsVariable(); |
|
|
|
String matchAllRemainingPathSegmentsVariable = requestPredicate.getMatchAllRemainingPathSegmentsVariable(); |
|
|
|
if (matchAllRemainingPathSegmentsVariable != null) { |
|
|
|
if (matchAllRemainingPathSegmentsVariable != null) { |
|
|
|
|
|
|
|
List<Resource> resources = new ArrayList<>(); |
|
|
|
for (HealthEndpointGroup group : this.groups) { |
|
|
|
for (HealthEndpointGroup group : this.groups) { |
|
|
|
AdditionalHealthEndpointPath additionalPath = group.getAdditionalPath(); |
|
|
|
AdditionalHealthEndpointPath additionalPath = group.getAdditionalPath(); |
|
|
|
if (additionalPath != null) { |
|
|
|
if (additionalPath != null) { |
|
|
|
return getResource(endpointMapping, operation, requestPredicate, additionalPath.getValue(), |
|
|
|
resources.add(this.delegate.getResource(endpointMapping, operation, requestPredicate, |
|
|
|
this.serverNamespace, (data, pathSegmentsVariable) -> data.getUriInfo().getPath()); |
|
|
|
additionalPath.getValue(), this.serverNamespace, |
|
|
|
|
|
|
|
(data, pathSegmentsVariable) -> data.getUriInfo().getPath())); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return resources.stream(); |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
return Stream.empty(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|