2 #include "tao/DiffServPolicy/DiffServPolicy_ORBInitializer.h"
3 #include "tao/DiffServPolicy/DiffServPolicy.h"
4 #include "tao/DiffServPolicy/DiffServPolicy_Factory.h"
5 #include "tao/DiffServPolicy/DiffServ_Service_Context_Handler.h"
6 #include "tao/DiffServPolicy/DiffServ_Protocols_Hooks.h"
7 #include "tao/ORB_Core.h"
8 #include "tao/PI/ORBInitInfo.h"
10 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
13 TAO_DiffServPolicy_ORBInitializer::pre_init (
14 PortableInterceptor::ORBInitInfo_ptr info
)
16 // Narrow to a TAO_ORBInitInfo object to get access to the
17 // orb_core() TAO extension.
18 TAO_ORBInitInfo_var tao_info
= TAO_ORBInitInfo::_narrow (info
);
20 if (CORBA::is_nil (tao_info
.in ()))
22 if (TAO_debug_level
> 0)
23 TAOLIB_ERROR ((LM_ERROR
,
24 "(%P|%t) TAO_RT_ORBInitializer::pre_init:\n"
25 "(%P|%t) Unable to narrow "
26 "\"PortableInterceptor::ORBInitInfo_ptr\" to\n"
27 "(%P|%t) \"TAO_ORBInitInfo *.\"\n"));
29 throw ::CORBA::INTERNAL ();
32 // Bind the service context handler for Diffserv
33 TAO_DiffServ_Service_Context_Handler
* h
= 0;
35 TAO_DiffServ_Service_Context_Handler());
36 tao_info
->orb_core ()->service_context_registry ().bind (IOP::REP_NWPRIORITY
, h
);
40 TAO_DiffServPolicy_ORBInitializer::post_init (
41 PortableInterceptor::ORBInitInfo_ptr info
)
43 this->register_policy_factories (info
);
47 TAO_DiffServPolicy_ORBInitializer::register_policy_factories (
48 PortableInterceptor::ORBInitInfo_ptr info
)
50 if (CORBA::is_nil (this->policy_factory_
.in ()))
52 PortableInterceptor::PolicyFactory_ptr policy_factory
;
53 ACE_NEW_THROW_EX (policy_factory
,
54 TAO_DiffServ_PolicyFactory
,
56 CORBA::SystemException::_tao_minor_code (
59 CORBA::COMPLETED_NO
));
61 this->policy_factory_
= policy_factory
;
64 // Bind the same policy factory to all DiffServ related policy
65 // types since a single policy factory is used to create each of
66 // the different types of DiffServ policies.
67 static CORBA::PolicyType
const type
[] = {
68 TAO::CLIENT_NETWORK_PRIORITY_TYPE
,
69 TAO::NETWORK_PRIORITY_TYPE
72 const CORBA::PolicyType
*end
=
73 type
+ sizeof (type
) / sizeof (type
[0]);
75 for (CORBA::PolicyType
const * i
= type
;
81 info
->register_policy_factory (*i
, this->policy_factory_
.in ());
83 catch (const ::CORBA::BAD_INV_ORDER
& ex
)
85 if (ex
.minor () == (CORBA::OMGVMCID
| 16))
87 // The factory is already there, it happens because the
88 // magic initializer in PortableServer.cpp registers
89 // with the ORB multiple times. This is an indication
90 // that we should do no more work in this
96 catch ( ::CORBA::Exception
&)
98 // Rethrow any other exceptions...
104 TAO_END_VERSIONED_NAMESPACE_DECL