Example usage for java.rmi NotBoundException NotBoundException

List of usage examples for java.rmi NotBoundException NotBoundException

Introduction

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

Prototype

public NotBoundException(String s) 

Source Link

Document

Constructs a NotBoundException with the specified detail message.

Usage

From source file:com.vmware.identity.SharedUtils.java

private ILoginManager getLoginManager() throws NotBoundException, MalformedURLException, RemoteException {
    String endpointURL = String.format("rmi://%s:%d/IdentityManager", this._realIdmHostName, Tenant.RMI_PORT);

    boolean bNotBound = false;
    boolean bRemoteException = false;

    for (int i = 0; i < RETRY_COUNT; i++) {
        bNotBound = false;// w  w  w.j  a v a  2  s . c  o m
        bRemoteException = false;

        try {
            return (ILoginManager) Naming.lookup(endpointURL);
        } catch (NotBoundException e) {
            bNotBound = true;
        } catch (RemoteException e) {
            bRemoteException = true;
        }

        try {
            Thread.sleep(RETRY_TIMEOUT_SECS * 1000);
        } catch (InterruptedException e) {
        }
    }

    if (bNotBound) {
        throw new NotBoundException(
                String.format("Failed to bind to [%s] after [%d] attempts", endpointURL, RETRY_COUNT));
    } else if (bRemoteException) {
        throw new RemoteException(
                String.format("Failed due to remote exception when looking up " + "[%s] after [%d] attempts",
                        endpointURL, RETRY_COUNT));
    } else {
        throw new RuntimeException(
                String.format("Failed to contact [%s] after [%d] attempts", endpointURL, RETRY_COUNT));
    }
}