3 #include "tao/PortableServer/Object_Adapter.h"
4 #include "tao/PortableServer/POA_Current.h"
5 #include "tao/PortableServer/POA_Current_Impl.h"
11 test_i (CORBA::ORB_ptr orb
,
12 PortableServer::POA_ptr poa
);
14 void set_other (test_ptr test
);
18 PortableServer::POA_ptr
_default_POA ();
22 PortableServer::POA_var poa_
;
26 PortableServer::Current_var poa_current_
;
29 test_i::test_i (CORBA::ORB_ptr orb
,
30 PortableServer::POA_ptr poa
)
31 : orb_ (CORBA::ORB::_duplicate (orb
)),
32 poa_ (PortableServer::POA::_duplicate (poa
))
34 CORBA::Object_var object
;
37 this->orb_
->resolve_initial_references ("POACurrent");
40 PortableServer::Current::_narrow (object
.in ());
44 test_i::set_other (test_ptr test
)
46 this->other_
= test::_duplicate (test
);
52 if (this->other_
.in () != test::_nil ())
54 this->other_
->method ();
58 TAO::Portable_Server::POA_Current
&tao_poa_current
=
59 dynamic_cast <TAO::Portable_Server::POA_Current
&>
60 (*(this->poa_current_
.in ()));
62 TAO::Portable_Server::POA_Current_Impl
&tao_poa_current_implementation
=
63 *tao_poa_current
.implementation ();
65 const char *upcall
= 0;
66 if (tao_poa_current_implementation
.previous ())
67 upcall
= "collocated";
71 PortableServer::ObjectId_var id
=
72 this->poa_current_
->get_object_id ();
74 CORBA::String_var id_string
=
75 PortableServer::ObjectId_to_string (id
.in ());
78 "%C method() invoked for <%C> servant in thread %t\n",
84 PortableServer::POA_ptr
85 test_i::_default_POA ()
87 return PortableServer::POA::_duplicate (this->poa_
.in ());
90 class Task
: public ACE_Task_Base
93 Task (CORBA::ORB_ptr orb
);
100 Task::Task (CORBA::ORB_ptr orb
)
101 : orb_ (CORBA::ORB::_duplicate (orb
))
112 catch (const CORBA::Exception
&)
120 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
125 CORBA::ORB_init (argc
, argv
);
127 CORBA::Object_var object
=
128 orb
->resolve_initial_references ("RootPOA");
130 PortableServer::POA_var root_poa
=
131 PortableServer::POA::_narrow (object
.in ());
133 PortableServer::POAManager_var poa_manager
=
134 root_poa
->the_POAManager ();
136 poa_manager
->activate ();
138 Task
task (orb
.in ());
142 ACE_ASSERT (result
!= -1);
143 ACE_UNUSED_ARG (result
);
145 CORBA::PolicyList
policies (1);
149 root_poa
->create_id_assignment_policy (PortableServer::USER_ID
);
151 PortableServer::POA_var child_poa
=
152 root_poa
->create_POA ("child_poa",
156 test_i
*base_servant
=
157 new test_i (orb
.in (),
160 PortableServer::ServantBase_var
safe_base_servant (base_servant
);
162 PortableServer::ObjectId_var base_oid
=
163 PortableServer::string_to_ObjectId ("base");
165 child_poa
->activate_object_with_id (base_oid
.in (),
168 PortableServer::ObjectId_var id_act
=
169 root_poa
->activate_object (base_servant
);
171 CORBA::Object_var object_act
= root_poa
->id_to_reference (id_act
.in ());
174 test::_narrow (object_act
.in ());
176 test_i
*first_servant
=
177 new test_i (orb
.in (),
180 PortableServer::ServantBase_var
safe_first_servant (first_servant
);
182 PortableServer::ObjectId_var first_oid
=
183 PortableServer::string_to_ObjectId ("first");
185 child_poa
->activate_object_with_id (first_oid
.in (),
188 PortableServer::ObjectId_var id_actu
=
189 root_poa
->activate_object (first_servant
);
191 object_act
= root_poa
->id_to_reference (id_actu
.in ());
193 test_var first_test
=
194 test::_narrow (object_act
.in ());
196 base_servant
->set_other (first_test
.in ());
198 base_test
->method ();
200 PortableServer::ObjectId_var second_oid
=
201 PortableServer::string_to_ObjectId ("second");
204 child_poa
->create_reference_with_id (second_oid
.in (),
207 test_var second_test
=
208 test::_narrow (object
.in ());
210 test_i
*second_servant
=
211 new test_i (orb
.in (),
214 PortableServer::ServantBase_var
safe_second_servant (second_servant
);
216 child_poa
->activate_object_with_id (second_oid
.in (),
219 base_servant
->set_other (second_test
.in ());
221 base_test
->method ();
223 PortableServer::ObjectId_var third_oid
=
224 PortableServer::string_to_ObjectId ("third");
227 child_poa
->create_reference_with_id (third_oid
.in (),
230 CORBA::String_var third_ior
=
231 orb
->object_to_string (object
.in ());
234 orb
->string_to_object (third_ior
.in ());
236 test_var third_test
=
237 test::_narrow (object
.in ());
239 test_i
*third_servant
=
240 new test_i (orb
.in (),
243 PortableServer::ServantBase_var
safe_third_servant (third_servant
);
245 child_poa
->activate_object_with_id (third_oid
.in (),
248 base_servant
->set_other (third_test
.in ());
250 base_test
->method ();
252 orb
->shutdown (true);
254 result
= task
.wait ();
255 ACE_ASSERT (result
!= -1);
256 ACE_UNUSED_ARG (result
);
258 catch (const CORBA::Exception
& ex
)
260 ex
._tao_print_exception ("Caught exception:");