1 //============================================================================
7 // Server class to perform testing of TAO's collocation mechanism.
12 //=============================================================================
14 #include "Collocation_Tester.h"
16 Collocation_Test::Collocation_Test ()
21 Collocation_Test::shutdown ()
23 this->root_poa_
->destroy (1, 1);
24 this->orb_
->destroy ();
28 Collocation_Test::init (int argc
, ACE_TCHAR
*argv
[])
30 // Initialize the ORB.
31 this->orb_
= CORBA::ORB_init (argc
, argv
);
33 int result
= this->parse_args (argc
, argv
);
37 // Get an Object reference to RootPOA.
38 CORBA::Object_var obj
=
39 this->orb_
->resolve_initial_references ("RootPOA");
41 // Narrow the Object reference to a POA reference
43 PortableServer::POA::_narrow (obj
.in ());
45 // Get the POAManager of RootPOA
47 this->root_poa_
->the_POAManager ();
49 // Create our own child POA
50 // Empty sequence means all default policies
52 CORBA::PolicyList policies
;
55 policies
[nPolicies
++] =
56 this->root_poa_
->create_implicit_activation_policy(PortableServer::IMPLICIT_ACTIVATION
);
58 obj
= this->root_poa_
->create_POA("child", this->poa_manager_
.in(), policies
);
59 PortableServer::POA_var childPOA
= PortableServer::POA::_narrow (obj
.in ());
61 // Destroy the Policy objects (before we may exit as a result of failures)
62 for (CORBA::ULong i
= 0; i
< policies
.length(); ++i
)
64 policies
[i
]->destroy();
67 // Activate the diamond servant and its base classes under childPOA.
68 PortableServer::ObjectId_var id
=
69 childPOA
->activate_object (&this->top_servant_
);
71 // // We only care about the most derived class here.
72 // this->diamond_obj_ = this->diamond_servant_._this ();
75 childPOA
->activate_object (&this->diamond_servant_
);
77 // We only care about the most derived class here.
78 this->diamond_obj_
= childPOA
->id_to_reference (id
.in ());
81 childPOA
->activate_object (&this->left_servant_
);
84 childPOA
->activate_object (&this->right_servant_
);
87 CORBA::String_var str
=
88 this->orb_
->object_to_string (this->diamond_obj_
.in ());
90 ACE_DEBUG ((LM_DEBUG
, "Diamond Servant activated:\n %C\n",
98 Collocation_Test::parse_args (int /*argc*/,
99 ACE_TCHAR
*[] /*argv*/)
105 Collocation_Test::test_narrow ()
107 Diamond::Top_var top
=
108 Diamond::Top::_narrow (this->diamond_obj_
.in ());
110 Diamond::Left_var left
=
111 Diamond::Left::_narrow (this->diamond_obj_
.in ());
113 Diamond::Right_var right
=
114 Diamond::Right::_narrow (this->diamond_obj_
.in ());
116 Diamond::Buttom_var buttom
=
117 Diamond::Buttom::_narrow (this->diamond_obj_
.in ());
119 CORBA::String_var str
= top
->shape ();
120 ACE_DEBUG ((LM_DEBUG
, "Calling top->shape: %C\n", str
.in ()));
122 str
= left
->shape ();
123 ACE_DEBUG ((LM_DEBUG
, "Calling left->shape: %C\n", str
.in ()));
125 str
= right
->shape ();
126 ACE_DEBUG ((LM_DEBUG
, "Calling right->shape: %C\n", str
.in ()));
128 str
= buttom
->shape ();
129 ACE_DEBUG ((LM_DEBUG
, "Calling buttom->shape: %C\n", str
.in ()));
135 Collocation_Test::run ()
137 this->poa_manager_
->activate ();
139 this->test_narrow ();