![]() |
![]() |
e-docs > Tuxedo > Administering a Tuxedo Application at Run Time > TP Framework |
Administering a Tuxedo Application at Run Time
|
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
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
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);
}
![]() |
![]() |
![]() |
![]() |
||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |