summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.h
blob: 560eacf6237f374dad49927622b8fab8356b0dd3 (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// -*- C++ -*-
//=============================================================================
/**
*  @file   ImR_Activator_i.h
*
*  $Id$
*
*  @author Priyanka Gontla <gontla_p@ociweb.com>
*  @author Darrell Brunsch <brunsch@cs.wustl.edu>
*/
//=============================================================================

#ifndef IMR_ACTIVATOR_I_H
#define IMR_ACTIVATOR_I_H

#include "activator_export.h"

#include "ImR_ActivatorS.h"
#include "ImR_LocatorC.h"

#include "ace/Process_Manager.h"
#include "ace/Vector_T.h"
#include "ace/SString.h"
#include "ace/Hash_Map_Manager.h"
#include "ace/Bound_Ptr.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

class Options;

/**
* @class ImR_Activator_i
*
* @brief IMR Activator Interface.
*
* This class provides the interface for the various activities
* that can be done by the ImR_Activator.
*
*/
class Activator_Export ImR_Activator_i : public POA_ImplementationRepository::AMH_Activator
{
  typedef ACE_Vector<ImplementationRepository::AMH_ActivatorResponseHandler_var> RHList;
  typedef ACE_Strong_Bound_Ptr<RHList, ACE_Null_Mutex> RHListPtr;
  typedef ACE_Hash_Map_Manager_Ex<ACE_CString,
    RHListPtr,
    ACE_Hash<ACE_CString>,
    ACE_Equal_To<ACE_CString>,
    ACE_Null_Mutex> ServerMap;

public:
  ImR_Activator_i (void);

 void start_server (
   ImplementationRepository::AMH_ActivatorResponseHandler_ptr rh,
   const char* name,
   const char* cmdline,
   const char* dir,
   const ImplementationRepository::EnvironmentList & env ACE_ENV_ARG_DECL)
   ACE_THROW_SPEC ((CORBA::SystemException));

  void server_status_changed(
    ImplementationRepository::AMH_ActivatorResponseHandler_ptr rh,
    const char* name ACE_ENV_ARG_DECL)
    ACE_THROW_SPEC ((CORBA::SystemException));

  /// Initialize the Server state - parsing arguments and waiting.
  int init (Options& opts ACE_ENV_ARG_DECL_WITH_DEFAULTS);

  /// Cleans up any state created by init*.
  int fini (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);

  /// Runs the orb.
  int run (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);

private:

  int init_with_orb (CORBA::ORB_ptr orb, const Options& opts ACE_ENV_ARG_DECL_WITH_DEFAULTS);

  void unblock_all_servers();
  void unblock_server(RHListPtr server);

private:
  ACE_Process_Manager process_mgr_;

  PortableServer::POA_var root_poa_;
  PortableServer::POA_var imr_poa_;

  /// IMR Locator Object
  ImplementationRepository::Locator_var locator_;

  /// We're given a token when registering with the locator, which
  /// we must use when unregistering.
  CORBA::Long registration_token_;

  CORBA::ORB_var orb_;

  unsigned int debug_;

  ACE_CString name_;

  ServerMap waiting_servers_;
};

#endif /* IMR_ACTIVATOR_I_H */