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