Package org.eclipse.sw360.http
Class NewHttpClientImpl
- java.lang.Object
-
- org.eclipse.sw360.http.NewHttpClientImpl
-
- All Implemented Interfaces:
HttpClient
public class NewHttpClientImpl extends Object implements HttpClient
This class implements the java native client library.- Author:
- smruti.sahoo@siemens.com
-
-
Constructor Summary
Constructors Constructor Description NewHttpClientImpl(HttpClient client, com.fasterxml.jackson.databind.ObjectMapper mapper)Creates a new instance ofNewHttpClientImplwith the dependencies passed in.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> CompletableFuture<T>execute(Consumer<? super RequestBuilder> producer, ResponseProcessor<? extends T> processor)Executes an HTTP request asynchronously and returns a future object with the result.
-
-
-
Constructor Detail
-
NewHttpClientImpl
public NewHttpClientImpl(HttpClient client, com.fasterxml.jackson.databind.ObjectMapper mapper)
Creates a new instance ofNewHttpClientImplwith the dependencies passed in.- Parameters:
client- the underlying HTTP clientmapper- the JSON object mapper
-
-
Method Detail
-
execute
public <T> CompletableFuture<T> execute(Consumer<? super RequestBuilder> producer, ResponseProcessor<? extends T> processor)
Description copied from interface:HttpClientExecutes an HTTP request asynchronously and returns a future object with the result. The method first invokes theConsumerto generate the request to be executed. This request is then sent to the server. If sending fails, e.g. because no connection could be established, the resulting future is failed with the corresponding exception. Otherwise, theResponseProcessoris invoked with a representation of the response; the outcome of this object is then used to complete the result future.- Specified by:
executein interfaceHttpClient- Type Parameters:
T- the type of the result produced by theResponseProcessor- Parameters:
producer- the object to produce the requestprocessor- the object to process the response- Returns:
- a future with the result of the execution
-
-