diff --git a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/service/RSocketServiceProxyFactory.java b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/service/RSocketServiceProxyFactory.java index 0e663386e3ff..f4480923f5b6 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/service/RSocketServiceProxyFactory.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/service/RSocketServiceProxyFactory.java @@ -30,8 +30,6 @@ import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.framework.ReflectiveMethodInvocation; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.context.EmbeddedValueResolverAware; import org.springframework.core.MethodIntrospector; import org.springframework.core.ReactiveAdapterRegistry; import org.springframework.core.annotation.AnnotatedElementUtils; @@ -44,116 +42,36 @@ * Factory for creating a client proxy given an RSocket service interface with * {@link RSocketExchange @RSocketExchange} methods. * - *

This class is intended to be declared as a bean in Spring configuration. + *

To create an instance, use static methods to obtain a + * {@link Builder Builder}. * * @author Rossen Stoyanchev * @since 6.0 */ -public final class RSocketServiceProxyFactory implements InitializingBean, EmbeddedValueResolverAware { +public final class RSocketServiceProxyFactory { - @Nullable - private final BuilderInitializedFactory builderInitializedFactory; + private final RSocketRequester rsocketRequester; + + private final List argumentResolvers; @Nullable - private final BeanStyleFactory beanStyleFactory; + private final StringValueResolver embeddedValueResolver; + private final ReactiveAdapterRegistry reactiveAdapterRegistry; + + private final Duration blockTimeout; - /** - * Create an instance with the underlying RSocketRequester to perform requests with. - * @param rsocketRequester the requester to use - * @deprecated in favor of using the Builder to initialize the - * RSocketServiceProxyFactory instance. - */ - @Deprecated(since = "6.0.0-RC2", forRemoval = true) - public RSocketServiceProxyFactory(RSocketRequester rsocketRequester) { - this.beanStyleFactory = new BeanStyleFactory(rsocketRequester); - this.builderInitializedFactory = null; - } private RSocketServiceProxyFactory( RSocketRequester rsocketRequester, List argumentResolvers, @Nullable StringValueResolver embeddedValueResolver, ReactiveAdapterRegistry reactiveAdapterRegistry, Duration blockTimeout) { - this.beanStyleFactory = null; - this.builderInitializedFactory = new BuilderInitializedFactory( - rsocketRequester, argumentResolvers, embeddedValueResolver, reactiveAdapterRegistry, blockTimeout); - } - - - /** - * Register a custom argument resolver, invoked ahead of default resolvers. - * @param resolver the resolver to add - * @deprecated in favor of using the Builder to initialize the - * RSocketServiceProxyFactory instance. - */ - @Deprecated(since = "6.0.0-RC2", forRemoval = true) - public void addCustomArgumentResolver(RSocketServiceArgumentResolver resolver) { - Assert.state(this.beanStyleFactory != null, "RSocketServiceProxyFactory was created through the builder"); - this.beanStyleFactory.addCustomArgumentResolver(resolver); - } - - /** - * Set the custom argument resolvers to use, ahead of default resolvers. - * @param resolvers the resolvers to use - * @deprecated in favor of using the Builder to initialize the - * RSocketServiceProxyFactory instance. - */ - @Deprecated(since = "6.0.0-RC2", forRemoval = true) - public void setCustomArgumentResolvers(List resolvers) { - Assert.state(this.beanStyleFactory != null, "RSocketServiceProxyFactory was created through the builder"); - this.beanStyleFactory.setCustomArgumentResolvers(resolvers); - } - - /** - * Set the StringValueResolver to use for resolving placeholders and - * expressions in {@link RSocketExchange#value()}. - * @param resolver the resolver to use - * @deprecated in favor of using the Builder to initialize the - * RSocketServiceProxyFactory instance. - */ - @Deprecated(since = "6.0.0-RC2", forRemoval = true) - @Override - public void setEmbeddedValueResolver(StringValueResolver resolver) { - if (this.beanStyleFactory != null) { - this.beanStyleFactory.setEmbeddedValueResolver(resolver); - } - } - - /** - * Set the {@link ReactiveAdapterRegistry} to use to support different - * asynchronous types for RSocket service method return values. - *

By default this is {@link ReactiveAdapterRegistry#getSharedInstance()}. - * @deprecated in favor of using the Builder to initialize the - * RSocketServiceProxyFactory instance. - */ - @Deprecated(since = "6.0.0-RC2", forRemoval = true) - public void setReactiveAdapterRegistry(ReactiveAdapterRegistry registry) { - Assert.state(this.beanStyleFactory != null, "RSocketServiceProxyFactory was created through the builder"); - this.beanStyleFactory.setReactiveAdapterRegistry(registry); - } - - /** - * Configure how long to wait for a response for an RSocket service method - * with a synchronous (blocking) method signature. - *

By default this is 5 seconds. - * @param blockTimeout the timeout value - * @deprecated in favor of using the Builder to initialize the - * RSocketServiceProxyFactory instance. - */ - @Deprecated(since = "6.0.0-RC2", forRemoval = true) - public void setBlockTimeout(Duration blockTimeout) { - Assert.state(this.beanStyleFactory != null, "RSocketServiceProxyFactory was created through the builder"); - this.beanStyleFactory.setBlockTimeout(blockTimeout); - } - - - @Override - @Deprecated - public void afterPropertiesSet() throws Exception { - if (this.beanStyleFactory != null) { - this.beanStyleFactory.afterPropertiesSet(); - } + this.rsocketRequester = rsocketRequester; + this.argumentResolvers = argumentResolvers; + this.embeddedValueResolver = embeddedValueResolver; + this.reactiveAdapterRegistry = reactiveAdapterRegistry; + this.blockTimeout = blockTimeout; } @@ -166,15 +84,26 @@ public void afterPropertiesSet() throws Exception { * @return the created proxy */ public S createClient(Class serviceType) { - if (this.builderInitializedFactory != null) { - return this.builderInitializedFactory.createClient(serviceType); - } - else if (this.beanStyleFactory != null) { - return this.beanStyleFactory.createClient(serviceType); - } - else { - throw new IllegalStateException("Expected Builder initialized or Bean-style delegate"); - } + + List serviceMethods = + MethodIntrospector.selectMethods(serviceType, this::isExchangeMethod).stream() + .map(method -> createRSocketServiceMethod(serviceType, method)) + .toList(); + + return ProxyFactory.getProxy(serviceType, new ServiceMethodInterceptor(serviceMethods)); + } + + private boolean isExchangeMethod(Method method) { + return AnnotatedElementUtils.hasAnnotation(method, RSocketExchange.class); + } + + private RSocketServiceMethod createRSocketServiceMethod(Class serviceType, Method method) { + Assert.notNull(this.argumentResolvers, + "No argument resolvers: afterPropertiesSet was not called"); + + return new RSocketServiceMethod( + method, serviceType, this.argumentResolvers, this.rsocketRequester, + this.embeddedValueResolver, this.reactiveAdapterRegistry, this.blockTimeout); } @@ -330,163 +259,4 @@ public Object invoke(MethodInvocation invocation) throws Throwable { } } - - /** - * Temporary class until bean-style initialization is removed. - */ - private static final class BuilderInitializedFactory { - - private final RSocketRequester rsocketRequester; - - private final List argumentResolvers; - - @Nullable - private final StringValueResolver embeddedValueResolver; - - private final ReactiveAdapterRegistry reactiveAdapterRegistry; - - private final Duration blockTimeout; - - - public BuilderInitializedFactory( - RSocketRequester rsocketRequester, List argumentResolvers, - @Nullable StringValueResolver embeddedValueResolver, - ReactiveAdapterRegistry reactiveAdapterRegistry, Duration blockTimeout) { - - this.rsocketRequester = rsocketRequester; - this.argumentResolvers = argumentResolvers; - this.embeddedValueResolver = embeddedValueResolver; - this.reactiveAdapterRegistry = reactiveAdapterRegistry; - this.blockTimeout = blockTimeout; - } - - - public S createClient(Class serviceType) { - - List serviceMethods = - MethodIntrospector.selectMethods(serviceType, this::isExchangeMethod).stream() - .map(method -> createRSocketServiceMethod(serviceType, method)) - .toList(); - - return ProxyFactory.getProxy(serviceType, new ServiceMethodInterceptor(serviceMethods)); - } - - private boolean isExchangeMethod(Method method) { - return AnnotatedElementUtils.hasAnnotation(method, RSocketExchange.class); - } - - private RSocketServiceMethod createRSocketServiceMethod(Class serviceType, Method method) { - Assert.notNull(this.argumentResolvers, - "No argument resolvers: afterPropertiesSet was not called"); - - return new RSocketServiceMethod( - method, serviceType, this.argumentResolvers, this.rsocketRequester, - this.embeddedValueResolver, this.reactiveAdapterRegistry, this.blockTimeout); - } - } - - - /** - * Temporary class to support bean-style initialization during deprecation period. - */ - private static final class BeanStyleFactory implements InitializingBean, EmbeddedValueResolverAware { - - private final RSocketRequester rsocketRequester; - - @Nullable - private List customArgumentResolvers; - - @Nullable - private List argumentResolvers; - - @Nullable - private StringValueResolver embeddedValueResolver; - - private ReactiveAdapterRegistry reactiveAdapterRegistry = ReactiveAdapterRegistry.getSharedInstance(); - - private Duration blockTimeout = Duration.ofSeconds(5); - - - public BeanStyleFactory(RSocketRequester rsocketRequester) { - Assert.notNull(rsocketRequester, "RSocketRequester is required"); - this.rsocketRequester = rsocketRequester; - } - - - public void addCustomArgumentResolver(RSocketServiceArgumentResolver resolver) { - if (this.customArgumentResolvers == null) { - this.customArgumentResolvers = new ArrayList<>(); - } - this.customArgumentResolvers.add(resolver); - } - - public void setCustomArgumentResolvers(List resolvers) { - this.customArgumentResolvers = new ArrayList<>(resolvers); - } - - @Override - public void setEmbeddedValueResolver(StringValueResolver resolver) { - this.embeddedValueResolver = resolver; - } - - public void setReactiveAdapterRegistry(ReactiveAdapterRegistry registry) { - this.reactiveAdapterRegistry = registry; - } - - public void setBlockTimeout(Duration blockTimeout) { - this.blockTimeout = blockTimeout; - } - - - @Override - public void afterPropertiesSet() { - this.argumentResolvers = initArgumentResolvers(); - } - - private List initArgumentResolvers() { - List resolvers = new ArrayList<>(); - - // Custom - if (this.customArgumentResolvers != null) { - resolvers.addAll(this.customArgumentResolvers); - } - - // Annotation-based - resolvers.add(new PayloadArgumentResolver(this.reactiveAdapterRegistry, false)); - resolvers.add(new DestinationVariableArgumentResolver()); - - // Type-based - resolvers.add(new MetadataArgumentResolver()); - - // Fallback - resolvers.add(new PayloadArgumentResolver(this.reactiveAdapterRegistry, true)); - - return resolvers; - } - - - public S createClient(Class serviceType) { - - List serviceMethods = - MethodIntrospector.selectMethods(serviceType, this::isExchangeMethod).stream() - .map(method -> createRSocketServiceMethod(serviceType, method)) - .toList(); - - return ProxyFactory.getProxy(serviceType, new ServiceMethodInterceptor(serviceMethods)); - } - - private boolean isExchangeMethod(Method method) { - return AnnotatedElementUtils.hasAnnotation(method, RSocketExchange.class); - } - - private RSocketServiceMethod createRSocketServiceMethod(Class serviceType, Method method) { - Assert.notNull(this.argumentResolvers, - "No argument resolvers: afterPropertiesSet was not called"); - - return new RSocketServiceMethod( - method, serviceType, this.argumentResolvers, this.rsocketRequester, - this.embeddedValueResolver, this.reactiveAdapterRegistry, this.blockTimeout); - } - } - } diff --git a/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceProxyFactory.java b/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceProxyFactory.java index 61e98f63ddff..af509524ba3d 100644 --- a/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceProxyFactory.java +++ b/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceProxyFactory.java @@ -30,8 +30,6 @@ import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.framework.ReflectiveMethodInvocation; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.context.EmbeddedValueResolverAware; import org.springframework.core.MethodIntrospector; import org.springframework.core.ReactiveAdapterRegistry; import org.springframework.core.annotation.AnnotatedElementUtils; @@ -46,163 +44,80 @@ * Factory to create a client proxy from an HTTP service interface with * {@link HttpExchange @HttpExchange} methods. * - *

To create an instance, use static methods to obtain a {@link Builder Builder}. + *

To create an instance, use static methods to obtain a + * {@link Builder Builder}. * * @author Rossen Stoyanchev * @since 6.0 * @see org.springframework.web.reactive.function.client.support.WebClientAdapter */ -public final class HttpServiceProxyFactory implements InitializingBean, EmbeddedValueResolverAware { +public final class HttpServiceProxyFactory { - @Nullable - private final BuilderInitializedFactory builderInitializedFactory; + private final HttpClientAdapter clientAdapter; + + private final List argumentResolvers; @Nullable - private final BeanStyleFactory beanStyleFactory; + private final StringValueResolver embeddedValueResolver; + private final ReactiveAdapterRegistry reactiveAdapterRegistry; + + private final Duration blockTimeout; - /** - * Create an instance with the underlying HTTP client to use. - * @param clientAdapter an adapter for the client - * @deprecated in favor of using the Builder to initialize the - * HttpServiceProxyFactory instance. - */ - @Deprecated(since = "6.0.0-RC2", forRemoval = true) - public HttpServiceProxyFactory(HttpClientAdapter clientAdapter) { - this.beanStyleFactory = new BeanStyleFactory(clientAdapter); - this.builderInitializedFactory = null; - } private HttpServiceProxyFactory( HttpClientAdapter clientAdapter, List argumentResolvers, @Nullable StringValueResolver embeddedValueResolver, ReactiveAdapterRegistry reactiveAdapterRegistry, Duration blockTimeout) { - this.beanStyleFactory = null; - this.builderInitializedFactory = new BuilderInitializedFactory( - clientAdapter, argumentResolvers, embeddedValueResolver, reactiveAdapterRegistry, blockTimeout); - } - - - /** - * Register a custom argument resolver, invoked ahead of default resolvers. - * @param resolver the resolver to add - * @deprecated in favor of using the Builder to initialize the - * HttpServiceProxyFactory instance. - */ - @Deprecated(since = "6.0.0-RC2", forRemoval = true) - public void addCustomArgumentResolver(HttpServiceArgumentResolver resolver) { - Assert.state(this.beanStyleFactory != null, "HttpServiceProxyFactory was created through the builder"); - this.beanStyleFactory.addCustomArgumentResolver(resolver); + this.clientAdapter = clientAdapter; + this.argumentResolvers = argumentResolvers; + this.embeddedValueResolver = embeddedValueResolver; + this.reactiveAdapterRegistry = reactiveAdapterRegistry; + this.blockTimeout = blockTimeout; } - /** - * Set the custom argument resolvers to use, ahead of default resolvers. - * @param resolvers the resolvers to use - * @deprecated in favor of using the Builder to initialize the - * HttpServiceProxyFactory instance. - */ - @Deprecated(since = "6.0.0-RC2", forRemoval = true) - public void setCustomArgumentResolvers(List resolvers) { - Assert.state(this.beanStyleFactory != null, "HttpServiceProxyFactory was created through the builder"); - this.beanStyleFactory.setCustomArgumentResolvers(resolvers); - } - - /** - * Set the {@link ConversionService} to use where input values need to - * be formatted as Strings. - *

By default this is {@link DefaultFormattingConversionService}. - * @deprecated in favor of using the Builder to initialize the - * HttpServiceProxyFactory instance. - */ - @Deprecated(since = "6.0.0-RC2", forRemoval = true) - public void setConversionService(ConversionService conversionService) { - Assert.state(this.beanStyleFactory != null, "HttpServiceProxyFactory was created through the builder"); - this.beanStyleFactory.setConversionService(conversionService); - } /** - * Set the StringValueResolver to use for resolving placeholders and - * expressions in {@link HttpExchange#url()}. - * @param resolver the resolver to use - * @deprecated in favor of using the Builder to initialize the - * HttpServiceProxyFactory instance. + * Return a proxy that implements the given HTTP service interface to perform + * HTTP requests and retrieve responses through an HTTP client. + * @param serviceType the HTTP service to create a proxy for + * @param the HTTP service type + * @return the created proxy */ - @Deprecated(since = "6.0.0-RC2", forRemoval = true) - @Override - public void setEmbeddedValueResolver(StringValueResolver resolver) { - if (this.beanStyleFactory != null) { - this.beanStyleFactory.setEmbeddedValueResolver(resolver); - } - } + public S createClient(Class serviceType) { - /** - * Set the {@link ReactiveAdapterRegistry} to use to support different - * asynchronous types for HTTP service method return values. - *

By default this is {@link ReactiveAdapterRegistry#getSharedInstance()}. - * @deprecated in favor of using the Builder to initialize the - * HttpServiceProxyFactory instance. - */ - @Deprecated(since = "6.0.0-RC2", forRemoval = true) - public void setReactiveAdapterRegistry(ReactiveAdapterRegistry registry) { - Assert.state(this.beanStyleFactory != null, "HttpServiceProxyFactory was created through the builder"); - this.beanStyleFactory.setReactiveAdapterRegistry(registry); - } + List httpServiceMethods = + MethodIntrospector.selectMethods(serviceType, this::isExchangeMethod).stream() + .map(method -> createHttpServiceMethod(serviceType, method)) + .toList(); - /** - * Configure how long to wait for a response for an HTTP service method - * with a synchronous (blocking) method signature. - *

By default this is 5 seconds. - * @param blockTimeout the timeout value - * @deprecated in favor of using the Builder to initialize the - * HttpServiceProxyFactory instance. - */ - @Deprecated(since = "6.0.0-RC2", forRemoval = true) - public void setBlockTimeout(Duration blockTimeout) { - Assert.state(this.beanStyleFactory != null, "HttpServiceProxyFactory was created through the builder"); - this.beanStyleFactory.setBlockTimeout(blockTimeout); + return ProxyFactory.getProxy(serviceType, new HttpServiceMethodInterceptor(httpServiceMethods)); } - - @Override - @Deprecated - public void afterPropertiesSet() throws Exception { - if (this.beanStyleFactory != null) { - this.beanStyleFactory.afterPropertiesSet(); - } + private boolean isExchangeMethod(Method method) { + return AnnotatedElementUtils.hasAnnotation(method, HttpExchange.class); } + private HttpServiceMethod createHttpServiceMethod(Class serviceType, Method method) { + Assert.notNull(this.argumentResolvers, + "No argument resolvers: afterPropertiesSet was not called"); - /** - * Return a proxy that implements the given HTTP service interface to perform - * HTTP requests and retrieve responses through an HTTP client. - * @param serviceType the HTTP service to create a proxy for - * @param the HTTP service type - * @return the created proxy - */ - public S createClient(Class serviceType) { - if (this.builderInitializedFactory != null) { - return this.builderInitializedFactory.createClient(serviceType); - } - else if (this.beanStyleFactory != null) { - return this.beanStyleFactory.createClient(serviceType); - } - else { - throw new IllegalStateException("Expected Builder initialized or Bean-style delegate"); - } + return new HttpServiceMethod( + method, serviceType, this.argumentResolvers, this.clientAdapter, + this.embeddedValueResolver, this.reactiveAdapterRegistry, this.blockTimeout); } /** - * Return an {@link HttpServiceProxyFactory} builder, initialized with the - * given client. + * Return a builder that's initialized with the given client. */ public static Builder builder(HttpClientAdapter clientAdapter) { return new Builder().clientAdapter(clientAdapter); } /** - * Return an {@link HttpServiceProxyFactory} builder. + * Return an empty builder, with the client to be provided to builder. */ public static Builder builder() { return new Builder(); @@ -365,173 +280,4 @@ public Object invoke(MethodInvocation invocation) throws Throwable { } } - - /** - * Temporary class until bean-style initialization is removed. - */ - private static final class BuilderInitializedFactory { - - private final HttpClientAdapter clientAdapter; - - private final List argumentResolvers; - - @Nullable - private final StringValueResolver embeddedValueResolver; - - private final ReactiveAdapterRegistry reactiveAdapterRegistry; - - private final Duration blockTimeout; - - private BuilderInitializedFactory( - HttpClientAdapter clientAdapter, List argumentResolvers, - @Nullable StringValueResolver embeddedValueResolver, - ReactiveAdapterRegistry reactiveAdapterRegistry, Duration blockTimeout) { - - this.clientAdapter = clientAdapter; - this.argumentResolvers = argumentResolvers; - this.embeddedValueResolver = embeddedValueResolver; - this.reactiveAdapterRegistry = reactiveAdapterRegistry; - this.blockTimeout = blockTimeout; - } - - public S createClient(Class serviceType) { - - List httpServiceMethods = - MethodIntrospector.selectMethods(serviceType, this::isExchangeMethod).stream() - .map(method -> createHttpServiceMethod(serviceType, method)) - .toList(); - - return ProxyFactory.getProxy(serviceType, new HttpServiceMethodInterceptor(httpServiceMethods)); - } - - private boolean isExchangeMethod(Method method) { - return AnnotatedElementUtils.hasAnnotation(method, HttpExchange.class); - } - - private HttpServiceMethod createHttpServiceMethod(Class serviceType, Method method) { - Assert.notNull(this.argumentResolvers, - "No argument resolvers: afterPropertiesSet was not called"); - - return new HttpServiceMethod( - method, serviceType, this.argumentResolvers, this.clientAdapter, - this.embeddedValueResolver, this.reactiveAdapterRegistry, this.blockTimeout); - } - } - - - /** - * Temporary class to support bean-style initialization during deprecation period. - */ - private static final class BeanStyleFactory implements InitializingBean, EmbeddedValueResolverAware { - - private final HttpClientAdapter clientAdapter; - - @Nullable - private List customArgumentResolvers; - - @Nullable - private List argumentResolvers; - - @Nullable - private ConversionService conversionService; - - @Nullable - private StringValueResolver embeddedValueResolver; - - private ReactiveAdapterRegistry reactiveAdapterRegistry = ReactiveAdapterRegistry.getSharedInstance(); - - private Duration blockTimeout = Duration.ofSeconds(5); - - BeanStyleFactory(HttpClientAdapter clientAdapter) { - Assert.notNull(clientAdapter, "HttpClientAdapter is required"); - this.clientAdapter = clientAdapter; - } - - public void addCustomArgumentResolver(HttpServiceArgumentResolver resolver) { - if (this.customArgumentResolvers == null) { - this.customArgumentResolvers = new ArrayList<>(); - } - this.customArgumentResolvers.add(resolver); - } - - public void setCustomArgumentResolvers(List resolvers) { - this.customArgumentResolvers = new ArrayList<>(resolvers); - } - - public void setConversionService(ConversionService conversionService) { - this.conversionService = conversionService; - } - - @Override - public void setEmbeddedValueResolver(StringValueResolver resolver) { - this.embeddedValueResolver = resolver; - } - - public void setReactiveAdapterRegistry(ReactiveAdapterRegistry registry) { - this.reactiveAdapterRegistry = registry; - } - - public void setBlockTimeout(Duration blockTimeout) { - this.blockTimeout = blockTimeout; - } - - - @Override - public void afterPropertiesSet() throws Exception { - - this.conversionService = (this.conversionService != null ? - this.conversionService : new DefaultFormattingConversionService()); - - this.argumentResolvers = initArgumentResolvers(this.conversionService); - } - - private List initArgumentResolvers(ConversionService conversionService) { - List resolvers = new ArrayList<>(); - - // Custom - if (this.customArgumentResolvers != null) { - resolvers.addAll(this.customArgumentResolvers); - } - - // Annotation-based - resolvers.add(new RequestHeaderArgumentResolver(conversionService)); - resolvers.add(new RequestBodyArgumentResolver(this.reactiveAdapterRegistry)); - resolvers.add(new PathVariableArgumentResolver(conversionService)); - resolvers.add(new RequestParamArgumentResolver(conversionService)); - resolvers.add(new RequestPartArgumentResolver(this.reactiveAdapterRegistry)); - resolvers.add(new CookieValueArgumentResolver(conversionService)); - resolvers.add(new RequestAttributeArgumentResolver()); - - // Specific type - resolvers.add(new UrlArgumentResolver()); - resolvers.add(new HttpMethodArgumentResolver()); - - return resolvers; - } - - - public S createClient(Class serviceType) { - - List httpServiceMethods = - MethodIntrospector.selectMethods(serviceType, this::isExchangeMethod).stream() - .map(method -> createHttpServiceMethod(serviceType, method)) - .toList(); - - return ProxyFactory.getProxy(serviceType, new HttpServiceMethodInterceptor(httpServiceMethods)); - } - - private boolean isExchangeMethod(Method method) { - return AnnotatedElementUtils.hasAnnotation(method, HttpExchange.class); - } - - private HttpServiceMethod createHttpServiceMethod(Class serviceType, Method method) { - Assert.notNull(this.argumentResolvers, - "No argument resolvers: afterPropertiesSet was not called"); - - return new HttpServiceMethod( - method, serviceType, this.argumentResolvers, this.clientAdapter, - this.embeddedValueResolver, this.reactiveAdapterRegistry, this.blockTimeout); - } - } - } diff --git a/spring-web/src/test/java/org/springframework/web/service/invoker/HttpMethodArgumentResolverTests.java b/spring-web/src/test/java/org/springframework/web/service/invoker/HttpMethodArgumentResolverTests.java index 4e7c2acc5418..d4185496f27f 100644 --- a/spring-web/src/test/java/org/springframework/web/service/invoker/HttpMethodArgumentResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/service/invoker/HttpMethodArgumentResolverTests.java @@ -42,10 +42,8 @@ public class HttpMethodArgumentResolverTests { @BeforeEach - @SuppressWarnings("deprecation") void setUp() throws Exception { HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(this.client).build(); - proxyFactory.afterPropertiesSet(); this.service = proxyFactory.createClient(Service.class); } diff --git a/spring-web/src/test/java/org/springframework/web/service/invoker/HttpServiceMethodTests.java b/spring-web/src/test/java/org/springframework/web/service/invoker/HttpServiceMethodTests.java index 0b31b8916062..beb6482db060 100644 --- a/spring-web/src/test/java/org/springframework/web/service/invoker/HttpServiceMethodTests.java +++ b/spring-web/src/test/java/org/springframework/web/service/invoker/HttpServiceMethodTests.java @@ -63,10 +63,8 @@ public class HttpServiceMethodTests { @BeforeEach - @SuppressWarnings("deprecation") void setUp() throws Exception { this.proxyFactory = HttpServiceProxyFactory.builder(this.client).build(); - this.proxyFactory.afterPropertiesSet(); } diff --git a/spring-web/src/test/java/org/springframework/web/service/invoker/NamedValueArgumentResolverTests.java b/spring-web/src/test/java/org/springframework/web/service/invoker/NamedValueArgumentResolverTests.java index ea09582c705b..b8c308a4804a 100644 --- a/spring-web/src/test/java/org/springframework/web/service/invoker/NamedValueArgumentResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/service/invoker/NamedValueArgumentResolverTests.java @@ -60,12 +60,10 @@ class NamedValueArgumentResolverTests { @BeforeEach - @SuppressWarnings("deprecation") void setUp() throws Exception { HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(this.client) .customArgumentResolver(this.argumentResolver) .build(); - proxyFactory.afterPropertiesSet(); this.service = proxyFactory.createClient(Service.class); } diff --git a/spring-web/src/test/java/org/springframework/web/service/invoker/PathVariableArgumentResolverTests.java b/spring-web/src/test/java/org/springframework/web/service/invoker/PathVariableArgumentResolverTests.java index e24304e4b6df..83c39cee9bc9 100644 --- a/spring-web/src/test/java/org/springframework/web/service/invoker/PathVariableArgumentResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/service/invoker/PathVariableArgumentResolverTests.java @@ -40,10 +40,8 @@ class PathVariableArgumentResolverTests { @BeforeEach - @SuppressWarnings("deprecation") void setUp() throws Exception { HttpServiceProxyFactory proxyFactory = HttpServiceProxyFactory.builder(this.client).build(); - proxyFactory.afterPropertiesSet(); this.service = proxyFactory.createClient(Service.class); } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/support/WebClientAdapter.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/support/WebClientAdapter.java index c62e255028ec..560eb4b201bd 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/support/WebClientAdapter.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/support/WebClientAdapter.java @@ -133,35 +133,4 @@ public static WebClientAdapter forClient(WebClient webClient) { return new WebClientAdapter(webClient); } - /** - * Static method to create a {@link HttpServiceProxyFactory} configured to - * use the given {@link WebClient} instance. Effectively a shortcut for: - *

-	 * WebClientAdapter adapter = WebClientAdapter.forClient(webClient);
-	 * HttpServiceProxyFactory proxyFactory = new HttpServiceProxyFactory(adapter);
-	 * 
- * @param webClient the client to use - * @return the created {@code HttpServiceProxyFactory} instance - * @deprecated in favor of using {@link #forClient(WebClient)} and - * {@link HttpServiceProxyFactory#builder(HttpClientAdapter)} - */ - @SuppressWarnings("removal") - @Deprecated(since = "6.0.0-RC1", forRemoval = true) - public static HttpServiceProxyFactory createHttpServiceProxyFactory(WebClient webClient) { - return new HttpServiceProxyFactory(new WebClientAdapter(webClient)); - } - - /** - * Variant of {@link #createHttpServiceProxyFactory(WebClient)} that accepts - * a {@link WebClient.Builder} and uses it to create the client. - * @param webClientBuilder a builder to create the client to use with - * @return the created {@code HttpServiceProxyFactory} instance - * @deprecated in favor of using {@link #forClient(WebClient)} and - * {@link HttpServiceProxyFactory#builder(HttpClientAdapter)} - */ - @Deprecated(since = "6.0.0-RC1", forRemoval = true) - public static HttpServiceProxyFactory createHttpServiceProxyFactory(WebClient.Builder webClientBuilder) { - return createHttpServiceProxyFactory(webClientBuilder.build()); - } - }