Package io.micronaut.http.client.netty
Class DefaultNettyHttpClientRegistry
java.lang.Object
io.micronaut.http.client.netty.DefaultNettyHttpClientRegistry
- All Implemented Interfaces:
HttpClientRegistry<HttpClient>
,NettyClientCustomizer.Registry
,ProxyHttpClientRegistry<ProxyHttpClient>
,SseClientRegistry<SseClient>
,StreamingHttpClientRegistry<StreamingHttpClient>
,ChannelPipelineCustomizer
,WebSocketClientRegistry<WebSocketClient>
,AutoCloseable
@Factory
@Internal
public class DefaultNettyHttpClientRegistry
extends Object
implements AutoCloseable, HttpClientRegistry<HttpClient>, SseClientRegistry<SseClient>, StreamingHttpClientRegistry<StreamingHttpClient>, WebSocketClientRegistry<WebSocketClient>, ProxyHttpClientRegistry<ProxyHttpClient>, ChannelPipelineCustomizer, NettyClientCustomizer.Registry
Factory for the default implementation of the
HttpClient
interface based on Netty.- Since:
- 2.0
- Author:
- Graeme Rocher
-
Field Summary
Fields inherited from interface io.micronaut.http.netty.channel.ChannelPipelineCustomizer
HANDLER_ACCESS_LOGGER, HANDLER_ACTIVITY_LISTENER, HANDLER_CONNECT_TTL, HANDLER_FLOW_CONTROL, HANDLER_HTTP_AGGREGATOR, HANDLER_HTTP_CHUNK, HANDLER_HTTP_CLIENT_CODEC, HANDLER_HTTP_CLIENT_INIT, HANDLER_HTTP_COMPRESSOR, HANDLER_HTTP_DECODER, HANDLER_HTTP_DECOMPRESSOR, HANDLER_HTTP_KEEP_ALIVE, HANDLER_HTTP_PROXY, HANDLER_HTTP_SERVER_CODEC, HANDLER_HTTP_STREAM, HANDLER_HTTP_TO_HTTPS_REDIRECT, HANDLER_HTTP2_CONNECTION, HANDLER_HTTP2_PROTOCOL_NEGOTIATOR, HANDLER_HTTP2_SETTINGS, HANDLER_HTTP2_UPGRADE_REQUEST, HANDLER_IDLE_STATE, HANDLER_INITIAL_ERROR, HANDLER_MICRONAUT_FULL_HTTP_RESPONSE, HANDLER_MICRONAUT_HTTP_RESPONSE_FULL, HANDLER_MICRONAUT_HTTP_RESPONSE_STREAM, HANDLER_MICRONAUT_INBOUND, HANDLER_MICRONAUT_SSE_CONTENT, HANDLER_MICRONAUT_SSE_EVENT_STREAM, HANDLER_MICRONAUT_WEBSOCKET_CLIENT, HANDLER_READ_TIMEOUT, HANDLER_SOCKS_5_PROXY, HANDLER_SSL, HANDLER_WEBSOCKET_UPGRADE
-
Constructor Summary
ConstructorDescriptionDefaultNettyHttpClientRegistry
(HttpClientConfiguration defaultHttpClientConfiguration, HttpClientFilterResolver httpClientFilterResolver, LoadBalancerResolver loadBalancerResolver, NettyClientSslBuilder nettyClientSslBuilder, ThreadFactory threadFactory, MediaTypeCodecRegistry codecRegistry, EventLoopGroupRegistry eventLoopGroupRegistry, EventLoopGroupFactory eventLoopGroupFactory, BeanContext beanContext, List<InvocationInstrumenterFactory> invocationInstrumenterFactories, JsonMapper jsonMapper) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
disposeClient
(AnnotationMetadata annotationMetadata) Dispose of the client defined by the given metadata.void
doOnConnect
(ChannelPipelineListener listener) A hook to customize the pipeline upon establishing a connection.getClient
(AnnotationMetadata metadata) Return the client for the given annotation metadata.getClient
(HttpVersionSelection httpVersion, String clientId, String path) Return the client for the client ID and path.getProxyHttpClient
(AnnotationMetadata metadata) Return the client for the given annotation metadata.getSseClient
(AnnotationMetadata metadata) Return the client for the given annotation metadata.getStreamingHttpClient
(AnnotationMetadata metadata) Return the client for the given annotation metadata.getWebSocketClient
(AnnotationMetadata metadata) Return the client for the given annotation metadata.protected DefaultHttpClient
httpClient
(InjectionPoint<?> injectionPoint, LoadBalancer loadBalancer, HttpClientConfiguration configuration, BeanContext beanContext) Creates a newHttpClient
for the given injection point.boolean
void
register
(NettyClientCustomizer customizer) Register a new customizer with this registry.resolveClient
(InjectionPoint<?> injectionPoint, LoadBalancer loadBalancer, HttpClientConfiguration configuration, BeanContext beanContext) Resolves aHttpClient
for the given injection point.resolveProxyHttpClient
(InjectionPoint<?> injectionPoint, LoadBalancer loadBalancer, HttpClientConfiguration configuration, BeanContext beanContext) Resolves aProxyHttpClient
for the given injection point.resolveSseClient
(InjectionPoint<?> injectionPoint, LoadBalancer loadBalancer, HttpClientConfiguration configuration, BeanContext beanContext) Resolves aSseClient
for the given injection point.resolveStreamingHttpClient
(InjectionPoint<?> injectionPoint, LoadBalancer loadBalancer, HttpClientConfiguration configuration, BeanContext beanContext) Resolves aStreamingHttpClient
for the given injection point.resolveWebSocketClient
(InjectionPoint<?> injectionPoint, LoadBalancer loadBalancer, HttpClientConfiguration configuration, BeanContext beanContext) Resolves aWebSocketClient
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.netty.channel.ChannelPipelineCustomizer
isServerChannel
Methods inherited from interface io.micronaut.http.client.HttpClientRegistry
getClient, getDefaultClient
Methods inherited from interface io.micronaut.http.client.ProxyHttpClientRegistry
getDefaultProxyHttpClient
Methods inherited from interface io.micronaut.http.client.sse.SseClientRegistry
getDefaultSseClient
Methods inherited from interface io.micronaut.http.client.StreamingHttpClientRegistry
getDefaultStreamingHttpClient
Methods inherited from interface io.micronaut.websocket.WebSocketClientRegistry
getDefaultWebSocketClient
-
Constructor Details
-
DefaultNettyHttpClientRegistry
public DefaultNettyHttpClientRegistry(HttpClientConfiguration defaultHttpClientConfiguration, HttpClientFilterResolver httpClientFilterResolver, LoadBalancerResolver loadBalancerResolver, NettyClientSslBuilder nettyClientSslBuilder, ThreadFactory threadFactory, MediaTypeCodecRegistry codecRegistry, EventLoopGroupRegistry eventLoopGroupRegistry, EventLoopGroupFactory eventLoopGroupFactory, BeanContext beanContext, List<InvocationInstrumenterFactory> invocationInstrumenterFactories, JsonMapper jsonMapper) Default constructor.- Parameters:
defaultHttpClientConfiguration
- The default HTTP client configurationhttpClientFilterResolver
- The HTTP client filter resolverloadBalancerResolver
- The load balancer resolvernettyClientSslBuilder
- The client SSL builderthreadFactory
- The thread factorycodecRegistry
- The codec registryeventLoopGroupRegistry
- The event loop group registryeventLoopGroupFactory
- The event loop group factorybeanContext
- The bean contextinvocationInstrumenterFactories
- The invocation instrumenter factoriesjsonMapper
- JSON Mapper
-
-
Method Details
-
getClient
@NonNull public HttpClient getClient(@NonNull HttpVersionSelection httpVersion, @NonNull String clientId, @Nullable String path) 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
-
getClient
Description copied from interface:HttpClientRegistry
Return the client for the given annotation metadata.- Specified by:
getClient
in interfaceHttpClientRegistry<HttpClient>
- Parameters:
metadata
- The annotation metadata.- Returns:
- The client
-
getSseClient
Description copied from interface:SseClientRegistry
Return the client for the given annotation metadata.- Specified by:
getSseClient
in interfaceSseClientRegistry<SseClient>
- Parameters:
metadata
- The annotation metadata.- Returns:
- The client
-
getStreamingHttpClient
Description copied from interface:StreamingHttpClientRegistry
Return the client for the given annotation metadata.- Specified by:
getStreamingHttpClient
in interfaceStreamingHttpClientRegistry<StreamingHttpClient>
- Parameters:
metadata
- The annotation metadata.- Returns:
- The client
-
getProxyHttpClient
Description copied from interface:ProxyHttpClientRegistry
Return the client for the given annotation metadata.- Specified by:
getProxyHttpClient
in interfaceProxyHttpClientRegistry<ProxyHttpClient>
- Parameters:
metadata
- The annotation metadata.- Returns:
- The client
-
getWebSocketClient
Description copied from interface:WebSocketClientRegistry
Return the client for the given annotation metadata.- Specified by:
getWebSocketClient
in interfaceWebSocketClientRegistry<WebSocketClient>
- Parameters:
metadata
- The annotation metadata.- Returns:
- The client
-
close
- Specified by:
close
in interfaceAutoCloseable
-
disposeClient
Description copied from interface:HttpClientRegistry
Dispose of the client defined by the given metadata.- Specified by:
disposeClient
in interfaceHttpClientRegistry<HttpClient>
- Specified by:
disposeClient
in interfaceProxyHttpClientRegistry<ProxyHttpClient>
- Specified by:
disposeClient
in interfaceSseClientRegistry<SseClient>
- Specified by:
disposeClient
in interfaceStreamingHttpClientRegistry<StreamingHttpClient>
- Specified by:
disposeClient
in interfaceWebSocketClientRegistry<WebSocketClient>
- Parameters:
annotationMetadata
- The annotation metadata
-
httpClient
@Bean @Primary protected DefaultHttpClient httpClient(@Nullable InjectionPoint<?> injectionPoint, @Parameter @Nullable LoadBalancer loadBalancer, @Parameter @Nullable HttpClientConfiguration configuration, BeanContext beanContext) Creates a newHttpClient
for the given injection point.- Parameters:
injectionPoint
- The injection pointloadBalancer
- The load balancer to use (Optional)configuration
- The configuration (Optional)beanContext
- The bean context to use- Returns:
- The client
-
resolveClient
@NonNull public HttpClient resolveClient(@Nullable InjectionPoint<?> injectionPoint, @Nullable LoadBalancer loadBalancer, @Nullable HttpClientConfiguration configuration, @NonNull 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
-
resolveProxyHttpClient
@NonNull public ProxyHttpClient resolveProxyHttpClient(@Nullable InjectionPoint<?> injectionPoint, @Nullable LoadBalancer loadBalancer, @Nullable HttpClientConfiguration configuration, @NonNull BeanContext beanContext) Description copied from interface:ProxyHttpClientRegistry
Resolves aProxyHttpClient
for the given injection point.- Specified by:
resolveProxyHttpClient
in interfaceProxyHttpClientRegistry<ProxyHttpClient>
- Parameters:
injectionPoint
- The injection pointloadBalancer
- The load balancer to use (Optional)configuration
- The configuration (Optional)beanContext
- The bean context to use- Returns:
- The Proxy HTTP Client
-
resolveSseClient
@NonNull public SseClient resolveSseClient(@Nullable InjectionPoint<?> injectionPoint, @Nullable LoadBalancer loadBalancer, @Nullable HttpClientConfiguration configuration, @NonNull BeanContext beanContext) Description copied from interface:SseClientRegistry
Resolves aSseClient
for the given injection point.- Specified by:
resolveSseClient
in interfaceSseClientRegistry<SseClient>
- Parameters:
injectionPoint
- The injection pointloadBalancer
- The load balancer to use (Optional)configuration
- The configuration (Optional)beanContext
- The bean context to use- Returns:
- The SSE HTTP Client
-
resolveStreamingHttpClient
@NonNull public StreamingHttpClient resolveStreamingHttpClient(@Nullable InjectionPoint<?> injectionPoint, @Nullable LoadBalancer loadBalancer, @Nullable HttpClientConfiguration configuration, @NonNull BeanContext beanContext) Description copied from interface:StreamingHttpClientRegistry
Resolves aStreamingHttpClient
for the given injection point.- Specified by:
resolveStreamingHttpClient
in interfaceStreamingHttpClientRegistry<StreamingHttpClient>
- Parameters:
injectionPoint
- The injection pointloadBalancer
- The load balancer to use (Optional)configuration
- The configuration (Optional)beanContext
- The bean context to use- Returns:
- The Streaming HTTP Client
-
resolveWebSocketClient
@NonNull public WebSocketClient resolveWebSocketClient(@Nullable InjectionPoint<?> injectionPoint, @Nullable LoadBalancer loadBalancer, @Nullable HttpClientConfiguration configuration, @NonNull BeanContext beanContext) Description copied from interface:WebSocketClientRegistry
Resolves aWebSocketClient
for the given injection point.- Specified by:
resolveWebSocketClient
in interfaceWebSocketClientRegistry<WebSocketClient>
- Parameters:
injectionPoint
- The injection pointloadBalancer
- The load balancer to use (Optional)configuration
- The configuration (Optional)beanContext
- The bean context to use- Returns:
- The Streaming HTTP Client
-
isClientChannel
public boolean isClientChannel()- Specified by:
isClientChannel
in interfaceChannelPipelineCustomizer
- Returns:
- Is this customizer the client.
-
doOnConnect
Description copied from interface:ChannelPipelineCustomizer
A hook to customize the pipeline upon establishing a connection.- Specified by:
doOnConnect
in interfaceChannelPipelineCustomizer
- Parameters:
listener
- The listener The listener.
-
register
Description copied from interface:NettyClientCustomizer.Registry
Register a new customizer with this registry.- Specified by:
register
in interfaceNettyClientCustomizer.Registry
- Parameters:
customizer
- The customizer to register.
-