summaryrefslogtreecommitdiff
path: root/TAO/examples/POA/On_Demand_Loading/Servant_Activator.h
blob: 2e68f6dc46b87651d6b718db1d100e4560929ee1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// $Id$

//=================================================================================
//
// = LIBRARY
//     TAO/tests/POA/On_Demand_Loading
//
// = FILENAME
//     Servant_Activator.h
//
// = DESCRIPTION
//     Defines a Dir_Service_Activator class which is an
//     Servant_Manager interface which activates a servant by loading
//     it and associates it with an object on demand.
//
// = AUTHOR
//     Kirthika Parameswaran <kirthika@cs.wustl.edu>
//
//==================================================================================

#include "tao/corba.h"
#include "ace/DLL.h"


class Dir_Service_Activator : public POA_PortableServer::ServantActivator
{
  //= TITLE
  //   Servant Activator for the directory service servant.
  //
  //= DESCRIPTION
  //   This class associates an unassociated servant with an object in
  //   the POA Active Object Map.

public:

  typedef PortableServer::Servant (*Servant_Creator_Prototype) (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa);
  // This typedef is used to typecast the void* obtained on finding a
  // symbol in the library.

  Dir_Service_Activator (CORBA::ORB_ptr orb);
  // Initialization.

  virtual PortableServer::Servant incarnate (const PortableServer::ObjectId &oid,
                                             PortableServer::POA_ptr poa,
                                             CORBA::Environment &env);
  // This method is invoked by a POA with USE_SERVANT_MANAGER and
  // RETAIN policies , whenever it receives a request for a MyFoo
  // object that is not currently active.

  virtual void etherealize (const PortableServer::ObjectId &oid,
                            PortableServer::POA_ptr adapter,
                            PortableServer::Servant servant,
                            CORBA::Boolean cleanup_in_progress,
                            CORBA::Boolean remaining_activations,
                            CORBA::Environment &env);
  // This method is invoked whenever a MyFooServant for a MyFoo object
  // is deactivated.

private:

   PortableServer::Servant activate_servant (const char *str,
                                             PortableServer::POA_ptr poa);
  // Gets the servant on activation by loading the appropriate library
  // and getting the servant object.

  void deactivate_servant (PortableServer::Servant servant);
  // The servant is killed and take is taken to close the library
  // loaded.

  void parse_string (const char* s);
  // Parse the string to obtain the library name and the symbol which
  // will get us the servant pointer.

  CORBA::ORB_var orb_;
  // A reference to the ORB.

  CORBA::String_var dllname_;
  // the name of the library containing the servant.

  CORBA::String_var create_symbol_;
  // The symbol which on getting invoked will give us the servant
  // pointer.

  ACE_DLL dll_;
  // the library object.
};