//This class was created automatically by CentiJ
package rmi.rmiSynth;

import java.rmi.AlreadyBoundException;
import java.rmi.RMISecurityManager;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

public class RMIServer
    extends java.rmi.server.UnicastRemoteObject
    implements RMIInterface {

  private rmi.rmiSynth.LocalServer ls;

  public RMIServer(LocalServer _ls) throws java.rmi.RemoteException {
    ls = _ls;
  }

  public RMIServer() throws java.rmi.RemoteException {
    super();
  }


  public long getBenchMark() throws java.rmi.RemoteException {
    return ls.getBenchMark();
  }

  public void hello() throws java.rmi.RemoteException {
    ls.hello();
  }

  public java.lang.String getHello() throws java.rmi.RemoteException {
    return ls.getHello();
  }

  public void multiplyBench(long p0) throws java.rmi.RemoteException {
    ls.multiplyBench(p0);
  }

  public static void main(String args[]) {
    try {
      serverFactory(new LocalServer(), RMIInterface.SERVER_NAME);
    } catch (Exception e) {
      e.printStackTrace();
    }

  }

  /**
   *  Use the serverFactor to start the RMIServer
   *  with an arbitrary LocalServer instance.
   */

  public static void serverFactory(LocalServer ls, String serverName)
      throws RemoteException, AlreadyBoundException {
    // Create and install a security manager
    Registry r = getRegistry();
    RMIServer rs = new RMIServer(ls);
    r.bind(serverName, rs);
    System.out.println("RMIServer is running");
  }

  private static Registry getRegistry() throws RemoteException {
    System.setSecurityManager(new RMISecurityManager());
    //Create the registry and bind the Server class to the registry
    LocateRegistry.createRegistry(1099);
    return LocateRegistry.getRegistry();
  }

}