Package org.attribyte.api.http.impl.jdk
Class JdkClient
java.lang.Object
org.attribyte.api.http.impl.jdk.JdkClient
- All Implemented Interfaces:
AsyncClient,Client
HTTP client implementation using the JDK
java.net.http.HttpClient.
Requires Java 11+. No external dependencies beyond the JDK and Guava.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an uninitialized client.JdkClient(ClientOptions options) Creates a client with specified options. -
Method Summary
Modifier and TypeMethodDescriptioncom.google.common.util.concurrent.ListenableFuture<Response> Sends a request with default options that completes with aListenableFuture.com.google.common.util.concurrent.ListenableFuture<Response> asyncSend(Request request, RequestOptions options) Sends a request with specified options that completes with aListenableFuture.completableSend(Request request) Sends a request with default options that completes with aCompletableFuture.completableSend(Request request, RequestOptions options) Sends a request with specified options that completes with aCompletableFuture.voidinit(String prefix, Properties props, org.attribyte.api.Logger logger) Initializes the client.Sends a request with default options.send(Request request, RequestOptions options) Sends a request with specified options.voidshutdown()Releases resources, interrupts threads, etc.
-
Constructor Details
-
JdkClient
public JdkClient()Creates an uninitialized client. -
JdkClient
Creates a client with specified options.- Parameters:
options- The options.- Throws:
org.attribyte.api.InitializationException- if options are invalid or other initialization error.
-
-
Method Details
-
init
public void init(String prefix, Properties props, org.attribyte.api.Logger logger) throws org.attribyte.api.InitializationException Description copied from interface:ClientInitializes the client. Must be called before first use. -
send
Description copied from interface:ClientSends a request with default options.- Specified by:
sendin interfaceClient- Parameters:
request- The request.- Returns:
- The response.
- Throws:
IOException- on I/O error.
-
send
Description copied from interface:ClientSends a request with specified options.- Specified by:
sendin interfaceClient- Parameters:
request- The request.options- The request options.- Returns:
- The response.
- Throws:
IOException- on I/O error.
-
asyncSend
Description copied from interface:AsyncClientSends a request with default options that completes with aListenableFuture.- Specified by:
asyncSendin interfaceAsyncClient- Parameters:
request- The request.- Returns:
- The (listenable) response future.
-
asyncSend
public com.google.common.util.concurrent.ListenableFuture<Response> asyncSend(Request request, RequestOptions options) Description copied from interface:AsyncClientSends a request with specified options that completes with aListenableFuture.- Specified by:
asyncSendin interfaceAsyncClient- Parameters:
request- The request.options- The request options.- Returns:
- The (listenable) response future.
-
completableSend
Description copied from interface:AsyncClientSends a request with default options that completes with aCompletableFuture.- Specified by:
completableSendin interfaceAsyncClient- Parameters:
request- The request.- Returns:
- The (completable) response future.
-
completableSend
Description copied from interface:AsyncClientSends a request with specified options that completes with aCompletableFuture.- Specified by:
completableSendin interfaceAsyncClient- Parameters:
request- The request.options- The request options.- Returns:
- The (completable) response future.
-
shutdown
public void shutdown()Description copied from interface:ClientReleases resources, interrupts threads, etc. Called when application using the client is terminated.
-