Search in sources :

Example 1 with Registry

use of java.rmi.registry.Registry in project che by eclipse.

the class RmiClient method acquire.

private Remote acquire(RunningInfo info) throws Exception {
    Remote result;
    Registry registry = LocateRegistry.getRegistry("localhost", info.port);
    java.rmi.Remote lookup = registry.lookup(info.name);
    if (java.rmi.Remote.class.isAssignableFrom(remoteClass)) {
        Remote entry = remoteClass.isInstance(lookup) ? (Remote) lookup : (Remote) PortableRemoteObject.narrow(lookup, remoteClass);
        if (entry == null) {
            result = null;
        } else {
            //TODO add proxy for remote object
            result = (Remote) lookup;
        }
    } else {
        result = (Remote) lookup;
    }
    info.remoteRef = result;
    return result;
}
Also used : Registry(java.rmi.registry.Registry) LocateRegistry(java.rmi.registry.LocateRegistry)

Example 2 with Registry

use of java.rmi.registry.Registry in project intellij-community by JetBrains.

the class DebuggerServer method create.

public static DebuggerServer create(Transformer xsl, Source xml, Result out, int port) throws TransformerConfigurationException, RemoteException {
    final DebuggerServer server = new DebuggerServer(xsl, xml, out, port);
    final Registry registry = LocateRegistry.createRegistry(port);
    registry.rebind(XSLT_DEBUGGER, server);
    return server;
}
Also used : Registry(java.rmi.registry.Registry) LocateRegistry(java.rmi.registry.LocateRegistry)

Example 3 with Registry

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

the class JMXStartStopTest method testConnect.

private static void testConnect(int port, int rmiPort) throws Exception {
    dbg_print("RmiRegistry lookup...");
    dbg_print("Using port: " + port);
    dbg_print("Using rmi port: " + rmiPort);
    Registry registry = LocateRegistry.getRegistry(port);
    // "jmxrmi"
    String[] relist = registry.list();
    for (int i = 0; i < relist.length; ++i) {
        dbg_print("Got registry: " + relist[i]);
    }
    String jmxUrlStr = (rmiPort != 0) ? String.format("service:jmx:rmi://localhost:%d/jndi/rmi://localhost:%d/jmxrmi", rmiPort, port) : String.format("service:jmx:rmi:///jndi/rmi://localhost:%d/jmxrmi", port);
    JMXServiceURL url = new JMXServiceURL(jmxUrlStr);
    JMXConnector c = JMXConnectorFactory.connect(url, null);
    MBeanServerConnection conn = c.getMBeanServerConnection();
    ObjectName pattern = new ObjectName("java.lang:type=Memory,*");
    int count = listMBeans(conn, pattern, null);
    if (count == 0)
        throw new Exception("Expected at least one matching " + "MBean for " + pattern);
}
Also used : Registry(java.rmi.registry.Registry) LocateRegistry(java.rmi.registry.LocateRegistry) NoSuchObjectException(java.rmi.NoSuchObjectException) SSLHandshakeException(javax.net.ssl.SSLHandshakeException) TimeoutException(java.util.concurrent.TimeoutException) IOException(java.io.IOException) ConnectException(java.net.ConnectException)

Example 4 with Registry

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

the class JstatdTest method startRegistry.

private Registry startRegistry() throws InterruptedException, RemoteException {
    Registry registry = null;
    try {
        System.out.println("Start rmiregistry on port " + port);
        registry = LocateRegistry.createRegistry(Integer.parseInt(port));
    } catch (RemoteException e) {
        if (e.getMessage().contains("Port already in use")) {
            System.out.println("Port already in use. Trying to restart with a new one...");
            Thread.sleep(100);
            return null;
        } else {
            throw e;
        }
    }
    return registry;
}
Also used : Registry(java.rmi.registry.Registry) LocateRegistry(java.rmi.registry.LocateRegistry) RemoteException(java.rmi.RemoteException)

Example 5 with Registry

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

the class JstatdTest method doTest.

public void doTest() throws Throwable {
    ProcessThread jstatdThread = null;
    try {
        while (jstatdThread == null) {
            if (!useDefaultPort || withExternalRegistry) {
                port = Integer.toString(Utils.getFreePort());
            }
            if (withExternalRegistry) {
                Registry registry = startRegistry();
                if (registry == null) {
                    // The port is already in use. Cancel and try with new one.
                    continue;
                }
            }
            jstatdThread = tryToSetupJstatdProcess();
        }
        runToolsAndVerify();
    } finally {
        cleanUpThread(jstatdThread);
    }
    // Verify output from jstatd
    OutputAnalyzer output = jstatdThread.getOutput();
    assertTrue(output.getOutput().isEmpty(), "jstatd should get an empty output, got: " + Utils.NEW_LINE + output.getOutput());
    assertNotEquals(output.getExitValue(), 0, "jstatd process exited with unexpected exit code");
}
Also used : OutputAnalyzer(jdk.testlibrary.OutputAnalyzer) Registry(java.rmi.registry.Registry) LocateRegistry(java.rmi.registry.LocateRegistry) ProcessThread(jdk.testlibrary.ProcessThread)

Aggregations

Registry (java.rmi.registry.Registry)128 LocateRegistry (java.rmi.registry.LocateRegistry)119 RemoteException (java.rmi.RemoteException)43 IOException (java.io.IOException)20 Remote (java.rmi.Remote)16 NodeRegisterRMIStub (org.mobicents.tools.sip.balancer.NodeRegisterRMIStub)14 UnknownHostException (java.net.UnknownHostException)13 JMXServiceURL (javax.management.remote.JMXServiceURL)12 HashMap (java.util.HashMap)10 NotBoundException (java.rmi.NotBoundException)9 JMXConnector (javax.management.remote.JMXConnector)9 DistributedRMICounter (examples.mvc.rmi.duplex.DistributedRMICounter)8 SocketException (java.net.SocketException)8 AlreadyBoundException (java.rmi.AlreadyBoundException)8 MBeanServerConnection (javax.management.MBeanServerConnection)8 JMXConnectorServer (javax.management.remote.JMXConnectorServer)8 Test (org.junit.Test)8 MBeanServer (javax.management.MBeanServer)7 InetAddress (java.net.InetAddress)6 MalformedURLException (java.net.MalformedURLException)6