1 //============================================================================
7 // Server class to perform testing of TAO's collocation mechanism.
12 //=============================================================================
14 #include "Coll_Tester.h"
15 #include "Smart_Proxy_Impl.h"
17 Collocation_Test::Collocation_Test ()
22 Collocation_Test::init (int argc
, ACE_TCHAR
*argv
[])
24 // Initialize the ORB.
25 this->orb_
= CORBA::ORB_init (argc
, argv
);
27 int result
= this->parse_args (argc
, argv
);
31 // Get an Object reference to RootPOA.
32 CORBA::Object_var obj
=
33 this->orb_
->resolve_initial_references ("RootPOA");
35 // Narrow the Object reference to a POA reference
37 PortableServer::POA::_narrow (obj
.in ());
39 // Get the POAManager of RootPOA
41 this->root_poa_
->the_POAManager ();
43 // Activate the diamond servant and its base classes under RootPOA.
44 PortableServer::ObjectId_var id
=
45 this->root_poa_
->activate_object (&this->top_servant_
);
47 // // We only care about the most derived class here.
48 // this->diamond_obj_ = this->diamond_servant_._this ();
51 this->root_poa_
->activate_object (&this->diamond_servant_
);
53 // We only care about the most derived class here.
54 this->diamond_obj_
= this->root_poa_
->id_to_reference (id
.in ());
57 this->root_poa_
->activate_object (&this->left_servant_
);
60 this->root_poa_
->activate_object (&this->right_servant_
);
62 CORBA::String_var str
=
63 this->orb_
->object_to_string (this->diamond_obj_
.in ());
65 ACE_DEBUG ((LM_DEBUG
, "Diamond Servant activated:\n %s\n",
73 Collocation_Test::parse_args (int, ACE_TCHAR
*[])
79 Collocation_Test::test_narrow ()
81 // Ensure that the smart proxy is the one which is used by registering
82 // the user-defined factory. Its necessary to create one on the heap so
83 // the lifetime of the factory object can be managed by the framework.
84 Smart_Diamond_Top_Factory
*factory
= 0;
85 ACE_NEW_RETURN (factory
,
86 Smart_Diamond_Top_Factory
,
89 Diamond::Top_var top
=
90 Diamond::Top::_narrow (this->diamond_obj_
.in());
92 Diamond::Left_var left
=
93 Diamond::Left::_narrow (this->diamond_obj_
.in());
95 Diamond::Right_var right
=
96 Diamond::Right::_narrow (this->diamond_obj_
.in());
98 Diamond::Buttom_var buttom
=
99 Diamond::Buttom::_narrow (this->diamond_obj_
.in());
101 CORBA::String_var str
= top
->shape ();
102 ACE_DEBUG ((LM_DEBUG
, "Calling top->shape: %s\n", str
.in ()));
104 str
= left
->shape ();
105 ACE_DEBUG ((LM_DEBUG
, "Calling left->shape: %s\n", str
.in ()));
107 str
= right
->shape ();
108 ACE_DEBUG ((LM_DEBUG
, "Calling right->shape: %s\n", str
.in ()));
110 str
= buttom
->shape ();
111 ACE_DEBUG ((LM_DEBUG
, "Calling buttom->shape: %s\n", str
.in ()));
117 Collocation_Test::run ()
119 this->poa_manager_
->activate ();
121 this->test_narrow ();