Skip to content

Commit 5d10683

Browse files
committed
Add hints for autoconfiguring ClientHttpConnector
Closes spring-atticgh-1291
1 parent 6830ee6 commit 5d10683

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.example.webclient;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
6+
import org.springframework.boot.CommandLineRunner;
7+
import org.springframework.stereotype.Component;
8+
import org.springframework.web.reactive.function.client.WebClient;
9+
10+
@Component
11+
public class HttpsWebClientBuilderRequester implements CommandLineRunner {
12+
13+
Logger logger = LoggerFactory.getLogger(HttpsRequester.class);
14+
15+
private WebClient client;
16+
17+
public HttpsWebClientBuilderRequester() {
18+
this.client = WebClient.builder().baseUrl("https://httpbin.org").build();
19+
}
20+
21+
@Override
22+
public void run(String... args) {
23+
this.client.get().uri("anything").retrieve().bodyToMono(Data.class).subscribe(message -> logger.info(message.toString()));
24+
}
25+
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2019-2021 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.autoconfigure.web.reactive.function.client;
18+
19+
import org.springframework.nativex.hint.AccessBits;
20+
import org.springframework.nativex.hint.NativeHint;
21+
import org.springframework.nativex.hint.TypeHint;
22+
import org.springframework.nativex.type.NativeConfiguration;
23+
24+
@NativeHint(trigger = ClientHttpConnectorAutoConfiguration.class,
25+
types = @TypeHint(typeNames = {
26+
"org.springframework.boot.autoconfigure.web.reactive.function.client.ClientHttpConnectorConfiguration$ReactorNetty",
27+
"org.springframework.boot.autoconfigure.web.reactive.function.client.ClientHttpConnectorConfiguration$JettyClient",
28+
"org.springframework.boot.autoconfigure.web.reactive.function.client.ClientHttpConnectorConfiguration$HttpClient5"
29+
}, access = AccessBits.QUERY_DECLARED_METHODS)
30+
)
31+
public class ClientHttpConnectorAutoConfigurationHints implements NativeConfiguration {
32+
}

spring-native-configuration/src/main/resources/META-INF/services/org.springframework.nativex.type.NativeConfiguration

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ org.springframework.boot.autoconfigure.task.TaskHints
6969
org.springframework.boot.autoconfigure.transaction.TransactionHints
7070
org.springframework.boot.autoconfigure.websocket.servlet.WebSocketHints
7171
org.springframework.boot.autoconfigure.web.reactive.WebFluxHints
72+
org.springframework.boot.autoconfigure.web.reactive.function.client.ClientHttpConnectorAutoConfigurationHints
7273
org.springframework.boot.autoconfigure.web.servlet.WebHints
7374
org.springframework.boot.autoconfigure.web.servlet.WebMvcHints
7475
org.springframework.boot.context.config.ConfigDataPropertiesHints

0 commit comments

Comments
 (0)