/* * Implements an abstract method from VizConnection. */ @Override protected IParaViewWebClient connectToWidget() { // Set the default return value. IParaViewWebClient client = null; // Try to create and connect to a ParaView web client. boolean connected = false; try { // Create an HTTP implementation of the ParaView web client.. client = new HttpParaViewWebClient(); // Set up the HTTP URL String host = getHost(); String port = Integer.toString(getPort()); String url = "http://" + host + ":" + port + "/rpc-http/"; // Try to connect. connected = client.connect(url).get(); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } // If the connection was not successful, we should return null. if (!connected) { client = null; } return client; }
/* * Implements an abstract method from VizConnection. */ @Override protected boolean disconnectFromWidget(IParaViewWebClient widget) { boolean closed = false; // Attempt to disconnect, returning the success of the operation. if (widget != null) { try { closed = widget.disconnect().get(); } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); } } return closed; }