1 #include "FooServantList.h"
3 #include "OrbShutdownTask.h"
5 FooServantList::FooServantList(const ACE_TCHAR
* prefix
,
10 num_servants_(num_servants
),
11 num_clients_(num_clients
),
12 orb_ (CORBA::ORB::_duplicate(orb
))
14 this->servants_
= new PortableServer::ServantBase_var
[num_servants
];
18 FooServantList::~FooServantList()
20 delete [] this->servants_
;
25 FooServantList::create_and_activate(PortableServer::POA_ptr poa
)
27 for (unsigned i
= 0; i
< this->num_servants_
; i
++)
30 ACE_OS::sprintf(buf
, ACE_TEXT("%02d"), i
+ 1);
31 ACE_TString servant_name
= this->prefix_
+ ACE_TEXT("_") + buf
;
33 this->servants_
[i
] = new Foo_i(servant_name
.c_str(),this);
35 PortableServer::ObjectId_var id
=
36 PortableServer::string_to_ObjectId(ACE_TEXT_ALWAYS_CHAR(servant_name
.c_str()));
38 poa
->activate_object_with_id(id
.in(),
39 this->servants_
[i
].in());
41 CORBA::Object_var obj
= poa
->id_to_reference(id
.in());
43 if (CORBA::is_nil(obj
.in()))
46 "(%P|%t) Failed to activate servant (%s).\n",
47 servant_name
.c_str()));
48 throw TestException();
52 = this->orb_
->object_to_string(obj
.in());
54 ACE_TString filename
= servant_name
+ ACE_TEXT(".ior");
55 FILE* ior_file
= ACE_OS::fopen(filename
.c_str(), "w");
60 "(%P|%t) Cannot open output file (%s) for writing IOR.",
62 throw TestException();
65 ACE_OS::fprintf(ior_file
, "%s", ior
.in());
66 ACE_OS::fclose(ior_file
);
72 FooServantList::client_done()
74 unsigned num_left
= --this->num_clients_
;
78 if (TheOrbShutdownTask::instance()->open(0) != 0)
80 ACE_ERROR((LM_ERROR
, "(%P|%t)FooServantList::client_done: "
81 "failed to create orb shutdown thread.\n"));