Top Description Inners Fields Constructors Methods
org.springframework.web.service.invoker

public final Class HttpServiceProxyFactory

extends Object
Class Inheritance
Imports
java.lang.reflect.InvocationHandler, .Method, java.time.Duration, java.util.ArrayList, .List, .Map, java.util.function.Function, java.util.stream.Collectors, org.aopalliance.intercept.MethodInterceptor, .MethodInvocation, org.springframework.aop.framework.ProxyFactory, .ReflectiveMethodInvocation, org.springframework.core.KotlinDetector, .MethodIntrospector, .ReactiveAdapterRegistry, org.springframework.core.annotation.AnnotatedElementUtils, org.springframework.core.convert.ConversionService, org.springframework.format.support.DefaultFormattingConversionService, org.springframework.lang.Nullable, org.springframework.util.Assert, .StringValueResolver, org.springframework.web.service.annotation.HttpExchange

Factory to create a client proxy from an HTTP service interface with @HttpExchange methods.

To create an instance, use static methods to obtain a Builder.

Author
Rossen Stoyanchev
Since
6.0
See Also
org.springframework.web.client.support.RestClientAdapter, org.springframework.web.reactive.function.client.support.WebClientAdapter, org.springframework.web.client.support.RestTemplateAdapter

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
private static class

Field Summary

Modifier and TypeField and Description
private final List<HttpServiceArgumentResolver>
private final StringValueResolver
private final HttpExchangeAdapter

Constructor Summary

AccessConstructor and Description
private
HttpServiceProxyFactory(HttpExchangeAdapter exchangeAdapter, List<HttpServiceArgumentResolver> argumentResolvers, StringValueResolver embeddedValueResolver)

Method Summary

Modifier and TypeMethod and Description
public static HttpServiceProxyFactory.Builder
builder(HttpClientAdapter clientAdapter)

Deprecated for removal since 6.1. in favor of builderFor(HttpExchangeAdapter); to be removed in 6.2.
Return a builder that's initialized with the given client.
public static HttpServiceProxyFactory.Builder
builder()

Return an empty builder, with the client to be provided to builder.

public static HttpServiceProxyFactory.Builder
builderFor(HttpExchangeAdapter exchangeAdapter)

Return a builder that's initialized with the given client.

public <
the HTTP service type
S
>
S

Returns:

the created proxy
createClient
(Class<S>
the HTTP service to create a proxy for
serviceType
)

Return a proxy that implements the given HTTP service interface to perform HTTP requests and retrieve responses through an HTTP client.

private <S> HttpServiceMethod
createHttpServiceMethod(Class<S> serviceType, Method method)

private boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

argumentResolversback to summary
private final List<HttpServiceArgumentResolver> argumentResolvers
embeddedValueResolverback to summary
private final StringValueResolver embeddedValueResolver
Annotations
@Nullable
exchangeAdapterback to summary
private final HttpExchangeAdapter exchangeAdapter

Constructor Detail

HttpServiceProxyFactoryback to summary
private HttpServiceProxyFactory(HttpExchangeAdapter exchangeAdapter, List<HttpServiceArgumentResolver> argumentResolvers, StringValueResolver embeddedValueResolver)

Method Detail

builderback to summary
public static HttpServiceProxyFactory.Builder builder(HttpClientAdapter clientAdapter)

Deprecated

for removal since 6.1.

in favor of builderFor(HttpExchangeAdapter); to be removed in 6.2.

Return a builder that's initialized with the given client.

Annotations
@SuppressWarnings:removal
@Deprecated
since:6.1
forRemoval:true
builderback to summary
public static HttpServiceProxyFactory.Builder builder()

Return an empty builder, with the client to be provided to builder.

builderForback to summary
public static HttpServiceProxyFactory.Builder builderFor(HttpExchangeAdapter exchangeAdapter)

Return a builder that's initialized with the given client.

Since
6.1
createClientback to summary
public <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.

Parameters
<S>
the HTTP service type
serviceType:Class<S>

the HTTP service to create a proxy for

Returns:S

the created proxy

createHttpServiceMethodback to summary
private <S> HttpServiceMethod createHttpServiceMethod(Class<S> serviceType, Method method)
isExchangeMethodback to summary
private boolean isExchangeMethod(Method method)
org.springframework.web.service.invoker back to summary

