import java.io.*; import java.rmi.*; import java.rmi.registry.*; import java.util.*; import java.net.*; import java.rmi.server.UnicastRemoteObject; public class Serveur extends UnicastRemoteObject implements Serveur_itf { public static void main(String args[]) { System.out.println("Démarrage du serveur"); try { System.out.println ("\n\nCréation d'un security manager pour pouvoir charger le stub de l'objet présent dans la troisième JVM"); System.setSecurityManager(new RMISecurityManager()); System.out.println ("Création d'un service de nom"); Registry registry = LocateRegistry.createRegistry(2000); Naming.rebind("//localhost:2000/Hello", new Serveur()); System.out.println("Le serveur est enregistré dans le service de nom"); } catch (Exception e) { System.out.println("Erreur dans le serveur error: " + e.getMessage()); e.printStackTrace(); } System.out.println("Le serveur est actif"); } public Serveur() throws RemoteException { super(); } public void Vide() throws RemoteException { return; } public void PasseObjetLocal(ObjetLocal ol) throws RemoteException { ol.Vide (); } public void PasseObjetDistant(ObjetDistant_itf od) throws RemoteException { od.Vide (); } public void PasseObjetStubInconnu(ObjetStubInconnu_itf osi) throws RemoteException { osi.Vide (); } public void AfficheObjetLocal(ObjetLocal ol) throws RemoteException { ol.AfficheEtat (); } public void AfficheObjetDistant(ObjetDistant_itf od) throws RemoteException { od.AfficheEtat (); } public void AfficheObjetStubInconnu(ObjetStubInconnu_itf osi) throws RemoteException { osi.AfficheEtat (); } }