summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.h
blob: fbab774fe28bb5dc1622bef94925b301fbcd474a (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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
// -*- C++ -*-
//=============================================================================
/**
 *  @file   ImplRepo_i.h
 *
 *  $Id$
 *
 *  @brief  This class implements the Implementation Repository.
 *
 *  @author Darrell Brunsch <brunsch@cs.wustl.edu>
 */
//=============================================================================

#ifndef IMPLREPO_I_H
#define IMPLREPO_I_H

#include "Repository.h"
#include "orbsvcs/IOR_Multicast.h"
#include "tao/PortableServer/ImplRepoS.h"
#include "tao/IORTable/IORTable.h"
#include "ace/Process_Manager.h"

class ImR_Adapter_Activator;
class ImR_Forwarder;

/**
 * @class ImplRepo_i
 *
 * @brief Implementation Repository
 *
 * This provides the interface to Administer the Implementation
 * Repository.
 */
class ImplRepo_i : public POA_ImplementationRepository::Administration
{
public:
  // = Constructor and destructor
  ImplRepo_i (void);
  ~ImplRepo_i (void);

  /// IOR_LookupTable_Callback method.  Will return an IOR
  char *find_ior (const ACE_CString &object_name,
                  CORBA::Environment &ACE_TRY_ENV)
    ACE_THROW_SPEC ((CORBA::SystemException, IORTable::NotFound));

  // = Interface methods

  /// Starts up the server <server> if not already running.
  virtual void activate_server (
      const char *server,
      CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()
    ) ACE_THROW_SPEC ((
          CORBA::SystemException,
          ImplementationRepository::Administration::NotFound,
          ImplementationRepository::Administration::CannotActivate
        ));

  /// Adds the server to the repository and registers the startup information
  /// about the server <server>.
  virtual void register_server (
      const char *server,
      const ImplementationRepository::StartupOptions &options,
      CORBA_Environment &ACE_TRY_ENV = TAO_default_environment ()
    ) ACE_THROW_SPEC ((
          CORBA::SystemException,
          ImplementationRepository::Administration::AlreadyRegistered
        ));

  /// Updates the startup information about the server <server>.
  virtual void reregister_server (
      const char *server,
      const ImplementationRepository::StartupOptions &options,
      CORBA_Environment &ACE_TRY_ENV = TAO_default_environment ()
    ) ACE_THROW_SPEC ((CORBA::SystemException));

  /// Removes the server <server> from the repository.
  virtual void remove_server (
      const char *server,
      CORBA_Environment &ACE_TRY_ENV = TAO_default_environment ()
    ) ACE_THROW_SPEC ((CORBA::SystemException,
                       ImplementationRepository::Administration::NotFound));

  /// Attempts to gracefully shut down the server, 
  virtual void shutdown_server (
      const char *server, 
      CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()
    ) ACE_THROW_SPEC ((CORBA::SystemException,
                       ImplementationRepository::Administration::NotFound));

  /// Called by the server to update transient information such as current
  /// location of the <server> and its ServerObject.
  virtual char *server_is_running (
      const char *server,
      const char *location,
      ImplementationRepository::ServerObject_ptr server_object,
      CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()
    ) ACE_THROW_SPEC ((CORBA::SystemException,
                       ImplementationRepository::Administration::NotFound));

  /// What the server should call before it shuts down.
  virtual void server_is_shutting_down (
      const char *server,
      CORBA_Environment &ACE_TRY_ENV = TAO_default_environment ()
    ) ACE_THROW_SPEC ((CORBA::SystemException,
                       ImplementationRepository::Administration::NotFound));

  /// Returns the startup information for a server
  virtual void find (
      const char *server,
      ImplementationRepository::ServerInformation_out info,
      CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()
    ) ACE_THROW_SPEC ((CORBA::SystemException,
                       ImplementationRepository::Administration::NotFound));

  /// Used to access the list of servers registered.  May also return an
  /// iterator which can be used to access more than <how_many> of them.
  virtual void list (
      CORBA::ULong how_many,
      ImplementationRepository::ServerInformationList_out server_list,
      ImplementationRepository::ServerInformationIterator_out server_iterator,
      CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()
    ) ACE_THROW_SPEC ((CORBA::SystemException));

  /// Initialize the Server state - parsing arguments and waiting.
  int init (CORBA_Environment &ACE_TRY_ENV = TAO_default_environment ());

  /// Cleans up any state created by init ().
  int fini (CORBA_Environment &ACE_TRY_ENV = TAO_default_environment ());

  /// Runs the orb.
  int run (CORBA_Environment &ACE_TRY_ENV = TAO_default_environment ());

private:
  /// Implementation of activate_server.  <check_startup> is a flag to check
  /// the activation mode before attempting to start it.
  ACE_TString activate_server_i (
      const char *server,
      const int check_startup,
      CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()
    ) ACE_THROW_SPEC ((
          CORBA::SystemException,
          ImplementationRepository::Administration::NotFound,
          ImplementationRepository::Administration::CannotActivate
        ));

  /// This method starts the server process.
  void start_server_i (
      const char *server,
      CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()
    ) ACE_THROW_SPEC ((
          CORBA::SystemException,
          ImplementationRepository::Administration::NotFound,
          ImplementationRepository::Administration::CannotActivate
        ));

  /// This method will continuously ping a server and either return when it
  /// responds to the ping or return -1 if it times out.
  int ready_check (const char *server)
    ACE_THROW_SPEC ((CORBA::SystemException,
                     ImplementationRepository::Administration::NotFound));

  /// Set up multicast handler, if multicast is enabled
  int setup_multicast (ACE_Reactor *reactor);

  /// The locator interface for the IORTable
  IORTable::Locator_var locator_;

  /// The Process Manager.
  ACE_Process_Manager process_mgr_;

  /// The class that handles the forwarding.
  ImR_Forwarder *forwarder_impl_;

  /// Used for the forwarding of any type of POA.
  ImR_Adapter_Activator *activator_;

  /// Repository containing information about each server.
  Server_Repository repository_;

  /// The Root POA for this ORB.
  PortableServer::POA_var root_poa_;

  /// Implementation Repository's POA.
  PortableServer::POA_var imr_poa_;

  /// Key of the obj ref of the server.
  char *server_key_;

  /// Copy of the filename for the server output file.
  char *server_input_file_;

  /// The ior_multicast event handler.
  TAO_IOR_Multicast *ior_multicast_;

  /// Implementation Repository's IOR.  Why do we store it here?  Multicast
  /// doesn't work otherwise.
  CORBA::String_var imr_ior_;

  /// Number of command line arguments.
  int argc_;

  /// The command line arguments.
  char **argv_;

  friend class ImR_Forwarder;
};

#endif /* IMPLREPO_I_H */