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;
}
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;
}
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);
}
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;
}
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");
}
Aggregations