Example usage for java.rmi.registry LocateRegistry getRegistry

List of usage examples for java.rmi.registry LocateRegistry getRegistry

Introduction

In this page you can find the example usage for java.rmi.registry LocateRegistry getRegistry.

Prototype

public static Registry getRegistry() throws RemoteException 

Source Link

Document

Returns a reference to the remote object Registry for the local host on the default registry port of 1099.

Usage

From source file:engine.ComputeEngine.java

public static void main(String[] args) {
    if (System.getSecurityManager() == null) {
        System.setSecurityManager(new SecurityManager());
    }//from w ww  .  j  a va  2 s.  co  m
    try {
        String name = "Compute";
        Compute engine = new ComputeEngine();
        Compute stub = (Compute) UnicastRemoteObject.exportObject(engine, 0);
        Registry registry = LocateRegistry.getRegistry();
        registry.rebind(name, stub);
        System.out.println("ComputeEngine bound");
    } catch (Exception e) {
        System.err.println("ComputeEngine exception:");
        e.printStackTrace();
    }
}

From source file:edu.cornell.med.icb.R.RConfigurationServer.java

public static void main(final String[] args) throws RemoteException {
    if (System.getSecurityManager() == null) {
        System.setSecurityManager(new SecurityManager());
    }//from  w ww  .  j  av  a 2s .c  o  m

    final String name = "RConfiguration";
    final RConfiguration engine = new RConfigurationServer();
    final RConfiguration stub = (RConfiguration) UnicastRemoteObject.exportObject(engine, 0);
    final Registry registry = LocateRegistry.getRegistry();
    System.out.println(ArrayUtils.toString(registry.list()));
    registry.rebind(name, stub);
    System.out.println("RConfiguration bound");
}

From source file:engine.Pi.java

public static void main(String[] args) {
        if (System.getSecurityManager() == null) {
            System.setSecurityManager(new SecurityManager());
        }//from   w ww .  j  a  v a  2  s .com
        try {
            String name = "Compute";
            Compute engine = new ComputeEngine();
            Compute stub = (Compute) UnicastRemoteObject.exportObject(engine, 0);
            Registry registry = LocateRegistry.getRegistry();
            registry.rebind(name, stub);
            System.out.println("ComputeEngine bound");
        } catch (Exception e) {
            System.err.println("ComputeEngine exception:");
            e.printStackTrace();
        }
    }

From source file:com.continuent.tungsten.common.jmx.JmxManager.java

protected Registry locateDefaultRegistry() {

    Registry registry = null;/* w  w  w. j a  v a  2s.c om*/

    try {
        registry = LocateRegistry.getRegistry();
    } catch (Exception r) {
        throw new ServerRuntimeException(String.format(
                "Unable to locate the default registry on registryPort 1099, reason='%s'", r.getMessage()));
    }

    return registry;
}

From source file:org.taverna.server.master.localworker.AbstractRemoteRunFactory.java

/**
 * Set up the run expiry management engine.
 * /*from w  ww .  j a  va  2 s . co  m*/
 * @throws JAXBException
 */
public AbstractRemoteRunFactory() throws JAXBException {
    try {
        registry = LocateRegistry.getRegistry();
        registry.list();
    } catch (RemoteException e) {
        log.warn("Failed to get working RMI registry handle.");
        log.warn("Will build new registry, but service restart ability is at risk.");
        try {
            registry = createRegistry(REGISTRY_PORT);
            registry.list();
        } catch (RemoteException e2) {
            log.error("failed to create working RMI registry", e2);
            log.info("original connection exception", e);
        }
    }
}