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
|
//=============================================================================
/**
* @file Iterator.cpp
*
* $Id$
*
* @brief This file declares ImR's iterator.
*
* @author Darrell Brunsch <brunsch@cs.wustl.edu>
*/
//=============================================================================
#include "Iterator.h"
// Plain old constructor
ImR_Iterator::ImR_Iterator (Server_Repository::HASH_IMR_ITER *iterator,
PortableServer::POA_ptr poa)
: iterator_ (iterator),
poa_ (poa)
{
// Nothing
}
// Destructor
ImR_Iterator::~ImR_Iterator ()
{
delete iterator_;
}
// Returns the next list of up to <how_many> servers. If empty, will return
// false.
CORBA::Boolean
ImR_Iterator::next_n (CORBA::ULong how_many,
ImplementationRepository::ServerInformationList_out server_list
TAO_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
ACE_NEW_THROW_EX (server_list,
ImplementationRepository::ServerInformationList (0),
CORBA::NO_MEMORY ());
// If there are no more bindings...
if (this->iterator_->done ())
return 0; // Return false
// Initially assume that iterator has the requested number of
// bindings.
server_list->length (how_many);
Server_Repository::HASH_IMR_ENTRY *server_entry;
// Iterate and populate the BindingList.
for (CORBA::ULong i = 0; i < how_many; i++)
{
this->iterator_->next (server_entry);
ACE_TString logical, server, command_line, working_directory, location, server_ior;
ImplementationRepository::EnvironmentList environment_vars;
ImplementationRepository::ActivationMode activation =
ImplementationRepository::NORMAL;
server_entry->int_id_->get_running_info (location, server_ior);
server_entry->int_id_->get_startup_info (logical,
command_line,
environment_vars,
working_directory,
activation);
server_list[i].logical_server = CORBA::string_dup (logical.c_str ());
server_list[i].server = CORBA::string_dup (server_entry->ext_id_.c_str ());
server_list[i].startup.command_line = CORBA::string_dup (command_line.c_str ());
server_list[i].startup.environment = environment_vars;
server_list[i].startup.working_directory = CORBA::string_dup (working_directory.c_str ());
server_list[i].startup.activation = activation;
server_list[i].location = CORBA::string_dup (location.c_str ());
if (this->iterator_->advance () == 0)
{
// If no more servers left, reset length to the actual
// number servers and get out of the loop.
server_list->length (i + 1);
break;
}
}
return 1;
}
// Destroys the iterator.
void
ImR_Iterator::destroy (TAO_ENV_SINGLE_ARG_DECL_NOT_USED)
ACE_THROW_SPEC ((CORBA::SystemException))
{
}
|