Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / POA / Loader / Servant_Locator.h
blob8f76acb75c3c93088d44039d01d13f57f34d6ce0
1 //=============================================================================
2 /**
3 * @file Servant_Locator.h
5 * Defines a ServantLocator class , used with a POA having
6 * a NON_RETAIN policy.
8 * @author Kirthika Parameswaran <kirthika@cs.wustl.edu>
9 */
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"
20 #include "tao/ORB.h"
22 #include "ace/DLL.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
30 // = TITLE
31 // This class is used by a POA with USE_SERVANT_MANAGER and
32 // NON_RETAIN policy.
34 // = DESCRIPTION
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.
38 public:
39 /**
40 * This typedef is used to typecast the void* obtained when finding
41 * a symbol in the dll. Invoking the function pointer obtained would
42 * get a servant.
44 typedef PortableServer::Servant
45 (*SERVANT_FACTORY) (const PortableServer::ObjectId &oid,
46 PortableServer::POA_ptr poa,
47 CORBA::ORB_ptr orb);
49 /**
50 * This typedef is used to obtain the garbage_collection_function symbol
51 * in the dll. Invoking the function pointer obtained would then destroy
52 * the servant.
54 typedef void
55 (*SERVANT_GARBAGE_COLLECTOR) (const PortableServer::ObjectId &oid,
56 PortableServer::POA_ptr,
57 PortableServer::Servant servant);
59 /// Constructor.
60 ServantLocator (CORBA::ORB_ptr orb,
61 const ACE_TCHAR *dllname,
62 const ACE_TCHAR *factory_function,
63 const ACE_TCHAR *garbage_collection_function);
65 /**
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);
81 /**
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);
95 private:
96 /// The name of the dll containing the servant.
97 ACE_CString dllname_;
99 /// The symbol which on getting invoked will give us the servant
100 /// pointer.
101 ACE_CString create_symbol_;
103 /// The ACE_DLL object which performs the task of loading the dll
104 /// and accessing it.
105 ACE_DLL dll_;
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.
114 CORBA::ORB_var orb_;
117 #endif /* SERVANT_LOCATOR_H */