Search in sources :

Example 1 with ClientConfiguration

use of com.canoo.platform.client.ClientConfiguration in project dolphin-platform-examples by canoo.

the class Client method createClientContext.

private final ClientContext createClientContext(final URI endpoint) throws Exception {
    final ClientConfiguration clientConfiguration = PlatformClient.getClientConfiguration();
    final ClientContextFactory clientContextFactory = PlatformClient.getService(ClientContextFactory.class);
    return clientContextFactory.create(clientConfiguration, endpoint);
}
Also used : ClientContextFactory(com.canoo.platform.remoting.client.ClientContextFactory) ClientConfiguration(com.canoo.platform.client.ClientConfiguration)

Example 2 with ClientConfiguration

use of com.canoo.platform.client.ClientConfiguration in project dolphin-platform-examples by canoo.

the class Client method showApp.

private void showApp(final Stage primaryStage) throws Exception {
    final ClientConfiguration clientConfiguration = PlatformClient.getClientConfiguration();
    final ClientContextFactory contextFactory = PlatformClient.getService(ClientContextFactory.class);
    final URI endpoint = new URI("http://localhost:8080/dolphin");
    final ClientContext clientContext = contextFactory.create(clientConfiguration, endpoint);
    clientContext.connect().handle((v, e) -> {
        final UserView view = new UserView(clientContext);
        Platform.runLater(() -> {
            primaryStage.setScene(new Scene(view.getParent()));
            primaryStage.show();
        });
        return null;
    });
}
Also used : ClientContext(com.canoo.platform.remoting.client.ClientContext) Scene(javafx.scene.Scene) ClientContextFactory(com.canoo.platform.remoting.client.ClientContextFactory) URI(java.net.URI) ClientConfiguration(com.canoo.platform.client.ClientConfiguration)

Example 3 with ClientConfiguration

use of com.canoo.platform.client.ClientConfiguration in project dolphin-platform by canoo.

the class LogListViewController method init.

@Override
protected void init() {
    FXBinder.bind(listView.getItems()).to(getModel().getEntries(), b -> convertBean(b));
    invoke(UPDATE_ACTION);
    final ClientConfiguration clientConfiguration = PlatformClient.getClientConfiguration();
    clientConfiguration.getBackgroundExecutor().execute(() -> {
        while (true) {
            try {
                Thread.sleep(2_000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            clientConfiguration.getUiExecutor().execute(() -> invoke(UPDATE_ACTION));
        }
    });
}
Also used : ClientConfiguration(com.canoo.platform.client.ClientConfiguration)

Example 4 with ClientConfiguration

use of com.canoo.platform.client.ClientConfiguration 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

ClientConfiguration (com.canoo.platform.client.ClientConfiguration)4 ClientContextFactory (com.canoo.platform.remoting.client.ClientContextFactory)3 ClientContext (com.canoo.platform.remoting.client.ClientContext)2 URI (java.net.URI)2 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 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 ClientInitializationException (com.canoo.platform.remoting.client.ClientInitializationException)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Function (java.util.function.Function)1 Scene (javafx.scene.Scene)1 API (org.apiguardian.api.API)1 INTERNAL (org.apiguardian.api.API.Status.INTERNAL)1