File tree Expand file tree Collapse file tree 3 files changed +39
-2
lines changed
main/java/org/springframework/aot/hint
test/java/org/springframework/aot/hint Expand file tree Collapse file tree 3 files changed +39
-2
lines changed Original file line number Diff line number Diff line change 29
29
*
30
30
* @author Stephane Nicoll
31
31
* @author Brian Clozel
32
+ * @author Sam Brannen
32
33
* @since 6.0
33
34
*/
34
35
public final class JdkProxyHint implements ConditionalHint {
@@ -130,6 +131,17 @@ public Builder proxiedInterfaces(Class<?>... proxiedInterfaces) {
130
131
return this ;
131
132
}
132
133
134
+ /**
135
+ * Add the specified interfaces that the proxy should implement.
136
+ * @param proxiedInterfaces the fully qualified class names of interfaces
137
+ * the proxy should implement
138
+ * @return {@code this}, to facilitate method chaining
139
+ */
140
+ public Builder proxiedInterfaces (String ... proxiedInterfaces ) {
141
+ this .proxiedInterfaces .addAll (toTypeReferences (proxiedInterfaces ));
142
+ return this ;
143
+ }
144
+
133
145
/**
134
146
* Make this hint conditional on the fact that the specified type
135
147
* can be resolved.
@@ -159,6 +171,10 @@ private static List<TypeReference> toTypeReferences(Class<?>... proxiedInterface
159
171
return Arrays .stream (proxiedInterfaces ).map (TypeReference ::of ).toList ();
160
172
}
161
173
174
+ private static List <TypeReference > toTypeReferences (String ... proxiedInterfaces ) {
175
+ return Arrays .stream (proxiedInterfaces ).map (TypeReference ::of ).toList ();
176
+ }
177
+
162
178
}
163
179
164
180
}
Original file line number Diff line number Diff line change 27
27
* Gather the need for using proxies at runtime.
28
28
*
29
29
* @author Stephane Nicoll
30
+ * @author Sam Brannen
30
31
* @since 6.0
31
32
*/
32
33
public class ProxyHints {
@@ -87,6 +88,18 @@ public ProxyHints registerJdkProxy(Class<?>... proxiedInterfaces) {
87
88
jdkProxyHint .proxiedInterfaces (proxiedInterfaces ));
88
89
}
89
90
91
+ /**
92
+ * Register that a JDK proxy implementing the specified interfaces is
93
+ * required.
94
+ * @param proxiedInterfaces the fully qualified class names of interfaces the
95
+ * proxy should implement
96
+ * @return {@code this}, to facilitate method chaining
97
+ */
98
+ public ProxyHints registerJdkProxy (String ... proxiedInterfaces ) {
99
+ return registerJdkProxy (jdkProxyHint ->
100
+ jdkProxyHint .proxiedInterfaces (proxiedInterfaces ));
101
+ }
102
+
90
103
/**
91
104
* Register that a class proxy is required for the class defined by the
92
105
* specified {@link TypeReference}.
Original file line number Diff line number Diff line change 32
32
* Tests for {@link ProxyHints}.
33
33
*
34
34
* @author Stephane Nicoll
35
+ * @author Sam Brannen
35
36
*/
36
37
class ProxyHintsTests {
37
38
@@ -52,10 +53,17 @@ void registerJdkProxyWithConcreteClass() {
52
53
53
54
@ Test
54
55
void registerJdkProxyWithInterfaceClassNames () {
56
+ this .proxyHints .registerJdkProxy (Function .class .getName (), "com.example.Advised" );
57
+ assertThat (this .proxyHints .jdkProxies ()).singleElement ()
58
+ .satisfies (proxiedInterfaces (Function .class .getName (), "com.example.Advised" ));
59
+ }
60
+
61
+ @ Test
62
+ void registerJdkProxyWithTypeReferences () {
55
63
this .proxyHints .registerJdkProxy (TypeReference .of (Function .class ),
56
64
TypeReference .of ("com.example.Advised" ));
57
- assertThat (this .proxyHints .jdkProxies ()).singleElement (). satisfies ( proxiedInterfaces (
58
- Function .class .getName (), "com.example.Advised" ));
65
+ assertThat (this .proxyHints .jdkProxies ()).singleElement ()
66
+ . satisfies ( proxiedInterfaces ( Function .class .getName (), "com.example.Advised" ));
59
67
}
60
68
61
69
@ Test
You can’t perform that action at this time.
0 commit comments