|
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.
|
|
19 | 19 | import java.util.Collection;
|
20 | 20 | import java.util.Collections;
|
21 | 21 | import java.util.LinkedHashMap;
|
| 22 | +import java.util.List; |
22 | 23 | import java.util.Map;
|
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.ExecutableMode; |
| 30 | +import org.springframework.aot.hint.RuntimeHints; |
| 31 | +import org.springframework.aot.hint.RuntimeHintsRegistrar; |
| 32 | +import org.springframework.aot.hint.TypeReference; |
28 | 33 | import org.springframework.boot.actuate.autoconfigure.cloudfoundry.AccessLevel;
|
29 | 34 | import org.springframework.boot.actuate.autoconfigure.cloudfoundry.SecurityResponse;
|
| 35 | +import org.springframework.boot.actuate.autoconfigure.cloudfoundry.reactive.CloudFoundryWebFluxEndpointHandlerMapping.CloudFoundryWebFluxEndpointHandlerMappingRuntimeHints; |
30 | 36 | import org.springframework.boot.actuate.endpoint.EndpointId;
|
31 | 37 | import org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver;
|
32 | 38 | import org.springframework.boot.actuate.endpoint.web.EndpointMapping;
|
|
35 | 41 | import org.springframework.boot.actuate.endpoint.web.Link;
|
36 | 42 | import org.springframework.boot.actuate.endpoint.web.WebOperation;
|
37 | 43 | import org.springframework.boot.actuate.endpoint.web.reactive.AbstractWebFluxEndpointHandlerMapping;
|
| 44 | +import org.springframework.context.annotation.ImportRuntimeHints; |
| 45 | +import org.springframework.context.aot.BindingReflectionHintsRegistrar; |
38 | 46 | import org.springframework.http.HttpStatus;
|
39 | 47 | import org.springframework.http.ResponseEntity;
|
40 | 48 | import org.springframework.http.server.reactive.ServerHttpRequest;
|
|
50 | 58 | * @author Phillip Webb
|
51 | 59 | * @author Brian Clozel
|
52 | 60 | */
|
| 61 | +@ImportRuntimeHints(CloudFoundryWebFluxEndpointHandlerMappingRuntimeHints.class) |
53 | 62 | class CloudFoundryWebFluxEndpointHandlerMapping extends AbstractWebFluxEndpointHandlerMapping {
|
54 | 63 |
|
55 | 64 | private final CloudFoundrySecurityInterceptor securityInterceptor;
|
@@ -145,4 +154,19 @@ private Mono<ResponseEntity<Object>> flatMapResponse(ServerWebExchange exchange,
|
145 | 154 |
|
146 | 155 | }
|
147 | 156 |
|
| 157 | + static class CloudFoundryWebFluxEndpointHandlerMappingRuntimeHints implements RuntimeHintsRegistrar { |
| 158 | + |
| 159 | + private final BindingReflectionHintsRegistrar bindingRegistrar = new BindingReflectionHintsRegistrar(); |
| 160 | + |
| 161 | + @Override |
| 162 | + public void registerHints(RuntimeHints hints, ClassLoader classLoader) { |
| 163 | + hints.reflection().registerType(CloudFoundryLinksHandler.class, |
| 164 | + (hint) -> hint.onReachableType(TypeReference.of(CloudFoundryLinksHandler.class)).withMethod("links", |
| 165 | + List.of(TypeReference.of(ServerWebExchange.class)), |
| 166 | + (method) -> method.setModes(ExecutableMode.INVOKE))); |
| 167 | + this.bindingRegistrar.registerReflectionHints(hints.reflection(), Link.class); |
| 168 | + } |
| 169 | + |
| 170 | + } |
| 171 | + |
148 | 172 | }
|
0 commit comments