[Enterprise Extensions only]
  Previous topic

Creating CORBA server main code (server.cpp), adding code to check input parameters

Use this task to add code to check input parameters to the source file for a CORBA server. This code is used to check the parameters that a user specifies when starting the CORBA server.

This task assumes that the CORBA server is started by the following command:

servantServer server_alias
Where:
servant
is the name of the server implementation class that the server supports.
server_alias
is the server alias (defined in the Implementation Respository).

The code checks that the command used to start the CORBA server specifies a string, server_alias, the server alias. During the subsequent server initialization function called when the server starts, the server alias is used to retrieve the server's ImplementationDef; therefore, the string specified must match the server alias predefined in the system Implementation Repository.

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

To add code to check the input parameters to the source file for a CORBA server main code, complete the following steps::

  1. Edit the server source file, servantServer.cpp, and add the following code:
    void main( int argc, char *argv[] )
    {
      ::CORBA::Object_ptr objPtr;
      ::CORBA::Status stat;
      int rc = 0;
    
    
      // Validate the input parameters.
      if ( argc != 2 )
      {
        cerr << "Usage: servant <server_alias>" << endl;
        exit( -1 );
      }
    
    
      if ( ( rc = perform_initialization( argc, argv ) ) != 0 )
        exit( rc );
      ...
      
    } 
    

    Where:

    server_alias
    Specifies the server alias predefined in the system Implementation Repository.
    perform_initialization( argc, argv )
    Calls the initialization function of the server main code, to check that the server alias is defined in the system Implementation Repository (and to perform other tasks to initialize the server environment).

This task adds code to check input parameters to the main method in the source file for a CORBA server.

You need to add code to the server source file for the server initialization function, as described in Creating CORBA server main code (server.cpp), adding code to initialize the server environment.

  Previous topic