One of the first tasks for a CORBA C++ application after startup is to initialize the Object Request Broker (ORB) by calling the CORBA::ORB_init() method. If necessary, this method creates a new instance of the ORB. For example, the following code fragment initializes the ORB:
CORBA::ORB_ptr op; op = ::CORBA::ORB_init(argc, argv, "DSOM");where argc and argv refer to the properties specified in the command used to start the server.
During the initialization of the ORB, the resolution of initial references can be configured. Refer to the CORBA::ORB_init method for more information on how the optional arguments, ORBInitRef and ORBDefaultInitRef are used to configure how the ORB resolves initial references. This affects how the ORB processes the CORBA::resolve_initial_references method.
The following is a command line invocation example:
myApp -ORBInitRef NameServer=file://c:/temp/namesvr.ref -ORBDefaultInitRef corbaloc::myHost.myOrg // Where myApp is a C++ program that passes // the command line args to ORB_init. // #include "corba.h" ... int main(int argc, char *argv[]) { // // Initialize the ORB and obtain a pointer to it // CORBA::ORB_ptr p = CORBA::ORB_init(argc, argv, "DSOM"); ... CORBA::Object_ptr obj = p->resolve_initial_references ( "NameService" ); ...
In the previous example, the resolve_initial_references invocation first searches for a Naming Service object reference in the file, c:/temp/namesvr.ref. If unsuccessful, the host myHost.myOrg is contacted to find the Naming Service.