00001 // -*- C++ -*- 00002 //============================================================================= 00003 /** 00004 * @file Adapter_Activator.cpp 00005 * 00006 * Adapter_Activator.cpp,v 1.8 2006/01/04 16:10:11 giovannd Exp 00007 * 00008 * @author Darrell Brunsch <brunsch@cs.wustl.edu> 00009 */ 00010 //============================================================================= 00011 00012 #include "Adapter_Activator.h" 00013 00014 #include "ace/Log_Msg.h" 00015 00016 ImR_Adapter::ImR_Adapter (void) 00017 : servant_locator_ (0) 00018 { 00019 } 00020 00021 void 00022 ImR_Adapter::init (PortableServer::ServantLocator_ptr servant) 00023 { 00024 servant_locator_ = servant; 00025 } 00026 00027 CORBA::Boolean 00028 ImR_Adapter::unknown_adapter (PortableServer::POA_ptr parent, 00029 const char *name 00030 ACE_ENV_ARG_DECL) 00031 ACE_THROW_SPEC ((CORBA::SystemException)) 00032 { 00033 ACE_ASSERT (! CORBA::is_nil(parent)); 00034 ACE_ASSERT (name != 0); 00035 CORBA::PolicyList policies (2); 00036 policies.length (2); 00037 00038 const char *exception_message = "Null Message"; 00039 00040 ACE_TRY 00041 { 00042 // Servant Retention Policy 00043 exception_message = "While PortableServer::POA::create_servant_retention_policy"; 00044 policies[0] = 00045 parent->create_servant_retention_policy (PortableServer::NON_RETAIN ACE_ENV_ARG_PARAMETER); 00046 ACE_TRY_CHECK; 00047 00048 // Request Processing Policy 00049 exception_message = "While PortableServer::POA::create_request_processing_policy"; 00050 policies[1] = 00051 parent->create_request_processing_policy (PortableServer::USE_SERVANT_MANAGER ACE_ENV_ARG_PARAMETER); 00052 ACE_TRY_CHECK; 00053 00054 PortableServer::POAManager_var poa_manager = 00055 parent->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); 00056 ACE_TRY_CHECK; 00057 00058 exception_message = "While create_POA"; 00059 PortableServer::POA_var child = 00060 parent->create_POA (name, 00061 poa_manager.in (), 00062 policies 00063 ACE_ENV_ARG_PARAMETER); 00064 ACE_TRY_CHECK; 00065 00066 exception_message = "While unknown_adapter::policy->destroy"; 00067 for (CORBA::ULong i = 0; i < policies.length (); ++i) 00068 { 00069 CORBA::Policy_ptr policy = policies[i]; 00070 policy->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); 00071 ACE_TRY_CHECK; 00072 } 00073 00074 exception_message = "While child->the_activator"; 00075 child->the_activator (this ACE_ENV_ARG_PARAMETER); 00076 ACE_TRY_CHECK; 00077 00078 exception_message = "While unknown_adapter, set_servant_manager"; 00079 child->set_servant_manager (this->servant_locator_ ACE_ENV_ARG_PARAMETER); 00080 ACE_TRY_CHECK; 00081 } 00082 ACE_CATCHANY 00083 { 00084 ACE_ERROR ((LM_ERROR, 00085 "IMR_Adapter_Activator::unknown_adapter - %s\n", 00086 exception_message)); 00087 ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "System Exception"); 00088 return 0; 00089 } 00090 ACE_ENDTRY; 00091 00092 // Finally, now everything is fine 00093 return 1; 00094 } 00095