Se connecter / S'enregistrer
Votre question

Recharger cette page Dossier medical avec corba

Tags :
  • Java
  • string
  • Programmation
Dernière réponse : dans Programmation
15 Décembre 2011 15:25:38

salut voici mon idl
  1. module dossier
  2. {
  3. struct MedicalNote
  4. {
  5. string author;
  6. string dateRedac;
  7. string text;
  8. };
  9. interface Patient
  10. {
  11. readonly attribute string name;
  12. readonly attribute long nSS;
  13. MedicalNote getNote(in string author);
  14. };
  15. interface Doctor
  16. {
  17. void insertNote(in string author,in string dateRedac,in string text);
  18. };
  19. interface Admin
  20. {
  21. void setName(in string name);
  22. void setNSS(in long nSS);
  23. };
  24. interface MedicalRecord:Patient,Admin,Doctor
  25. {
  26. };
  27. interface PatientManager
  28. {
  29. Patient rechercherPatient(in long nSS);
  30. };
  31. interface DoctorManager
  32. {
  33. Doctor rechercherDoctor(in long nSS);
  34. };
  35. interface AdminManager
  36. {
  37. Admin rechercherAdmin(in long nSS);
  38. void creerDos(in string name,in long nSS);
  39. };
  40.  
  41. interface Manager:AdminManager,PatientManager,DoctorManager
  42. {
  43. };
  44. };



et voici mon code d'implémentation de la classe ManagerImpl et MedicalRecordImpl

  1. package dossier;
  2.  
  3. import java.util.Vector;
  4.  
  5. public class MedicalRecordImpl extends MedicalRecordPOA
  6. {
  7. private String name;
  8. private int nss;
  9. Vector<MedicalNote> note;
  10.  
  11. public MedicalRecordImpl(String name,int nss)
  12. {
  13. this.name=name;
  14. this.nss=nss;
  15. note=new Vector<MedicalNote>();
  16. }
  17. public String name()
  18. {
  19. return this.name;
  20. }
  21. public MedicalNote getNote(String author)
  22. {
  23. for(MedicalNote noteM:note)
  24. {
  25. if(noteM.author.equals(author))
  26. return noteM;
  27. }
  28. return null;
  29. }
  30. public void setName(String name)
  31. {
  32. this.name=name;
  33. }
  34. public void setNSS(int nSS)
  35. {
  36. this.nss=nSS;
  37. }
  38. public void insertNote(String author,String dateRedac,String text)
  39. {
  40. MedicalNote noteM=new MedicalNote(author,dateRedac,text);
  41. note.add(noteM);
  42. }
  43. @Override
  44. public int nSS() {
  45. return this.nss;
  46. }
  47. }


  1. package dossier;
  2.  
  3. import java.util.Vector;
  4.  
  5. public class ManagerImpl extends ManagerPOA
  6. {
  7. private String title;
  8. Vector<MedicalRecordImpl> dosMed;
  9. public ManagerImpl(String title)
  10. {
  11. this.setTitle(title);
  12. dosMed=new Vector<MedicalRecordImpl>();
  13. }
  14. public void creerDos(String name,int nSS)
  15. {
  16. MedicalRecordImpl dos=new MedicalRecordImpl(name,nSS);
  17. dosMed.add(dos);
  18. }
  19. public Admin rechercherAdmin(int nSS) {
  20. for(MedicalRecordImpl med:dosMed)
  21. if(med.nSS()==nSS)
  22. return (Admin) med;
  23. return null;
  24. }
  25.  
  26. public Patient rechercherPatient(int nSS) {
  27. for(MedicalRecordImpl med:dosMed)
  28. if(med.nSS()==nSS)
  29. return (Patient) med;
  30. return null;
  31. }
  32.  
  33. public Doctor rechercherDoctor(int nSS) {
  34. for(MedicalRecordImpl med:dosMed)
  35. if(med.nSS()==nSS)
  36. {
  37. System.out.println("trouver");
  38. return (MedicalRecord) med;
  39. }
  40. return null;
  41. }
  42. public String getTitle() {
  43. return title;
  44. }
  45. public void setTitle(String title) {
  46. this.title = title;
  47. }
  48. }
  49.  
  50.  
  51. voici mon serveur il marche correctement
  52.  
  53. [code="java"]
  54. package dossier;
  55.  
  56.  
  57. public class Server{
  58.  
  59.  
  60.  
  61. public static void main(String args[])
  62. {
  63.  
  64. // These properties are necessary to use the ORBACUS ORB instead of the JDK�s ORB.
  65. //java.util.Properties props = System.getProperties();
  66. //props.put("org.omg.CORBA.ORBClass", "com.ooc.CORBA.ORB");
  67. //props.put("org.omg.CORBA.ORBSingletonClass","com.ooc.CORBA.ORBSingleton");
  68. int status = 0;
  69. // The ORB must be initialized using ORB.init.
  70. org.omg.CORBA.ORB orb = null;
  71. try
  72. {
  73. orb = org.omg.CORBA.ORB.init(args,null);
  74. status = run(orb);
  75. System.out.print("orb runed");
  76. }
  77. catch(Exception ex)
  78. {
  79. ex.printStackTrace();
  80. status = 1;
  81. }
  82.  
  83. // If the ORB was successfully created, it is destroyed. This releases the resources used by
  84. // the ORB.
  85. if(orb != null)
  86. {
  87. try
  88. {
  89. orb.destroy();
  90. }
  91. catch(Exception ex)
  92. {
  93. ex.printStackTrace();
  94. status = 1;
  95. }
  96. }
  97.  
  98. // The exit status is returned. If there was no error, 0 is returned, or 1 otherwise.
  99. System.exit(status);
  100. }
  101.  
  102. static int run(org.omg.CORBA.ORB orb) throws org.omg.CORBA.UserException
  103. {
  104. // A reference to the Root POA is obtained using the ORB reference, and the Root POA is
  105. // used to obtain a reference to its POA Manager.
  106. org.omg.PortableServer.POA rootPOA =
  107. org.omg.PortableServer.POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
  108.  
  109. org.omg.PortableServer.POAManager manager = rootPOA.the_POAManager();
  110.  
  111. // A servant of type Hello_impl is created and is used to incarnate a CORBA object.
  112. // The CORBA object is released automatically when it is not used anymore.
  113. ManagerImpl managImpl=new ManagerImpl("Salima");
  114. Manager AppManag=managImpl._this(orb);
  115.  
  116. // The object reference is "stringified" and written to a file.
  117. try
  118. {
  119. String ref = orb.object_to_string(AppManag);
  120. String refFile = "Medical_Record.ref";
  121. java.io.PrintWriter out = new java.io.PrintWriter(new java.io.FileOutputStream(refFile));
  122. out.println(ref);
  123. out.close();
  124. }
  125. catch(java.io.IOException ex)
  126. {
  127. ex.printStackTrace();
  128. return 1;
  129. }
  130.  
  131. // The server enters its event loop to receive incoming requests.
  132. manager.activate();
  133. orb.run();
  134.  
  135. return 0;
  136. }
  137.  
  138. }

