1 / 34

Components in GNOME

Components in GNOME. 林咸禮. Outline. Components in GNOME Why object model ? The uses of CORBA Implementation notes ORBit Programming. Why object model ? (1/3). UNIX pipe system Allow users to create new results by joining smaller components. > ls | more. orbit-docs.tar.gz orbit.zip ….

evette
Download Presentation

Components in GNOME

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. Components in GNOME 林咸禮

  2. Outline • Components in GNOME • Why object model ? • The uses of CORBA • Implementation notes • ORBit Programming

  3. Why object model ? (1/3) • UNIX pipe system • Allow users to create new results by joining smaller components. • > ls | more orbit-docs.tar.gz orbit.zip … ls More pipe

  4. Why object model ? (2/3) • Pipe in modern desktop environment • The information flow is unidirectional • Characters, lines, and entire files are basic unit of information exchange. • Not scale well with complex application • Solution • Component based programming framework • But UNIX lacks such a framework

  5. Why object model ? (3/3) • GNOME provides a component model • Based on OMG’s CORBA • Adapt ORBit implementation Object D CORBA Object A Object B Object C

  6. The uses of CORBA in GNOME • Exporting an application’s API • General IPC and RPC mechanism • Scripting • Automate common tasks • Define system services • Standard interfaces • Bonobo • Document based application

  7. Exporting an application’s API • Export internal engine • Use interfaces in GNOME::Gnumeric • Guppi can manipulate a spreadsheet in gnumeric • Standard interfaces to implement • Desktop::Editor • A mail client can choose any Editor that implement Desktop::Editor

  8. IPC and RPC Mechanism (1/4) • Process communication • In traditional UNIX world • IPC: shared memory, pipe… • RPC: TCP/IP • IPC/RPC protocols are hand-crafted individually • Hard to maintain and too efforts on details Hand-crafted protocol Program1 Program2 RPC/IPC codes RPC/IPC codes IPC / RPC

  9. IPC and RPC Mechanism (2/4) • CORBA provide object location transparency Program1 Program2 Handle by ORB Object reference Remote Object Stub skeleton CORBA Programmer’s view

  10. IPC and RPC Mechanism (3/4) • Currently use: • Communicate with embedded applications • GNOME Control and GNOME Panel • Modify a “live” application • Changes happen to the current server on the fly • Mod_CORBA apache module, Dents DNS Server)

  11. IPC and RPC Mechanism (4/4) embedded program

  12. Scripting • Allow user to automate common tasks • Like macro and VBA in Windows • Manipulate a gnumeric spreadsheet, automate some repetitive tasks… • Major scripting languages on UNIX have CORBA binding • Such as Perl, Python and Java

  13. Define system services • Many procedure carried on UNIX do not have a standard (rely on tradition) • Use helper script is not robust • Define standard interface about system service • Encapsulate details by CORBA-based server • System::admin::user • System::Mail::deliver

  14. Bonobo (1/2) • GNOME Document model • Let document-based applications embed themselves in each other • Similar with OLE and ActiveX in Windows

  15. Bonobo (2/2) • Embed many programs in gnumeric

  16. Implementation notes • ORBit • CORBA implementation on GNOME • Written in straight C, but have many language binding • GNORBA • Wrapper of common CORBA services in GNOME • Name server and the initialization code • Allow to create specific application name server • Start automatically when needed

  17. What is CORBA (1/2) • Protocol for interaction between objects • Programmer does not care whether the method was executed on a local machine or remote • The ORB (Object Request Broker) will take care of sending message between objects

  18. What is CORBA (2/2) Client object Create correct message Stub skeleton Translate messages to correct call ORB IIOP/GIOP ORB

  19. Interface Definition Language • Define object type • A specification language • Use idl-compiler to generate stubs and skeletons from IDL files C stub C mapping C skeleton .idl file Java stub Java mapping Java skeleton

  20. IDL basics (1/2) • IDL modules and interfaces • Namespace and object definition • #include and #pragma are support • IDL types • short , unsigned short, long, long long… • IDL methods • in, out, inout, oneway

  21. IDL basics (2/2) • #include “orange.idl”module FruitBasket { interface Apple { void eat_me (in boolean eat_yes_or_not); boolean who_ate (out string who_name); // asynchronous method oneway boolean eaten (); };};

  22. C mapping (1/2) • Language mapping • Native representation of a CORBA-object • GNOME is almost entirely written in C • IDL C-mapping basics: methods and attributes • All method-calls need an object reference as first parameter and a CORBA_Environment object as last parameter • Mapping attribute to a _get-function and a _set-function

  23. C mapping (2/2) • Module FruitsBasket { interface Apple { void eat_me (in boolean eat_yes_or_not); attribute boolean is_eaten; }} • typedef CORBA_Object FruitsBasket_Apple;void FruitsBasket_Apple_eat_me (Fruit_Apple object, CORBA_boolean eat_yes_or_not, CORBA_Environment *ev); FruitsBasket_Apple_set_is_eaten (…);CORBA_boolean FruitsBasket_Apple_get_is_eaten (…);

  24. The CORBA module (1/3) • Use IDL to describe all standardized objects • The ORB is a CORBA object which has IDL interfaces • Defined in CORBA spec:module CORBA {…}module IOR {…}…

  25. The CORBA module (2/3) • CORBA::Object interfacemodule CORBA { interface Object { InterfaceDef get_interface (); boolean is_nil (); Object duplicate (); void release (); boolean is_a (in string logical_type_id); boolean non_existant (); boolean is_equivalent (in Object other_object); unsigned long hash (in unsigned long maximum); }; }; • This interface is implicitly inherited by all other interfaces

  26. The CORBA module (3/3) • CORBA::ORB interface module CORBA { typedef string ORBid; type sequence <string> arg_list; ORB ORB_init (inout arg_list argv, in ORBid orb_ideftifier); interface ORB { /* serialize function */ string object_to_string (in Object obj); Object string_to_object(in string str); };}; • Bootstrap function of the core ORB • CORBA::ORB_init() • Simple sample

  27. Naming service • Use to associate each object with a human readable string • Bind and resolve • Tree structure Root GNOME servers … GNOME.servers.Panel GNOME.servers.GMC … Panel GMC

  28. The POA interface (1/4) • Clients hold object references on which that invoke methods • Server object that implements the methods talks only to the POA • POA and the server skeleton all cooperate to decide to which function the client request must be passed to. Server Servant POA Servant

  29. The POA interface (2/4) • The server registration • Create a POA and tell the POA about its servants • Ask the POA for an object reference • Advertised to the outside world • IOR string • Binding this object reference to a name with the Naming Service IOR string Servant (3) (2) Naming Service POA (1) (3) Servant Server

  30. The POA interface (3/4) • A client request 1 • Ask the Name Service about some object reference and get a object reference • The invocation is passed to the ORB through the stub, once the ORB find the correct server, it hands the request to the server Naming Service (1) Client (2) ORB

  31. The POA interface (4/4) • A client request 2 • The ORB pass request to the server • The server then locate the POA which created the object reference and pass the request to the POA • The request is finally passed to the correct servant by the POA POA Servant (3) (2) (1) ORB Server Servant

  32. CORBA in GNOME (1/2) • The Gnorba library • Initialization • Combine GTK+ event loop with ORBit event loop • gnome_CORBA_init() • Naming service • gnome_name_service_get() • The GOAD (GNOME Object Activation Directory) • Find a server by its name • Add servers to the GOAD • .gnorba files in /etc/CORBA or /urs/etc/CORBA

  33. CORBA in GNOME (2/2) • include <orb/orbit.h> #include <libgnorba/gnorba.h> #include <gnome.h> int main (int argc, char **argv) { CORBA_Object name_server; CORBA_Environment ev; CORBA_exception_init (&ev); orb = gnome_CORBA_init ("a simple gnorba test prgm", "v 1.0", &argc, argv, &ev); name_server = gnome_name_service_get (); return 0; }

  34. Reference • Components in the GNOME Project • GNOME & CORBA

More Related