TD3: Add code skeleton for the hostel reservations though RMI.
[TD_SR.git] / TD3 / hotel / ChaineHotelsServeurRMI.java
diff --git a/TD3/hotel/ChaineHotelsServeurRMI.java b/TD3/hotel/ChaineHotelsServeurRMI.java
new file mode 100644 (file)
index 0000000..eb93ba3
--- /dev/null
@@ -0,0 +1,69 @@
+package hotel;
+
+import java.net.MalformedURLException;
+import java.rmi.Naming;
+import java.rmi.RMISecurityManager;
+import java.rmi.RemoteException;
+
+/**
+ * Applications reparties
+ * TP - Exercice
+ * Chaine d'hotels
+ * 
+ * Programme serveur RMI
+ * 
+ * @author Toto
+ * @version 1.0
+ */
+public class ChaineHotelsServeurRMI {
+
+
+       private static int DEFAULT_REGISTRY_PORT = 1099;
+
+
+       /**
+        * Constructeur par defaut
+        */
+       public ChaineHotelsServeurRMI() {
+       }
+
+
+       /**
+        * Programme principal
+        * args[0] Port du registre rmi
+        */
+       public static void main(String[] args) {
+               ChaineHotels hotels;
+               int port = -1;
+
+               if(args.length != 1) {
+                       System.out.println("Usage: java ChaineHotelServeurRMI Port");
+                       System.out.println("Utilisation du port par defaut ("+DEFAULT_REGISTRY_PORT+")");
+                       port = DEFAULT_REGISTRY_PORT;
+               }
+               else { 
+                       try {
+                               port = Integer.parseInt(args[0]);
+                       }
+                       catch(NumberFormatException nfe) {
+                               nfe.printStackTrace();
+                               System.exit(1);
+                       }
+               }
+               
+               try {
+                       /*************************/
+                       //TODO
+                       /*************************/
+               }
+               catch (RemoteException e) {
+                       System.err.println("Serveur : erreur\n"+e.getMessage());
+                       e.printStackTrace();
+               } 
+               catch (MalformedURLException e) {
+                       System.err.println("Serveur : erreur\n"+e.getMessage());
+                       e.printStackTrace();
+               }
+       }
+
+}