Class HttpServiceProxyFactory
java.lang.Object
org.springframework.web.service.invoker.HttpServiceProxyFactory
- All Implemented Interfaces:
Aware
,InitializingBean
,EmbeddedValueResolverAware
public final class HttpServiceProxyFactory
extends Object
implements InitializingBean, EmbeddedValueResolverAware
Factory for creating a client proxy given an HTTP service interface with
@HttpExchange
methods.
This class is intended to be declared as a bean in a Spring configuration.
- Since:
- 6.0
- Author:
- Rossen Stoyanchev
- See Also:
-
Constructor Summary
ConstructorDescriptionHttpServiceProxyFactory
(HttpClientAdapter clientAdapter) Create an instance with the underlying HTTP client to use. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Register a custom argument resolver, invoked ahead of default resolvers.void
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.<S> S
createClient
(Class<S> serviceType) Return a proxy that implements the given HTTP service interface to perform HTTP requests and retrieve responses through an HTTP client.void
setBlockTimeout
(Duration blockTimeout) Configure how long to wait for a response for an HTTP service method with a synchronous (blocking) method signature.void
setConversionService
(ConversionService conversionService) Set theConversionService
to use where input values need to be formatted as Strings.void
Set the custom argument resolvers to use, ahead of default resolvers.void
setEmbeddedValueResolver
(StringValueResolver resolver) Set the StringValueResolver to use for resolving placeholders and expressions inHttpExchange.url()
.void
Set theReactiveAdapterRegistry
to use to support different asynchronous types for HTTP service method return values.
-
Constructor Details
-
HttpServiceProxyFactory
Create an instance with the underlying HTTP client to use.- Parameters:
clientAdapter
- an adapter for the client- See Also:
-
-
Method Details
-
addCustomArgumentResolver
Register a custom argument resolver, invoked ahead of default resolvers.- Parameters:
resolver
- the resolver to add
-
setCustomArgumentResolvers
Set the custom argument resolvers to use, ahead of default resolvers.- Parameters:
resolvers
- the resolvers to use
-
setConversionService
Set theConversionService
to use where input values need to be formatted as Strings.By default this is
DefaultFormattingConversionService
. -
setEmbeddedValueResolver
Set the StringValueResolver to use for resolving placeholders and expressions inHttpExchange.url()
.- Specified by:
setEmbeddedValueResolver
in interfaceEmbeddedValueResolverAware
- Parameters:
resolver
- the resolver to use
-
setReactiveAdapterRegistry
Set theReactiveAdapterRegistry
to use to support different asynchronous types for HTTP service method return values.By default this is
ReactiveAdapterRegistry.getSharedInstance()
. -
setBlockTimeout
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.
- Parameters:
blockTimeout
- the timeout value
-
afterPropertiesSet
Description copied from interface:InitializingBean
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
- Specified by:
afterPropertiesSet
in interfaceInitializingBean
- Throws:
Exception
- in the event of misconfiguration (such as failure to set an essential property) or if initialization fails for any other reason
-
createClient
Return a proxy that implements the given HTTP service interface to perform HTTP requests and retrieve responses through an HTTP client.- Type Parameters:
S
- the HTTP service type- Parameters:
serviceType
- the HTTP service to create a proxy for- Returns:
- the created proxy
-