1 / 27

Quelques notes sur CORBA

Quelques notes sur CORBA. F. Boyer, Oct 2003. Principes. Programmation distribuée Multi-plateformes Notion de client et de serveur Notion de stub et de squelette. Architecture. Servant : étend le squelette ou est un délégué. POA. ORB = serveur POA = sous_serveur

cheung
Télécharger la présentation

Quelques notes sur CORBA

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Quelques notes sur CORBA F. Boyer, Oct 2003

  2. Principes • Programmation distribuée • Multi-plateformes • Notion de client et de serveur • Notion de stub et de squelette

  3. Architecture Servant : étend le squelette ou est un délégué

  4. POA • ORB = serveur • POA = sous_serveur • Actions effectuées avant / après appels sur les objets distribués • Politique d’activation • Traitement des erreurs

  5. Etapes • Définition interfaces IDL • Mapping IDL – langages de programmation • Implémentation des classes distribuées • Réalisation des serveurs • Réalisation des clients

  6. Exemple module HelloApp { interface Hello { string sayHello(); // This line is an operation statement. oneway void shutdown(); // This line is another }; };

  7. Génération IDLJ Pour une interface IDL • HelloPOA.java (squelette) • _HelloStub.java (talon) • Hello.java (interface) • HelloHolder.java (paramètres out) • HelloOperations.java (interface Hello) • HelloHelper.java (cast)

  8. Référence distribuée • Obtenue par : • Appel au serveur de noms • Lecture d’une référence sérialisée dans un fichier • Réception d’un paramètre Org.omg.CORBA.Object servant_to_reference(in Servant) Org.omg.CORBA. Servant reference_to_servant(in Object)

  9. Helper • HelloHelper : pour forger une référence distribuée de type Hello • Les méthodes standarts Corba retournent le type org.omg.CORBA.Object helloRef = HelloHelper.narrow(objRef)

  10. IOR • Référence sérialisée String helloIor = orb.object_to_string(helloRef) Hello helloRef = orb.string_to_object(helloIor)

  11. Implémentation d’une classe distribuée class HelloImpl extends HelloPOA { private ORB orb; private POA poa; public void setORB(ORB orb_val) { orb = orb_val; } public void setPOA(POA poa_val) { poa = poa_val; } public String sayHello() { return "\nHello world !!\n"; } method public void shutdown() { orb.shutdown(false); } }

  12. Implémentation d’un serveur et d’un client • Voir serveurCorba.html et clientCorba.html

  13. Serveur générique • Fichier de propriétés Java • poas=rootpoa • servants=shutdown;repertory;hello • shutdown.class=corbatraining.ShutdownImpl • shutdown.poa=rootpoa • shutdown.nsbind=Shutdown • shutdown.iorfile=ior/shutdown.ior • shutdown.codebase=file://build • repertory.class=corbatraining.RepertoryImpl • repertory.poa=rootpoa • repertory.nsbind=Repertory • repertory.iorfile=ior/repertory.ior • shutdown.codebase=relfile://./build

  14. Gestion du projet • Build.xml

  15. RepertoryFactory Repertory pro Repertory fri Repertory – version 2 get get, mget create, delete, get set, modify, remove Administrateur Client

  16. Utilisation d’un Holder SeqOfPerson listBetween( in string regexp, inout long x, inout long y, out long size) 0 x y 200 On souhaite obtenir la fenêtre x-y Si y > 200, alors y  200

  17. Utilisation d’un Holder • Holder = conteneur (objet) qui contient le paramèter de type in ou inout • Classes Holder prédéfinies Org.omg.CORBA.BooleanHolder, Org.omg.CORBA.StringHolder, … • Classes générées TimeHolder, RepertoryHolder, …

  18. Utilisation d’un Holder (suite) • // impl : • Public class HorlogeImpl extends HorlogePOA { • public void getFullTime(shortHolder hour, shortHolder min) { • hour.value = …, min.value = …; • … • // client : • shortHolder hour = new shortHolder(); • shortHolder min = new minHolder(); • Horloge.getTime(hour, min); • System.out.println(« hour » + hour.value + « min » + min.value);

  19. Utilisation d’un Holder (suite) // idl struct time { short hour; short min }; … // impl public class HorlogeImpl … { public void getTime(timeHolder t) { time _t = new time(); _t.hour = …, _t.min = …; t.value = _t; … // client .time t = new timeHolder(); horloge.getTime(t); System.out.println(« hour » + t.value.hour + « min » + t.value.min);

  20. Utilisation d’un Holder (suite) // idl interface Time { void setHour(short h); void setMin (short m); ..} … // impl public class HorlogeImpl … { public void getTime(TimeHolder t) { Time _t = new Time(); _t.setHour (…), _t.setMin(…); t.value = _t; … // client .TimeHolder ht = new TimeHolder(); horloge.getTime(ht); Time t = ht.value; System.out.println(« hour » + t.getHour() + « min » + t.getMin());

  21. Répartition de la charge de travail • Lancer repertory_i sur Si • Repertory_i : s’enregistre dans le serveur de noms, par exemple sous le nom rep_i • Soit les clients savent à qui s’adresser • Soit lancer un (ou plusieurs) dispatcher, qui va récupérer les références des repertory_1..n et aiguiller les requetes clients en fonction : • De leur nom • De leur localisation • …

  22. Contextes de nommage • Cos Naming Service : service de nommage hiérarchisé • Bind (NameComponent[], Object o) • Rebind (NameComponent[], Corba.Object o) • Resolve (NameComponent[]) -> Corba.Object o • List() -> BindingIterator

  23. COS Naming Service (deprecated) • Exemple serveur: imp = new … org.omg.CosNaming.NameComponent[] name = new NameComponent[1]; name[0] = new Org.omg.CosNaming.NameComponent(); name[0].id = « imprimeur »; name[0].kind= «  »; try { naming.bind(name, imp); …

  24. COS Naming Service (deprecated) • Exemple client: org.omg.CosNaming.NameComponent[] name = new NameComponent[1]; name[0] = new Org.omg.CosNaming.NameComponent(); name[0].id = « imprimeur »; name[0].kind= «  »; try { obj = naming.resolve(name); …

  25. Contextes de nommage Création nom NameComponent [] nameC = ctxt.to_name(« name ») Ajout liaison nom-ref Ctxt.bind(nameC, ref) Ajout contexte de nommage NamingContexteExt ctxt2 = ctxt.bind_new_context(nameC); … Ctxt2.bind (…)

  26. Contextes de nommage (ex) • NamingContextExt ctx = NamingContextExtHelper.narrow(orb.resolve_initial_references( "NameService")); • NameComponent name2[] = ctx.to_name("Personal"); NamingContextExt ctx2 = (NamingContextExt)ctx.bind_new_context(name2); System.out.println("New naming context, Personal, added!"); • NameComponent name3[] = ctx.to_name("schedule"); ctx2.rebind(name3, objref); System.out.println("schedule rebind successful!");

  27. Contexte de nommage (Itérateur) • BindingListHolder bl = new BindingListHolder(); BindingIteratorHolder blIt= new BindingIteratorHolder(); nc.list(1000, bl, blIt); • Get the array of bindings. This code gets the array of bindings out of the returned BindingListHolder. • Binding bindings[] = bl.value; • This code loops through the bindings and prints the names out. for (int i=0; i < bindings.length; i++) { • int lastIx = bindings[i].binding_name.length-1; // check to see if this is a naming context • if (bindings[i].binding_type == BindingType.ncontext) { System.out.println( "Context: " + bindings[i].binding_name[lastIx].id); } else { System.out.println("Object: " + bindings[i].binding_name[lastIx].id); } }

More Related