Example usage for java.rmi ConnectIOException getCause

List of usage examples for java.rmi ConnectIOException getCause

Introduction

In this page you can find the example usage for java.rmi ConnectIOException getCause.

Prototype

public Throwable getCause() 

Source Link

Document

Returns the cause of this exception.

Usage

From source file:org.ut.biolab.medsavant.MedSavantClient.java

public static void initializeRegistry(String serverAddress, String serverPort)
        throws RemoteException, NotBoundException, NoRouteToHostException, ConnectIOException {

    if (initialized) {
        return;//  ww w  .jav a 2 s  . com
    }

    int port = (new Integer(serverPort)).intValue();

    Registry registry;

    LOG.debug("Connecting to MedSavantServerEngine @ " + serverAddress + ":" + serverPort + "...");

    try {
        registry = LocateRegistry.getRegistry(serverAddress, port, new SslRMIClientSocketFactory());
        LOG.debug("Retrieving adapters...");
        setAdaptersFromRegistry(registry);
        LOG.info("Connected with SSL/TLS Encryption");
    } catch (ConnectIOException ex) {
        if (ex.getCause() instanceof SSLHandshakeException) {
            registry = LocateRegistry.getRegistry(serverAddress, port);
            LOG.debug("Retrieving adapters...");
            setAdaptersFromRegistry(registry);
            LOG.info("Connected without SSL/TLS encryption");
        }
    }
    LOG.debug("Done");

}

From source file:org.ut.biolab.medsavant.MedSavantServlet.java

public void initializeRegistry(String serverAddress, String serverPort)
        throws RemoteException, NotBoundException, NoRouteToHostException, ConnectIOException {

    if (initialized) {
        return;//  w ww.  j  a v  a 2s  . c  om
    }

    int port = (new Integer(serverPort)).intValue();

    Registry registry;

    LOG.info("Connecting to MedSavantServerEngine @ " + serverAddress + ":" + serverPort + "...");

    try {
        registry = LocateRegistry.getRegistry(serverAddress, port, new SslRMIClientSocketFactory());
        LOG.debug("Retrieving adapters...");
        setAdaptersFromRegistry(registry);
        setLocalAdapters();
        LOG.info("Connected with SSL/TLS Encryption");
        initialized = true;
    } catch (ConnectIOException ex) {
        if (ex.getCause() instanceof SSLHandshakeException) {
            registry = LocateRegistry.getRegistry(serverAddress, port);
            LOG.info("Retrieving adapters...");
            setAdaptersFromRegistry(registry);
            LOG.info("Connected without SSL/TLS encryption");
        }
    }
    LOG.info("Done");

}