import java.rmi.Naming; import java.rmi.RemoteException; public class ArbreNoeud { private static int port = 1664; private Noeud noeud; public ArbreNoeud(String nom, String pere){ Noeud noeud_pere; System.out.println("creation du noeud:" + nom); if(pere == null) { try{ noeud = new NoeudImpl(nom,null); Naming.rebind("rmi://127.0.0.1:" + port + "/" + nom, noeud); } catch(Exception e){ e.printStackTrace(); } } else { try{ noeud_pere = (Noeud)Naming.lookup("rmi://localhost:" + port + "/" + pere); noeud = new NoeudImpl(nom,pere); Naming.rebind("rmi://127.0.0.1:" + port + "/" + nom, noeud); noeud_pere.addFils(nom.toString()); } catch(Exception e) { e.printStackTrace(); } } } // Main public static void main (String[] args) throws RemoteException { if(args.length == 2){ new ArbreNoeud(args[0], args[1]); } else { if(args.length == 1) { new ArbreNoeud(args[0],null); } else { System.out.println(" ->Utilisation : java ArbreNoeud name father (pour un noeud)"); System.out.println(" ->Utilisation : java ArbreNoeud name (pour la racine)"); } } } }