[Enterprise Extensions only]
  Previous topic

Creating CORBA client main code (client.cpp), adding code to initialize the client environment

Use this task to add an initialization method to the source file for a CORBA client. This code is used to perform the initialization tasks needed when the client is started.

The aim of the client initialization method is to complete the following tasks to initialize the ORB and object adapter.

This task is one step of the parent task to create the CORBA client main code, as described in Creating a CORBA client main code (client.cpp).

To add an initialization method to the source file for a CORBA client main code, edit the client source file, client.cpp, and add the following code:

  1. Add an initialization method, and add a statement to the main method to call the new method, as shown in the following code extract:
    int perform_initialization( int argc, char *argv[] )
    {
      // Initialize the ORB.
      op = ::CORBA::ORB_init(argc, argv, "DSOM");
      }
      cout << "Initialized ORB" << endl;
    
      return( 0 );
    }
    
    ...
    
    main(int argc, char *argv[])
    {
     ...
     if ( ( rc = perform_initialization( argc, argv ) ) != 0 )
        exit( rc );
    
    }

    Where:

    perform_initialization( argc, argv )
    Calls the initialization method of the client main code, to initialize the client environment. The method takes as argument the log file name and iteration count specified on the command used to start the client.

This task adds code to initialize the client environment for a CORBA client.

You need to add code to the client source file to enable the client to access naming contexts, as described in Creating CORBA client main code (client.cpp), adding code to access naming contexts.

  Previous topic