// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.io.IOException;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.server.RMISocketFactory; 
import java.rmi.registry.LocateRegistry;

public class TestImpl extends UnicastRemoteObject implements Test {
   public TestImpl() throws RemoteException {
   }
   public String dup(String s) {
      return (s + s);
   }
   public static void main(String[] args) {
      try {
         RMISocketFactory.setSocketFactory(new FixedPortRMISocketFactory());
         LocateRegistry.createRegistry(50000);
         Naming.rebind("rmi://localhost:50000/test", new TestImpl());
      } catch (RemoteException e) {
         e.printStackTrace();
      } catch (MalformedURLException e) {
         e.printStackTrace();
      } catch (IOException e) {
         e.printStackTrace();
      }
   }
}
