Home

O2 Corba User Manual

image

Contents

1. 75 INDEX 77 2 User Manual 1 Introduction The database system provides complete database solution for object developers OMG CORBA provides a means to run distributed object applications over a network Several vendors provide products compliant with this technology Among these products are Orbix IONA Chorus ORB Sun Microsystems and Visibroker Visigenic These products can be used jointly with to provide a fully distributed development environment for persistent object applications You will find that developing applications with an object request broker ORB has several key benefits conformance to CORBA and ODMG standards automatic IDL generation from an schema collection management transaction service and query service via OQL This chapter is divided into the following sections e System overview O2 and CORBA Architecture e Manual overview Important We assume that the reader is familiar with the CORBA technology and has experience with an ORB product as well as a knowledge of O Corba User Manual 9 Introduction 1 1 System overview The system architecture of is illustrated in Figure 1 1 External Interfaces Development Tools Standard Dev Tools 2 Java Database Engine O2Engine O2Store Figure 1 1 Oo Sy
2. User Manual Release 5 0 May 1998 zo Information in this document is subject to change without notice and should not be construed as a commitment by Technology The software described in this document is delivered under a license or nondisclosure agreement The software can only be used or copied in accordance with the terms of the agreement It is against the law to copy this software on magnetic tape disk or any other medium for any purpose other that the purchaser s own use Copyright 1992 1998 by O Technology rights reserved No part of this publication can be reproduced stored in a retrieval system or transmitted in any form or by any means electronic mechanical photocopy without prior written permission of Technology and O5Engine O5Corba O5DBAccess O5Engine O5Graph O5Kit OoLook O Store O Tools are registered trademarks of Technology SQL and AIX are registered trademarks of International Business Machines Corporation Sun SunOS and SOLARIS are registered trademarks of Sun Microsystems Inc X Window System is a registered trademark of the Massachusetts Institute of Technology Unix is a registered trademark of Unix System Laboratories Inc HPUX is a registered trademark of Hewlett Packard Company BOSX is a registered trademark of Bull S A IRIX is a registered trademark of Siemens Nixdorf A G NeXTStep is a registered t
3. 43 Transaction EEN OE M HH EISE 43 44 Database ian B TUBE 45 4 8 Memory 48 pole paris MH 48 E Cmn AL s s idi 49 Example of an O2 Corba Application on top of Orbix 51 2 1 JUDGE ND Dp E CDU DEM GU 52 5 2 Define the class Grid in file Grid hxx 53 5 3 Implement the class Grid in file Grid cc 54 5 4 Implement the O2Corba server file srv main cc 56 5 5 Implement the CORBA client in Client cc 57 5 6 Compile the O2Corba 59 5 7 Compile lur Me n 62 So NUDO 62 Example of an O2 Corba Application on top of Chorus ORB63 8 1 e 64 6 2 Define the class Grid in file Grid hxx using COOL 65 6 3 Implement the class Grid file Grid cc 66 6 4 Implement the O2Corba server in file srv main cc 68 6 5 Implement the CORBA client in Client cc 70 O Corba User Manual 7 C22 TABLE OF CONTENTS 6 6 Compile the O2Corba 72 6 7 Compile ihe chent 75 EB NUS
4. User Manual 53 5 Example of an O2 Corba Application on top of 5 3 Implement the class Grid in file Grid cc The following gives the code which implements the class Grid This is in file Grid cc include Grid hxx ctor Grid Grid const short const short m_height h set up height m_width w set up width for int i 0 i lt h itt d_Ref lt Row gt r new Row for int j 0 j lt w jtt r l insert element last j m a insert element last r Grid Grid m height 10 set up height m width 10 set up width for int i 0 i lt 10 144 d Ref Row r new Row for int j 0 j lt 10 r l insert element last j m a insert element last r dtor Grid Grid then free the overall array delete m a void Grid initialize int h int m height h set up height m width w set up width m a remove all for int i 0 i lt h 144 d Ref Row r new Row m a insert element last r for int j 0 j w jtt m_a i gt l insert_element_last j 54 User Manual Implement the class Grid in file Grid cc implementation of the function which reads the height attribute int Grid height const return m height implementation of the function which reads the width attribute int Grid width const return m width implemen
5. pos of g2 res endl 192 lfact create list Grid 191 gt 192 trans validate gl release instance g2 release instance lgl release instance 41 release g2 release lgl release lg2 release Note The classes d List Gridandd List Grid Factory are generated by the IDL compiler from the IDL interfaces d List Grid and d List Grid Factory You have to instanciate the template file d List 141 with the class Grid in order to produce the file d List Grid idl This file will be used as input to the IDL compiler Important You do not need to instanciate templates for atomic collections e g d List long d List string they are provided by the library libo2orbc a User Manual 41 4 Programming Iterators For a list of objects of the interface d Iter List Grid implements the behavior for iteration with the same interface as the ODMG class d Iterator Inadditionthed Iter List interface inherits the Iterator interface of the OMG query service include CosQueryCollection idl interface d Grid interface d Iter List Grid CosQueryCollection Iterator readonly attribute long not done void release instance void advance d Grid get element long get next out d Grid element Example d List Grid 1 d List Grid Factory lfact d I
6. of the o2cpp export tool o2cpp export class K noheader nocode idl type method m 1 Refer to the ODMG Binding Guide and ODMG Binding Reference Manual for details about the 2 export command User Manual 23 Building an O2Corba Server 2 Only the files d_K id1 d_K_i hxx and d_K_i cc will be generated All the generated files will be deleted by the o2unexport command Exporting attributes The option t ype of the command o2cpp export has to be used to export attributes from to IDL Only public attributes can be exported For each exported attribute 2 export generates a twin IDL attribute See the table Corresponding O2 and IDL types for export to learn the type mapping and two access member functions in the implementation class one for reading the attribute and one for writing the attribute Example Let K be the class to be exported class K private inherit Object type tuple s string o K2 K2 is an O2 class end and the command o2cpp export o2cpp export class K idl type The corresponding interface will be generated as follows forward declarations interface d K2 interface attribute string s attribute d K2 o Note that an interface called d K Factory will also be generated This interface will be used to create temporary and persistent objects of the class
7. CORBA ORB init argc argv 0 env if env exception fprintf stderr Impossible to initialize the ORB n return 1 CORBA BOA ptr orb OA init argc argv 0 env if env exception fprintf stderr Impossible to initialize the object adapter n return 1 Get the COOL Naming Service object reference orb ns thisCapsule naming service env instantiate the database object continue 68 User Manual Implement the O2Corba server in file srv main cc db new o2 Database i grid b argc argv env myGrid new d Grid Factory i Grid lgrid new d List Grid Factory i List Grid qgrid new d Query List Grid Factory i Query Grid tell ORB that we have completed the server s initialisation cout lt lt calling boa gt run lt lt endl boa run cout lt lt server exiting lt lt 1 db release instance myGrid release instance lgrid release instance qgrid release instance return 0 O Corba User Manual 69 6 Example of an O2 Corba Application on top of 6 5 Implement the CORBA client in Client cc This section gives the main program which implements a CORBA client Client cc client for the grid example include lt api api H gt include d Iter List long H include d List long H include d Grid H include o2 Database H includ
8. argv o2 Database i database i d Grid Factory i grid i d List Grid Factory i lgrid i database i new o2 Database 1 4 Grid argc argv grid i new d Grid Factory i Grid lgrid i new d List Grid Factory i List Grid try tell Orbix that we have completed the server s initialisation CORBA Orbix impl is ready d Grid catch const CORBA SystemException amp an error occured calling impl is ready output the error cerr Unexpected exception endl amp se cout lt lt server exiting lt lt 1 return 0 56 O Corba User Manual Implement the CORBA client in Client cc 5 5 Implement the CORBA client in Client cc This section gives the main program which implements a CORBA client include lt stream h gt include lt stdlib h gt include d_Grid hh include o2 Ref Any hh include o2 Session hh include o2 Database hh include o2 Transaction hh int main int argc char argv o2 Database var database o2 Transaction var trans d Grid var g d Grid Factory var gfact d List long var 1 CORBA Short h w CORBA Long v if lt 2 cout usage argv 0 hostname endl exit 1 cout lt lt CORBA client is running lt lt endl try database o2 Database bind d Grid d Grid argv 1 database open grid b read write cout Client has
9. database lookup object the grid Grid if gt gt 0 0 lt lt ref any did not return grid lt lt endl 4 6 Collection management Unlike IDL does not provide generic parametric types nor method overloading This implies that we cannot provide an IDL interface for List lt T gt We thus have to define an IDL class for each needed typed collection For instance if we want a List of K we will have the class d List K which implements the same interface as the ODMG class List enhanced with some operations allowing to manipulate sequences In addition the d List interface inherits the Collection interface of the OMG Query Service For example the interface d List Grid will be defined as follows 38 O Corba User Manual Collection management module CosQueryCollection exception ElementInvalid exception PositionInvalid exception IteratorInvalid typedef string Istring struct NVPair Istring name any value typedef sequence lt NVPair gt ParameterList interface Iterator boolean more any next raises IteratorInvalid PositionInvalid void reset interface Collection readonly attribute long cardinality void add element in any element raises ElementInvalid void add all elements in Collection elements raises ElementInvalid void insert element at in any element in Iterator where raises PositionInva
10. Database management void extend const char database name const char volume name CORBA Environment amp IT env zCORBA default environment void set current 02 Database cur CORBA Environment amp IT CORBA default environment void set default vol const char volume name CORBA Environment amp IT CORBA default environment virtual char get default vol CORBA Environment amp IT env CORBA default environment virtual o2 Database get current CORBA Environment amp IT env CORBA default environment virtual void disconnect CORBA Environment amp IT env CORBA default environment The disconnect operation shuts down the server process It is only effective in the scope of the Chorus ORB Example o2 Database database CORBA Any ref o2 Transaction trans database o2 Database bind d Grid d Grid hostname database open grid b read write trans database create transaction ref database lookup object the grid Grid trans database create transaction Note The class o2 Database is provided by ORB library libo2orbc a User Manual 47 Programming 4 8 Memory management As explained in Section 4 1 the connection between the CORBA class implementation the class is performed through the attribute o2 pointer of type d Ref K p On the
11. K and to access persistent objects of the class K see Sections 4 5 and 4 4 interface d K Factory o2 Factory d K create K d K create persistent K in string name d K lookup K in string name 24 O Corba User Manual Export to IDL Exporting methods The class d K i will be generated with the following access member functions two functions per attribute class d K i public d KBOAImpl private d Ref K o2 object public virtual void s const char s CORBA Environment amp env CORBA default environment virtual char s CORBA Environment amp env CORBA default environment virtual void o d K2 o CORBA Environment amp env CORBA default environment virtual d K2 o CORBA Environment amp env CORBA default environment Exporting methods For each O exported method o2cpp export generates a twin IDL operation see the table Corresponding and IDL types for export to learn the type mapping and a member function in the implementation class Example Let K be the class to be exported class K private inherit Object method public get s string public set s v string public foo obj K2 and the command 2 export O Corba User Manual 25 3 Building an O2Corba Server The corresponding interface will be generated as follows forward declarations interface d K2 interface dK string get
12. System OVEFVIDM 10 and CORBA aai 12 Bodo PnP ae a OO DEN eds 12 Patriae IDL pond tp E DUM UR 13 Features and 8 MEO 13 1 3 iei lin mem 15 14 ru 16 Installation 17 21 18 2 2 Running the samples 19 Running the example program on top of Orbix 19 Running the example program on top of Chorus ORB 19 Building an O2Corba Server 21 22 22 Export Io 23 pe Bee aos 24 ee d dien i 25 OPE m 26 Be Term 28 3 3 Building an O2Corba server With O2 29 34 IDL o0 eeee 31 Programming 33 WU c I 34 4 2 Structure of an O2Corba 34 4 3 Structure of a CORBA client eese 35 2 User Manual TABLE OF CONTENTS 4 4 Creating persistent objects nnn 37 4 5 Accessing persistent objects sss 37 4 6 Collection management eere 38 one ere 42 Af
13. and Database management in this chapter Note All these classes are provided by the O5 ORB library libo2orbc a Corba User Manual 35 Programming A CORBA client can be written as follows int main int argc char argv o2 Database database o2 Transaction trans d Grid Factory gfact d Grid g long v first bind to the database object argv 1 is the hostname of the target d Grid object database o2 Database bind d Grid d Grid argv 1 database open grid b read write trans database create transaction bind to the d Grid Factory object gfact d Grid Factory bind Grid d Grid argv 1 get the d Grid object from its name the grid gfact lookup Grid the grid v g get 1 2 cout lt lt g2 1 2 is lt lt v lt lt endl trans begin g set 1 2 15 trans validate database close release proxies g release instance trans release database release gfact release g release return 0 A client will have first to getan o2 Database object using the Orbix binding mechanism in order to open a database and create transactions Then it can get an object using the associated Factory class and the binding mechanism For example an object of class d Grid will be retrieved using the d Grid Factory lookup Grid member function Object that are not returned through the Orb
14. height m_width w set up width for int i 0 i lt h itt d_Ref lt Row gt r new Row for int j 0 j lt w jtt r l insert element last j m a insert element last r Grid Grid m height 10 set up height m width 10 set up width for int i 0 i lt 10 144 d Ref Row r new Row for int j 0 j lt 10 j r l insert element last j m a insert element last r dtor Grid Grid then free the overall array delete m a void Grid initialize int h int m_height h set up height m_width w set up width m a remove 11 for int i 0 i lt h 144 d Ref Row new Row m a insert element last r for int j 0 j lt w jtt m a i l insert element last j 66 User Manual Implement the class Grid in file Grid cc implementation of the function which reads the height attribute int Grid height const return m height implementation of the function which reads the width attribute int Grid width const return m width implementation of the set operation void Grid set const int n const int m const int value m a n 1l replace element at value m implementation of the get operation int Grid get const int n const int m const return m gt 1 implementation of the get row operation d_List lt int gt Grid get row
15. opened base grid b endl catch const CORBA SystemException amp se an error occurred while trying to bind to the database object cerr lt lt open base failed lt lt 1 cerr Unexpected exception endl amp se exit 1 try trans database create transaction trans begin First retrieves the grid object gfact d Grid Factory bind Grid d Grid argv 1 fact lookup Grid the grid g initialize 10 10 catch const CORBA SystemException amp se an error occurred while trying to bind to the factory object continue O Corba User Manual 57 5 Example of an O2 Corba Application on top of cerr Bind to factory or lookup the grid failed endl cerr Unexpected exception endl amp se exit 1 try try to read the height and width of the grid h g gt height w g width catch const CORBA SystemException amp se an error occurred while trying to read the height and width cerr lt lt call to height or width failed lt lt endl cerr lt lt Unexpected exception lt lt endl amp se end 1 no problem reading the height and width cout lt lt height is lt lt lt lt 1 cout lt lt width is lt lt lt lt endl try try to set element 2 4 of the grid to value 123 g set 2 4 123 then read ba
16. server side when a CORBA implementation method must return a pointer to K a K_i object must be created to carry the o2 pointer As it is likely that there will be many accesses to the same object it would be prohibitive to create as many proxies K i as the number of accesses to be done Therefore we ensure that a single proxy K_i is created for a corresponding K_p When a method must return a Q O5 Corba checks whether the Q 1 already exists for the corresponding Ref If it exists it just returns it otherwise a new Q 1 is created and fixed in memory Releasing proxies d Grid g Objects retrieved by the CORBA binding mechanism should not be released because further bind calls would fail Objects created by factories or returned by method calls should be released when they are no longer used As long as a K_i object refers to a K_p object the K_p object cannot be released by It is up to the application to free a K_i object when the CORBA client the application does not need the corresponding K object any longer To make this possible we will provide in each K_i class and thus in each IDL class too a method named release_instance that the client can call explicitely to release the CORBA object on the server In any case the method release_instance should be called by the application as early as possible in order to minimize memory consumption As soon as a client does not need an object any longer it is a good prac
17. G application and it is linked with the Orbix server library in order to provide an O5Corba server A simple client will also be shown To run the grid example you have to go through the following steps which are the remaining sections of this chapter Define the class Grid in file Grid hxx Implement the class Grid in file Grid cc Implement the O2Corba server in file srv main cc Implement the CORBA client in Client cc Compile the O2Corba server Compile the client Running 52 O Corba User Manual Define the class Grid in file Grid hxx 5 2 Define the class Grid in file Grid hxx Define the classes Grid and Row in the file Grid hxx This file will be used as input to the 2 import command class Row public d List int 1 Row class Grid protected short m height store the height short m width store the width d List d Ref Row m a public constructors Grid Grid const short h const short w destructor virtual Grid functions corresponding to the IDL operations virtual int width const virtual int height const virtual void set const int n const int m const int value virtual int get const int n const int m const virtual d_List lt int gt get row const int range virtual void set row d List int 1 const int range virtual void set grid d Ref Grid g virtual void initialize int h int w
18. Grid Factory qlfact d Query List Grid qlg d List Grid 1g d Iter List Grid itg d Grid g long v parameterList params 2 CORBA any a qlfact d Query List Grid Factory Grid d Grid hostname qlg qlfact create query evaluator params length 2 1 lt lt v params 0 2 lt lt v 1 lg qlg oql execute sort x in the list grid by x gt get 1 2 params itg lg create d Iterator while itg not done itg get element v g get 1 2 cout lt lt 1 2 is lt lt v lt lt endl itg advance itg gt reset Note You have to instantiate the template file d Query List ref idl with the class Grid in order to produce the file d Query List Grid idl This file will be used as input to the IDL compiler Database management A class o2 Database provides an interface to the ODMG class d Database The class o2 Database is defined as follows User Manual 45 4 Programming class o2 Database public virtual CORBA Object public virtual virtual void release instance CORBA Environment amp IT env CORBA default environment void create const char database name const char schema name CORBA Environment amp IT env zCORBA default environment create on volume const char database name const cha
19. MG compliant interface with persistence transaction and query services User Manual 13 Introduction Fully heterogeneous platforms ORB implementations and jointly provide a fully heterogeneous platform For instance a client from an INTEL PC will be able to access an database managed SPARC or RS 6000 platforms Multiple servers An system manages a distributed database i e a set of schemas and bases distributed on a set of disks within a network Because provides a C ODMG compliant interface and tools to generate IDL files from schemas the development of a CORBA server using is very straightforward 14 O Corba User Manual Architecture Features and advantages 1 3 CORBA client Architecture On the client side an object of the class K generated by the IDL compiler is called a proxy object it implements the support necessary to send requests to the remote object on the server side object of the class K i On the O Corba server side an object of the class K_i deals with one or more database object s instance s of a persistence capable class The following figure shows the communication protocol O2 CORBA server function call function call return database objects Figure 1 3 The O5Corba protocol There can be two possible architectures 1 one client for each CORBA clien
20. O Corba User Manual O2 and CORBA Automatic IDL generation The programmer can define a simple way to bind the K i class to a persistence capable class called K p which is known by and which allows you to access and manipulate persistent objects The class i can be written as follows i public virtual KBOAImpl d Ref K p o2 object public all the methods of the view 1 object is a transient C object that refers to an C object of the persistence capable class K_p It is straightforward to implement the methods of K_i For instance assuming that has an attribute called att of type t the methods to read and update the att attribute are defined as follows i public virtual KBOAImpl d Ref K p o2 object public t att return o2 object att att t value o2 object att value Automatic IDL generation Starting from an existing O schema proposes to generate automatically the IDL specification and the C implementation classes The code generation follows the approach described above i e K i refers to one object of a persistence capable class and is performed by 2 export tool of the O5 binding development tool see Chapter 3 for details about IDL generation Features and advantages When using O and CORBA together the user benefits from OMG interface The joint O5 CORBA solution offers a standard O
21. O Corba server An O Corba server is an ODMG application an client which is linked with the ORB server library Therefore an object of class o2 Database i must be created in order to establish a connection to and to be able to open a database on the client side The server then runs under the control of the transaction manager d Transaction begin d Transaction commit etc The following example shows a server program in which an object of class d Grid will run The CORBA server has been registered with the name Grid int main int argc char argv o2 Database i database i new 02 Database i d Grid argc argv d Grid Factory i grid i new d Grid Factory i Grid tell Orbix that we have completed the server s initialisation CORBA Orbix impl is ready d Grid cout Server terminating endl session end return 0 The declaration of the o2 Database 1i constructor is o2 Database 1 02 Database i const char name int argc char argv CORBA Environment amp env 34 O Corba User Manual Structure of a CORBA client where name is a marker name Factories must also be created before connection to the CORBA server 4 3 Structure of a CORBA client A client deals with Database and Transaction through the mirror classes o2 Database and o2 Transaction images of the ODMG classes d Database and d Transaction see Transaction service
22. ORBA client in Client cc Compile the O2Corba server Compile the client Running 64 O Corba User Manual Define the class Grid in file Grid hxx using COOL 6 2 Define the class Grid in file Grid hxx using COOL Define the classes Grid and Row in the file Grid hxx This file will be used as input to the 2 import command class Row public d List int 1 Row class Grid protected short m_height store the height short m_width store the width d_List lt d_Ref lt Row gt gt m_a constructors Grid Grid const short h const short w destructor virtual Grid functions corresponding to the IDL operations virtual int width const virtual int height const virtual void set const int n const int m const int value virtual int get const int n const int m const virtual d List int get row const int range virtual void set_row d_List lt int gt 1 const int range virtual void set grid d Ref Grid g virtual void initialize int h int w User Manual 65 6 Example of an O2 Corba Application on top of 6 3 Implement the class Grid in file Grid cc The following gives the code which implements the class Grid This is in file Grid cc Class grid o2 implements the grid IDL interface include Grid hxx ctor Grid Grid const short const short m_height h set up
23. Row and three collections List integer list Row and list Grid the public member functions of the class Grid are imported You also need to generate IDL interfaces for the class Grid using the 2 export tool All the methods which will be used from the CORBA client must be exported Finally the final executable must be linked with the COOL server library libOrb mt so and the O library 1ibo2orbs a in order to produce an server grid server O Corba User Manual Compile the O2Corba server configuration file O2Home 502 O2System O2SYSTEM O2Server O2SERVER O2Schema grid s ImpFiles Grid hxx Grid hxx ImpClasses Row Grid Grid hxx Grid ImpAllPublicMemberFunc Grid hxx ImpOutputDir out ImpList int Row Grid ExpClasses Grid Grid ExpIdl Grid ExpHeader Grid ExpCode Grid ExpMethods width height set get get row set row set grid initialize ProgramName grid server Sources srv main cc Grid cc d List Grid i cc d Iter List Grid i cc d List Grid cc d Iter List Grid cc ProgramObjs srv main o Grid o d List Grid i o d Iter List Grid i o d List Grid o d Iter List Grid o ProgramLibDir ORB INSTALLATION PATH lib ProgramLib C Orb mt o2orbs Define REENTRANT COOL 4 ORB O2 TIE Include ORB INSTALLATTION PATH include UserLdFlags mt TUseOql TUseConfirmClasses Generate a Makefile o2makegen grid cf Do not forget to set the en
24. ad the height and width of the grid h p gt height w p width cout lt lt height is lt lt h lt lt endl cout lt lt width is lt lt w lt lt endl set element 2 4 of the grid to value 123 p gt set 2 4 123 then read back what we have just set 1 p get row 2 v l retrieve element at pos 4 env no problem setting and getting the elememt cout lt lt grid 2 4 is lt lt v lt lt endl make sure we got the value 123 back if v 123 cerr lt lt something went seriously wrong lt lt 1 exit 1 p release instance l release instance db close trans commit trans release instance CORBA release trans CORBA release db CORBA release fact CORBA release 1 CORBA release p return 0 O Corba User Manual 71 Example of an O2 Corba Application on top of 6 6 Compile the O Corba server Through o2dsa shell create a schema grid 5 create schema grid s Create a configuration file Grid cf For this application you have two source files serv main cc and This application uses a list of Grid and an iterator on it so you have to add to the Sources list the appropriate files e g d List Grid i cc These files are obtained by instantiation of the delivered template files e g d List ref i cc You need to import the classes Grid and
25. as attribute type for exported attributes The corresponding IDL types are also given Q is taken as any O5type shown and P its corresponding IDL type Corresponding and IDL types for export O2 Type IDL Type no type void integer long real double Boolean Boolean char char string string class d K IDL interface 02 list Q collection class d List P IDL collection interface 02 setQ O2 collection class d Set P IDL collection interface O2 bag Q O2 collection class d Bag P IDL collection interface O Corba User Manual 31 Building an O2Corba Server 32 O Corba User Manual Programming This chapter is divided into the following sections Introduction Structure of an O2Corba server Structure of a CORBA client Creating persistent objects Accessing persistent objects Collection management ODMG Services Memory management User Manual 33 Programming 4 1 4 2 Introduction This chapter explains how to program a CORBA client connected to an O5Corba server It presents how to create and access persistent objects how to define transactions how to use collections and OQL and how the memory is managed We use Orbix as an example of an ORB Its binding mechanism using markers may be replaced by the use of a name service on other ORBs Structure of an
26. bc a 18 28 35 41 43 47 libo2orbs a 18 28 59 72 liborbix so 59 libOrb mt so 72 link edition 28 long 31 lookup object 37 M Makefile 28 marker 35 memory 48 multi thread 28 O O2 Architecture 10 02 Database 43 45 02 OQL Query 44 02 Transaction 35 43 11 Oz2Corba 11 20 11 2 10 o2export 23 2 11 2 User Manual 79 INDEX 2 11 O Look 11 o2makegen 22 26 O20DBC 11 O2SERVER 60 73 OsStore 10 O2SYSTEM 60 73 OsTools 11 o2unexport 24 OoWeb 11 ODMG 9 OMG 13 OMG CORBA 9 OQL 11 44 ogl execute 44 P persistent object accessing 37 creating 37 ProgramLib 28 ProgramObjs directive 27 proxy 15 48 putit 62 75 Q query 44 R real 31 release 48 release instance 48 running sample programs 19 S string 31 System Architecture 10 template 41 42 45 59 72 transaction 43 U UserLdFlags directive 27 2 User Manual INDEX void 31 81 2 User Manual
27. ck what we have just set 1 g get row 2 v l retrieve element at 4 catch const CORBA SystemException amp se an error occurred while calling set get or retrieve element at cerr Call to set get or retrieve element at failed endl cerr lt lt Unexpected exception lt lt endl lt lt amp se exit 1 no problem setting and getting the elememt cout lt lt grid 2 4 is lt lt v lt lt endl make sure we got the value 123 back if v 123 cerr lt lt something went seriously wrong lt lt endl exit 1 try g release instance l release instance trans commit continue 58 O Corba User Manual Compile the O2Corba server trans release instance catch const CORBA SystemException amp se an error occurred while releasing instances cerr lt lt Call to release instance failed lt lt 1 cerr Unexpected exception endl amp se exit 1 database close return 0 5 6 Compile the Os5Corba server Through o2dsa shell create a schema grid s create schema grid s e Create a configuration file Grid cf For this application you have two source files main cc and Grid cc This application uses a list of Grid and an iterator on it so you have to add to the Sources list the appropriate files e g d List Grid i cc These files are obtained by instant
28. clude UserLdFlags mt TUseOql UseConfirmClasses Generate a Makefile o2makegen grid cf Do not forget to set the environment variables 2 O2SERVER and O2SYSTEM and to change the installation path of the CORBA ORB product in the configuration file Import the C classes Do not forget to run the server before 60 User Manual Compile the O2Corba server Generate IDL files make export Do not forget to run the O server before Call the IDL compiler on the generated IDL files idl B A d Grid idl The options B and A must be used Compile OoCorba server make The following figure shows how to create the O5Corba server for the Grid application d Grid idl i Y o2cpp export IDL Grid hxx EN Grid d Grid i hxx d Grid hh ORE Grid code cc d Grid i cc d GridS cc PRIS library Oa funtime 0 0 0067 grid server Figure 5 1 Building the Grid O5Corba server O Corba User Manual 61 5 Example of an O2 Corba Application on top of Through o2dsa shell create a base grid b create base grid b Register the CORBA server called Grid using the correct ORB program such as putit for Orbix putit d Grid h hostname ORBIX INSTALLATION PATH grid grid server 5 7 Compile the client There is no automatic way to generate a client Makefile Just follow the Makefile examp
29. const int range d List int res the row d List int tmp tmp insert element first m gt 1 0 for int i 0 i lt m height 1 1 tmp insert element after m a int range 1 i 1 i res tmp return res void Grid set_row d_List lt int gt 1 const int range for int i 0 i lt m_height i m a int range l insert element last 1 i void Grid set grid d Ref Grid g this m height g gt height this m width g width User Manual 67 6 Example of an O2 Corba Application on top of 6 4 Implement the O Corba server in file srv main cc This section gives the main program which implements the O5Corba server This program connects to the server by creating an o2 Database 1 creates two factory objects and starts the CORBA server The server for the grid example include lt stdlib h gt include lt iostream h gt include o21ib CC hxx include lt Grid hxx gt include svr orb port hxx include o2 Session i hxx include o2 Database i hxx include o2 Factory i hxx include d Grid i hxx include d List Grid i hxx include d Query List Grid i hxx COOL NamingService ptr orb ns d Grid Factory i myGrid d List Grid Factory i lgrid d Query List Grid Factory i qgrid int main int argc char argv CORBA Environment env o2 Database i db CORBA ORB ptr orb
30. corba The examples in this directory show how to use the ORB libraries of on top of the ODMG C binding in order to build an Corba server and client 18 O Corba User Manual Running the samples Running the example 2 2 Running the samples In what follows the Orb installation directory is denoted as lt Orb installation directory gt Running the example program on top of Orbix e cd lt O2 installation directory gt samples o2corba Edit the file init env Set the variable ORBIX ROOT to lt Orb installation directory gt Setthe variable O20RB VERSION to one of the subdirectories available in lt O2 installation directory gt samples o2corba It can be for instance Orbix 21cMT or Orbix_2 2 Set the O variables 2 O2SYSTEM and O2SERVER Execute the script init env source init env Run demo sh shell script which compiles and runs the examples Running the example program on top of Chorus ORB e cd O2 installation directory samples o2corba ChorusOrb Edit the file init env Set the variable ROOT to lt Orb installation directory gt Setthe variable O20RB VERSION to the COOL directory Set the O variables O2SYSTEM and O2SERVER Execute the script init env source init env Run demo sh shell script which compiles and runs the examples O Corba User Manual 19 Installation 20 O Corba User Man
31. e o2 Transaction H include d Grid H include stream h include lt stdlib h gt include orb port hxx int main int argc char argv d Grid p o2 Database db d List long 1 d Grid Factory fact CORBA Short h w CORBA Long v o2 Transaction trans if 2 cout usage argv 0 hostname endl exit 1 Initialize COOL runtime CORBA Environment env cout CORBA client is running endl CORBA ORB ptr orb CORBA ORB init argc argv 0 env if env exception fprintf stderr Impossible to initialize the ORB in return 1 Get the COOL Naming Service object reference COOL NamingService var naming thisCapsule naming service env continue 70 User Manual Implement the CORBA client in Client cc Imports the first interface must use method import CORBA Object ptr bind obj naming import grid b bind obj env if env exception printf Import failed n return 1 o2 Database narrow bind obj db gt open grid b read write cout Client has opened base grid b endl trans db gt create transaction trans begin First retrieves the grid object CORBA Object ptr bind fact naming gt import Grid bind fact env fact d Grid Factory narrow bind fact fact lookup Grid the grid p initialize 10 10 try to re
32. e IDL compiler The file d K idl generated by o2cpp export will be used as input of IDL compiler The following files are generated d K hh and d KS cc Compile and link the generated files plus the application sources must be compiled and linked with the ORB and O libraries O Corba User Manual 29 3 Building an O2Corba Server The o2makegen tool takes charge of the whole process d K idl N V o2cpp export IDL compiler X Application ORB O2runtime K hxx code cc d i cc d d_KS cc files library libraries 100000000 O2 CORBA Server Figure 3 1 Building an O5Corba server with 30 User Manual O2 to IDL mapping Creating a Makefile Table 3 1 3 4 O to IDL mapping An exported class is mapped into an IDL interface the name of the interface is the name of class prefixed by For each exported public attribute a corresponding IDL attribute is generated with the same type For each exported method a corresponding IDL operation is generated with the same name and the same signature the parameters will be declared using the in parameter passing mode out parameters will be managed by return values The following table Corresponding O2 and IDL types for export shows the O types that you can use as parameter types and result type for exported O methods and
33. fault environment An object of the class o2 Transaction can be created using the o2 Database create transaction member function Example o2 Transaction trans database open grid b read write trans database create transaction trans begin trans commit Note The class o2 Transaction is provided by the ORB library libo2orbc a User Manual 43 4 Programming OQL service To execute a query whose result is a List of we will use the class d Query List which implements the oq1 execute function For example the class d Query List Grid will be defined as follows class d Query List Grid public virtual o2 OQL Query public virtual d List Grid 1 execute const char query const parameterList amp params CORBA Environment amp IT env CORBA default environment Like for persistent objects and collection an object of the class d Query List Grid will be created through an auxilliary class d Query List Grid Factory class d Query List Grid Factory public virtual CORBA Object public virtual void release instance CORBA Environment amp IT env CORBA default environment virtual d Query List Grid create query evaluator CORBA Environment amp IT env CORBA default environment 44 O Corba User Manual ODNG Services Database management Example d Query List
34. g position d Grid retrieve element at unsigned long position void remove element at pos in unsigned long position void replace element at pos in d Grid element in unsigned long position void insert element first in d Grid element void insert element last in d Grid element void insert element after in d Grid element in unsigned long position void insert element before in d Grid element in unsigned long position d List Grid concat in d List Grid 1 d List Grid append in d List Grid 1 d Sequence Grid concat list in d List Grid 1 d Sequence Grid append list in d List Grid 1 d Sequence Grid concat sequence in 4 Sequence Grid 1 d Sequence Grid append sequence in 4 Sequence Grid 1 The same technique as persistent object is available to create and access a collection i e through an auxilliary interface d List K Factory 40 O Corba User Manual Collection management The following example shows how to use a list of objects of the class d Grid d Grid 91 d Grid g2 d List Grid 191 d List Grid 1g2 d List Grid Factory lfact trans begin lfact d List Grid Factory bind List Grid d Grid hostname 141 lfact create persistent list Grid the list grid lgl insert element 31 long res lgl contains element 91 cout lgl contains gl res endl lgl insert element 32 lgl find element g2 res cout
35. gramming languages utilizing all the features available with persistence collection management transaction management OQL queries etc C functions can be invoked by C programs ODMG compliant binding Java ODMG compliant Java binding A powerful and elegant object oriented fourth generation language specialized for easy development of object database applications OQL ODNG standard easy to use SQL like object query language with special features for dealing with complex O objects and methods O Development Tools O Graph Create modify and edit any type of object graph O Look Design and develop graphical user interfaces provides interactive manipulation of complex and multimedia objects Library of predefined classes and methods for faster development of user applications O2Tools Complete graphical programming environment to design and develop O2 database applications Standard Development Tools standard programming languages can be used with standard environments e g Visual C Sun Sparcworks External Interfaces Create an O Orbix server to access database with CORBA Os5DBAccess Connect applications to relational databases on remote hosts and invoke SQL statements 0 0DBC Connect remote ODBC client applications to O databases O5Web Create an O5 World Wide Web server to access an database through the internet netwo
36. iation of the delivered template files e g d List ref i cc You need to import the classes Grid and Row and three collections list integer list Row and list Grid the public member functions of the class Grid are imported You also need to generate IDL interfaces for the class Grid using the 2 export tool All the methods which will be used from the CORBA client must be exported Finally the final executable must be linked with the Orbix server library liborbix so and the library Libo2orbs a in order to produce an O Corba server grid_server O Corba User Manual 59 5 Example of an O2 Corba Application on top of configuration file grid cf O2Home 502 O2System 5025 5 O2Server O2SERVER O2Schema grid s ImpFiles Grid hxx Grid hxx ImpClasses Row Grid Grid hxx Grid ImpAllPublicMemberFunc Grid hxx ImpOutputDir out ImpList int Row Grid ExpClasses Grid Grid ExpIdl Grid ExpHeader Grid ExpCode Grid ExpMethods width height set get get row set row set grid initialize ProgramName grid server Sources srv main cc Grid cc d List Grid i cc d Iter List Grid i cc d List GridS cc d Iter List GridS cc ProgramObjs srv main o Grid o d List Grid i o d Iter List Grid i o d List GridS o d Iter List GridS o ProgramLibDir ORB INSTALLATION PATH lib ProgramLib C orbix o2orbs Define REENTRANT Include ORB INSTALLATION PATH in
37. ix binding mechanism must be released by the release instance member function in order not to populate the server memory space 36 O Corba User Manual Creating persistent objects 4 4 4 5 Creating persistent objects A persistent object of the class d Gridcan be created using the d Grid Factory create persistent Grid member function The first parameter of this function will be the name of the object The class d Grid Factory is automatically generated by the O Export tool when the d Grid class is exported see Chapter 3 Example d Grid g d Grid Factory gfact gfact d Grid Factory bind Grid d Grid hostname gfact create persistent Grid my grid Accessing persistent objects A persistent object of the class Grid can be accessed by name using the d Grid Factory lookup Grid member function The first parameter of this function will be the name of the object Example d Grid g d Grid Factory gfact gfact d Grid Factory bind Grid d Grid hostname gfact lookup Grid the grid An object can also be accessed by name through the o2 Database lookup object member function in this case the returned object is typed as any and must be converted to the right class 1 The semantics of names corresponds to the ODMG semantic Corba User Manual 37 Programming o2 Database database CORBA any a d Grid g
38. les delivered with your ORB demos and add 1 the include directory of the o2corba distribution to include directives 2 the lib directory of the o2corba distribution and the o2orbc library to the link directives 5 8 Running Start the O Corba server grid_server amp e Start the CORBA client client hostname 62 User Manual Example of an O 6 Corba Application on top of Chorus ORB This chapter is divided into the following sections Introduction Define the class Grid in file Grid hxx using COOL Implement the class Grid in file Grid cc Implement the O2Corba server in file srv main cc Implement the CORBA client in Client cc Compile the O2Corba server Compile the client Running User Manual 63 Example of an O2 Corba Application on top of 6 1 Introduction The example that we develop in this section is a two dimensional grid that illustrates the use of ODMG Collections and OQL via Chorus ORB This application is an ODMG application linked with the Chorus ORB Library in order to provide O5Corba server A simple client will also be shown To run the grid example you have to go through the following steps which are the remaining sections of this chapter Define the class Grid in file Grid hxx using COOL Implement the class Grid in file Grid cc Implement the O2Corba server in file srv main cc Implement the C
39. lid IteratorInvalid ElementInvalid void replace element at in any element in Iterator where raises PositionInvalid IteratorInvalid ElementInvalid void remove element at in Iterator where raises PositionInvalid IteratorInvalid void remove all elements raises ElementInvalid any retrieve element Iterator where raises PositionInvalid IteratorInvalid Iterator create iterator O Corba User Manual 39 4 Programming interface odmg Collection CosQueryCollection Collection void release instance long is empty long is ordered long allows duplicates void remove all interface d Grid interface d Iter List Grid interface d List Grid typedef sequence d Grid d Sequence Grid interface d List Grid odmg Collection readonly attribute d Sequence Grid collection value void display long contains element in d Grid element void insert element in d Grid element void remove element d Grid element d Grid select element in string predicate long query out d List Grid 1 in string predicate long sequence query out d Sequence Grid 1 in string predicate d Iter List Grid create d Iterator d Iter List Grid select in string predicate d Grid retrieve first element d Grid retrieve last element void remove first element void remove last element long find element d Grid element inout unsigned lon
40. nd their associated methods in a application It also provides the generation for each exported class of the corresponding IDL interface and the IDL C implementation class The o2cpp export command provides an option called 141 this option allows to generate IDL files for a given exported class Example Let us suppose that we want to export the class K its public attributes and its method m and generate IDL files we invoke 2 export as follows o2cpp export class K idl type method m The generated files are the following C standard export K hxx C header containing the definition of the C class K image of the O exported class 2 K code cc C implementation of the function members K 02 read K 02 write etc IDL export 1 d Interface header containing the definition of the IDL interface image of the exported class Note that the prefix d_ is added 2 ihxx C header containing the definition of the C IDL implementation class d i hxx subclass of the class d KBOAImp1 generated by the IDL compiler we use the BOAImpl approach 3 dK icc C Implementation of the function members of the class d K i Note 1 In case the C files i e K hxx and K code were already generated e g by the 2 import tool you can turn off the files generation and only generate the IDL files using the options noheader and 4
41. ndard files are generated or not The syntax of these two directives is the following the default is ExpClassName ExpHeader ExpClassName ExpCode When these directives are set the 2 export tool will be triggered with the noheader and nocode options and the standard C files will not be generated In the example below only the IDL files will be produced for the class K K ExpHeader K ExpCode ExpType directive The directive ExpType must be used to trigger the o2cpp export tool with the type option in order to export public attributes of an class The directive ExpType has the following syntax the default is ExpClassName ExpType Link and preprocessing directives The link edition of the final application must be performed using the multi thread option mt and the files must be compiled using the REENTRANT option To set these options use the directives UserLdFlags and Define of the configuration file as follows UserLdFlags mt Define REENTRANT User Manual 27 Building an O2Corba Server The final executable must be linked with the O5 library 14bo2orbs a and your ORB library for example library 143bITsrvmt for Orbix using the ProgramLib directive ProgramLib ITsrvmt o2orbs Creating a Makefile If you prefer not to use the o2makegen tool you have to write your own Makefile This section outline
42. r schema name const char volume name long size long factor CORBA Environment amp IT CORBA default environment destroy const char database name CORBA Environment amp IT env CORBA default environment open const char database name access rights status CORBA Environment amp IT env CORBA default environment close CORBA Environment amp IT env CORBA default environment garbage const char database name CORBA Environment amp IT env zCORBA default environment set object name CORBA Any the object const char the name const char old name CORBA Environment amp IT CORBA default environment get object name CORBA Any the object CORBA Environment amp IT CORBA default environment rename object const char old name const char new name CORBA Environment amp IT CORBA default environment o2 Transaction create transaction CORBA Environment amp IT env CORBA default environment CORBA Any lookup object const char the name const char factory name CORBA Environment amp IT CORBA default environment void create persistent root const char root name const char class name long mode CORBA Environment amp IT env CORBA default environment void destroy persistent root const char root name CORBA Environment amp IT env CORBA default environment 46 O Corba User Manual ODMG Services
43. rademark of the NeXT Computer Inc Purify Quantify are registered trademarks of Rational Software Inc Windows is a registered trademark of Microsoft Corporation other company or product names quoted are trademarks or registered trademarks of their respective trademark holders Who should read this manual This manual is for programmers who want to write Object Management Group OMG CORBA compliant applications using the O object database The manual introduces O5Corba technology and describes how to generate interface definition language IDL files from classes It also explains how to use the Common Object Request Broker Architecture CORBA services O5Corba provides We assume in this manual that the reader is familiar with CORBA technology and with Object Database Management Group ODMG C binding This manual should be used in conjunction with the ODMG C Reference Manual which contains the full list of O5 C interface options Other documents available are outlined click below See O2 Documentation set TABLE OF CONTENTS This manual is divided into the following chapters 1 2 3 4 5 6 Introduction Installation Building an 2 Server Programming Example of an O2Corba Application on top of Orbix Example of an O2 Corba Application on top of Chorus ORB 2 User Manual 5 C22 TABLE OF CONTENTS Introduction 9 11i
44. rk O Corba User Manual 11 1 Introduction 1 2 and CORBA Basic principles To access O database from outside IDL is the language which allows you to give an external view of it In IDL you define the interface of any objects you want and you select the methods you need for the particular purpose of the view An O Corba server can be produced as follows The interface definition language IDL compiler parses the IDL interface and generates corresponding class Let us call the IDL interface The compiler generates a class called This class can be used directly by the CORBA client The programmer then has to define a implementation class called K i which implements the view inside O This class has to inherit from a generated class called KBOAImpl Basic Object Adapter Implementation for which implements the CORBA client server protocol The class KBOAImpl is a subclass of K The following figure shows the class hierarchy K IDL interface used by CORBA clients inherits KBOAImpl class generated by the IDL compiler inherits K i class written by the programmer Figure 1 2 The CORBA class hierarchy K_i can use any features of C binding provided by K_i is a pure transient C class it does not need to be known by It is linked with an O5 process which runs a standard client 12
45. s void set s in string v void foo in d K2 obj The class d i will be generated with the following member functions class d K i public d KBOAImpl private d Ref K o2 object public virtual char get s CORBA Environment amp env CORBA default environment virtual void set s char v CORBA Environment amp env CORBA default environment virtual void foo d K2 obj CORBA Environment amp env CORBA default environment Makegen directive The configuration file of o2makegen accepts a directive called ExpId1 related to export information This directive indicates whether the IDL generation is performed or not default is not The directive ExpId1 has the following syntax the default is t ExpClassName ExpIdl When this directive is set the 2 tool will be triggered with the id1 option and the Makefile generated by o2makegen will define rules in order to compile the source files produced by the IDL export mechanism e g K i cc 26 O Corba User Manual Export to IDL O2 Makegen Important The object files generated from the C IDL source files e g K_i o must NOT be in the list of the ProgramObjs directive These object files will be automatically linked with the final executable ExpHeader and ExpCode directives Two directives ExpHeader and ExpCode can be used to indicate to the o2cpp export tool whether sta
46. s the compilation options and libraries you need to generate an O Corba server For a full description of the Makefile creation refer to the C ODNG Binding Guide Compilation The source files used to build the O5Corba server must be compiled with the REENTRANT compilation flag Link edition An Corba server must be linked with the following O libraries libo2common libo2util libo2store libo2api libo2runtime libo2cppruntime e liboql if you use the Object Query Language OQL service libo2orbs and your ORB server library such as Liborbix so for Orbix The CORBA client must be linked with the library Llibo2orbc a Finally the link edition of the server and the client must be performed using the multithread option mt 28 O Corba User Manual Building an O2Corba server with O2 Creating a 3 3 Building an O Corba server with O Building an O5Corba server with the C Interface to consists in compiling and linking the files produced by the O Export tool if you use the IDL automatic generation and the compiler the applications files if needed the CORBA server library and the runtime libraries see Figure 3 1 To produce an O Corba server you must go through the following steps Export the classes automatic IDL generation For a class the following files are generated K hxx code cc d K i hxx d K i ccandd K idl Call th
47. stem Architecture Dev Tools OQL O DB Access O2Web 3 1 The system can be viewed as consisting of three components The Database Engine provides all the features of a Database system and an object oriented system This engine is accessed with Development Tools such as various programming languages O5 development tools and any standard development tool Numerous External Interfaces are provided All encompassing is a versatile portable distributed high performance dynamic object oriented database system Database Engine Os5Store The database management system provides low level facilities through Os5Store API to access and manage a database disk volumes files records indices and transactions Os5Engine The object database engine provides direct control of schemas classes objects and transactions through O5Engine API It provides full text indexing and search capabilities with O5Search and spatial indexing and retrieval capabilities with O5Spatial It includes a Notification manager for informing other clients connected to the same server that an event has occurred a Version manager for handling multiple object versions and a Replication API for synchronizing multiple copies of an O2 system 10 O Corba User Manual System overview Programming Languages objects may be created and managed using the following pro
48. t or 2 a single client for several CORBA clients The architecture 1 must be chosen when the CORBA clients run concurrently on the same data in potentially conflicting modes In this case they need to rely on the O5 transactional system one client for each transaction The architecture 2 can be adopted when either the CORBA clients are not conflicting for instance they all run in read only mode or when each request coming from a CORBA client can be implemented as a complete transaction which is worth only when the implementation of the request involves a significant amount of data manipulation User Manual 15 Introduction 1 4 Manual overview This manual describes how to use an ORB product to access an database and it is divided into the following chapters Introduction Introduces the and CORBA connection and outlines some of its advantages Installation Describes the contents of the Corba connection module and explains how to run the example application in the distribution Building an Corba server Describes how to build a server from O and CORBA using the O ODMG Binding development tools Programming Provides guidelines on programming with the CORBA architecture including managing persistent objects collection manipulation transaction management memory management and using OQL Example of an Corba application on top of Orbi
49. tation of the set operation void Grid set const int n const int m const int value m a n 1l replace element at value m implementation of the get operation int Grid get const int n const int m const return m gt 1 implementation of the get row operation d_List lt int gt Grid get row const int range d List int res the row d List int tmp tmp insert element first m gt 1 0 for int i 0 i lt m height 1 1 tmp insert element after m a int range 1 i 1 i res tmp return res void Grid set_row d_List lt int gt 1 const int range for int i 0 i lt m_height i m a int range l insert element last 1 i void Grid set grid d Ref Grid g this m height g gt height this m width g width User Manual 25 5 Example of an O2 Corba Application on top of 5 4 Implement the server in file srv main cc This section gives the main program which implements the Corba server This program connects to server by creating an o2 Database i object creates two factory objects and starts the CORBA server include lt stdlib h gt include lt iostream h gt include o21ib CC hxx include Grid hxx include o2 Database i hxx include o2 Factory i hxx include d Grid i hxx include d List Grid i hxx int main int argc char
50. ter List Grid itg long card lfact d List Grid Factory bind List Grid d Grid hostname lg lfact lookup list Grid the list grid itg lg create d Iterator card lg cardinality cout lg cardinality card endl while itg not done itg get element v g get 1 2 cout lt lt 1 2 is lt lt v lt lt endl itg advance itg reset Note You have to instantiate the template file d Iter List Ref idl with the class Grid in order to produce the file d Iter List Grid idl This file will be used as input to the IDL compiler 42 O Corba User Manual ODMG Services Transaction service 4 7 ODMG Services Transaction service A class o2 Transaction image of the ODMG class Transaction is available to manage the transaction service The class o2 Transaction is defined as follows class o2 Transaction public virtual CORBA Object public virtual void begin CORBA Environment amp IT env CORBA default environment virtual void commit CORBA Environment amp IT env CORBA default environment virtual void validate CORBA Environment amp IT env CORBA default environment virtual void abort CORBA Environment amp IT CORBA default environment virtual void checkpoint CORBA Environment amp IT env CORBA default environment virtual void promote CORBA Environment amp IT env CORBA de
51. tice then to release both proxies on the client and on the server To do this the client just writes the following assuming g has been set then used and finally g is no more needed g release instance Release the server proxy g release Release the client proxy 48 O Corba User Manual Memory management Commit and abort Commit and abort CORBA objects must be deleted at commit and abort time since O objects are no more valid in memory O Corba User Manual 49 Programming 50 O Corba User Manual Example of an O5 Corba 5 Application on top of Orbix This chapter is divided into the following sections Introduction Define the class Grid in file Grid hxx Implement the class Grid in file Grid cc Implement the O2Corba server in file srv main cc Implement the CORBA client in Client cc Compile the O2Corba server Compile the client Running User Manual 51 Example of an O2 Corba Application on top of 5 1 Introduction The example that we develop in this Section corresponds to the one described in the Orbix documentation This example is a two dimensional grid it is extended by some additional operations in order to illustrate the use of ODMG collections and OQL via Orbix Refer to the Orbix programmer s guide for more details about this example This application is an ODM
52. tion to include directives 2 the lib directory of the o2corba distribution and the o2orbc library to the link directives 6 8 Running Start the O Corba server grid server amp Start the CORBA client client O Corba User Manual 75 Example of an O2 Corba Application on top of 76 O Corba User Manual INDEX 2 User Manual 77 INDEX Symbols option 23 method option 23 mt flag 27 nocode option 27 noheader option 27 27 option 24 _ 27 REENTRANT flag 27 A abort 49 Architecture 10 architecture 15 B binding 36 BOAImpl 12 23 Boolean 31 C Interface 11 char 31 collection 31 38 commit 49 communication protocol 15 compilation 28 configuration file 59 72 CORBA 9 13 create transaction 36 D d Database 35 45 d Iter List Ref idl 42 d lterator 42 d List Ref idl 41 d Query List ref idl 45 d Transaction 34 43 Define 27 Delivery 18 demo 19 19 double 31 ExpCode directives 27 ExpHeader directive 27 Expldl directive 26 Export tool 23 ExpType directive 27 2 User Manual INDEX F factory 36 37 40 41 H heterogeneousness 14 IDL 22 files 23 compiler 15 23 61 74 implementation class 15 22 Installation 19 integer 31 Iterator 42 Java 11 liblITsrvmt 28 libo2or
53. ual Building an O5Corba Server This chapter is divided into the following sections Introduction Export to IDL Building an O2Corba server with O2 O2 to IDL mapping User Manual 21 Building an O2Corba Server 3 1 Introduction There two ways to build a server with and CORBA Starting from an existing schema you build an IDL view on it which will be used by the CORBA client This IDL view including IDL interfaces and IDL implementation classes can be automatically generated by the 2 export tool of the O5 binding programming environment In this case an object of the CORBA server will be linked with one object of the database see Chapter 1 Note The schema can be defined using the standard tools and in particular the o2cpp import tool of the C binding programming environment Starting from an existing IDL definition you use the system and its ODMG C interface to implement this IDL interface In both cases an O2Corba server is an ODMG application which is linked with the Orbix server library The following section describes how to use the 2 export and o2makegen commands to produce IDL interfaces from an schema 22 O Corba User Manual Export to IDL 3 2 Export to IDL The O Export tool allows to export class to C in order to use the objects a
54. vironment variables O2HOME O2SERVER and O2SYSTEM and to change the installation path of the CORBA ORB product in the configuration file Import the C classes Do not forget to run the server before User Manual 73 6 Example of an O2 Corba Application on top of Generate IDL files make export Do not forget to run the server before Call the IDL compiler on the generated IDL files idl B A d Grid idl The options B and A must be used Compile the O2Corba server make The following figure shows how to create the O5Corba server for the Grid application Grid hxx d Grid idl 02 o2cpp import eme export IDL Grid d Grid i hxx d Grid H Application ORB o2 Grid code cc d Grid i cc d Grid cc les library 5 Compiler and Linker grid server Figure 6 1 Building the Grid O 5Corba server 74 User Manual Compile the client Through o2dsa shell create a base grid b create base grid b Hegister the CORBA server called Grid using the correct ORB program such as putit for Orbix putit d Grid h hostname ORB INSTALLATION PATH grid grid server 6 7 Compile the client There is no automatic way to generate a client Makefile Just follow the Makefile examples delivered with your ORB demos and add 1 the include directory of the o2corba distribu
55. x Gives a simple example of an O5Corba server it implements a two dimensional grid with Orbix Example of an O Corba application on top of Chorus ORB Gives a two dimensional grid example implemented with Chorus ORB 16 O Corba User Manual Installation This chapter describes the contents of the Corba connection module and explains how to run the example application in the distribution It is divided into the following sections Delivery e Running the samples User Manual 17 Installation 2 1 Delivery Your lt O2 installation directory gt contains two directories related to the Corba connection module e lt QO2 installation directory gt o2corba This directory contains all the material needed to use the O Corba connection in your applications According to the platform you are using there can be several subdirectories one for each ORB product supported on your platform For each supported ORB version are three directories include The include files needed to use the librairies Libo2orbs a and libo2orbc a lib The 1ib directory contains the libraries from which the Corba server and the CORBA client must be linked respectively 14bo2orbs a and libo2orbc a templates This directory contains template files which can be instanciated by the program mer see Chapter 4 e lt QO2 installation directory gt samples o2

Download Pdf Manuals

image

Related Search

Related Contents

User's manual Primor 2000 / Level 15  Betriebsanleitung zum BMW Autotelefon. Mobile Kommunikation im  Manual do proprietário  Open9X Manual - BlackEye Team  PDFファイル  Orion IMAGING FLIP MIRROR 5523 User's Manual  Janvier 2013  

Copyright © All rights reserved.
Failed to retrieve file