Skip to content

Commit d661550

Browse files
committed
Update docs for HttpServiceClient
Closes gh-35244
1 parent c8b2a0f commit d661550

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

framework-docs/modules/ROOT/pages/integration/rest-clients.adoc

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,6 +1195,46 @@ One way to declare HTTP Service groups is via `@ImportHttpServices` annotations
11951195
<1> Manually list interfaces for group "echo"
11961196
<2> Detect interfaces for group "greeting" under a base package
11971197

1198+
The above lets you declare HTTP Services and groups. As an alternative, you can also
1199+
annotate HTTP interfaces as follows:
1200+
1201+
[source,java,indent=0,subs="verbatim,quotes"]
1202+
----
1203+
@HttpServiceClient("echo")
1204+
public class EchoServiceA {
1205+
// ...
1206+
}
1207+
1208+
@HttpServiceClient("echo")
1209+
public class EchoServiceB {
1210+
// ...
1211+
}
1212+
----
1213+
1214+
The above requires a dedicated import registrar as follows:
1215+
1216+
[source,java,indent=0,subs="verbatim,quotes"]
1217+
----
1218+
public class MyClientHttpServiceRegistrar implements AbstractClientHttpServiceRegistrar { // <1>
1219+
1220+
@Override
1221+
protected void registerHttpServices(GroupRegistry registry, AnnotationMetadata metadata) {
1222+
findAndRegisterHttpServiceClients(groupRegistry, List.of("org.example.echo")); // <2>
1223+
}
1224+
}
1225+
1226+
@Configuration
1227+
@Import(MyClientHttpServiceRegistrar.class) // <3>
1228+
public class ClientConfig {
1229+
}
1230+
----
1231+
<1> Extend dedicated `AbstractClientHttpServiceRegistrar`
1232+
<2> Specify base packages where to find client interfaces
1233+
<3> Import the registrar
1234+
1235+
TIP: `@HttpServiceClient` interfaces are excluded from `@ImportHttpServices` scans, so there
1236+
is no overlap with scans for client interfaces when pointed at the same package.
1237+
11981238
It is also possible to declare groups programmatically by creating an HTTP Service
11991239
registrar and then importing it:
12001240

0 commit comments

Comments
 (0)