![]() |
|
Use this task to add code to the source file for a CORBA server, to create a WSServerShutdown object, which enables the server to be shut down whenever needed.
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 create a WSServerShutdown object, complete the following steps:
void main( int argc, char *argv[] ) { ... // Create a new servant_Impl object and bind it to the objectNameContext. if ( ( rc = create_and_bind( nc, servantNameContext ) ) != 0 ) exit( -1 ); ... // Create a WSServerShutdown object that can break the server out of the // method execute_request_loop() when we are ready to terminate // the server. The WSStopServer command will make the subsequent // invocation of execute_request_loop() return to the server. WSServerShutdown *shutdownObj = new WSServerShutdown( argv[1], bp ); cout << "Created WSServerShutdown object" << endl; cout << endl; cout << "server listening...." << endl << endl; cout.flush(); // Go into an infinite loop, servicing ORB requests as they are received. ... }
When created, the WSServerShutdown object is initialized with the server alias and the object adapter pointer.
This task adds code to create a WSServerShutdown object. After the server has initialized itself, it creates the WSServerShutdown object, which waits for a message informing it that the server is to be shutdown. That message can be sent by the StopServer command line program provided with WebSphere Application Server enterprise services.
To continue developing the server main code, you need to add code to put the server into an infinite wait loop, during which the ORB can transmit requests to and from the servant object hosted by the server, as described in Creating CORBA server main code (server.cpp), adding code to put the server into an infinite loop.
![]() |