package calcul; import org.omg.CORBA.ORB; import org.omg.CORBA.UserException; import org.omg.CosNaming.NamingContextExt; import org.omg.CosNaming.NamingContextExtHelper; import org.omg.PortableServer.POA; import org.omg.PortableServer.POAHelper; import org.omg.PortableServer.POAManager; public class Client { public static void main(String args[]){ String arg[] = {"ORBInitialHost","localhost","-ORBInitialPort","1234"}; int status; // initialisation de l'orb ORB orb = ORB.init(arg, null); try { // Obtention d'une reference vers le POA manager de la racine POA rootPoa = POAHelper.narrow(orb .resolve_initial_references("RootPOA")); org.omg.CORBA.Object nc_obj = orb.resolve_initial_references("NameService"); POAManager manager = rootPoa.the_POAManager(); // Activation du POA Manager manager.activate(); //Récupération de la référence de l'objet à partir du fichier String ior ; String refFile = "Calculette.IOR" ; java.io.BufferedReader in = new java.io.BufferedReader(new java.io.FileReader(refFile)) ; ior = in.readLine() ; org.omg.CORBA.Object o = orb.string_to_object(ior) ; Calculette calc = CalculetteHelper.narrow(o); calc.addition(7); System.out.println("Etat après +7="+calc.etat()); calc.multiplication(6); System.out.println("Etat après *6="+calc.etat()); calc.soustraction(2); System.out.println("Etat après -2="+calc.etat()); calc.division(4); System.out.println("Etat après /4="+calc.etat()); System.out.println("Tentative de division par 0..."); calc.division(0); //on le test //CalculetteHandler handler = new CalculetteHandler(calc); //handler.execute(); orb.run(); } catch (Exception ex) { ex.printStackTrace(); } } }