1 #include "tao/Dynamic_TP/DTP_POA_Loader.h"
3 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
6 #include "tao/CSD_Framework/CSD_Framework_Loader.h"
7 #include "tao/Dynamic_TP/DTP_Config.h"
8 #include "tao/Dynamic_TP/DTP_POA_Strategy.h"
9 #include "ace/OS_NS_strings.h"
10 #include "tao/CSD_Framework/CSD_ORBInitializer.h"
11 #include "tao/PI/DLL_Resident_ORB_Initializer.h"
12 #include "tao/ORBInitializer_Registry.h"
13 #include "tao/ORB_Core.h"
16 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
18 TAO_DTP_POA_Loader::TAO_DTP_POA_Loader ()
22 TAO_DTP_POA_Loader::~TAO_DTP_POA_Loader ()
27 TAO_DTP_POA_Loader::init (int argc
, ACE_TCHAR
* argv
[])
29 //TAO_debug_level = 5;
31 ACE_TRACE ("TAO_DTP_POA_Loader::init");
33 // Only allow initialization once.
34 static bool initialized
= false;
39 TAO_CSD_Strategy_Repository
* repo
=
40 ACE_Dynamic_Service
<TAO_CSD_Strategy_Repository
>::instance
41 ("TAO_CSD_Strategy_Repository");
44 /* Now create a POA Configuration Map Registry to look up what
45 thread pool settings are associated with each POA
50 ACE_Service_Config::process_directive(
51 ace_svc_desc_TAO_CSD_Strategy_Repository
);
52 repo
= ACE_Dynamic_Service
<TAO_CSD_Strategy_Repository
>::instance
53 ("TAO_CSD_Strategy_Repository");
58 if (TAO_debug_level
> 0)
60 TAOLIB_DEBUG((LM_DEBUG
,
61 ACE_TEXT ("TAO (%P|%t) - DTP_POA_Loader - ")
62 ACE_TEXT ("cannot initialize strategy repo\n")));
69 for (int curarg
= 0; curarg
< argc
; curarg
++)
71 if (TAO_debug_level
> 0)
73 TAOLIB_DEBUG((LM_DEBUG
,
74 ACE_TEXT ("TAO (%P|%t) - DTP_POA_Loader - ")
75 ACE_TEXT ("parsing args\n")));
78 if (ACE_OS::strcasecmp (argv
[curarg
], ACE_TEXT ("-DTPPOAConfigMap"))
84 this->report_option_value_error (ACE_TEXT ("-DTPPOAConfigMap"),
85 ACE_TEXT("<missing>"));
88 if ((this->load_poa_map (argv
[curarg
], repo
)) < 0)
96 If we get here then we have another map set to process and
97 add to the map registry.
99 if (TAO_debug_level
> 0)
101 TAOLIB_ERROR ((LM_ERROR
,
102 ACE_TEXT ("DTP_POA_Loader: Missing option\n")
103 ACE_TEXT ("Usage: -DTPPOAConfigMap <comma-separated ")
104 ACE_TEXT ("list of POAs>:<POA Config Name>\n")
105 ACE_TEXT ("<%s>.\n"),
117 TAO_DTP_POA_Loader::load_poa_map (ACE_TCHAR
*map
,
118 TAO_CSD_Strategy_Repository
*repo
)
120 ACE_CString poa_name
;
121 ACE_CString config_name
;
122 TAO_DTP_POA_Strategy
* strategy_container
= 0;
124 ACE_TCHAR
*sep
= ACE_OS::strchr (map
, ':');
128 if (TAO_debug_level
> 0)
130 TAOLIB_ERROR ((LM_ERROR
,
131 ACE_TEXT ("DTP_POA_Loader: Missing option\n")
132 ACE_TEXT ("Usage: -DTPPOAConfigMap <comma-separated ")
133 ACE_TEXT ("list of POAs>:<POA Config Name>\n<%s>.\n"),
139 config_name
= ACE_TEXT_ALWAYS_CHAR (sep
+ 1);
142 // Now that we have a config name and a null strategy
143 // implementation class we can allocate a new instance of a
144 // strategy configuration container.
146 ACE_NEW_RETURN(strategy_container
,
147 TAO_DTP_POA_Strategy(config_name
,
150 sep
= ACE_OS::strchr (map
, ',');
154 poa_name
= ACE_TEXT_ALWAYS_CHAR (map
);
155 repo
->add_strategy (poa_name
, strategy_container
);
157 sep
= ACE_OS::strchr (map
, ',');
159 poa_name
= ACE_TEXT_ALWAYS_CHAR (map
);
160 repo
->add_strategy(poa_name
, strategy_container
);
162 CORBA::release (strategy_container
);
168 TAO_DTP_POA_Loader::report_option_value_error (const ACE_TCHAR
* name
,
169 const ACE_TCHAR
* value
)
171 if (TAO_debug_level
> 0)
173 TAOLIB_DEBUG((LM_DEBUG
,
174 ACE_TEXT ("TAO (%P|%t) - DTP_POA_Loader - unknown ")
175 ACE_TEXT ("argument <%s> for <%s>\n"),
181 /////////////////////////////////////////////////////////////////////
184 ACE_FACTORY_DEFINE (TAO_Dynamic_TP
, TAO_DTP_POA_Loader
)
185 ACE_STATIC_SVC_DEFINE (TAO_DTP_POA_Loader
,
186 ACE_TEXT ("DTP_POA_Loader"),
188 &ACE_SVC_NAME (TAO_DTP_POA_Loader
),
189 ACE_Service_Type::DELETE_THIS
190 | ACE_Service_Type::DELETE_OBJ
,
193 TAO_END_VERSIONED_NAMESPACE_DECL
196 #endif /* TAO_HAS_CORBA_MESSAGING && TAO_HAS_CORBA_MESSAGING != 0 */