|
|
|
@ -115,12 +115,41 @@ public final class EndpointRequest { |
|
|
|
return new LinksServerWebExchangeMatcher(); |
|
|
|
return new LinksServerWebExchangeMatcher(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Base class for supported request matchers. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private abstract static class AbstractWebExchangeMatcher<T> extends ApplicationContextServerWebExchangeMatcher<T> { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ManagementPortType managementPortType; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AbstractWebExchangeMatcher(Class<? extends T> contextClass) { |
|
|
|
|
|
|
|
super(contextClass); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
protected boolean ignoreApplicationContext(ApplicationContext applicationContext) { |
|
|
|
|
|
|
|
if (this.managementPortType == null) { |
|
|
|
|
|
|
|
this.managementPortType = ManagementPortType.get(applicationContext.getEnvironment()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (this.managementPortType == ManagementPortType.DIFFERENT) { |
|
|
|
|
|
|
|
if (applicationContext.getParent() == null) { |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
String managementContextId = applicationContext.getParent().getId() + ":management"; |
|
|
|
|
|
|
|
if (!managementContextId.equals(applicationContext.getId())) { |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* The {@link ServerWebExchangeMatcher} used to match against {@link Endpoint actuator |
|
|
|
* The {@link ServerWebExchangeMatcher} used to match against {@link Endpoint actuator |
|
|
|
* endpoints}. |
|
|
|
* endpoints}. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static final class EndpointServerWebExchangeMatcher |
|
|
|
public static final class EndpointServerWebExchangeMatcher extends AbstractWebExchangeMatcher<PathMappedEndpoints> { |
|
|
|
extends ApplicationContextServerWebExchangeMatcher<PathMappedEndpoints> { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final List<Object> includes; |
|
|
|
private final List<Object> includes; |
|
|
|
|
|
|
|
|
|
|
|
@ -225,36 +254,15 @@ public final class EndpointRequest { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected Mono<MatchResult> matches(ServerWebExchange exchange, Supplier<PathMappedEndpoints> context) { |
|
|
|
protected Mono<MatchResult> matches(ServerWebExchange exchange, Supplier<PathMappedEndpoints> context) { |
|
|
|
if (!isManagementContext(exchange)) { |
|
|
|
|
|
|
|
return MatchResult.notMatch(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return this.delegate.matches(exchange); |
|
|
|
return this.delegate.matches(exchange); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static boolean isManagementContext(ServerWebExchange exchange) { |
|
|
|
|
|
|
|
ApplicationContext applicationContext = exchange.getApplicationContext(); |
|
|
|
|
|
|
|
if (managementPortType == null) { |
|
|
|
|
|
|
|
managementPortType = ManagementPortType.get(applicationContext.getEnvironment()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (managementPortType == ManagementPortType.DIFFERENT) { |
|
|
|
|
|
|
|
if (applicationContext.getParent() == null) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
String managementContextId = applicationContext.getParent().getId() + ":management"; |
|
|
|
|
|
|
|
if (!managementContextId.equals(applicationContext.getId())) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* The {@link ServerWebExchangeMatcher} used to match against the links endpoint. |
|
|
|
* The {@link ServerWebExchangeMatcher} used to match against the links endpoint. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static final class LinksServerWebExchangeMatcher |
|
|
|
public static final class LinksServerWebExchangeMatcher extends AbstractWebExchangeMatcher<WebEndpointProperties> { |
|
|
|
extends ApplicationContextServerWebExchangeMatcher<WebEndpointProperties> { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private volatile ServerWebExchangeMatcher delegate; |
|
|
|
private volatile ServerWebExchangeMatcher delegate; |
|
|
|
|
|
|
|
|
|
|
|
@ -276,9 +284,6 @@ public final class EndpointRequest { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected Mono<MatchResult> matches(ServerWebExchange exchange, Supplier<WebEndpointProperties> context) { |
|
|
|
protected Mono<MatchResult> matches(ServerWebExchange exchange, Supplier<WebEndpointProperties> context) { |
|
|
|
if (!EndpointServerWebExchangeMatcher.isManagementContext(exchange)) { |
|
|
|
|
|
|
|
return MatchResult.notMatch(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return this.delegate.matches(exchange); |
|
|
|
return this.delegate.matches(exchange); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|