diff options
Diffstat (limited to 'TAO/examples/CSD_Strategy/ThreadPool4/ServerApp.cpp')
-rw-r--r-- | TAO/examples/CSD_Strategy/ThreadPool4/ServerApp.cpp | 80 |
1 files changed, 26 insertions, 54 deletions
diff --git a/TAO/examples/CSD_Strategy/ThreadPool4/ServerApp.cpp b/TAO/examples/CSD_Strategy/ThreadPool4/ServerApp.cpp index f5e5a1006d8..ef97fc97748 100644 --- a/TAO/examples/CSD_Strategy/ThreadPool4/ServerApp.cpp +++ b/TAO/examples/CSD_Strategy/ThreadPool4/ServerApp.cpp @@ -29,13 +29,12 @@ int ServerApp::run(int argc, char* argv[] ACE_ENV_ARG_DECL) { this->orb_ = CORBA::ORB_init(argc, argv, "" ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); // Parse the command-line args for this application. // * Raises -1 if problems are encountered. // * Returns 1 if the usage statement was explicitly requested. // * Returns 0 otherwise. - int result = this->parse_args(argc, argv); + int result = this->parse_args(argc, argv); if (result != 0) { return result; @@ -46,14 +45,12 @@ ServerApp::run(int argc, char* argv[] ACE_ENV_ARG_DECL) if (synch_with_server_) { CORBA::Object_var manager_object = - orb_->resolve_initial_references("ORBPolicyManager" + orb_->resolve_initial_references("ORBPolicyManager" ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); - CORBA::PolicyManager_var policy_manager - = CORBA::PolicyManager::_narrow(manager_object.in() + CORBA::PolicyManager_var policy_manager + = CORBA::PolicyManager::_narrow(manager_object.in() ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); if (CORBA::is_nil (policy_manager.in ())) { @@ -64,27 +61,23 @@ ServerApp::run(int argc, char* argv[] ACE_ENV_ARG_DECL) CORBA::Any policy_value; policy_value <<= Messaging::SYNC_WITH_SERVER; - CORBA::PolicyList policies(1); + CORBA::PolicyList policies(1); policies.length(1); policies[0] = orb_->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE, policy_value ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); policy_manager->set_policy_overrides (policies, CORBA::ADD_OVERRIDE ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); - policies[0]->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); + policies[0]->destroy (); } - CORBA::Object_var obj + CORBA::Object_var obj = orb_->resolve_initial_references("RootPOA" ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); if (CORBA::is_nil(obj.in())) { @@ -93,9 +86,8 @@ ServerApp::run(int argc, char* argv[] ACE_ENV_ARG_DECL) ACE_THROW_RETURN (TestException(), -1); } - PortableServer::POA_var root_poa + PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj.in() ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); if (CORBA::is_nil(root_poa.in())) { @@ -104,23 +96,20 @@ ServerApp::run(int argc, char* argv[] ACE_ENV_ARG_DECL) ACE_THROW_RETURN (TestException(), -1); } - PortableServer::POAManager_var poa_manager - = root_poa->the_POAManager(ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); + PortableServer::POAManager_var poa_manager + = root_poa->the_POAManager(); // Create the child POA. CORBA::PolicyList policies(1); policies.length(1); - policies[0] = root_poa->create_id_assignment_policy(PortableServer::USER_ID + policies[0] = root_poa->create_id_assignment_policy(PortableServer::USER_ID ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); PortableServer::POA_var child_poa_1 = root_poa->create_POA("ChildPoa_1", poa_manager.in(), policies ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); if (CORBA::is_nil(child_poa_1.in())) { @@ -133,7 +122,6 @@ ServerApp::run(int argc, char* argv[] ACE_ENV_ARG_DECL) poa_manager.in(), policies ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); if (CORBA::is_nil(child_poa_2.in())) { @@ -142,8 +130,7 @@ ServerApp::run(int argc, char* argv[] ACE_ENV_ARG_DECL) ACE_THROW_RETURN (TestException(), -1); } - policies[0]->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); + policies[0]->destroy (); // Create the thread pool servant dispatching strategy object, and // hold it in a (local) smart pointer variable. @@ -161,33 +148,27 @@ ServerApp::run(int argc, char* argv[] ACE_ENV_ARG_DECL) "Failed to apply custom dispatching strategy to child poa 1.\n")); ACE_THROW_RETURN (TestException(), -1); } - ACE_CHECK_RETURN (-1); - Foo_var foo1 = this->create_foo(child_poa_1.in(), + Foo_var foo1 = this->create_foo(child_poa_1.in(), "foo_applied_strategy" ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); - Foo_var foo2 = this->create_foo(child_poa_2.in(), + Foo_var foo2 = this->create_foo(child_poa_2.in(), "foo_not_applied_strategy" ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); - Callback_var callback1 - = this->create_callback(child_poa_1.in(), + Callback_var callback1 + = this->create_callback(child_poa_1.in(), "callback_applied_strategy" ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); - Callback_var callback2 - = this->create_callback(child_poa_2.in(), + Callback_var callback2 + = this->create_callback(child_poa_2.in(), "callback_not_applied_strategy" ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); // Activate the POA Manager - poa_manager->activate(ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); + poa_manager->activate(); ACE_DEBUG((LM_DEBUG, "(%P|%t) ServerApp is ready. Running the ORB event loop.\n")); @@ -195,7 +176,7 @@ ServerApp::run(int argc, char* argv[] ACE_ENV_ARG_DECL) // Wait for the custom stretegy launch the dispatching threads. ACE_OS::sleep (2); - ClientTask client1 (foo1.in (), callback1.in ()); + ClientTask client1 (foo1.in (), callback1.in ()); if (client1.open() != 0) { ACE_ERROR((LM_ERROR, @@ -212,8 +193,7 @@ ServerApp::run(int argc, char* argv[] ACE_ENV_ARG_DECL) } // Run the ORB event loop. - orb_->run(ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); + orb_->run(); ACE_DEBUG((LM_DEBUG, "(%P|%t) ServerApp ORB has stopped running.\n")); @@ -237,13 +217,11 @@ ServerApp::run(int argc, char* argv[] ACE_ENV_ARG_DECL) // Tear-down the root poa and orb_. root_poa->destroy(1, 1 ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); ACE_DEBUG((LM_DEBUG, "(%P|%t) ServerApp is destroying the ORB.\n")); - orb_->destroy(ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); + orb_->destroy(); ACE_DEBUG((LM_DEBUG, "(%P|%t) ServerApp has completed running successfully.\n")); @@ -281,25 +259,23 @@ ServerApp::parse_args(int argc, char* argv[]) return 0; } - + Foo_ptr ServerApp::create_foo ( - PortableServer::POA_ptr poa, + PortableServer::POA_ptr poa, const char* servant_name ACE_ENV_ARG_DECL) { - PortableServer::ServantBase_var servant + PortableServer::ServantBase_var servant = new Foo_i(servant_name); PortableServer::ObjectId_var id = PortableServer::string_to_ObjectId(servant_name); poa->activate_object_with_id(id.in(), servant.in() ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (Foo::_nil ()); CORBA::Object_var obj = poa->id_to_reference(id.in() ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (Foo::_nil ()); if (CORBA::is_nil(obj.in())) { @@ -310,7 +286,6 @@ ServerApp::create_foo ( } Foo_var foo = Foo::_narrow (obj.in () ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (Foo::_nil ()); return foo._retn (); } @@ -321,17 +296,15 @@ ServerApp::create_callback( const char* servant_name ACE_ENV_ARG_DECL) { - PortableServer::ServantBase_var servant + PortableServer::ServantBase_var servant = new Callback_i(); PortableServer::ObjectId_var id = PortableServer::string_to_ObjectId("callback"); poa->activate_object_with_id(id.in(), servant.in() ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (Callback::_nil ()); CORBA::Object_var obj = poa->id_to_reference(id.in() ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (Callback::_nil ()); if (CORBA::is_nil(obj.in())) { @@ -342,7 +315,6 @@ ServerApp::create_callback( } Callback_var callback = Callback::_narrow (obj.in () ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (Callback::_nil ()); return callback._retn (); } |