X-Git-Url: https://git.piment-noir.org/?p=TD_SR.git;a=blobdiff_plain;f=TD3%2Fhotel%2FChaineHotelsClientRMI.java;fp=TD3%2Fhotel%2FChaineHotelsClientRMI.java;h=d6b3235f25087e14af78ed2f8dcc09841d888ea9;hp=0000000000000000000000000000000000000000;hb=3a8c8f1926734c79be64af8debbc807ee2eabb5e;hpb=ae09e645684a4f53aad5566f811ab7e99d6b68ac diff --git a/TD3/hotel/ChaineHotelsClientRMI.java b/TD3/hotel/ChaineHotelsClientRMI.java new file mode 100644 index 0000000..d6b3235 --- /dev/null +++ b/TD3/hotel/ChaineHotelsClientRMI.java @@ -0,0 +1,78 @@ +package hotel; + +import java.io.IOException; +import java.rmi.Naming; +import java.rmi.NotBoundException; +import java.rmi.RMISecurityManager; + + +/** + * Applications reparties + * TP - Exercice + * Chaine d'hotels + * + * Programme client RMI + * + * @author Toto + * @version 1.0 + */ +public class ChaineHotelsClientRMI { + + + /** + * Nom par defaut de la machine ou tourne le registre RMI + */ + private static String DEFAULT_HOST = "localhost"; + + /** + * Port par defaut du registre RMI distant + */ + private static int DEFAULT_REGISTRY_PORT = 1099; + + + /** + * Programme principal (les arguments sont optionnels) + * @param args[0] Nom du serveur + * @param args[1] Port du serveur + */ + public static void main(String[] args) { + String server = null; + int port = -1; + + if(args.length != 2) { + System.out.println("Usage: java ChaineHotelsClientRMI NomServeur PortServeur"); + System.out.println("Utilisation du nom de serveur et du port par defaut ("+DEFAULT_HOST+":"+DEFAULT_REGISTRY_PORT+")"); + server = DEFAULT_HOST; + port = DEFAULT_REGISTRY_PORT; + } + else { + try { + server = args[0]; + port = Integer.parseInt(args[1]); + } + catch(NumberFormatException nfe) { + nfe.printStackTrace(); + System.exit(1); + } + } + + try { + + /********************/ + //TODO + /********************/ + + } catch (ExceptionChambresIndispo ec) { + System.err.println("Erreur : "+ec); + } catch (ExceptionNumReservation en) { + System.err.println("Erreur : "+en); + } catch (IOException ioe) { + System.err.println("Erreur : "+ioe); + ioe.printStackTrace(); + } catch (NotBoundException nbe) { + System.err.println("Erreur : "+nbe); + nbe.printStackTrace(); + } + } + +}