RemoteRef ref = ((RemoteObject)stub).getRef(); if (ref.getClass() != UnicastRef2.class) { throw new SecurityException(
public boolean equals (Object obj) { if (obj instanceof RemoteObject) { if (ref == null) { return obj == this; } else { RemoteRef otherRef = ((RemoteObject)obj).getRef(); return ref.remoteEquals (otherRef); } } else if (obj != null) { return obj.equals (this); } else { return false; } } }
//nopackage -- move if you like import java.rmi.Remote; import java.rmi.registry.*; import java.rmi.server.*; import sun.rmi.server.UnicastRef; import sun.rmi.transport.LiveRef; public class JMXTarget { /* * run: java JMXTarget host port * where host (name or address) contains the JVM process offering JMX * and port (number) is the registry specified by -Dcom.sun.management.jmxremote.port */ public static void main(String[] args) throws Exception { Registry reg = LocateRegistry.getRegistry (args[0], Integer.parseInt(args[1])); Remote r = reg.lookup ("jmxrmi"); RemoteObject ro = (RemoteObject)r; RemoteRef rr = ro.getRef(); UnicastRef ur = (UnicastRef)rr; LiveRef lr = ur.getLiveRef(); System.out.println (lr); } }
private static RemoteJMeterEngine getEngine(String hostAndPort) throws RemoteException, NotBoundException { final String name = RemoteJMeterEngineImpl.JMETER_ENGINE_RMI_NAME; // $NON-NLS-1$ $NON-NLS-2$ String host = hostAndPort; int port = RmiUtils.DEFAULT_RMI_PORT; int indexOfSeparator = hostAndPort.indexOf(':'); if (indexOfSeparator >= 0) { host = hostAndPort.substring(0, indexOfSeparator); String portAsString = hostAndPort.substring(indexOfSeparator+1); port = Integer.parseInt(portAsString); } Registry registry = LocateRegistry.getRegistry( host, port, RmiUtils.createClientSocketFactory()); Remote remobj = registry.lookup(name); if (remobj instanceof RemoteJMeterEngine){ final RemoteJMeterEngine rje = (RemoteJMeterEngine) remobj; if (remobj instanceof RemoteObject){ RemoteObject robj = (RemoteObject) remobj; System.out.println("Using remote object: "+robj.getRef().remoteToString()); // NOSONAR } return rje; } throw new RemoteException("Could not find "+name); }
actualRegistryPort = ((UnicastRef) registry.getRef()).getLiveRef().getPort();
actualRegistryPort = ((UnicastRef) registry.getRef()).getLiveRef().getPort();
actualRegistryPort = ((UnicastRef) registry.getRef()).getLiveRef().getPort();
RemoteRef remoteRef = remoteObject.getRef(); Assert.assertTrue(remoteRef instanceof ProxyRef); ProxyRef proxyRef = (ProxyRef) remoteRef;