Search in sources :

Example 31 with Registry

use of java.rmi.registry.Registry in project jdk8u_jdk by JetBrains.

the class SelfTerminator method main.

public static void main(String[] args) {
    try {
        int registryPort = Integer.parseInt(System.getProperty("rmi.registry.port"));
        Registry registry = LocateRegistry.getRegistry("", registryPort);
        Remote stub = registry.lookup(LeaseCheckInterval.BINDING);
        Runtime.getRuntime().halt(0);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Remote(java.rmi.Remote) LocateRegistry(java.rmi.registry.LocateRegistry) Registry(java.rmi.registry.Registry)

Example 32 with Registry

use of java.rmi.registry.Registry in project jdk8u_jdk by JetBrains.

the class KeepAliveDuringCall method main.

public static void main(String[] args) {
    System.err.println("\nRegression test for bug 4308492\n");
    KeepAliveDuringCall obj = new KeepAliveDuringCall();
    try {
        UnicastRemoteObject.exportObject(obj);
        System.err.println("exported shutdown monitor");
        Registry localRegistry = TestLibrary.createRegistryOnUnusedPort();
        int registryPort = TestLibrary.getRegistryPort(localRegistry);
        System.err.println("created local registry");
        localRegistry.bind(BINDING, obj);
        System.err.println("bound shutdown monitor in local registry");
        System.err.println("starting remote ShutdownImpl VM...");
        (new JavaVM("ShutdownImpl", "-Drmi.registry.port=" + registryPort, "")).start();
        Shutdown s;
        synchronized (obj.lock) {
            System.err.println("waiting for submission of object to shutdown...");
            while ((s = obj.shutdown) == null) {
                obj.lock.wait(TIMEOUT);
            }
            if (s == null) {
                throw new RuntimeException("TEST FAILED: timeout waiting for shutdown object " + "to make initial contact");
            }
            System.err.println("shutdown object submitted: " + s);
        }
        try {
            s.shutdown();
        } catch (RemoteException e) {
            throw new RuntimeException("TEST FAILED: shutdown method threw remote exception", e);
        }
        synchronized (obj.lock) {
            if (!obj.stillAlive) {
                throw new RuntimeException("TEST FAILED: " + "shutdown object not detected alive after unexport");
            }
        }
        System.err.println("TEST PASSED: " + "shutdown object detected still alive after unexport");
    } catch (Exception e) {
        if (e instanceof RuntimeException) {
            throw (RuntimeException) e;
        } else {
            throw new RuntimeException("TEST FAILED: unexpected exception", e);
        }
    } finally {
        try {
            UnicastRemoteObject.unexportObject(obj, true);
        } catch (RemoteException e) {
        }
    }
}
Also used : LocateRegistry(java.rmi.registry.LocateRegistry) Registry(java.rmi.registry.Registry) RemoteException(java.rmi.RemoteException) RemoteException(java.rmi.RemoteException)

Example 33 with Registry

use of java.rmi.registry.Registry in project Lucee by lucee.

the class CLIFactory method invoke.

private void invoke(final InetAddress current, final String name) throws RemoteException, NotBoundException {
    final Registry registry = LocateRegistry.getRegistry(current.getHostAddress(), PORT);
    final CLIInvoker invoker = (CLIInvoker) registry.lookup(name);
    invoker.invoke(config);
}
Also used : LocateRegistry(java.rmi.registry.LocateRegistry) Registry(java.rmi.registry.Registry)

Example 34 with Registry

use of java.rmi.registry.Registry in project Lucee by lucee.

the class CLIFactory method getRegistry.

public static Registry getRegistry(final int port) {
    Registry registry = null;
    try {
        registry = LocateRegistry.createRegistry(port);
    } catch (final RemoteException e) {
    }
    try {
        if (registry == null)
            registry = LocateRegistry.getRegistry(port);
    } catch (final RemoteException e) {
    }
    RemoteServer.setLog(System.out);
    return registry;
}
Also used : LocateRegistry(java.rmi.registry.LocateRegistry) Registry(java.rmi.registry.Registry) RemoteException(java.rmi.RemoteException)

Example 35 with Registry

use of java.rmi.registry.Registry in project Lucee by lucee.

the class CLIFactory method startInvoker.

private void startInvoker(final String name) throws ServletException, RemoteException {
    final Registry myReg = getRegistry(PORT);
    final CLIInvokerImpl invoker = new CLIInvokerImpl(root, servletName);
    final CLIInvoker stub = (CLIInvoker) UnicastRemoteObject.exportObject(invoker, 0);
    myReg.rebind(name, stub);
    if (idleTime > 0) {
        final Closer closer = new Closer(myReg, invoker, name, idleTime);
        closer.setDaemon(false);
        closer.start();
    }
}
Also used : LocateRegistry(java.rmi.registry.LocateRegistry) Registry(java.rmi.registry.Registry)

Aggregations

Registry (java.rmi.registry.Registry)77 LocateRegistry (java.rmi.registry.LocateRegistry)71 RemoteException (java.rmi.RemoteException)35 Remote (java.rmi.Remote)12 HashMap (java.util.HashMap)9 JMXServiceURL (javax.management.remote.JMXServiceURL)9 IOException (java.io.IOException)8 JMXConnector (javax.management.remote.JMXConnector)8 UnknownHostException (java.net.UnknownHostException)7 MBeanServer (javax.management.MBeanServer)7 MBeanServerConnection (javax.management.MBeanServerConnection)7 JMXConnectorServer (javax.management.remote.JMXConnectorServer)7 ObjectName (javax.management.ObjectName)6 JMXPluggableAuthenticator (com.sun.jmx.remote.security.JMXPluggableAuthenticator)5 InetAddress (java.net.InetAddress)5 MalformedURLException (java.net.MalformedURLException)5 AlreadyBoundException (java.rmi.AlreadyBoundException)5 Properties (java.util.Properties)5 Attribute (javax.management.Attribute)5 Notification (javax.management.Notification)5