Package io.micronaut.http.client.jdk
Class DefaultJdkHttpClientRegistry
java.lang.Object
io.micronaut.http.client.jdk.DefaultJdkHttpClientRegistry
- All Implemented Interfaces:
HttpClientRegistry<HttpClient>,RawHttpClientRegistry,AutoCloseable
@Factory
@Order(2)
@Internal
public final class DefaultJdkHttpClientRegistry
extends Object
implements AutoCloseable, HttpClientRegistry<HttpClient>, RawHttpClientRegistry
Factory to create java.net.http.* HTTP Clients.
- Since:
- 4.0.0
- Author:
- Sergio del Amo, Tim Yates
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultJdkHttpClientRegistry(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 TypeMethodDescriptionvoidclose()voiddisposeClient(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.getRawClient(@NonNull HttpVersionSelection httpVersion, @NonNull String clientId, @Nullable String path) Return the client for the client ID and path.protected DefaultJdkHttpClienthttpClient(@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 aHttpClientfor the given injection point.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:HttpClientRegistryReturn the client for the given annotation metadata.- Specified by:
getClientin interfaceHttpClientRegistry<HttpClient>- Parameters:
annotationMetadata- The annotation metadata.- Returns:
- The client
-
getClient
public DefaultJdkHttpClient getClient(HttpVersionSelection httpVersion, String clientId, String path) Description copied from interface:HttpClientRegistryReturn the client for the client ID and path.- Specified by:
getClientin 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:HttpClientRegistryResolves aHttpClientfor the given injection point.- Specified by:
resolveClientin 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:HttpClientRegistryDispose of the client defined by the given metadata.- Specified by:
disposeClientin interfaceHttpClientRegistry<HttpClient>- Parameters:
annotationMetadata- The annotation metadata
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
getRawClient
@NonNull public @NonNull RawHttpClient getRawClient(@NonNull @NonNull HttpVersionSelection httpVersion, @NonNull @NonNull String clientId, @Nullable @Nullable String path) Description copied from interface:RawHttpClientRegistryReturn the client for the client ID and path.- Specified by:
getRawClientin interfaceRawHttpClientRegistry- Parameters:
httpVersion- The HTTP versionclientId- The client IDpath- The path (Optional)- Returns:
- The client
-