private static RemoteJMeterEngine getEngine(String hostAndPort)
throws RemoteException, NotBoundException {
final String name = RemoteJMeterEngineImpl.JMETER_ENGINE_RMI_NAME;
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());
}
return rje;
}
throw new RemoteException("Could not find "+name);
}