|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2019 the original author or authors. |
| 2 | + * Copyright 2012-2022 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
20 | 20 | import java.util.Collections;
|
21 | 21 | import java.util.LinkedHashMap;
|
22 | 22 | import java.util.Map;
|
| 23 | +import java.util.Objects; |
23 | 24 | import java.util.stream.Collectors;
|
24 | 25 |
|
25 | 26 | import org.reactivestreams.Publisher;
|
26 | 27 | import reactor.core.publisher.Mono;
|
27 | 28 |
|
| 29 | +import org.springframework.aot.hint.RuntimeHints; |
| 30 | +import org.springframework.aot.hint.RuntimeHintsRegistrar; |
28 | 31 | import org.springframework.boot.actuate.autoconfigure.cloudfoundry.AccessLevel;
|
29 | 32 | import org.springframework.boot.actuate.autoconfigure.cloudfoundry.SecurityResponse;
|
| 33 | +import org.springframework.boot.actuate.autoconfigure.cloudfoundry.reactive.CloudFoundryWebFluxEndpointHandlerMapping.CloudFoundryWebFluxEndpointHandlerMappingRuntimeHints; |
30 | 34 | import org.springframework.boot.actuate.endpoint.EndpointId;
|
31 | 35 | import org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver;
|
32 | 36 | import org.springframework.boot.actuate.endpoint.web.EndpointMapping;
|
|
35 | 39 | import org.springframework.boot.actuate.endpoint.web.Link;
|
36 | 40 | import org.springframework.boot.actuate.endpoint.web.WebOperation;
|
37 | 41 | import org.springframework.boot.actuate.endpoint.web.reactive.AbstractWebFluxEndpointHandlerMapping;
|
| 42 | +import org.springframework.context.annotation.ImportRuntimeHints; |
| 43 | +import org.springframework.context.aot.BindingReflectionHintsRegistrar; |
38 | 44 | import org.springframework.http.HttpStatus;
|
39 | 45 | import org.springframework.http.ResponseEntity;
|
40 | 46 | import org.springframework.http.server.reactive.ServerHttpRequest;
|
| 47 | +import org.springframework.util.ReflectionUtils; |
41 | 48 | import org.springframework.web.cors.CorsConfiguration;
|
42 | 49 | import org.springframework.web.reactive.result.method.RequestMappingInfoHandlerMapping;
|
43 | 50 | import org.springframework.web.server.ServerWebExchange;
|
|
50 | 57 | * @author Phillip Webb
|
51 | 58 | * @author Brian Clozel
|
52 | 59 | */
|
| 60 | +@ImportRuntimeHints(CloudFoundryWebFluxEndpointHandlerMappingRuntimeHints.class) |
53 | 61 | class CloudFoundryWebFluxEndpointHandlerMapping extends AbstractWebFluxEndpointHandlerMapping {
|
54 | 62 |
|
55 | 63 | private final CloudFoundrySecurityInterceptor securityInterceptor;
|
@@ -145,4 +153,17 @@ private Mono<ResponseEntity<Object>> flatMapResponse(ServerWebExchange exchange,
|
145 | 153 |
|
146 | 154 | }
|
147 | 155 |
|
| 156 | + static class CloudFoundryWebFluxEndpointHandlerMappingRuntimeHints implements RuntimeHintsRegistrar { |
| 157 | + |
| 158 | + private final BindingReflectionHintsRegistrar bindingRegistrar = new BindingReflectionHintsRegistrar(); |
| 159 | + |
| 160 | + @Override |
| 161 | + public void registerHints(RuntimeHints hints, ClassLoader classLoader) { |
| 162 | + hints.reflection().registerMethod(Objects.requireNonNull( |
| 163 | + ReflectionUtils.findMethod(CloudFoundryLinksHandler.class, "links", ServerWebExchange.class))); |
| 164 | + this.bindingRegistrar.registerReflectionHints(hints.reflection(), Link.class); |
| 165 | + } |
| 166 | + |
| 167 | + } |
| 168 | + |
148 | 169 | }
|
0 commit comments