Package io.micronaut.http.client.jdk
Class DefaultJdkHttpClientRegistry
java.lang.Object
io.micronaut.http.client.jdk.DefaultJdkHttpClientRegistry
- All Implemented Interfaces:
HttpClientRegistry<HttpClient>
,AutoCloseable
@Factory
@Order(2)
@Internal
public final class DefaultJdkHttpClientRegistry
extends Object
implements AutoCloseable, HttpClientRegistry<HttpClient>
Factory to create java.net.http.* HTTP Clients.
- Since:
- 4.0.0
- Author:
- Sergio del Amo, Tim Yates
-
Constructor Summary
ConstructorDescriptionDefaultJdkHttpClientRegistry
(BeanContext beanContext, LoadBalancerResolver loadBalancerResolver, HttpClientConfiguration defaultHttpClientConfiguration, HttpClientFilterResolver<ClientFilterResolutionContext> httpClientFilterResolver, JsonMapper jsonMapper, @Nullable MediaTypeCodecRegistry mediaTypeCodecRegistry, MessageBodyHandlerRegistry messageBodyHandlerRegistry, BeanProvider<RequestBinderRegistry> requestBinderRegistryProvider, BeanProvider<JdkClientSslBuilder> sslBuilderBeanProvider, BeanProvider<CookieDecoder> cookieDecoderBeanProvider) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
disposeClient
(AnnotationMetadata annotationMetadata) Dispose of the client defined by the given metadata.getClient
(AnnotationMetadata annotationMetadata) Return the client for the given annotation metadata.getClient
(HttpVersionSelection httpVersion, String clientId, String path) Return the client for the client ID and path.protected DefaultJdkHttpClient
httpClient
(@Nullable InjectionPoint<?> injectionPoint, @Nullable LoadBalancer loadBalancer, @Nullable HttpClientConfiguration configuration, BeanContext beanContext) Creates a java.net.http.* HTTP Client.resolveClient
(InjectionPoint<?> injectionPoint, LoadBalancer loadBalancer, HttpClientConfiguration configuration, BeanContext beanContext) Resolves aHttpClient
for the given injection point.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.http.client.HttpClientRegistry
getClient, getDefaultClient
-
Constructor Details
-
DefaultJdkHttpClientRegistry
public DefaultJdkHttpClientRegistry(BeanContext beanContext, LoadBalancerResolver loadBalancerResolver, HttpClientConfiguration defaultHttpClientConfiguration, HttpClientFilterResolver<ClientFilterResolutionContext> httpClientFilterResolver, JsonMapper jsonMapper, @Nullable @Nullable MediaTypeCodecRegistry mediaTypeCodecRegistry, MessageBodyHandlerRegistry messageBodyHandlerRegistry, BeanProvider<RequestBinderRegistry> requestBinderRegistryProvider, BeanProvider<JdkClientSslBuilder> sslBuilderBeanProvider, BeanProvider<CookieDecoder> cookieDecoderBeanProvider)
-
-
Method Details
-
httpClient
@Bean @Primary @Order(2) protected DefaultJdkHttpClient httpClient(@Nullable @Nullable InjectionPoint<?> injectionPoint, @Parameter @Nullable @Nullable LoadBalancer loadBalancer, @Parameter @Nullable @Nullable HttpClientConfiguration configuration, BeanContext beanContext) Creates a java.net.http.* HTTP Client.- Parameters:
injectionPoint
-loadBalancer
-configuration
-beanContext
-- Returns:
- A java.net.http.* HTTP Client
-
getClient
Description copied from interface:HttpClientRegistry
Return the client for the given annotation metadata.- Specified by:
getClient
in interfaceHttpClientRegistry<HttpClient>
- Parameters:
annotationMetadata
- The annotation metadata.- Returns:
- The client
-
getClient
Description copied from interface:HttpClientRegistry
Return the client for the client ID and path.- Specified by:
getClient
in interfaceHttpClientRegistry<HttpClient>
- Parameters:
httpVersion
- The HTTP versionclientId
- The client IDpath
- The path (Optional)- Returns:
- The client
-
resolveClient
public HttpClient resolveClient(InjectionPoint<?> injectionPoint, LoadBalancer loadBalancer, HttpClientConfiguration configuration, BeanContext beanContext) Description copied from interface:HttpClientRegistry
Resolves aHttpClient
for the given injection point.- Specified by:
resolveClient
in interfaceHttpClientRegistry<HttpClient>
- Parameters:
injectionPoint
- The injection pointloadBalancer
- The load balancer to use (Optional)configuration
- The configuration (Optional)beanContext
- The bean context to use- Returns:
- The HTTP Client
-
disposeClient
Description copied from interface:HttpClientRegistry
Dispose of the client defined by the given metadata.- Specified by:
disposeClient
in interfaceHttpClientRegistry<HttpClient>
- Parameters:
annotationMetadata
- The annotation metadata
-
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-