Merge pull request #2301 from sonndinh/remove-dup-reactor-functions
[ACE_TAO.git] / TAO / tests / Two_Objects / Object_Factory_i.cpp
blobe14f9d6e7adfcd2498d7ec6a7bf2a63c51490fc5
1 #include "tao/ORB_Core.h"
2 #include "tao/debug.h"
3 #include "tao/Transport_Cache_Manager.h"
4 #include "Object_Factory_i.h"
5 #include "ace/Synch.h"
7 Object_Factory_i::Object_Factory_i (CORBA::ORB_ptr orb, CORBA::ULong len)
8 : orb_ (CORBA::ORB::_duplicate (orb)),
9 length_(len)
13 //factory method to create first object
14 Two_Objects_Test::First_ptr
15 Object_Factory_i::create_first ()
17 First_i *first_impl;
19 ACE_NEW_THROW_EX (first_impl,
20 First_i (orb_.in(), two_way_done_ ),
21 CORBA::NO_MEMORY());
22 // Ownership is transfered to the POA.
23 PortableServer::ServantBase_var safe (first_impl);
25 CORBA::Object_var poa_object =
26 this->orb_->resolve_initial_references("RootPOA");
28 PortableServer::POA_var root_poa =
29 PortableServer::POA::_narrow (poa_object.in ());
31 PortableServer::ObjectId_var id =
32 root_poa->activate_object (first_impl);
34 CORBA::Object_var object = root_poa->id_to_reference (id.in ());
36 Two_Objects_Test::First_var first =
37 Two_Objects_Test::First::_narrow (object.in ());
39 return first._retn();
42 //factory method to create second object
43 Two_Objects_Test::Second_ptr
44 Object_Factory_i::create_second ()
46 Second_i *second_impl;
48 ACE_NEW_THROW_EX (second_impl,
49 Second_i (orb_.in(),
50 length_, two_way_done_),
51 CORBA::NO_MEMORY ());
52 // Ownership is transfered to the POA.
53 PortableServer::ServantBase_var safe (second_impl);
55 CORBA::Object_var poa_object =
56 this->orb_->resolve_initial_references("RootPOA");
58 PortableServer::POA_var root_poa =
59 PortableServer::POA::_narrow (poa_object.in ());
61 PortableServer::ObjectId_var id =
62 root_poa->activate_object (second_impl);
64 CORBA::Object_var object = root_poa->id_to_reference (id.in ());
66 Two_Objects_Test::Second_var second =
67 Two_Objects_Test::Second::_narrow (object.in ());
69 return second._retn();