Skip navigation.

CORBA Programming Reference

  Previous Next vertical dots separating previous/next from contents/index/pdf Contents View as PDF   Get Adobe Reader

 


ServerBase::create_servant_with_id()

Synopsis

Creates a servant for this target object. This method supports the development of single-headed and multithreaded server applications.

C++ Binding

Tobj_Servant create_servant_with_id (const char* interfaceName,
const char* stroid);

Arguments

interfaceName

Specifies a character string containing the fully qualified interface name for the object. This must be the same interface name that was supplied when the object reference was created.

stroid

Specifies an object ID in string format. The object ID uniquely identifies the object associated with the request to be processed. This is the same object ID that was specified when the object reference was created.

Description

The TP Framework invokes the create_servant_with_id method when a request arrives at the server and there no servant is available to satisfy the request. The TP Framework passes in the interface name for the servant to be created and the object ID associated with the object with which the servant will be associated. The server application instantiates an appropriate C++ object and returns a pointer to it. Typically, the method contains a switch statement on the interface name and creates a new object, depending on the interface name. Providing the object ID allows a servant implementation to make decisions during the creation of the servant instance that require knowledge of the target object. Reentrancy support is one example of how a servant implementation might employ knowledge of the target object.

The ServerBase class provides a default implementation of create_servant_with_id which calls the standard create_servant method passing the interface name. This default implementation ignores the target object ID parameter.

Caution: The server application must not depend on the invocation of this method for every activation of a CORBA object. The server application must not handle the CORBA object state in the constructors or destructors of any servant classes for CORBA objects. This is because the TP Framework might reuse servants on activation and might not destroy servants on deactivation.

Return Value

Tobj_Servant

A pointer to the newly created servant (instance) for the specified interface. Returns NULL if either of these conditions is true:

Example

Tobj_Servant simple_per_request_server::create_servant_with_id(
const char* intf_repos_id, const char* stroid)
{
TP::userlog("create_servant_with_id called in thread %ld",
(unsigned long)SIMPTHR_GETCURRENTTHREADID);

// Perform any necessary initialization based on
// this object ID

return create_servant(intf_repos_id);
}

 

Skip navigation bar  Back to Top Previous Next