package org.saf.remote;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import org.apache.log4j.Logger;
import org.saf.business.RemoteNodeRmiData;
public class RemoteUtility {
protected static final Logger logger =
Logger.getLogger(RemoteUtility.class);
public static boolean registerToRmiNode(RemoteNodeRmiData rmiNode) {
boolean ret = false;
Registry registry = null;
RemoteInterface rmi = null;
rmiNode.setConnected(false);
try {
registry = LocateRegistry.getRegistry(rmiNode.getNode().getAddress(),
(new Integer(rmiNode.getNode().getPort())));
rmi = (RemoteInterface)(registry.lookup("RemoteServer"));
ret = true;
rmiNode.setConnected(true);
} catch (RemoteException e) {
logger.error(e.getMessage());
registry = null;
rmi = null;
} catch (NotBoundException e) {
logger.error(e.getMessage());
registry = null;
rmi = null;
}
rmiNode.setRegistry(registry);
rmiNode.setRmiNode(rmi);
return ret;
}
}