Skip to content

Commit 5cb3af7

Browse files
committed
Add Builder to HttpServiceProxyFactory
HttpServiceProxyFactory now support programmatic initialization through a builder, while bean-style initialization is deprecated. See gh-29296
1 parent e03abc9 commit 5cb3af7

File tree

14 files changed

+410
-104
lines changed

14 files changed

+410
-104
lines changed

spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceProxyFactory.java

Lines changed: 372 additions & 68 deletions
Large diffs are not rendered by default.

spring-web/src/test/java/org/springframework/web/service/invoker/CookieValueArgumentResolverTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ class CookieValueArgumentResolverTests {
4242

4343
@BeforeEach
4444
void setUp() throws Exception {
45-
HttpServiceProxyFactory proxyFactory = new HttpServiceProxyFactory(this.client);
46-
proxyFactory.afterPropertiesSet();
45+
HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(this.client).build();
4746
this.service = proxyFactory.createClient(Service.class);
4847
}
4948

spring-web/src/test/java/org/springframework/web/service/invoker/HttpMethodArgumentResolverTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class HttpMethodArgumentResolverTests {
4343

4444
@BeforeEach
4545
void setUp() throws Exception {
46-
HttpServiceProxyFactory proxyFactory = new HttpServiceProxyFactory(this.client);
46+
HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(this.client).build();
4747
proxyFactory.afterPropertiesSet();
4848
this.service = proxyFactory.createClient(Service.class);
4949
}

spring-web/src/test/java/org/springframework/web/service/invoker/HttpServiceMethodTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public class HttpServiceMethodTests {
6464

6565
@BeforeEach
6666
void setUp() throws Exception {
67-
this.proxyFactory = new HttpServiceProxyFactory(this.client);
67+
this.proxyFactory = HttpServiceProxyFactory.builder(this.client).build();
6868
this.proxyFactory.afterPropertiesSet();
6969
}
7070

@@ -174,10 +174,10 @@ void methodAnnotatedService() {
174174
}
175175

176176
@Test
177-
void typeAndMethodAnnotatedService() throws Exception {
178-
HttpServiceProxyFactory proxyFactory = new HttpServiceProxyFactory(this.client);
179-
proxyFactory.setEmbeddedValueResolver(value -> (value.equals("${baseUrl}") ? "/base" : value));
180-
proxyFactory.afterPropertiesSet();
177+
void typeAndMethodAnnotatedService() {
178+
HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(this.client)
179+
.embeddedValueResolver(value -> (value.equals("${baseUrl}") ? "/base" : value))
180+
.build();
181181

182182
MethodLevelAnnotatedService service = proxyFactory.createClient(TypeAndMethodLevelAnnotatedService.class);
183183

spring-web/src/test/java/org/springframework/web/service/invoker/NamedValueArgumentResolverTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ class NamedValueArgumentResolverTests {
6161

6262
@BeforeEach
6363
void setUp() throws Exception {
64-
HttpServiceProxyFactory proxyFactory = new HttpServiceProxyFactory(this.client);
65-
proxyFactory.addCustomArgumentResolver(this.argumentResolver);
64+
HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(this.client)
65+
.customArgumentResolver(this.argumentResolver)
66+
.build();
6667
proxyFactory.afterPropertiesSet();
6768

6869
this.service = proxyFactory.createClient(Service.class);

spring-web/src/test/java/org/springframework/web/service/invoker/PathVariableArgumentResolverTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class PathVariableArgumentResolverTests {
4141

4242
@BeforeEach
4343
void setUp() throws Exception {
44-
HttpServiceProxyFactory proxyFactory = new HttpServiceProxyFactory(this.client);
44+
HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(this.client).build();
4545
proxyFactory.afterPropertiesSet();
4646
this.service = proxyFactory.createClient(Service.class);
4747
}

spring-web/src/test/java/org/springframework/web/service/invoker/RequestAttributeArgumentResolverTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ class RequestAttributeArgumentResolverTests {
4040

4141
@BeforeEach
4242
void setUp() throws Exception {
43-
HttpServiceProxyFactory proxyFactory = new HttpServiceProxyFactory(this.client);
44-
proxyFactory.afterPropertiesSet();
43+
HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(this.client).build();
4544
this.service = proxyFactory.createClient(Service.class);
4645
}
4746

spring-web/src/test/java/org/springframework/web/service/invoker/RequestBodyArgumentResolverTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ public class RequestBodyArgumentResolverTests {
4545

4646
@BeforeEach
4747
void setUp() throws Exception {
48-
HttpServiceProxyFactory proxyFactory = new HttpServiceProxyFactory(this.client);
49-
proxyFactory.afterPropertiesSet();
48+
HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(this.client).build();
5049
this.service = proxyFactory.createClient(Service.class);
5150
}
5251

spring-web/src/test/java/org/springframework/web/service/invoker/RequestHeaderArgumentResolverTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ class RequestHeaderArgumentResolverTests {
4343

4444
@BeforeEach
4545
void setUp() throws Exception {
46-
HttpServiceProxyFactory proxyFactory = new HttpServiceProxyFactory(this.client);
47-
proxyFactory.afterPropertiesSet();
46+
HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(this.client).build();
4847
this.service = proxyFactory.createClient(Service.class);
4948
}
5049

spring-web/src/test/java/org/springframework/web/service/invoker/RequestParamArgumentResolverTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ public class RequestParamArgumentResolverTests {
4545

4646
@BeforeEach
4747
void setUp() throws Exception {
48-
HttpServiceProxyFactory proxyFactory = new HttpServiceProxyFactory(this.client);
49-
proxyFactory.afterPropertiesSet();
48+
HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(this.client).build();
5049
this.service = proxyFactory.createClient(Service.class);
5150
}
5251

0 commit comments

Comments
 (0)