1 //=============================================================================
3 * @file Servant_Activator.h
5 * Defines a <ServantActivator> class, which activates a servant by
6 * obtaining it and associates it with an object on-demand.
8 * @author Kirthika Parameswaran <kirthika@cs.wustl.edu>
10 //=============================================================================
12 #ifndef SERVANT_ACTIVATOR_H
13 #define SERVANT_ACTIVATOR_H
15 #include "tao/PortableServer/PortableServer.h"
16 #include "tao/PortableServer/ServantActivatorC.h"
17 #include "tao/LocalObject.h"
22 #include "ace/Log_Msg.h"
25 * Servant Activator for the test servant.
27 * This class associates an unassociated servant with an object in
28 * the POA Active Object Map.
30 class ServantActivator
:
31 public virtual PortableServer::ServantActivator
,
32 public virtual ::CORBA::LocalObject
36 * This typedef is used to typecast the void* obtained when finding
37 * a symbol in the dll. Invoking the function pointer obtained would
40 typedef PortableServer::Servant
41 (*SERVANT_FACTORY
) (const PortableServer::ObjectId
&oid
,
42 PortableServer::POA_ptr poa
,
46 * This typedef is used to obtain the garbage_collection_function symbol
47 * in the dll. Invoking the function pointer obtained would then destroy
51 (*SERVANT_GARBAGE_COLLECTOR
) (const PortableServer::ObjectId
&oid
,
52 PortableServer::POA_ptr
,
53 PortableServer::Servant servant
);
56 ServantActivator (CORBA::ORB_ptr orb
,
57 const ACE_TCHAR
*dllname
,
58 const ACE_TCHAR
*factory_function
,
59 const ACE_TCHAR
*garbage_collection_function
);
62 * This method is invoked by a POA with USE_SERVANT_MANAGER and
63 * RETAIN policies, whenever it receives a request for a
64 * test object that is not currently active. When an servant
65 * pointer corresponding to objectId is not found in the Active
66 * Object Map, the POA hands over the job of obtaining the servant
67 * to the Servant Manager. Depending upon whether the POA is created
68 * with RETAIN or NON_RETAIN as the servant_retention policy, the
69 * Servant Activator or the Servant Locator interface is invoked
72 virtual PortableServer::Servant
incarnate (const PortableServer::ObjectId
&oid
,
73 PortableServer::POA_ptr poa
);
76 * This method is invoked whenever a test object is
77 * deactivated. This occurs when the POA is destroyed or the Object
78 * is deactivated. When the POA is getting destroyed, it needs to
79 * deactivate every object in the Active Object Map and on that call
80 * the ServantActivator invokes this method which will destroy the
81 * servant associated with the object.
83 virtual void etherealize (const PortableServer::ObjectId
&oid
,
84 PortableServer::POA_ptr adapter
,
85 PortableServer::Servant servant
,
86 CORBA::Boolean cleanup_in_progress
,
87 CORBA::Boolean remaining_activations
);
90 /// The ACE_DLL object which performs the task of loading the dll
94 /// The function pointer of factory_function type.
95 SERVANT_FACTORY servant_supplier_
;
97 /// The function pointer of garbage_collection_function type.
98 SERVANT_GARBAGE_COLLECTOR servant_garbage_collector_
;
100 /// A reference to the ORB.
104 #endif /* SERVANT_ACTIVATOR_H */