00001 // $Id: EndpointPolicy_ORBInitializer.cpp 78787 2007-07-05 08:02:28Z johnnyw $ 00002 00003 #include "tao/EndpointPolicy/EndpointPolicy_ORBInitializer.h" 00004 00005 #include "tao/EndpointPolicy/EndpointPolicyC.h" 00006 #include "tao/EndpointPolicy/EndpointPolicy_Factory.h" 00007 #include "tao/ORB_Core.h" 00008 #include "tao/PI/ORBInitInfo.h" 00009 00010 ACE_RCSID (EndpointPolicy, 00011 EndpointPolicy_ORBInitializer, 00012 "$Id: EndpointPolicy_ORBInitializer.cpp 78787 2007-07-05 08:02:28Z johnnyw $") 00013 00014 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00015 00016 void 00017 TAO_EndpointPolicy_ORBInitializer::pre_init ( 00018 PortableInterceptor::ORBInitInfo_ptr) 00019 { 00020 } 00021 00022 void 00023 TAO_EndpointPolicy_ORBInitializer::post_init ( 00024 PortableInterceptor::ORBInitInfo_ptr info 00025 ) 00026 { 00027 this->register_policy_factories (info); 00028 } 00029 00030 void 00031 TAO_EndpointPolicy_ORBInitializer::register_policy_factories ( 00032 PortableInterceptor::ORBInitInfo_ptr info) 00033 { 00034 TAO_ORBInitInfo * local_info = dynamic_cast <TAO_ORBInitInfo *> (info); 00035 00036 if (!local_info) 00037 throw CORBA::INTERNAL (); 00038 00039 TAO_ORB_Core * the_orb_core = local_info->orb_core (); 00040 00041 // Register the EndpointPolicy policy factories. 00042 PortableInterceptor::PolicyFactory_ptr policy_factory_ptr; 00043 ACE_NEW_THROW_EX (policy_factory_ptr, 00044 TAO_EndpointPolicy_Factory(the_orb_core), 00045 CORBA::NO_MEMORY ( 00046 CORBA::SystemException::_tao_minor_code ( 00047 TAO::VMCID, 00048 ENOMEM), 00049 CORBA::COMPLETED_NO)); 00050 00051 00052 PortableInterceptor::PolicyFactory_var policy_factory = 00053 policy_factory_ptr; 00054 00055 try 00056 { 00057 info->register_policy_factory (EndpointPolicy::ENDPOINT_POLICY_TYPE, 00058 policy_factory.in ()); 00059 } 00060 catch (const ::CORBA::BAD_INV_ORDER& ex) 00061 { 00062 if (ex.minor () == (CORBA::OMGVMCID | 16)) 00063 { 00064 // The factory is already there, it happens because the 00065 // magic initializer in Messaging.cpp registers with the 00066 // ORB multiple times. This is an indication that we 00067 // should do no more work in this ORBInitializer. 00068 return; 00069 } 00070 throw; 00071 } 00072 } 00073 00074 TAO_END_VERSIONED_NAMESPACE_DECL