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();
}
}
public static void serverFactory(LocalServer ls, String serverName)
throws RemoteException, AlreadyBoundException {
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());
LocateRegistry.createRegistry(1099);
return LocateRegistry.getRegistry();
}
}