background image
Tech Note #40:  Initializing CORBA Applications
©
1998 Bionic Buffalo Corporation; All Rights Reserved.
          1 November 1998
http://www.tatanka.com
Page 
2 of 5
Upon return from a call to an object method, the 
 
_major
 element has one of the three values
 
CORBA_NO_EXCEPTION
 
CORBA_USER_EXCEPTION
, or 
 
CORBA_SYSTEM_EXCEPTION
. Other
elements in the Environment structure are defined by the implementor, and are opaque to the
user.
Although examples in the Specification declare the Environment as a static or global structure,
there is no explicit guidance on how the Environment is to be initialized. Furthermore, static or
global structures will not work in multithreaded applications, since a thread would expect its
own unique value for 
 
_major
.
Bionic Buffalo’s CORBA implementation provides a separate instance of the Environment for
each thread. To acquire its own instance of the Environment, a thread must call
 
eg_new_
 
environment
 
()
. (This procedure is Bionic Buffalo’s proprietary solution to the problem
of Environment acquisition and initialization.) The prototype is:
 
unsigned long
 
eg_environment_create
 
( eg_environment_parms_t
 
* parms1,
 
CORBA_Environment
 
** ev1 ) ;
The 
 
parms1
 parameter specifies details for threaded or multiprocessor environments. For
almost all purposes, the 
 
parms1
 parameter can be specified as 
 
NULL
. The use of 
 
parms1
 is
discussed elsewhere in the documentation.
 
eg
 
_environment_create()
 uses the 
 
ev1
 parameter to return a pointer to the 
 
CORBA_Environment
structure. This pointer is used subsequently in the following steps.
If successful, 
 
eg_environment_
 
create
 
()
 returns zero. Otherwise, it returns an error code
indicating why the operation failed.
Initializing the ORB
The Specification defines an ORB initialization procedure as follows:
 
typedef char*
 
CORBA_ORBid;
 
extern CORBA_ORB
 
CORBA_ORB_init
 
( int
 
* argc,
 
char
 
** argv,
 
CORBA_ORBid
 
orb_identifier,
 
CORBA_Environment
 
* env );
Each implementation may define different values for these parameters. In general:
 
The 
 
orb_identifier
 argument is used to select from among different possible ORBs. If the
string is empty, then the default ORB is selected.