The Java Program: IdentityServer.java

  1 import IdentityRemoteObject;
  2 import java.net.MalformedURLException;
  3 import java.rmi.ConnectException;
  4 import java.rmi.RemoteException;
  5 import java.rmi.Naming;
  6 
  7 public class IdentityServer {
  8 
  9    private final static String service_name = "identity";
 10    
 11    public static void main (String args[]) {
 12       try {
 13          IdentityRemoteObject ro = new IdentityRemoteObject ();
 14          final String url = "//"+args[0]+":"+args[1]+"/"+service_name;
 15          Naming.rebind (url, ro);
 16          System.out.println ("Added an identity object to the registery");
 17 
 18          Thread t = Thread.currentThread();
 19          t.setName("Identity Server");
 20          ThreadGroup g = t.getThreadGroup().getParent();
 21          int active = g.activeCount();
 22          System.out.println("Currently active threads: " + active);
 23          Thread all[] = new Thread[active];
 24          g.enumerate(all);
 25          for (int i = 0; i < active; i++) {
 26             System.out.println ((i<10?" ":"") + i + ": " + all[i]);
 27          }
 28       } catch (MalformedURLException e) {
 29          e.printStackTrace();
 30       } catch (ConnectException e) {
 31          System.err.println ("Is the registry running?");
 32          e.printStackTrace();
 33       } catch (RemoteException e) {
 34          e.printStackTrace();
 35       }
 36    }
 37 }