CORBA 2.6.1 Programmer's Guide for C++

Figure 12.1. Legacy Server Wrapper
Basic Structure of a Server Wrapper
Because it is a NonStop CORBA server, the server wrapper must perform the usual ORB initialization operations:
1. Call ORB::init().
2. Create a POA.
3. Create a servant.
4. Activate the servant.
5. Call
ORB::run().
The
ORB::run() operation blocks the main thread until the server is shut down. This blocking allows the event thread to take over to receive I/O
events.
The wrapper then must receive CORBA requests from the client. Regardless of which operation is invoked by the client, the server must do the
following:
1. Marshal the parameters into a legacy request.
2. Use an appropriate API (one recognized by that type of legacy server) to deliver the legacy request to the legacy server and wait for the
reply.
3. Demarshal the legacy reply message.
4. Translate the legacy results into CORBA interface components.
5. Return.
If the POA for your server wrapper uses the default threading policy (ORB_CTRL_MODEL), NonStop CORBA automatically creates a new
thread, as needed, for each CORBA request to the wrapper. Existing threads are recycled; when a request completes, its thread is returned to
the thread pool for later reuse.
If you need to do explicit multithreading, HP recommends that you use the vthread interface unless you require conformance to POSIX threading
standards. For more information, see
Writing Multithreaded Applications.
The programming interfaces the server wrapper uses to communicate with the legacy server depend on the kind of legacy server and whether it
performs waited or nowait communication with the server.
For nowait communication with context-free NonStop TS/MP servers, the wrapper can use the SPT_SERVERCLASS_SEND_ procedure,
described in the Open System Services Programmer's Guide. This procedure provides a thread-blocking jacket for context-free Pathsend calls.
For waited requests and replies, the wrapper can use conventional means of access to legacy servers of various types:
Pathsend requests for access to server pools
Guardian file-system requests for access to individual local processes, using methods from the NonStop CORBA event framework
Socket requests for access to remote processes, using methods from the NonStop CORBA event framework
Note:
Although context-free and context-sensitive Pathsend are conceptually similar to stateless and stateful CORBA
objects, they are not exactly the same. Internally, the NonStop CORBA ORB uses context-sensitive Pathsend calls
to send requests to stateless servants because the context-sensitive Pathsend interface allows indefinitely long
messages to be sent to the same process.
Calling a Context-Free TS/MP Server for Nowait Operations
The simplest type of legacy wrapper involves nowait calls to a context-free TS/MP server. A NonStop CORBA client can use the services of
such a server by calling the SPT_SERVERCLASS_SEND_ routine. This routine sends a message to, and receives a reply message from, a
server process in a TS/MP server class. It is a jacket procedure that converts process-blocking SERVERCLASS_SEND_ calls to thread-
blocking calls.
This type of server-wrapper program must do the following:
1. Include the
$NSD_ROOT/include/pthread.h header file in your program:
#include <pthread.h>
2. Create a POA and servant.
3. Send data and receive replies by making calls to the SPT_SERVERCLASS_SEND_ procedure.