diff options
author | marina <marina@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-04-30 03:08:20 +0000 |
---|---|---|
committer | marina <marina@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-04-30 03:08:20 +0000 |
commit | 31b601952865640ccb90dad903968819ba868118 (patch) | |
tree | eb189ff31b1853e0e36ae2e91cb2839b90bd256e /TAO/orbsvcs/tests/Simple_Naming | |
parent | 61ee4a5a3a07e2d511e4c9b2100818a5ccc87e2f (diff) | |
download | ATCD-31b601952865640ccb90dad903968819ba868118.tar.gz |
Updated the dummy servants to use POA reference counting
Diffstat (limited to 'TAO/orbsvcs/tests/Simple_Naming')
-rw-r--r-- | TAO/orbsvcs/tests/Simple_Naming/client.cpp | 211 |
1 files changed, 63 insertions, 148 deletions
diff --git a/TAO/orbsvcs/tests/Simple_Naming/client.cpp b/TAO/orbsvcs/tests/Simple_Naming/client.cpp index 981c364b88c..1fbb81dbfc9 100644 --- a/TAO/orbsvcs/tests/Simple_Naming/client.cpp +++ b/TAO/orbsvcs/tests/Simple_Naming/client.cpp @@ -23,7 +23,13 @@ ACE_RCSID(Simple_Naming, client, "$Id$") -class My_Test_Object : public POA_Test_Object +#if defined (_MSC_VER) +# pragma warning (disable : 4250) +#endif /* _MSC_VER */ + +class My_Test_Object : + public virtual PortableServer::RefCountServantBase, + public virtual POA_Test_Object { public: // = Initialization and termination methods. @@ -343,13 +349,17 @@ MT_Test::execute (TAO_Naming_Client &root_context) // Create data which will be used by all threads. // Dummy object instantiation. - My_Test_Object test_obj_impl (CosNaming_Client::OBJ1_ID); + My_Test_Object *test_obj_impl = + new My_Test_Object (CosNaming_Client::OBJ1_ID); ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY { test_ref_ = - test_obj_impl._this (ACE_TRY_ENV); + test_obj_impl->_this (ACE_TRY_ENV); + ACE_TRY_CHECK; + + test_obj_impl->_remove_ref (ACE_TRY_ENV); ACE_TRY_CHECK; // Get the IOR for the Naming Service. Each thread @@ -380,44 +390,29 @@ MT_Test::execute (TAO_Naming_Client &root_context) int status = this->activate (THR_NEW_LWP | THR_JOINABLE, size_); - // @@The code below isn't right for cases with error conditions. - // The proper thing to do is to make impl objects deregister from - // poa in their destructors. - if (status == -1) return -1; else - this->wait (); - - // Now, unregister our servant from POA before exiting - PortableServer::POA_var poa = - test_obj_impl._default_POA (); - - PortableServer::ObjectId_var id = - poa->servant_to_id (&test_obj_impl, - ACE_TRY_ENV); - ACE_CHECK_RETURN (-1); - - poa->deactivate_object (id.in (), - ACE_TRY_ENV); - ACE_CHECK_RETURN (-1); - - return 0; + return this->wait (); } int Loop_Test::execute (TAO_Naming_Client &root_context) { // Create a dummy object. - My_Test_Object test_obj_impl (CosNaming_Client::OBJ1_ID); + My_Test_Object * test_obj_impl = + new My_Test_Object (CosNaming_Client::OBJ1_ID); Test_Object_var test_ref; ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY_EX (SETUP) { test_ref = - test_obj_impl._this (ACE_TRY_ENV); + test_obj_impl->_this (ACE_TRY_ENV); ACE_TRY_CHECK_EX (SETUP); + + test_obj_impl->_remove_ref (ACE_TRY_ENV); + ACE_TRY_CHECK_EX (SETUP); } ACE_CATCHANY { @@ -541,9 +536,13 @@ Simple_Test::execute (TAO_Naming_Client &root_context) ACE_TRY { // Dummy object instantiation. - My_Test_Object test_obj_impl (CosNaming_Client::OBJ1_ID); + My_Test_Object *test_obj_impl = new My_Test_Object (CosNaming_Client::OBJ1_ID); Test_Object_var test_obj_ref = - test_obj_impl._this (ACE_TRY_ENV); + test_obj_impl->_this (ACE_TRY_ENV); + ACE_TRY_CHECK; + + // Give ownership of this object to POA. + test_obj_impl->_remove_ref (ACE_TRY_ENV); ACE_TRY_CHECK; // Bind an object to the Naming Context. @@ -578,19 +577,6 @@ Simple_Test::execute (TAO_Naming_Client &root_context) ACE_TRY_CHECK; ACE_DEBUG ((LM_DEBUG, "Unbound name OK\n")); - - // Now, unregister our servant from POA before exiting - PortableServer::POA_var poa = - test_obj_impl._default_POA (); - - PortableServer::ObjectId_var id = - poa->servant_to_id (&test_obj_impl, - ACE_TRY_ENV); - ACE_TRY_CHECK; - - poa->deactivate_object (id.in (), - ACE_TRY_ENV); - ACE_TRY_CHECK; } ACE_CATCHANY { @@ -627,9 +613,13 @@ Tree_Test::execute (TAO_Naming_Client &root_context) ACE_TRY_CHECK; // Instantiate a dummy object and bind it under the new context. - My_Test_Object impl1 (CosNaming_Client::OBJ1_ID); - Test_Object_var obj1 = impl1._this (ACE_TRY_ENV); + My_Test_Object *impl1 = + new My_Test_Object (CosNaming_Client::OBJ1_ID); + Test_Object_var obj1 = impl1->_this (ACE_TRY_ENV); + ACE_TRY_CHECK; + impl1->_remove_ref (ACE_TRY_ENV); ACE_TRY_CHECK; + CosNaming::Name obj_name; obj_name.length (1); obj_name[0].id = CORBA::string_dup ("foo"); @@ -703,9 +693,14 @@ Tree_Test::execute (TAO_Naming_Client &root_context) -1); ACE_TRY_CHECK; - My_Test_Object impl2 (CosNaming_Client::OBJ2_ID); - Test_Object_var obj2 = impl2._this (ACE_TRY_ENV); + My_Test_Object *impl2 = + new My_Test_Object (CosNaming_Client::OBJ2_ID); + Test_Object_var obj2 = impl2->_this (ACE_TRY_ENV); ACE_TRY_CHECK; + + impl2->_remove_ref (ACE_TRY_ENV); + ACE_TRY_CHECK; + root_context->rebind (test_name, obj2.in (), ACE_TRY_ENV); @@ -722,22 +717,6 @@ Tree_Test::execute (TAO_Naming_Client &root_context) "Problems with rebind in Tree Test\n"), -1); ACE_TRY_CHECK; - - // Now, unregister our servant from POA before exiting. - PortableServer::POA_var poa = impl1._default_POA (); - - PortableServer::ObjectId_var id = - poa->servant_to_id (&impl1, ACE_TRY_ENV); - ACE_TRY_CHECK; - - poa->deactivate_object (id.in (), ACE_TRY_ENV); - ACE_TRY_CHECK; - - id = poa->servant_to_id (&impl2, ACE_TRY_ENV); - ACE_TRY_CHECK; - - poa->deactivate_object (id.in (), ACE_TRY_ENV); - ACE_TRY_CHECK; } ACE_CATCHANY @@ -777,9 +756,12 @@ Exceptions_Test::execute (TAO_Naming_Client &root_context) ACE_TRY_CHECK; // Bind a dummy object foo under each context. - My_Test_Object impl; - Test_Object_var obj = impl._this (ACE_TRY_ENV); + My_Test_Object *impl = new My_Test_Object; + Test_Object_var obj = impl->_this (ACE_TRY_ENV); + ACE_TRY_CHECK; + impl->_remove_ref (ACE_TRY_ENV); ACE_TRY_CHECK; + CosNaming::Name object_name; object_name.length (1); object_name[0].id = CORBA::string_dup ("foo"); @@ -817,18 +799,6 @@ Exceptions_Test::execute (TAO_Naming_Client &root_context) not_found_test3 (root_context, ACE_TRY_ENV); ACE_TRY_CHECK; - - // Now, unregister our servant from POA before exiting. - PortableServer::POA_var poa = impl._default_POA (); - - PortableServer::ObjectId_var id = - poa->servant_to_id (&impl, - ACE_TRY_ENV); - ACE_TRY_CHECK; - - poa->deactivate_object (id.in (), - ACE_TRY_ENV); - ACE_TRY_CHECK; } ACE_CATCHANY { @@ -879,19 +849,12 @@ Exceptions_Test::already_bound_test (TAO_Naming_Client &root_context, CosNaming::Name test_name; test_name.length (1); test_name[0].id = CORBA::string_dup ("foo"); - My_Test_Object impl; - Test_Object_var obj = impl._this (ACE_TRY_ENV); + My_Test_Object *impl = new My_Test_Object; + Test_Object_var obj = impl->_this (ACE_TRY_ENV); ACE_TRY_CHECK; - // Now, unregister our servant from POA. - PortableServer::POA_var poa = impl._default_POA (); - PortableServer::ObjectId_var id = - poa->servant_to_id (&impl, - ACE_TRY_ENV); - ACE_TRY_CHECK; - poa->deactivate_object (id.in (), - ACE_TRY_ENV); + impl->_remove_ref (ACE_TRY_ENV); ACE_TRY_CHECK; - + root_context->bind (test_name, obj.in (), ACE_TRY_ENV); @@ -924,17 +887,10 @@ Exceptions_Test::already_bound_test2 (TAO_Naming_Client &root_context, test_name.length (2); test_name[0].id = CORBA::string_dup ("level1_context"); test_name[1].id = CORBA::string_dup ("foo"); - My_Test_Object impl; - Test_Object_var obj = impl._this (ACE_TRY_ENV); + My_Test_Object *impl = new My_Test_Object; + Test_Object_var obj = impl->_this (ACE_TRY_ENV); ACE_TRY_CHECK; - // Now, unregister our servant from POA before exiting. - PortableServer::POA_var poa = impl._default_POA (); - PortableServer::ObjectId_var id = - poa->servant_to_id (&impl, - ACE_TRY_ENV); - ACE_TRY_CHECK; - poa->deactivate_object (id.in (), - ACE_TRY_ENV); + impl->_remove_ref (ACE_TRY_ENV); ACE_TRY_CHECK; root_context->bind (test_name, @@ -1089,17 +1045,10 @@ Iterator_Test::execute (TAO_Naming_Client &root_context) ACE_TRY { // Instantiate four dummy objects. - My_Test_Object impl1; - Test_Object_var obj1 = impl1._this (ACE_TRY_ENV); - ACE_TRY_CHECK; - My_Test_Object impl2; - Test_Object_var obj2 = impl2._this (ACE_TRY_ENV); + My_Test_Object *impl = new My_Test_Object; + Test_Object_var obj = impl->_this (ACE_TRY_ENV); ACE_TRY_CHECK; - My_Test_Object impl3; - Test_Object_var obj3 = impl3._this (ACE_TRY_ENV); - ACE_TRY_CHECK; - My_Test_Object impl4; - Test_Object_var obj4 = impl4._this (ACE_TRY_ENV); + impl->_remove_ref (ACE_TRY_ENV); ACE_TRY_CHECK; // Bind objects to the naming context. @@ -1116,19 +1065,19 @@ Iterator_Test::execute (TAO_Naming_Client &root_context) name4.length (1); name4[0].id = CORBA::string_dup ("foo4"); root_context->bind (name1, - obj1.in (), + obj.in (), ACE_TRY_ENV); ACE_TRY_CHECK; root_context->bind (name2, - obj2.in (), + obj.in (), ACE_TRY_ENV); ACE_TRY_CHECK; root_context->bind (name3, - obj3.in (), + obj.in (), ACE_TRY_ENV); ACE_TRY_CHECK; root_context->bind (name4, - obj4.in (), + obj.in (), ACE_TRY_ENV); ACE_TRY_CHECK; @@ -1188,33 +1137,6 @@ Iterator_Test::execute (TAO_Naming_Client &root_context) -1); iter->destroy (ACE_TRY_ENV); ACE_TRY_CHECK; - - PortableServer::POA_var poa = impl1._default_POA (); - - PortableServer::ObjectId_var id = - poa->servant_to_id (&impl1, ACE_TRY_ENV); - ACE_TRY_CHECK; - - poa->deactivate_object (id.in (), ACE_TRY_ENV); - ACE_TRY_CHECK; - - id = poa->servant_to_id (&impl2, ACE_TRY_ENV); - ACE_TRY_CHECK; - - poa->deactivate_object (id.in (), ACE_TRY_ENV); - ACE_TRY_CHECK; - - id = poa->servant_to_id (&impl3, ACE_TRY_ENV); - ACE_TRY_CHECK; - - poa->deactivate_object (id.in (), ACE_TRY_ENV); - ACE_TRY_CHECK; - - id = poa->servant_to_id (&impl4, ACE_TRY_ENV); - ACE_TRY_CHECK; - - poa->deactivate_object (id.in (), ACE_TRY_ENV); - ACE_TRY_CHECK; } ACE_CATCHANY { @@ -1240,9 +1162,12 @@ Destroy_Test::execute (TAO_Naming_Client &root_context) ACE_TRY_CHECK; // Bind a dummy object foo under my_context. - My_Test_Object impl; - Test_Object_var obj = impl._this (ACE_TRY_ENV); + My_Test_Object *impl = new My_Test_Object; + Test_Object_var obj = impl->_this (ACE_TRY_ENV); ACE_TRY_CHECK; + impl->_remove_ref (ACE_TRY_ENV); + ACE_TRY_CHECK; + CosNaming::Name object_name; object_name.length (1); object_name[0].id = CORBA::string_dup ("foo"); @@ -1264,16 +1189,6 @@ Destroy_Test::execute (TAO_Naming_Client &root_context) not_exist_test (my_context, ACE_TRY_ENV); ACE_TRY_CHECK; - - // Now, unregister our servant from POA before exiting. - PortableServer::POA_var poa = impl._default_POA (); - - PortableServer::ObjectId_var id = - poa->servant_to_id (&impl, ACE_TRY_ENV); - ACE_TRY_CHECK; - - poa->deactivate_object (id.in (), ACE_TRY_ENV); - ACE_TRY_CHECK; } ACE_CATCHANY |