1 #include "tao/Dynamic_TP/DTP_ORBInitializer.h"
3 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
5 #include "tao/Dynamic_TP/DTP_Config.h"
6 #include "tao/Dynamic_TP/DTP_Thread_Lane_Resources_Manager.h"
7 #include "tao/Dynamic_TP/DTP_Thread_Pool.h"
8 #include "tao/Exception.h"
9 #include "tao/ORB_Core.h"
10 #include "tao/PI/ORBInitInfo.h"
11 #include "tao/debug.h"
12 #include "tao/Leader_Follower.h"
14 #include "ace/Service_Repository.h"
15 #include "ace/Svc_Conf.h"
16 #include "ace/Sched_Params.h"
18 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
20 TAO_DTP_ORBInitializer::TAO_DTP_ORBInitializer (/*const ACE_CString &tplist*/)
25 TAO_DTP_ORBInitializer::pre_init (PortableInterceptor::ORBInitInfo_ptr info
)
27 TAO_ORBInitInfo_var tao_info
= TAO_ORBInitInfo::_narrow (info
);
29 if (CORBA::is_nil (tao_info
.in ()))
31 if (TAO_debug_level
> 0)
32 TAOLIB_ERROR ((LM_ERROR
,
33 ACE_TEXT ("(%P|%t) TAO_DTP_ORBInitializer::pre_init:\n")
34 ACE_TEXT ("(%P|%t) Unable to narrow ")
35 ACE_TEXT ("\"PortableInterceptor::ORBInitInfo_ptr\" to\n")
36 ACE_TEXT ("(%P|%t) \"TAO_ORBInitInfo *.\"\n")));
38 throw ::CORBA::INTERNAL ();
42 ACE_Service_Gestalt
*gestalt
= tao_info
->orb_core ()->configuration();
44 ACE_Service_Object
* const config_obj
=
45 ACE_Dynamic_Service
<ACE_Service_Object
>::instance (
51 // no config manager object loaded
55 TAO_DTP_Config
*config_mgr
= dynamic_cast<TAO_DTP_Config
*>(config_obj
);
58 if (TAO_debug_level
> 0)
59 TAOLIB_ERROR ((LM_ERROR
,
60 ACE_TEXT ("(%P|%t) TAO_DTP_ORBInitializer::pre_init:\n")
61 ACE_TEXT ("(%P|%t) Unable to resolve DTP_Config ")
62 ACE_TEXT ("object\n")));
64 throw ::CORBA::INTERNAL ();
67 // Set the name of the thread lane resources manager to be
68 // DTP_Thread_Lane_Resources_Manager.
69 tao_info
->orb_core ()->orb_params ()
70 ->thread_lane_resources_manager_factory_name (
71 "DTP_Thread_Lane_Resources_Manager_Factory");
72 ACE_Service_Config::process_directive (
73 ace_svc_desc_TAO_DTP_Thread_Lane_Resources_Manager_Factory
);
77 TAO_DTP_ORBInitializer::post_init (PortableInterceptor::ORBInitInfo_ptr info
)
79 TAO_ORBInitInfo_var tao_info
= TAO_ORBInitInfo::_narrow (info
);
81 TAO_Thread_Lane_Resources_Manager
&tlrm
=
82 tao_info
->orb_core ()->thread_lane_resources_manager();
84 ACE_Service_Gestalt
*gestalt
= tao_info
->orb_core ()->configuration();
86 const char *dtp_name
=
87 tao_info
->orb_core ()->orb_params ()->dynamic_thread_pool_config_name ();
89 if (dtp_name
!= 0 && dtp_name
[0] != 0)
91 if (TAO_debug_level
> 0)
93 TAOLIB_DEBUG ((LM_DEBUG
,
94 ACE_TEXT ("(%P|%t) TAO_DTP_ORBInitializer::post_init ")
95 ACE_TEXT ("using thread pool name %s\n"), dtp_name
));
98 TAO_DTP_Config_Registry
*config_registry
=
99 dynamic_cast<TAO_DTP_Config_Registry
*>
100 (ACE_Dynamic_Service
<ACE_Service_Object
>::instance
101 (gestalt
, "DTP_Config_Registry", true));
103 TAO_DTP_Definition def
;
105 if (config_registry
== 0 || !config_registry
->find(dtp_name
, def
))
107 if (TAO_debug_level
> 0)
108 TAOLIB_ERROR ((LM_ERROR
,
109 ACE_TEXT ("(%P|%t) TAO_DTP_ORBInitializer::")
110 ACE_TEXT ("post_init:\n")
111 ACE_TEXT ("(%P|%t) Unable to resolve ")
112 ACE_TEXT ("DTP_Config object\n")));
114 throw ::CORBA::INTERNAL ();
117 TAO_DTP_Thread_Lane_Resources_Manager
&dtp_tlrm
=
118 dynamic_cast<TAO_DTP_Thread_Lane_Resources_Manager
&>(tlrm
);
120 dtp_tlrm
.tp_manager().create_threadpool (def
);
122 tao_info
->orb_core ()->leader_follower ().set_avoid_client_leader ();
129 TAO_END_VERSIONED_NAMESPACE_DECL
131 #endif /* TAO_HAS_CORBA_MESSAGING && TAO_HAS_CORBA_MESSAGING != 0 */