public enum HttpClientStrategy extends Enum<HttpClientStrategy>
Currently, following strategies are available:
ASYNC_HTTP_CLIENT: use the async-http-client library.OK_HTTP3: use OkHttp library.NING_ASYNC_HTTP_CLIENT: use async-http-client from ning library.APACHE_HTTP_CLIENT: use apache http-client library.AUTO: use classpath detection and choose the best available strategy (see below).
How the "best" strategy is selected:
Classpath detection is implemented in this order:
| Enum Constant and Description |
|---|
APACHE_HTTP_CLIENT
Build http client using ApacheHttpClient library.
|
ASYNC_HTTP_CLIENT
Build http client using AsyncHttpClient library.
|
AUTO
Detect class available on classpath and use appropriate strategy to
build http client client implementation:
Try
OK_HTTP3.
Try ASYNC_HTTP_CLIENT.
Try NING_ASYNC_HTTP_CLIENT.
Try APACHE_HTTP_CLIENT.
|
NING_ASYNC_HTTP_CLIENT
Build http client using (Ning) AsyncHttpClient library.
|
OK_HTTP3
Build http client using OkHttp library.
|
| Modifier and Type | Method and Description |
|---|---|
HttpClient |
build(EmbeddedServer<? extends AbstractConfiguration> server)
Return the http client implementation.
|
HttpClient |
build(HttpClientConfiguration configuration,
EmbeddedServer<? extends AbstractConfiguration> server)
Return the http client implementation.
|
abstract boolean |
support()
Check if the strategy can be used as it is supported by the runtime environment.
|
static HttpClientStrategy |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static HttpClientStrategy[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final HttpClientStrategy OK_HTTP3
public static final HttpClientStrategy ASYNC_HTTP_CLIENT
This strategy requires Java 8.
public static final HttpClientStrategy NING_ASYNC_HTTP_CLIENT
public static final HttpClientStrategy APACHE_HTTP_CLIENT
public static final HttpClientStrategy AUTO
OK_HTTP3.ASYNC_HTTP_CLIENT.NING_ASYNC_HTTP_CLIENT.APACHE_HTTP_CLIENT.public static HttpClientStrategy[] values()
for (HttpClientStrategy c : HttpClientStrategy.values()) System.out.println(c);
public static HttpClientStrategy valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic HttpClient build(EmbeddedServer<? extends AbstractConfiguration> server)
server - Embedded server.UnsupportedOperationException - If the runtime environment does not allow the strategy (such as: the library has not been imported).public HttpClient build(HttpClientConfiguration configuration, EmbeddedServer<? extends AbstractConfiguration> server)
configuration - HTTP Client configuration.server - Embedded server.UnsupportedOperationException - If the runtime environment does not allow the strategy (such as: the library has not been imported).public abstract boolean support()
true if the strategy can be instantiated, false otherwise.Copyright © 2018. All rights reserved.