public final Class HttpServiceProxyFactory.Builder

extends Object
Class Inheritance
  • java.lang.Object
  • org.springframework.web.service.invoker.HttpServiceProxyFactory.Builder

Builder to create an HttpServiceProxyFactory.

Field Summary

Modifier and TypeField and Description
private ConversionService
private final List<HttpServiceArgumentResolver>
private StringValueResolver
private HttpExchangeAdapter

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public HttpServiceProxyFactory.Builder

Returns:

this same builder instance
blockTimeout
(Duration
the timeout value
blockTimeout
)

Deprecated for removal since 6.1. in favor of setting the same directly on the HttpExchangeAdapter
Configure how long to block for the response of an HTTP service method with a synchronous (blocking) method signature.
public HttpServiceProxyFactory
build()

Build the HttpServiceProxyFactory instance.

public HttpServiceProxyFactory.Builder

Returns:

this same builder instance
clientAdapter
(HttpClientAdapter
a client adapted to HttpClientAdapter
clientAdapter
)

Deprecated for removal since 6.1. in favor of exchangeAdapter(HttpExchangeAdapter); to be removed in 6.2
Provide the HTTP client to perform requests through.
public HttpServiceProxyFactory.Builder

Returns:

this same builder instance
conversionService
(ConversionService conversionService)

Set the ConversionService to use where input values need to be formatted as Strings.

public HttpServiceProxyFactory.Builder

Returns:

this same builder instance
customArgumentResolver
(HttpServiceArgumentResolver
the resolver to add
resolver
)

Register a custom argument resolver, invoked ahead of default resolvers.

public HttpServiceProxyFactory.Builder

Returns:

this same builder instance
embeddedValueResolver
(StringValueResolver
the resolver to use
embeddedValueResolver
)

Set the StringValueResolver to use for resolving placeholders and expressions embedded in HttpExchange#url().

public HttpServiceProxyFactory.Builder

Returns:

this same builder instance
exchangeAdapter
(HttpExchangeAdapter
a client adapted to HttpExchangeAdapter
adapter
)

Provide the HTTP client to perform requests through.

private List<HttpServiceArgumentResolver>
public HttpServiceProxyFactory.Builder

Returns:

this same builder instance
reactiveAdapterRegistry
(ReactiveAdapterRegistry registry)

Deprecated for removal since 6.1. in favor of setting the same directly on the HttpExchangeAdapter
Set the ReactiveAdapterRegistry to use to support different asynchronous types for HTTP service method return values.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

conversionServiceback to summary
private ConversionService conversionService
Annotations
@Nullable
customArgumentResolversback to summary
private final List<HttpServiceArgumentResolver> customArgumentResolvers
embeddedValueResolverback to summary
private StringValueResolver embeddedValueResolver
Annotations
@Nullable
exchangeAdapterback to summary
private HttpExchangeAdapter exchangeAdapter
Annotations
@Nullable

Constructor Detail

Builderback to summary
private Builder()

Method Detail

blockTimeoutback to summary
public HttpServiceProxyFactory.Builder blockTimeout(Duration blockTimeout)

Deprecated

for removal since 6.1.

in favor of setting the same directly on the HttpExchangeAdapter

Configure how long to block for the response of an HTTP service method with a synchronous (blocking) method signature.

By default this is not set, in which case the behavior depends on connection and request timeout settings of the underlying HTTP client. We recommend configuring timeout values directly on the underlying HTTP client, which provides more control over such settings.

Parameters
blockTimeout:Duration

the timeout value

Returns:HttpServiceProxyFactory.Builder

this same builder instance

Annotations
@Deprecated
since:6.1
forRemoval:true
buildback to summary
public HttpServiceProxyFactory build()

Build the HttpServiceProxyFactory instance.

clientAdapterback to summary
public HttpServiceProxyFactory.Builder clientAdapter(HttpClientAdapter clientAdapter)

Deprecated

for removal since 6.1.

in favor of exchangeAdapter(HttpExchangeAdapter); to be removed in 6.2

Provide the HTTP client to perform requests through.

Parameters
clientAdapter:HttpClientAdapter

