Programmation RMI

aymenboy Messages postés 8 Date d'inscription mardi 22 décembre 2009 Statut Membre Dernière intervention 30 mars 2010 - 3 janv. 2010 à 23:29
saber2 Messages postés 3 Date d'inscription vendredi 12 décembre 2008 Statut Membre Dernière intervention 15 mars 2011 - 15 mars 2011 à 16:28
slt je besoin de m'aider à mon projet je veut que tu me corrige mes faute s'il te plait bon le projet est :

une compagnie aérienne offre un service de reservavtion accessible à distance chaque vol est défini par son numero (identifiant unique ),pays de départ ,pays destination ,heure , nombre de place non encore réservéés et prix du tiket
le service offre trois opérations
1_reserver : à paritr d'un nom de client , un numero de vol et d'une date . cette opération renvois un entier qui correspond au numero du ticket si réservation réussie ou -1 sinon
2_annuler à partir d'un numero de vol et un tiket cette opération annule la réseravation corespondante .elle retourne 1 si annulation réussie ,0 si paramétre d'entréé non valides
3_ lister à partir d'une date , de pays départ et destination ,cette opération rend les numéros et les horaires ainsi que le prix de ticket des vols corresondant à ces paramétres de recherche


question :
réaliset en java RMI une implémentation du systéme décrit ci-dessus



et voila le code que je l'écris pour le client dabor :

public interface AgenceInterface extends java.rmi.Remote {

public int[] reserver(String nomClient,int numVol,String dateV,String NomHotel,String dateH,int nbChambre) throws java.rmi.RemoteException;

public int annuler(int numVol,int numTicket,int numReservation) throws java.rmi.RemoteException;

public String[] listerV(String date ,String paysDepart,String paysDestination) throws java.rmi.RemoteException;

public String[] listerH(int numReservation) throws java.rmi.RemoteException;

}


pour le serveur :




public class AgenceServeur extends UnicastRemoteObject implements AgenceInterface {


Connection cn;
Statement st;


public AgenceServeur() throws java.rmi.RemoteException { }

public int[] reserver(String nomClient,int numVol,String dateV,String nomHotel,String dateH,int nbChambre) throws java.rmi.RemoteException {

int numTicket=-1;
int numReservation=-1;
int reservation[]={numTicket,numReservation};
try{
InterfaceVol obj = (InterfaceVol) Naming.lookup ("rmi://localhost:1099/volServeur");
numTicket = obj.reserverV(nomClient,numVol,dateV);
InterfaceHotel obj1 = (InterfaceHotel) Naming.lookup ("rmi://localhost:1099/hotelServeur");
numReservation = obj1.reserverH(nomClient,nomHotel,dateH,nbChambre);
reservation[0]=numTicket;
reservation[1]=numReservation;


}

catch (SQLException ex) {
System.out.println(ex.getMessage());

return reservation;
}

catch (ClassNotFoundException ex) {


return reservation;
}
catch (NotBoundException ex) {
System.out.println("Erreur NotBoundException");


return reservation;
}

catch (MalformedURLException ex) {
System.out.println("Erreur MalformedURLException");


return reservation;
}

catch (RemoteException ex) {
System.out.println("Erreur RemoteException");

return reservation;
}

}

public int annuler(int numVol,int numTicket,int numReservation) throws java.rmi.RemoteException {

int testVol;
int testHotel;
try{
InterfaceVol obj = (InterfaceVol) Naming.lookup ("rmi://localhost:1099/volServeur");
testVol = obj.annulerV(numVol,numTicket);
InterfaceHotel obj1 = (InterfaceHotel) Naming.lookup ("rmi://localhost:1099/hotelServeur");
testHotel = obj1.annulerH(numReservation);


return(1);
}

else
return(0);

}

catch (SQLException ex) {


return(0);
}

catch (ClassNotFoundException ex) {


return(0);
}
catch (NotBoundException ex) {


return(0);
}

catch (MalformedURLException ex) {


return(0);
}

catch (RemoteException ex) {


return(0);
}


}

public String[] listerV(String date ,String paysDepart,String paysDestination) throws java.rmi.RemoteException {

String[] rs={" "," "," "} ;

try{
InterfaceVol obj = (InterfaceVol) Naming.lookup ("rmi://localhost:1099/volServeur");
rs = obj.listerV(date,paysDepart,paysDestination);

}
/*
catch (SQLException ex) {
System.out.println("Erreur Sql");
rs = null;
}
*/

catch (NotBoundException ex) {
System.out.println("Erreur NotBoundException");
rs=null;
}

catch (RemoteException ex) {
System.out.println("Erreur RemoteException");
rs=null;
}
catch (MalformedURLException ex) {
System.out.println("Erreur MalformedURLException");
rs=null;;
}

return(rs);
}//fin listerV()

public String[] listerH(int numReservation) throws java.rmi.RemoteException {

String info="Reservation introuvable";
String s[];
try{
InterfaceHotel obj = (InterfaceHotel) Naming.lookup ("rmi://localhost:1099/hotelServeur");
s = obj.listerH(numReservation);
}

catch (NotBoundException ex) {

s=null;
}

catch (RemoteException ex) {

s= null ;
}
catch (MalformedURLException ex) {

s=null;
}

return(s) ;
}

public static void main(String args[]) throws IOException {


try{

AgenceServeur monServeur = new AgenceServeur();

Naming.rebind("rmi://localhost:1099/AgenceServeur", monServeur);

}

catch (RemoteException e) {
System.out.println("AgenceServeur err: " + e.getMessage());
}
}

}

2 réponses

fares6 Messages postés 3 Date d'inscription lundi 27 avril 2009 Statut Membre Dernière intervention 5 janvier 2010
5 janv. 2010 à 01:45
bonsoir j'ai le même sujet que vous mais apparemment votre solution me parait plus logique Est se que vous avez trouvé une solution pour vos fautes !??? merci de me repondre
0
saber2 Messages postés 3 Date d'inscription vendredi 12 décembre 2008 Statut Membre Dernière intervention 15 mars 2011
15 mars 2011 à 16:28
salut tous le monde je suis débutant ,j'entarin de faire un projet de fin d'etude :realisation deERP por le e-tourisme
cela veut dire il faut avoir une application ou solution web pour gestion de agence de voyage par un administrateur ou empolyé aussi le client peut faire une resrevation en ligne de hotel vol ;je utlise EJB et JSF comme technologie de plus la connection rmi ;je besoin de vous pour m'aider :mon emailest salsabil.antir@gmail.com méme le demarch afin de me facilite tache
0
Rejoignez-nous