import java.rmi.*; import java.rmi.server.*; import java.net.*; // Cette classe implante l'interface d'objet reparti "Hote" // public class Hote_implem extends UnicastRemoteObject implements Hote { // Encapsule les informations sur les ingredients // public Magasin monMagasin; public Hote_implem(String fichier) throws RemoteException { super(); monMagasin = new Magasin(fichier); } // Methode invoquee de facon distante // Celle-ci cree un thread et demande a // ce dernier d'executer le traitement de l'agent // // La methode rend donc la main avant la // fin du traitement de l'agent // public void migre(Agent a) { threadAgent monThread = new threadAgent(a, monMagasin); monThread.start(); } public static void main(String[] args) { if (System.getSecurityManager() == null) System.setSecurityManager(new mySecurity()); if (args.length != 2) { System.out.println("Deux parametres : portRmiregistry nom-du-fichier ! "); System.exit(1); } try { // Creation de l'objet reparti et publication // sur le reseau // Hote monHote = new Hote_implem(args[1]); myHostname machine = new myHostname(); String nom = "//" + machine.QualifiedHost() + ":" + args[0] + "/Hote"; .... System.out.println("Hote_implem enregistre : " + nom); } catch (Exception e) { System.err.println("Hote_implem exception: " + e.getMessage()); e.printStackTrace(); } } }