[/code]


et voici mon client qu'il me retourne un erreur mais j'ai pas pu comprendre l'erreur
  1. package dossier;
  2.  
  3. public class Client{
  4. public static void main(String args[]){
  5. java.util.Properties props= System.getProperties();
  6. props.put("org.omg.CORBA.ORBClass","com.ooc.CORBA.ORB");
  7. int status=0;
  8. org.omg.CORBA.ORB orb=null;
  9. try{
  10. orb=org.omg.CORBA.ORB.init(args,props);
  11. status=run(orb);
  12. }catch(Exception ex){
  13. ex.printStackTrace();
  14. status=1;
  15. }}
  16. static int run(org.omg.CORBA.ORB orb)
  17. {
  18. org.omg.CORBA.Object obj=null;
  19. try
  20. {
  21. String refFile="Medical_Record.ref";
  22. java.io.BufferedReader in= new java.io.BufferedReader(new java.io.FileReader(refFile));
  23. String ref=in.readLine();
  24. obj=orb.string_to_object(ref);
  25. }
  26. catch(java.io.IOException ex)
  27. {
  28. ex.printStackTrace();
  29. return 1;
  30. }
  31. AdminManager AdminManag=AdminManagerHelper.narrow(obj);
  32. AdminManag.creerDos("salima", 123);
  33. AdminManag.creerDos("ahmed", 124);
  34. DoctorManager docManag=DoctorManagerHelper.narrow(obj);
  35. try
  36. {
  37. Doctor dosDoc=docManag.rechercherDoctor(123);
  38. }catch(Exception e)
  39. {
  40. System.out.println(e);
  41. }
  42.  
  43.  
  44. return 0;
  45. }
  46.  
  47. }

voici l'erreur


org.omg.CORBA.UNKNOWN vmcid: SUN minor code: 202 completed: Maybe
at com.ooc.OB.Util.unmarshalSystemException(Unknown Source)
at com.ooc.OB.GIOPConnection.processReply(Unknown Source)
at com.ooc.OB.GIOPConnection.processMessage(Unknown Source)
at com.ooc.OB.GIOPConnectionThreaded.execReceive(Unknown Source)
at com.ooc.OB.GIOPConnectionThreaded$ReceiverThread.run(Unknown Source)



est ce que vous pouvez m'aidez ???

Autres pages sur : recharger page dossier medical corba

a b L Programmation
17 Décembre 2011 16:43:19

Tes objets sont tous bien instanciés ?
Tom's guide dans le monde
  • Allemagne
  • Italie
  • Irlande
  • Royaume Uni
  • Etats Unis
Suivre Tom's Guide
Inscrivez-vous à la Newsletter
  • ajouter à twitter
  • ajouter à facebook
  • ajouter un flux RSS