Presentation is loading. Please wait.

Presentation is loading. Please wait.

Components in GNOME 林咸禮. Outline Components in GNOME Why object model ? The uses of CORBA Implementation notes ORBit Programming.

Similar presentations


Presentation on theme: "Components in GNOME 林咸禮. Outline Components in GNOME Why object model ? The uses of CORBA Implementation notes ORBit Programming."— 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 lsMore pipe orbit-docs.tar.gz orbit.zip …

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 CORBA Object A Object B Object C Object D

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 Program1Program2 Hand-crafted protocol IPC / RPC RPC/IPC codes RPC/IPC codes

9 IPC and RPC Mechanism (2/4) CORBA provide object location transparency Program1Program2 CORBA Object reference Stub Remote Object skeleton Handle by ORB 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) Clientobject skeletonStub ORB IIOP/GIOP Create correct message Translate messages to correct call

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

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 interface module 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 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 Panel GMC GNOME.servers.Panel GNOME.servers.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. POA Servant Server

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 Servant POA Naming Service IOR string (1) (2) (3) 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 Client Naming Service ORB (1) (2)

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 ORB POA Servant Server (1) (2) (3)

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 #include #include 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


Download ppt "Components in GNOME 林咸禮. Outline Components in GNOME Why object model ? The uses of CORBA Implementation notes ORBit Programming."

Similar presentations


Ads by Google