Skip to content

Commit a2521fc

Browse files
committed
Add hints for service group adapters.
Signed-off-by: Olga Maciaszek-Sharma <[email protected]>
1 parent 1a5cc87 commit a2521fc

File tree

6 files changed

+200
-1
lines changed

6 files changed

+200
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2002-2025 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.web.client.support;
18+
19+
import org.jspecify.annotations.Nullable;
20+
21+
import org.springframework.aot.hint.MemberCategory;
22+
import org.springframework.aot.hint.RuntimeHints;
23+
import org.springframework.aot.hint.RuntimeHintsRegistrar;
24+
import org.springframework.aot.hint.TypeReference;
25+
26+
/**
27+
* A {@link RuntimeHintsRegistrar} implementation that adds hints for {@link RestClientHttpServiceGroupAdapter}.
28+
*
29+
* @author Olga Maciaszek-Sharma
30+
* @since 7.0
31+
*/
32+
public class RestClientHttpServiceGroupAdapterRuntimeHints implements RuntimeHintsRegistrar {
33+
34+
@Override
35+
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
36+
hints.reflection()
37+
.registerType(TypeReference.of(RestClientHttpServiceGroupAdapter.class),
38+
MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS);
39+
}
40+
}

spring-web/src/main/resources/META-INF/spring/aot.factories

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ org.springframework.http.HttpMimeTypesRuntimeHints,\
33
org.springframework.http.codec.CodecConfigurerRuntimeHints,\
44
org.springframework.http.converter.json.JacksonModulesRuntimeHints,\
55
org.springframework.http.converter.json.ProblemDetailRuntimeHints,\
6-
org.springframework.web.util.WebUtilRuntimeHints
6+
org.springframework.web.util.WebUtilRuntimeHints,\
7+
org.springframework.web.client.support.RestClientHttpServiceGroupAdapterRuntimeHints
78

89
org.springframework.beans.factory.aot.BeanRegistrationAotProcessor=\
910
org.springframework.web.service.annotation.HttpExchangeBeanRegistrationAotProcessor,\
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright 2002-2025 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.web.client.support;
18+
19+
import org.junit.jupiter.api.BeforeEach;
20+
import org.junit.jupiter.api.Test;
21+
22+
import org.springframework.aot.hint.MemberCategory;
23+
import org.springframework.aot.hint.RuntimeHints;
24+
import org.springframework.aot.hint.RuntimeHintsRegistrar;
25+
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
26+
import org.springframework.core.io.support.SpringFactoriesLoader;
27+
import org.springframework.util.ClassUtils;
28+
29+
import static org.assertj.core.api.Assertions.assertThat;
30+
31+
/**
32+
* Tests for {@link RestClientHttpServiceGroupAdapterRuntimeHints}.
33+
*
34+
* @author Olga Maciaszek-Sharma
35+
*/
36+
class RestClientHttpServiceGroupAdapterRuntimeHintsRegistrarTests {
37+
38+
private RuntimeHints hints;
39+
40+
@BeforeEach
41+
void setUp() {
42+
this.hints = new RuntimeHints();
43+
SpringFactoriesLoader.forResourceLocation("META-INF/spring/aot.factories")
44+
.load(RuntimeHintsRegistrar.class)
45+
.forEach(registrar ->
46+
registrar.registerHints(this.hints, ClassUtils.getDefaultClassLoader()));
47+
}
48+
49+
@Test
50+
void shouldRegisterHintsForAdapter() {
51+
assertThat(RuntimeHintsPredicates.reflection()
52+
.onType(RestClientHttpServiceGroupAdapter.class)
53+
.withMemberCategory(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
54+
.accepts(this.hints);
55+
56+
}
57+
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2002-2025 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.web.reactive.function.client.support;
18+
19+
import org.jspecify.annotations.Nullable;
20+
21+
import org.springframework.aot.hint.MemberCategory;
22+
import org.springframework.aot.hint.RuntimeHints;
23+
import org.springframework.aot.hint.RuntimeHintsRegistrar;
24+
import org.springframework.aot.hint.TypeReference;
25+
26+
/**
27+
* A {@link RuntimeHintsRegistrar} implementation that adds hints for {@link WebClientHttpServiceGroupAdapter}.
28+
*
29+
* @author Olga Maciaszek-Sharma
30+
* @since 7.0
31+
*/
32+
public class WebClientHttpServiceGroupAdapterRuntimeHints implements RuntimeHintsRegistrar {
33+
34+
@Override
35+
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
36+
hints.reflection()
37+
.registerType(TypeReference.of(WebClientHttpServiceGroupAdapter.class),
38+
MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS);
39+
}
40+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
org.springframework.aot.hint.RuntimeHintsRegistrar= \
2+
org.springframework.web.reactive.function.client.support.WebClientHttpServiceGroupAdapterRuntimeHints
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright 2002-2025 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.web.reactive.function.client.support;
18+
19+
import org.junit.jupiter.api.BeforeEach;
20+
import org.junit.jupiter.api.Test;
21+
22+
import org.springframework.aot.hint.MemberCategory;
23+
import org.springframework.aot.hint.RuntimeHints;
24+
import org.springframework.aot.hint.RuntimeHintsRegistrar;
25+
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
26+
import org.springframework.core.io.support.SpringFactoriesLoader;
27+
import org.springframework.util.ClassUtils;
28+
29+
import static org.assertj.core.api.Assertions.assertThat;
30+
31+
/**
32+
* Tests for {@link WebClientHttpServiceGroupAdapterRuntimeHints}.
33+
*
34+
* @author Olga Maciaszek-Sharma
35+
*/
36+
class WebClientHttpServiceGroupAdapterRuntimeHintsTests {
37+
38+
private RuntimeHints hints;
39+
40+
@BeforeEach
41+
void setUp() {
42+
this.hints = new RuntimeHints();
43+
SpringFactoriesLoader.forResourceLocation("META-INF/spring/aot.factories")
44+
.load(RuntimeHintsRegistrar.class)
45+
.forEach(registrar ->
46+
registrar.registerHints(this.hints, ClassUtils.getDefaultClassLoader()));
47+
}
48+
49+
@Test
50+
void shouldRegisterHintsForAdapter() {
51+
assertThat(RuntimeHintsPredicates.reflection()
52+
.onType(WebClientHttpServiceGroupAdapter.class)
53+
.withMemberCategory(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
54+
.accepts(this.hints);
55+
56+
}
57+
58+
}

0 commit comments

Comments
 (0)