Bionic Buffalo Tech Note #20: Quick Start Guide to Writing CORBA Client Applications
1. Set up the programming environment
2. Acquire references for initial system object or objects
3. Handle possible exceptions
4. Acquire a reference for the server object or objects
5. Do the primary activity of the application
6. Release resources and tear down the programming environment
Set up the programming environment. What constitutes this activity is mostly dependent upon the
programming language, but may also involve proprietary considerations. For example, in the C
programming language, it is necessary to acquire a pointer to a partially-opaque data structure
CORBA_Environment, which is used as an argument in subsequent calls to object operations; the
OMG C mapping specification doesn't say how this pointer is acquired, leaving it to proprietary
mechanisms. Some environments require setting up initial service objects (such as the repository or
naming service) in advance of ORB initialization; in other environments, initial service objects are
created or set up automatically. For specific set up procedures, it is necessary to consult documentation
for the environment you are using.
When programming in C using Bionic Buffalo tools, the
CORBA_Environment pointer is acquired
by the routine
tbt_get_environment(), prototyped as
int tbt_get_environment ( CORBA_Environment ** env ) ;
Each thread must have its own copy of the
CORBA_Environment structure, and the pointers from
the above call may not be shared among threads. If a thread makes the above call more than once, it
will get the same pointer back each time.
Acquire references for initial system object or objects. As a minimum, every non-trivial application
will need a reference to the ORB. The CORBA specification says this will be done using a procedure
or subroutine
CORBA_ORB_init(), but the mapping of that subroutine to each programming
language is different. For C, the prototype is
typedef char * CORBA_ORBid ;
extern CORBA_ORB CORBA_ORB_init
( int * argc,
char ** argv,
CORBA_ORBid orb_identifier,
CORBA_Environment * env ) ;
For simple cases, the argument list (
argc and argv) may be left empty in Bionic Buffalo's
environment, and the
orb_identifier may be left empty to select the default ORB. (Multiple
ORBs may be used together by one program; the orb_identifier is used to distinguish among them.)
After this subroutine has been invoked successfully, then the application will have an object reference
for the
ORB.
Page 6 of 11