use of com.canoo.platform.core.http.HttpURLConnectionHandler in project dolphin-platform by canoo.
the class ClientContextFactoryImpl method create.
/**
* Create a {@link ClientContext} based on the given configuration. This method doesn't block and returns a
* {@link CompletableFuture} to receive its result. If the {@link ClientContext} can't be created the
* {@link CompletableFuture#get()} will throw a {@link ClientInitializationException}.
*
* @param clientConfiguration the configuration
* @return the future
*/
public ClientContext create(final ClientConfiguration clientConfiguration, final URI endpoint) {
Assert.requireNonNull(clientConfiguration, "clientConfiguration");
final HttpClient httpClient = PlatformClient.getService(HttpClient.class);
final HttpURLConnectionHandler clientSessionCheckResponseHandler = new StrictClientSessionResponseHandler(endpoint);
httpClient.addResponseHandler(clientSessionCheckResponseHandler);
final Function<ClientModelStore, AbstractClientConnector> connectionProvider = s -> {
return new DolphinPlatformHttpClientConnector(endpoint, clientConfiguration, s, OptimizedJsonCodec.getInstance(), e -> {
}, httpClient);
};
return new ClientContextImpl(clientConfiguration, endpoint, connectionProvider, PlatformClient.getService(ClientSessionStore.class));
}
Aggregations