TD3: Add code skeleton for the hostel reservations though RMI.
[TD_SR.git] / TD3 / hotel / ChaineHotelsClientRMI.java
1 package hotel;
2
3 import java.io.IOException;
4 import java.rmi.Naming;
5 import java.rmi.NotBoundException;
6 import java.rmi.RMISecurityManager;
7
8
9 /**
10 * Applications reparties
11 * TP - Exercice
12 * Chaine d'hotels
13 *
14 * Programme client RMI
15 *
16 * @author Toto
17 * @version 1.0
18 */
19 public class ChaineHotelsClientRMI {
20
21
22 /**
23 * Nom par defaut de la machine ou tourne le registre RMI
24 */
25 private static String DEFAULT_HOST = "localhost";
26
27 /**
28 * Port par defaut du registre RMI distant
29 */
30 private static int DEFAULT_REGISTRY_PORT = 1099;
31
32
33 /**
34 * Programme principal (les arguments sont optionnels)
35 * @param args[0] Nom du serveur
36 * @param args[1] Port du serveur
37 */
38 public static void main(String[] args) {
39 String server = null;
40 int port = -1;
41
42 if(args.length != 2) {
43 System.out.println("Usage: java ChaineHotelsClientRMI NomServeur PortServeur");
44 System.out.println("Utilisation du nom de serveur et du port par defaut ("+DEFAULT_HOST+":"+DEFAULT_REGISTRY_PORT+")");
45 server = DEFAULT_HOST;
46 port = DEFAULT_REGISTRY_PORT;
47 }
48 else {
49 try {
50 server = args[0];
51 port = Integer.parseInt(args[1]);
52 }
53 catch(NumberFormatException nfe) {
54 nfe.printStackTrace();
55 System.exit(1);
56 }
57 }
58
59 try {
60
61 /********************/
62 //TODO
63 /********************/
64
65 } catch (ExceptionChambresIndispo ec) {
66 System.err.println("Erreur : "+ec);
67 } catch (ExceptionNumReservation en) {
68 System.err.println("Erreur : "+en);
69 } catch (IOException ioe) {
70 System.err.println("Erreur : "+ioe);
71 ioe.printStackTrace();
72 } catch (NotBoundException nbe) {
73 System.err.println("Erreur : "+nbe);
74 nbe.printStackTrace();
75 }
76 }
77
78 }