a client adapted to HttpClientAdapter

Returns:HttpServiceProxyFactory.Builder

this same builder instance

Annotations
@SuppressWarnings:removal
@Deprecated
since:6.1
forRemoval:true
conversionServiceback to summary
public HttpServiceProxyFactory.Builder conversionService(ConversionService conversionService)

Set the ConversionService to use where input values need to be formatted as Strings.

By default this is DefaultFormattingConversionService.

Returns:HttpServiceProxyFactory.Builder

this same builder instance

customArgumentResolverback to summary
public HttpServiceProxyFactory.Builder customArgumentResolver(HttpServiceArgumentResolver resolver)

Register a custom argument resolver, invoked ahead of default resolvers.

Parameters
resolver:HttpServiceArgumentResolver

the resolver to add

Returns:HttpServiceProxyFactory.Builder

this same builder instance

embeddedValueResolverback to summary
public HttpServiceProxyFactory.Builder embeddedValueResolver(StringValueResolver embeddedValueResolver)

Set the StringValueResolver to use for resolving placeholders and expressions embedded in HttpExchange#url().

Parameters
embeddedValueResolver:StringValueResolver

the resolver to use

Returns:HttpServiceProxyFactory.Builder

this same builder instance

exchangeAdapterback to summary
public HttpServiceProxyFactory.Builder exchangeAdapter(HttpExchangeAdapter adapter)

Provide the HTTP client to perform requests through.

Parameters
adapter:HttpExchangeAdapter

a client adapted to HttpExchangeAdapter

Returns:HttpServiceProxyFactory.Builder

this same builder instance

Since
6.1
initArgumentResolversback to summary
private List<HttpServiceArgumentResolver> initArgumentResolvers()
Annotations
@SuppressWarnings:DataFlowIssue
reactiveAdapterRegistryback to summary
public HttpServiceProxyFactory.Builder reactiveAdapterRegistry(ReactiveAdapterRegistry registry)

Deprecated

for removal since 6.1.

in favor of setting the same directly on the HttpExchangeAdapter

Set the ReactiveAdapterRegistry to use to support different asynchronous types for HTTP service method return values.

By default this is ReactiveAdapterRegistry#getSharedInstance().

Returns:HttpServiceProxyFactory.Builder

this same builder instance

Annotations
@Deprecated
since:6.1
forRemoval:true
org.springframework.web.service.invoker back to summary

private final Class HttpServiceProxyFactory.HttpServiceMethodInterceptor

extends Object
implements MethodInterceptor
Class Inheritance
  • java.lang.Object
  • org.springframework.web.service.invoker.HttpServiceProxyFactory.HttpServiceMethodInterceptor
All Implemented Interfaces
org.aopalliance.intercept.MethodInterceptor, org.aopalliance.intercept.Interceptor, org.aopalliance.aop.Advice

MethodInterceptor that invokes an HttpServiceMethod.

Field Summary

Modifier and TypeField and Description
private final Map<Method, HttpServiceMethod>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Object
invoke(MethodInvocation
the method invocation joinpoint
invocation
)

Implements org.aopalliance.intercept.MethodInterceptor.invoke.

Implement this method to perform extra treatments before and after the invocation.
private static Object[]
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

httpServiceMethodsback to summary
private final Map<Method, HttpServiceMethod> httpServiceMethods

Constructor Detail

HttpServiceMethodInterceptorback to summary
private HttpServiceMethodInterceptor(List<HttpServiceMethod> methods)

Method Detail

invokeback to summary
public Object invoke(MethodInvocation invocation) throws Throwable

Implements org.aopalliance.intercept.MethodInterceptor.invoke.

Doc from org.aopalliance.intercept.MethodInterceptor.invoke.

Implement this method to perform extra treatments before and after the invocation. Polite implementations would certainly like to invoke Joinpoint#proceed().

Parameters
invocation:MethodInvocation

the method invocation joinpoint

Returns:Object

the result of the call to Joinpoint#proceed(); might be intercepted by the interceptor

Annotations
@Override
Exceptions
Throwable:
if the interceptors or the target object throws an exception
resolveCoroutinesArgumentsback to summary
private static Object[] resolveCoroutinesArguments(Object[] args)