CORBA::Boolean ImR_Adapter::unknown_adapter (PortableServer::POA_ptr parent, const char *name) { ACE_ASSERT (! CORBA::is_nil(parent)); ACE_ASSERT (name != 0); CORBA::PolicyList policies (3); const char *exception_message = "Null Message"; policies.length (3); try { // Servant Retention Policy exception_message = "While PortableServer::POA::create_servant_retention_policy"; policies[0] = parent->create_servant_retention_policy (PortableServer::NON_RETAIN); // Request Processing Policy exception_message = "While PortableServer::POA::create_request_processing_policy"; policies[1] = parent->create_request_processing_policy (PortableServer::USE_DEFAULT_SERVANT); policies[2] = parent->create_id_uniqueness_policy (PortableServer::MULTIPLE_ID); PortableServer::POAManager_var poa_manager = parent->the_POAManager (); exception_message = "While create_POA"; PortableServer::POA_var child = parent->create_POA (name, poa_manager.in (), policies); exception_message = "While policy->destroy"; for (CORBA::ULong i = 0; i < policies.length (); ++i) { CORBA::Policy_ptr policy = policies[i]; policy->destroy (); } exception_message = "While child->the_activator"; child->the_activator (this); exception_message = "While set_servant"; child->set_servant (this->default_servant_); } catch (const CORBA::Exception& ex) { ORBSVCS_ERROR ((LM_ERROR, "IMR_Adapter_Activator::unknown_adapter - %s\n", exception_message)); ex._tao_print_exception ("System Exception"); return 0; } // Finally, now everything is fine return 1; }
CORBA::Boolean Adapter_Activator::unknown_adapter (PortableServer::POA_ptr parent, const char *name) { if (ACE_OS::strcmp (name, "firstPOA") == 0) { PortableServer::POA_var child = parent->create_POA (name, this->poa_manager_.in (), this->first_poa_policies_); // Creation of firstPOA is over. Destroy the Policy objects. for (CORBA::ULong i = 0; i < this->first_poa_policies_.length (); ++i) { this->first_poa_policies_[i]->destroy (); } child->the_activator (this); reference_counted_test_i *servant = new reference_counted_test_i (this->orb_.in (), child.in ()); child->set_servant (servant); // This means that the ownership of <servant> now belongs to the // POA. servant->_remove_ref (); // Finally everything is fine return 1; } else if (ACE_OS::strcmp (name, "secondPOA") == 0) { PortableServer::POA_var child = parent->create_POA (name, this->poa_manager_.in (), this->second_poa_policies_); // Creation of secondPOA is over. Destroy the Policy objects. for (CORBA::ULong i = 0; i < this->second_poa_policies_.length (); ++i) { this->second_poa_policies_[i]->destroy (); } reference_counted_test_i *servant = new reference_counted_test_i (this->orb_.in (), child.in ()); PortableServer::ObjectId_var oid = PortableServer::string_to_ObjectId ("third test"); child->activate_object_with_id (oid.in (), servant); // This means that the ownership of <servant> now belongs to the // POA. servant->_remove_ref (); // Finally everything is fine return 1; } else { // Unknown POA. return 0; } }