Search in sources :

Example 6 with Registry

use of java.rmi.registry.Registry in project camel by apache.

the class RmiConsumer method doStop.

@Override
protected void doStop() throws Exception {
    super.doStop();
    try {
        Registry registry = endpoint.getRegistry();
        registry.unbind(endpoint.getName());
    } catch (Throwable e) {
    // do our best to unregister
    }
    UnicastRemoteObject.unexportObject(proxy, true);
}
Also used : Registry(java.rmi.registry.Registry)

Example 7 with Registry

use of java.rmi.registry.Registry in project otter by alibaba.

the class JmxConnectorServerFactoryBean method getRegistry.

private Registry getRegistry(int registryPort) throws RemoteException {
    if (this.alwaysCreateRegistry) {
        logger.info("Creating new RMI registry");
        return LocateRegistry.createRegistry(registryPort);
    }
    if (logger.isInfoEnabled()) {
        logger.info("Looking for RMI registry at port '" + registryPort + "'");
    }
    try {
        // Retrieve existing registry.
        Registry reg = LocateRegistry.getRegistry(registryPort);
        testRegistry(reg);
        return reg;
    } catch (RemoteException ex) {
        logger.debug("RMI registry access threw exception", ex);
        logger.info("Could not detect RMI registry - creating new one");
        // Assume no registry found -> create new one.
        return LocateRegistry.createRegistry(registryPort);
    }
}
Also used : LocateRegistry(java.rmi.registry.LocateRegistry) Registry(java.rmi.registry.Registry) RemoteException(java.rmi.RemoteException)

Example 8 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 9 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 10 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)

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