Search in sources :

Example 1 with HttpURLConnectionHandler

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));
}
Also used : ClientModelStore(com.canoo.dp.impl.client.legacy.ClientModelStore) Assert(com.canoo.dp.impl.platform.core.Assert) ClientContextFactory(com.canoo.platform.remoting.client.ClientContextFactory) HttpClient(com.canoo.platform.core.http.HttpClient) AbstractClientConnector(com.canoo.dp.impl.client.legacy.communication.AbstractClientConnector) CompletableFuture(java.util.concurrent.CompletableFuture) API(org.apiguardian.api.API) ClientContext(com.canoo.platform.remoting.client.ClientContext) ClientInitializationException(com.canoo.platform.remoting.client.ClientInitializationException) Function(java.util.function.Function) INTERNAL(org.apiguardian.api.API.Status.INTERNAL) PlatformClient(com.canoo.platform.client.PlatformClient) HttpURLConnectionHandler(com.canoo.platform.core.http.HttpURLConnectionHandler) StrictClientSessionResponseHandler(com.canoo.dp.impl.platform.client.session.StrictClientSessionResponseHandler) URI(java.net.URI) ClientSessionStore(com.canoo.platform.client.session.ClientSessionStore) OptimizedJsonCodec(com.canoo.dp.impl.remoting.codec.OptimizedJsonCodec) ClientConfiguration(com.canoo.platform.client.ClientConfiguration) StrictClientSessionResponseHandler(com.canoo.dp.impl.platform.client.session.StrictClientSessionResponseHandler) ClientSessionStore(com.canoo.platform.client.session.ClientSessionStore) HttpClient(com.canoo.platform.core.http.HttpClient) ClientModelStore(com.canoo.dp.impl.client.legacy.ClientModelStore) HttpURLConnectionHandler(com.canoo.platform.core.http.HttpURLConnectionHandler) AbstractClientConnector(com.canoo.dp.impl.client.legacy.communication.AbstractClientConnector)

Aggregations

ClientModelStore (com.canoo.dp.impl.client.legacy.ClientModelStore)1 AbstractClientConnector (com.canoo.dp.impl.client.legacy.communication.AbstractClientConnector)1 StrictClientSessionResponseHandler (com.canoo.dp.impl.platform.client.session.StrictClientSessionResponseHandler)1 Assert (com.canoo.dp.impl.platform.core.Assert)1 OptimizedJsonCodec (com.canoo.dp.impl.remoting.codec.OptimizedJsonCodec)1 ClientConfiguration (com.canoo.platform.client.ClientConfiguration)1 PlatformClient (com.canoo.platform.client.PlatformClient)1 ClientSessionStore (com.canoo.platform.client.session.ClientSessionStore)1 HttpClient (com.canoo.platform.core.http.HttpClient)1 HttpURLConnectionHandler (com.canoo.platform.core.http.HttpURLConnectionHandler)1 ClientContext (com.canoo.platform.remoting.client.ClientContext)1 ClientContextFactory (com.canoo.platform.remoting.client.ClientContextFactory)1 ClientInitializationException (com.canoo.platform.remoting.client.ClientInitializationException)1 URI (java.net.URI)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Function (java.util.function.Function)1 API (org.apiguardian.api.API)1 INTERNAL (org.apiguardian.api.API.Status.INTERNAL)1