00001 // -*- C++ -*- 00002 00003 #include "tao/PI/PI_ORBInitializer.h" 00004 00005 #if TAO_HAS_INTERCEPTORS == 1 00006 00007 #include "tao/PI/PI_PolicyFactory.h" 00008 #include "tao/PI/ProcessingModePolicyC.h" 00009 #include "tao/ORB_Core.h" 00010 #include "tao/PI/ORBInitInfoC.h" 00011 #include "ace/CORBA_macros.h" 00012 00013 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00014 00015 ACE_RCSID (tao, 00016 PI_ORBInitializer, 00017 "$Id: PI_ORBInitializer.cpp 77357 2007-02-24 06:58:14Z johnnyw $") 00018 00019 void 00020 TAO_PI_ORBInitializer::pre_init (PortableInterceptor::ORBInitInfo_ptr) 00021 { 00022 } 00023 00024 00025 void 00026 TAO_PI_ORBInitializer::post_init (PortableInterceptor::ORBInitInfo_ptr info) 00027 { 00028 // The PI policy factory is stateless and reentrant, so share a 00029 // single instance between all ORBs. 00030 if (CORBA::is_nil (this->policy_factory_.in ())) 00031 { 00032 PortableInterceptor::PolicyFactory_ptr policy_factory; 00033 ACE_NEW_THROW_EX (policy_factory, 00034 TAO_PI_PolicyFactory, 00035 CORBA::NO_MEMORY ( 00036 CORBA::SystemException::_tao_minor_code ( 00037 TAO::VMCID, 00038 ENOMEM), 00039 CORBA::COMPLETED_NO)); 00040 00041 this->policy_factory_ = policy_factory; 00042 } 00043 00044 this->register_policy_factories (info); 00045 } 00046 00047 00048 void 00049 TAO_PI_ORBInitializer::register_policy_factories ( 00050 PortableInterceptor::ORBInitInfo_ptr info) 00051 { 00052 // Register the PI policy factory. 00053 00054 // Bind the same policy factory to all PortableInterceptor related policy 00055 // types since a single policy factory is used to create each of the 00056 // different types of PortableInterceptor policies. 00057 CORBA::PolicyType type[] = { 00058 PortableInterceptor::PROCESSING_MODE_POLICY_TYPE 00059 }; 00060 00061 const CORBA::PolicyType *end = type + sizeof (type) / sizeof (type[0]); 00062 00063 for (CORBA::PolicyType *i = type; i != end; ++i) 00064 { 00065 try 00066 { 00067 info->register_policy_factory (*i, this->policy_factory_.in ()); 00068 } 00069 catch (const ::CORBA::BAD_INV_ORDER& ex) 00070 { 00071 if (ex.minor () == (CORBA::OMGVMCID | 16)) 00072 { 00073 // The factory is already there, it happens because the 00074 // magic initializer in PI_Initializer.cpp registers 00075 // with the ORB multiple times. This is an indication 00076 // that we should do no more work in this 00077 // ORBInitializer. 00078 return; 00079 } 00080 throw; 00081 } 00082 } 00083 } 00084 00085 TAO_END_VERSIONED_NAMESPACE_DECL 00086 00087 #endif /* TAO_HAS_INTERCEPTORS == 1 */