MàJ par récupération sur Clé USB et dans /mnt/hd/Chargement du pc portable
This commit is contained in:
		
							
								
								
									
										
											BIN
										
									
								
								A61/FASD/ArbreNoeud.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								A61/FASD/ArbreNoeud.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										53
									
								
								A61/FASD/ArbreNoeud.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								A61/FASD/ArbreNoeud.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,53 @@
 | 
			
		||||
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)");
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								A61/FASD/MyNoeud.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								A61/FASD/MyNoeud.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										44
									
								
								A61/FASD/MyNoeud.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								A61/FASD/MyNoeud.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,44 @@
 | 
			
		||||
import java.rmi.Naming;
 | 
			
		||||
import java.rmi.RemoteException;
 | 
			
		||||
 | 
			
		||||
public class MyNoeud {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	public MyNoeud(String nom, String pere, String port) {
 | 
			
		||||
 | 
			
		||||
		Noeud pere_temp;
 | 
			
		||||
		NoeudImpl n;
 | 
			
		||||
 | 
			
		||||
		try{
 | 
			
		||||
			if(pere != null && !pere.equals("null")) {
 | 
			
		||||
				pere_temp = (Noeud)Naming.lookup("rmi://localhost:" + port + "/"  + pere);
 | 
			
		||||
				n = new NoeudImpl(nom,pere_temp.getName());
 | 
			
		||||
			} else {
 | 
			
		||||
				pere_temp = null;
 | 
			
		||||
				n = new NoeudImpl(nom,null);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			try{			
 | 
			
		||||
				Naming.rebind("rmi://127.0.0.1:" + port + "/" + nom, n);
 | 
			
		||||
			}catch (RemoteException e) {
 | 
			
		||||
				System.out.println(e.getMessage());
 | 
			
		||||
				System.exit(1);
 | 
			
		||||
			}
 | 
			
		||||
			System.out.println("rmi://localhost:" + port + "/" + nom);
 | 
			
		||||
 | 
			
		||||
			if(pere_temp != null)
 | 
			
		||||
				pere_temp.addFils(nom);	
 | 
			
		||||
 | 
			
		||||
		}catch(Exception e) {
 | 
			
		||||
			e.printStackTrace();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public static void main (String[] args) throws RemoteException {
 | 
			
		||||
		if(args.length == 3){
 | 
			
		||||
			new MyNoeud(args[0], args[1], args[2]);
 | 
			
		||||
		} else {
 | 
			
		||||
			System.out.println(" please use : java MyNoeud name father port");
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								A61/FASD/Noeud.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								A61/FASD/Noeud.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										15
									
								
								A61/FASD/Noeud.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								A61/FASD/Noeud.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
			
		||||
import java.rmi.Remote;
 | 
			
		||||
import java.rmi.RemoteException;
 | 
			
		||||
import java.util.*;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public interface Noeud extends Remote {
 | 
			
		||||
 | 
			
		||||
  String getPere()         throws RemoteException;
 | 
			
		||||
	String getName()         throws RemoteException;
 | 
			
		||||
	String getFils(int i)    throws RemoteException;
 | 
			
		||||
	void   addFils(String n) throws RemoteException;
 | 
			
		||||
	int    getNbFils()       throws RemoteException;
 | 
			
		||||
	Vector getAllFils()      throws RemoteException;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								A61/FASD/NoeudImpl.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								A61/FASD/NoeudImpl.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										46
									
								
								A61/FASD/NoeudImpl.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								A61/FASD/NoeudImpl.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,46 @@
 | 
			
		||||
import java.rmi.Remote;
 | 
			
		||||
import java.rmi.RemoteException;
 | 
			
		||||
import java.util.*;
 | 
			
		||||
import java.rmi.server.UnicastRemoteObject;
 | 
			
		||||
 | 
			
		||||
public class NoeudImpl extends UnicastRemoteObject implements Noeud {
 | 
			
		||||
 | 
			
		||||
	private String name;
 | 
			
		||||
	private String pere;
 | 
			
		||||
	private int nbFils;
 | 
			
		||||
	private Vector<String> fils;
 | 
			
		||||
 | 
			
		||||
	public NoeudImpl(String n, String p) throws RemoteException {
 | 
			
		||||
		name = n;
 | 
			
		||||
		pere = p;
 | 
			
		||||
		fils = new Vector<String>();
 | 
			
		||||
		nbFils = 0;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public String getPere() throws RemoteException {
 | 
			
		||||
		return pere;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public String getName() throws RemoteException {
 | 
			
		||||
		return name;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public String getFils(int i) throws RemoteException {
 | 
			
		||||
		return fils.get(i);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void addFils(String n) throws RemoteException {
 | 
			
		||||
		System.out.println("Message du pere:"+ name + ", Ajout du fils:" + n );
 | 
			
		||||
		fils.add(n);
 | 
			
		||||
		nbFils ++;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public int getNbFils() throws RemoteException {
 | 
			
		||||
		return nbFils;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public Vector getAllFils() throws RemoteException {
 | 
			
		||||
		return fils;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								A61/FASD/NoeudImpl_Stub.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								A61/FASD/NoeudImpl_Stub.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										44
									
								
								A61/FASD/launch.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								A61/FASD/launch.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,44 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
echo "rmiregistry 1664&"
 | 
			
		||||
rmiregistry 1664&
 | 
			
		||||
sleep 1
 | 
			
		||||
 | 
			
		||||
echo
 | 
			
		||||
# le parent & l'entrée dans l'arbre
 | 
			
		||||
java ArbreNoeud n1&
 | 
			
		||||
sleep 1
 | 
			
		||||
 | 
			
		||||
echo
 | 
			
		||||
# n1 a 3 fils
 | 
			
		||||
java ArbreNoeud n2 n1&
 | 
			
		||||
sleep 1
 | 
			
		||||
java ArbreNoeud n3 n1&
 | 
			
		||||
sleep 1
 | 
			
		||||
java ArbreNoeud n4 n1&
 | 
			
		||||
sleep 1
 | 
			
		||||
 | 
			
		||||
echo
 | 
			
		||||
# n2 a 2 fils
 | 
			
		||||
java ArbreNoeud n5 n2&
 | 
			
		||||
sleep 1
 | 
			
		||||
java ArbreNoeud n6 n2&
 | 
			
		||||
sleep 1
 | 
			
		||||
 | 
			
		||||
echo
 | 
			
		||||
# n4 a 3 fils
 | 
			
		||||
java ArbreNoeud n7 n4&
 | 
			
		||||
sleep 1
 | 
			
		||||
java ArbreNoeud n8 n4&
 | 
			
		||||
sleep 1
 | 
			
		||||
java ArbreNoeud n9 n4&
 | 
			
		||||
sleep 1
 | 
			
		||||
 | 
			
		||||
#           n1
 | 
			
		||||
#           |
 | 
			
		||||
#     ------------
 | 
			
		||||
#     |     |    |
 | 
			
		||||
#     n2    n3   n4
 | 
			
		||||
#   -----      ---------
 | 
			
		||||
#   |   |      |   |   |
 | 
			
		||||
#   n5  n6     n7  n8  n9
 | 
			
		||||
		Reference in New Issue
	
	Block a user