diff options
-rw-r--r-- | TAO/tao/DiffServPolicy/DiffServPolicy_ORBInitializer.cpp | 88 | ||||
-rw-r--r-- | TAO/tao/DiffServPolicy/DiffServPolicy_ORBInitializer.h | 3 |
2 files changed, 54 insertions, 37 deletions
diff --git a/TAO/tao/DiffServPolicy/DiffServPolicy_ORBInitializer.cpp b/TAO/tao/DiffServPolicy/DiffServPolicy_ORBInitializer.cpp index 67221902d31..c4756e371fd 100644 --- a/TAO/tao/DiffServPolicy/DiffServPolicy_ORBInitializer.cpp +++ b/TAO/tao/DiffServPolicy/DiffServPolicy_ORBInitializer.cpp @@ -36,50 +36,64 @@ TAO_DiffServPolicy_ORBInitializer::register_policy_factories ( PortableInterceptor::ORBInitInfo_ptr info ACE_ENV_ARG_DECL) { - TAO_ORBInitInfo * local_info = dynamic_cast <TAO_ORBInitInfo *> (info); - TAO_ORB_Core * the_orb_core = local_info->orb_core (); - - // Register the EndpointPolicy policy factories. - PortableInterceptor::PolicyFactory_ptr policy_factory_ptr; - ACE_NEW_THROW_EX (policy_factory_ptr, - TAO_EndpointPolicy_Factory(the_orb_core), - CORBA::NO_MEMORY ( - CORBA::SystemException::_tao_minor_code ( - TAO::VMCID, - ENOMEM), - CORBA::COMPLETED_NO)); - ACE_CHECK; + if (CORBA::is_nil (this->policy_factory_.in ())) + { + PortableInterceptor::PolicyFactory_ptr policy_factory; + ACE_NEW_THROW_EX (policy_factory, + TAO_DiffServ_PolicyFactory, + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO::VMCID, + ENOMEM), + CORBA::COMPLETED_NO)); + ACE_CHECK; + this->policy_factory_ = policy_factory; + } - PortableInterceptor::PolicyFactory_var policy_factory = - policy_factory_ptr; + // Bind the same policy factory to all DiffServ related policy + // types since a single policy factory is used to create each of + // the different types of DiffServ policies. + static CORBA::PolicyType const type[] = { + TAO::CLIENT_NETWORK_PRIORITY_TYPE, + TAO::NETWORK_PRIORITY_TYPE + }; - ACE_TRY + const CORBA::PolicyType *end = + type + sizeof (type) / sizeof (type[0]); + + for (CORBA::PolicyType const * i = type; + i != end; + ++i) { - info->register_policy_factory (EndpointPolicy::ENDPOINT_POLICY_TYPE, - policy_factory.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } - ACE_CATCH (CORBA::BAD_INV_ORDER, ex) - { - if (ex.minor () == (CORBA::OMGVMCID | 16)) + ACE_TRY { - // The factory is already there, it happens because the - // magic initializer in Messaging.cpp registers with the - // ORB multiple times. This is an indication that we - // should do no more work in this ORBInitializer. - return; + info->register_policy_factory (*i, + this->policy_factory_.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; } - ACE_RE_THROW; - } - ACE_CATCHANY - { - // Rethrow any other exceptions... - ACE_RE_THROW; + ACE_CATCH (CORBA::BAD_INV_ORDER, ex) + { + if (ex.minor () == (CORBA::OMGVMCID | 16)) + { + // The factory is already there, it happens because the + // magic initializer in PortableServer.cpp registers + // with the ORB multiple times. This is an indication + // that we should do no more work in this + // ORBInitializer. + return; + } + ACE_RE_THROW; + } + ACE_CATCHANY + { + // Rethrow any other exceptions... + ACE_RE_THROW; + } + ACE_ENDTRY; + ACE_CHECK; } - ACE_ENDTRY; - ACE_CHECK; } TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/DiffServPolicy/DiffServPolicy_ORBInitializer.h b/TAO/tao/DiffServPolicy/DiffServPolicy_ORBInitializer.h index f1825d8084e..41c23112f5c 100644 --- a/TAO/tao/DiffServPolicy/DiffServPolicy_ORBInitializer.h +++ b/TAO/tao/DiffServPolicy/DiffServPolicy_ORBInitializer.h @@ -56,6 +56,9 @@ private: void register_policy_factories ( PortableInterceptor::ORBInitInfo_ptr info ACE_ENV_ARG_DECL); + +private: + PortableInterceptor::PolicyFactory_var policy_factory_; }; TAO_END_VERSIONED_NAMESPACE_DECL |