/* (non-Javadoc) * @see org.objectweb.proactive.core.remoteobject.RemoteObjectFactory#register(org.objectweb.proactive.core.remoteobject.RemoteObject, java.net.URI, boolean) */ public RemoteRemoteObject register( InternalRemoteRemoteObject target, URI url, boolean replacePreviousBinding) throws ProActiveException { RmiRemoteObject rro = null; try { Constructor<? extends RmiRemoteObject> c = clRemoteObject.getConstructor(InternalRemoteRemoteObject.class); rro = c.newInstance(target); } catch (Exception e) { throw new ProActiveException(e); } Registry reg = null; try { reg = getRegistry(url); } catch (Exception e) { LOGGER_RO.debug("creating new rmiregistry on port : " + url.getPort()); try { LocateRegistry.createRegistry(URIBuilder.getPortNumber(url)); } catch (RemoteException e1) { LOGGER_RO.warn("damn cannot start a rmiregistry on port " + url.getPort()); throw new ProActiveException(e1); } } try { if (replacePreviousBinding) { reg.rebind(URIBuilder.getNameFromURI(url), rro); } else { reg.bind(URIBuilder.getNameFromURI(url), rro); } LOGGER_RO.debug(" successfully bound in registry at " + url); } catch (java.rmi.AlreadyBoundException e) { LOGGER_RO.warn(url + " already bound in registry", e); throw new AlreadyBoundException(e); } catch (RemoteException e) { LOGGER_RO.debug(" cannot bind object at " + url); throw new ProActiveException(e); } return rro; }
/* (non-Javadoc) * @see org.objectweb.proactive.core.remoteobject.RemoteObjectFactory#list(java.net.URI) */ public URI[] list(URI url) throws ProActiveException { try { Registry registry = getRegistry(url); String[] names = registry.list(); if (names != null) { URI[] uris = new URI[names.length]; for (int i = 0; i < names.length; i++) { uris[i] = URIBuilder.buildURI( URIBuilder.getHostNameFromUrl(url), names[i], protocolIdentifier, URIBuilder.getPortNumber(url)); } return uris; } } catch (Exception e) { throw new ProActiveException(e); } return null; }