Package org.saf.remote

Source Code of org.saf.remote.RemoteUtility

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;
 
 
}
TOP

Related Classes of org.saf.remote.RemoteUtility

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.