1 //=============================================================================
3 * @file Servant_Locator.h
5 * Defines a ServantLocator class , used with a POA having
8 * @author Kirthika Parameswaran <kirthika@cs.wustl.edu>
10 //=============================================================================
13 #ifndef SERVANT_LOCATOR_H
14 #define SERVANT_LOCATOR_H
16 #include "tao/PortableServer/PortableServer.h"
17 #include "tao/PortableServer/ServantLocatorC.h"
18 #include "tao/LocalObject.h"
23 #include "ace/SString.h"
24 #include "ace/Log_Msg.h"
26 class ServantLocator
:
27 public virtual PortableServer::ServantLocator
,
28 public virtual ::CORBA::LocalObject
31 // This class is used by a POA with USE_SERVANT_MANAGER and
35 // This class defines the Servant Locator interface of the Servant
36 // Manager. It is invoked when the POA has an USE_SERVANT_MANAGER
37 // policy and a servant_retention policy of NON_RETAIN type.
40 * This typedef is used to typecast the void* obtained when finding
41 * a symbol in the dll. Invoking the function pointer obtained would
44 typedef PortableServer::Servant
45 (*SERVANT_FACTORY
) (const PortableServer::ObjectId
&oid
,
46 PortableServer::POA_ptr poa
,
50 * This typedef is used to obtain the garbage_collection_function symbol
51 * in the dll. Invoking the function pointer obtained would then destroy
55 (*SERVANT_GARBAGE_COLLECTOR
) (const PortableServer::ObjectId
&oid
,
56 PortableServer::POA_ptr
,
57 PortableServer::Servant servant
);
60 ServantLocator (CORBA::ORB_ptr orb
,
61 const ACE_TCHAR
*dllname
,
62 const ACE_TCHAR
*factory_function
,
63 const ACE_TCHAR
*garbage_collection_function
);
66 * This method is invoked by a POA whenever it receives a request
67 * for test object that is not currently active. When the POA is
68 * created using the NON_RETAIN policy the Active Object Map is not
69 * maintained, in other words, an association between the ObjectId
70 * and the servant is not maintained. Hence every client request the
71 * servant has to be loaded. Note the operation argument. This
72 * argument specifies the operation to be invoked on the
73 * servant. The cookie helps in marking the servant. This marking is
74 * useful while destroying the servant.
76 virtual PortableServer::Servant
preinvoke (const PortableServer::ObjectId
&oid
,
77 PortableServer::POA_ptr adapter
,
78 const char *operation
,
79 PortableServer::ServantLocator::Cookie
&the_cookie
);
82 * This method is invoked whenever a test servant completes a
83 * request. As the Servant Loactor interface is used when the POA
84 * doesnt maintain the Active Object Map, its necessary to get rid
85 * of the servant after the client request has been processed. The
86 * appropriate servant is destroyed by verifying the cookie.Again
87 * this method is invoked per client request.
89 virtual void postinvoke (const PortableServer::ObjectId
&oid
,
90 PortableServer::POA_ptr adapter
,
91 const char *operation
,
92 PortableServer::ServantLocator::Cookie the_cookie
,
93 PortableServer::Servant the_servant
);
96 /// The name of the dll containing the servant.
99 /// The symbol which on getting invoked will give us the servant
101 ACE_CString create_symbol_
;
103 /// The ACE_DLL object which performs the task of loading the dll
104 /// and accessing it.
107 /// The function pointer of factory_function type.
108 SERVANT_FACTORY servant_supplier_
;
110 /// The function pointer of garbage_collection_function type.
111 SERVANT_GARBAGE_COLLECTOR servant_garbage_collector_
;
113 /// A reference to the ORB.
117 #endif /* SERVANT_LOCATOR_H */