Go to the documentation of this file.00001
00002
00003 #include "tao/DiffServPolicy/DiffServPolicy_ORBInitializer.h"
00004 #include "tao/DiffServPolicy/DiffServPolicy.h"
00005 #include "tao/DiffServPolicy/DiffServPolicy_Factory.h"
00006 #include "tao/DiffServPolicy/DiffServ_Service_Context_Handler.h"
00007 #include "tao/DiffServPolicy/DiffServ_Protocols_Hooks.h"
00008 #include "tao/ORB_Core.h"
00009 #include "tao/PI/ORBInitInfo.h"
00010
00011 ACE_RCSID (DiffServPolicy,
00012 DiffServPolicy_ORBInitializer,
00013 "$Id: DiffServPolicy_ORBInitializer.cpp 84860 2009-03-17 10:17:38Z johnnyw $")
00014
00015 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00016
00017 void
00018 TAO_DiffServPolicy_ORBInitializer::pre_init (
00019 PortableInterceptor::ORBInitInfo_ptr info)
00020 {
00021
00022
00023 TAO_ORBInitInfo_var tao_info = TAO_ORBInitInfo::_narrow (info);
00024
00025 if (CORBA::is_nil (tao_info.in ()))
00026 {
00027 if (TAO_debug_level > 0)
00028 ACE_ERROR ((LM_ERROR,
00029 "(%P|%t) TAO_RT_ORBInitializer::pre_init:\n"
00030 "(%P|%t) Unable to narrow "
00031 "\"PortableInterceptor::ORBInitInfo_ptr\" to\n"
00032 "(%P|%t) \"TAO_ORBInitInfo *.\"\n"));
00033
00034 throw ::CORBA::INTERNAL ();
00035 }
00036
00037
00038 TAO_DiffServ_Service_Context_Handler* h = 0;
00039 ACE_NEW (h,
00040 TAO_DiffServ_Service_Context_Handler());
00041 tao_info->orb_core ()->service_context_registry ().bind (IOP::REP_NWPRIORITY, h);
00042 }
00043
00044 void
00045 TAO_DiffServPolicy_ORBInitializer::post_init (
00046 PortableInterceptor::ORBInitInfo_ptr info)
00047 {
00048 this->register_policy_factories (info);
00049 }
00050
00051 void
00052 TAO_DiffServPolicy_ORBInitializer::register_policy_factories (
00053 PortableInterceptor::ORBInitInfo_ptr info)
00054 {
00055 if (CORBA::is_nil (this->policy_factory_.in ()))
00056 {
00057 PortableInterceptor::PolicyFactory_ptr policy_factory;
00058 ACE_NEW_THROW_EX (policy_factory,
00059 TAO_DiffServ_PolicyFactory,
00060 CORBA::NO_MEMORY (
00061 CORBA::SystemException::_tao_minor_code (
00062 TAO::VMCID,
00063 ENOMEM),
00064 CORBA::COMPLETED_NO));
00065
00066 this->policy_factory_ = policy_factory;
00067 }
00068
00069
00070
00071
00072 static CORBA::PolicyType const type[] = {
00073 TAO::CLIENT_NETWORK_PRIORITY_TYPE,
00074 TAO::NETWORK_PRIORITY_TYPE
00075 };
00076
00077 const CORBA::PolicyType *end =
00078 type + sizeof (type) / sizeof (type[0]);
00079
00080 for (CORBA::PolicyType const * i = type;
00081 i != end;
00082 ++i)
00083 {
00084 try
00085 {
00086 info->register_policy_factory (*i, this->policy_factory_.in ());
00087 }
00088 catch (const ::CORBA::BAD_INV_ORDER& ex)
00089 {
00090 if (ex.minor () == (CORBA::OMGVMCID | 16))
00091 {
00092
00093
00094
00095
00096
00097 return;
00098 }
00099 throw;
00100 }
00101 catch ( ::CORBA::Exception&)
00102 {
00103
00104 throw;
00105 }
00106 }
00107 }
00108
00109 TAO_END_VERSIONED_NAMESPACE_DECL