Upload
hilary-curtis
View
225
Download
0
Embed Size (px)
Citation preview
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 joini
ng smaller components. > ls | more
ls Morepipe
orbit-docs.tar.gzorbit.zip…
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
Why object model ? (3/3)
GNOME provides a component model Based on OMG’s CORBA Adapt ORBit implementation
CORBAObject A
Object B
Object C
Object D
The uses of CORBA in GNOME
Exporting an application’s APIGeneral IPC and RPC mechanismScripting Automate common tasks
Define system services Standard interfaces
Bonobo Document based application
Exporting an application’s API
Export internal engine Use interfaces in GNOME::Gnumeric Guppi can manipulate a spreadsheet in g
numericStandard interfaces to implement Desktop::Editor A mail client can choose any Editor that i
mplement Desktop::Editor
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
Program1 Program2
Hand-crafted protocol
IPC / RPC
RPC/IPCcodes
RPC/IPCcodes
IPC and RPC Mechanism (2/4)
CORBA provide object location transparency
Program1 Program2
CORBA
ObjectreferenceStub
RemoteObjectskeleton
Handle by ORB
Programmer’s view
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)
Scripting
Allow user to automate common tasks Like macro and VBA in Windows Manipulate a gnumeric spreadsheet, aut
omate some repetitive tasks…Major scripting languages on UNIX have CORBA binding Such as Perl, Python and Java
Define system services
Many procedure carried on UNIX do not have a standard (rely on tradition)Use helper script is not robustDefine standard interface about system service Encapsulate details by CORBA-based
server System::admin::user System::Mail::deliver
Bonobo (1/2)
GNOME Document model Let document-based applications
embed themselves in each other
Similar with OLE and ActiveX in Windows
Implementation notes
ORBit CORBA implementation on GNOME Written in straight C, but have many language bi
ndingGNORBA Wrapper of common CORBA services in GNOME Name server and the initialization code
Allow to create specific application name server Start automatically when needed
What is CORBA (1/2)
Protocol for interaction between objectsProgrammer does not care whether the method was executed on a local machine or remoteThe ORB (Object Request Broker) will take care of sending message between objects
What is CORBA (2/2)
Client object
skeletonStub
ORB
ORB
IIOP/GIOP
Create correct message
Translate messages to correct call
Interface Definition Language
Define object typeA specification languageUse idl-compiler to generate stubs and skeletons from IDL files
.idl file
C stub
C skeleton
Java stub
Java skeleton
C mapping
Java mapping
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
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 methodoneway boolean eaten ();
};};
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
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 (…);
The CORBA module (1/3)
Use IDL to describe all standardized objectsThe ORB is a CORBA object which has IDL interfacesDefined in CORBA spec:module CORBA {…}module IOR {…}…
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
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
Naming service
Use to associate each object with a human readable string Bind and resolveTree structure
…
Root
…
GNOME
servers
PanelGMC
GNOME.servers.Panel
GNOME.servers.GMC
The POA interface (1/4)
Clients hold object references on which that invoke methodsServer object that implements the methods talks only to the POAPOA and the server skeleton all cooperate to decide to which function the client request must be passed to.
POA
Servant
Servant
Server
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
Servant
POA Naming Service
IOR string
(1)
(2)(3)
(3)
Server
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
ClientNaming Service
ORB
(1)
(2)
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
ServantServer
(1)(2)
(3)
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
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; }