@Test public void testRemote() throws InterruptedException, ProActiveException, URISyntaxException { GCMVirtualNode vn1 = super.gcmad.getVirtualNode(DEFAULT_VN_NAME); Node node = super.getANode(); RemoteAO rao = PAActiveObject.newActive(RemoteAO.class, new Object[] {}, node); String url = rao.createRemoteObject(); RemoteObject<RO> remoteObject = (RemoteObject<RO>) RemoteObjectHelper.lookup(new URI(url)); RO ro = (RO) RemoteObjectHelper.generatedObjectStub(remoteObject); rao.setVirtualNode(vn1); ro.setVirtualNode(vn1); ro.setRemoteObject(ro); ro.setCallback(); ro.waitSuccess(); }
/* (non-Javadoc) * @see org.objectweb.proactive.core.remoteobject.RemoteObjectFactory#lookup(java.net.URI) */ public <T> RemoteObject<T> lookup(URI uri) throws ProActiveException { Object o = null; URI modifiedURI = uri; if (uri.getPort() == -1) { LOGGER_RO.debug("No port specified, using the default one"); modifiedURI = URIBuilder.buildURI( URIBuilder.getHostNameFromUrl(uri), URIBuilder.getNameFromURI(uri), this.protocolIdentifier); modifiedURI = RemoteObjectHelper.expandURI(modifiedURI); } // Try if URL is the address of a RmiRemoteBody try { Registry reg = getRegistry(modifiedURI); o = reg.lookup(URIBuilder.getNameFromURI(modifiedURI)); LOGGER_RO.debug(modifiedURI.toString() + " looked up successfully"); } catch (java.rmi.NotBoundException e) { // there are one rmiregistry on target computer but nothing bound to this url is not bound throw new ProActiveException( "The url " + modifiedURI + " is not bound to any known object", e); } catch (RemoteException e) { throw new ProActiveException("Registry could not be contacted, " + modifiedURI, e); } if (o instanceof RmiRemoteObject) { return new RemoteObjectAdapter((RmiRemoteObject) o); } throw new ProActiveException( "The given url does exist but doesn't point to a remote object url=" + modifiedURI + " class found is " + o.getClass().getName()); }