Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / Bug_2084_Regression / Client_Task.cpp
blob0d9904744fcd5f9a0a670cba8b1fb3f27bcc4fea
2 #include "Client_Task.h"
3 #include "TestC.h"
4 #include "Hello.h"
5 #include "tao/ORB_Core.h"
6 #include "tao/PortableServer/PortableServer.h"
8 Client_Task::Client_Task (const ACE_TCHAR *ior,
9 CORBA::ORB_ptr corb,
10 ACE_Thread_Manager *thr_mgr)
11 : ACE_Task_Base (thr_mgr)
12 , input_ (ior)
13 , corb_ (CORBA::ORB::_duplicate (corb))
18 int
19 Client_Task::svc (void)
21 try
23 CORBA::Object_var poa_object =
24 this->corb_->resolve_initial_references("RootPOA");
26 PortableServer::POA_var root_poa =
27 PortableServer::POA::_narrow (poa_object.in ());
29 if (CORBA::is_nil (root_poa.in ()))
30 ACE_ERROR_RETURN ((LM_ERROR,
31 " (%P|%t) Panic: nil RootPOA\n"),
32 1);
34 PortableServer::POAManager_var poa_manager =
35 root_poa->the_POAManager ();
37 Hello *hello_impl = 0;
38 ACE_NEW_RETURN (hello_impl,
39 Hello (this->corb_.in (),
40 ACE_Thread::self ()),
41 1);
43 PortableServer::ServantBase_var owner_transfer(hello_impl);
45 PortableServer::ObjectId_var id =
46 root_poa->activate_object (hello_impl);
48 CORBA::Object_var object = root_poa->id_to_reference (id.in ());
50 Test::Hello_var hello_servant = Test::Hello::_narrow (object.in ());
51 poa_manager->activate ();
53 ACE_DEBUG((LM_DEBUG,"Client (%t) optimize_collocation_objects=%d use_global_collocation=%d\n",
54 corb_->orb_core()->optimize_collocation_objects(),
55 corb_->orb_core()->use_global_collocation ()));
57 CORBA::Object_var tmp =
58 this->corb_->string_to_object (input_);
60 Test::EventNode_var evNode=
61 Test::EventNode::_narrow(tmp.in ());
63 if (CORBA::is_nil (evNode.in ()))
65 ACE_ERROR_RETURN ((LM_DEBUG,
66 "Nil Test::EventNode reference <%s>\n",
67 input_),
68 1);
71 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Client starting\n"));
73 evNode->registerHello( hello_servant.in() );
75 evNode->shutdown ();
77 catch (const CORBA::Exception& ex)
79 ex._tao_print_exception ("Exception caught:");
80 return 1;
83 return 0;