[Enterprise Extensions only]
Previous topic Next topic

Creating the CORBA server main code (server.cpp)

Use this task to create a CORBA server that hosts a servant object. The server performs the following tasks

  1. Validating user input
  2. Initializing the server environment
  3. Accessing naming contexts
  4. Naming, creating, and binding a servant object
  5. Creating a server shutdown object
  6. Going into a wait loop
  7. Servicing requests

This task follows on from adding code for the business logic methods in the servant implementation file,servant_I.cpp. For more information about adding code to a servant implementation file, see Completing the servant implementation (servant_I.cpp).

To create the main code for a CORBA server, complete the following steps:

  1. Create a source file,servantServer.cpp, where servant is the name of the implementation class for which the server is to service requests.
  2. Edit the server source file, servantServer.cpp, to add appropriate code to implement the server methods. To do this, complete the following steps:
    1. Add include statements and global declarations needed, as described in Creating CORBA server main code (server.cpp), adding include statements and global declarations.
    2. Add the main method, in the form:
      void main( int argc, char *argv[] )
       {
         ::CORBA::Object_ptr objPtr;
         ::CORBA::Status stat;
         int rc = 0;
       }
       
  3. Edit the server source file, servantServer.cpp, to add appropriate code to check the input parameters provided on the command used to start the server, as described in Creating CORBA server main code (server.cpp), adding code to check input parameters.
  4. Edit the server source file, servantServer.cpp, to add appropriate code to initialize the server environment, as described in Creating CORBA server main code (server.cpp), adding code to initialize the server environment.
  5. Edit the server source file, servantServer.cpp, to add appropriate code to access naming contexts, as described in Creating CORBA server main code (server.cpp), adding code to access naming contexts.

    At this point initialization has been accomplished and a naming context created for servant objects.

  6. Edit the server source file, servantServer.cpp, to add appropriate code to name, create, and bind servant objects, as described in Creating CORBA server main code (server.cpp), adding code to name, create, and bind servant objects.
  7. Edit the server source file, servantServer.cpp, to add code to create a server shutdown object, as described in Creating CORBA server main code (server.cpp), adding code to create a server shutdown object.
  8. Edit the server source file, servantServer.cpp, to add code to put the server into an infinite loop (to service any ORB requests received), as described in Creating CORBA server main code (server.cpp), adding code to put the server into an infinite loop.
  9. Edit the server source file, servantServer.cpp, to add code to shutdown the server and release resources used, as described in Creating CORBA server main code (server.cpp), adding code to shutdown the server and release resources used.

This task is one step of the parent task, Developing a CORBA server.

Previous topic Next topic