1 #include "tao/Dynamic_TP/DTP_Config.h"
3 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
5 #include "tao/Dynamic_TP/DTP_ORBInitializer.h"
8 #include "ace/Dynamic_Service.h"
9 #include "ace/OS_NS_strings.h"
11 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
13 TAO_DTP_Config_Registry_Installer::TAO_DTP_Config_Registry_Installer ()
15 ACE_Service_Config::process_directive (ace_svc_desc_TAO_DTP_Config_Registry
);
19 TAO_DTP_Config_Registry::TAO_DTP_Config_Registry ()
23 TAO_DTP_Config_Registry::~TAO_DTP_Config_Registry ()
28 TAO_DTP_Config_Registry::init (int , ACE_TCHAR
* [] )
34 TAO_DTP_Config_Registry::find (const ACE_CString
& name
,
35 TAO_DTP_Definition
&entry
)
37 return registry_
.find (name
, entry
) == 0;
41 TAO_DTP_Config_Registry::bind (const ACE_CString
& name
,
42 TAO_DTP_Definition
&entry
)
44 return registry_
.bind (name
, entry
);
48 TAO_DTP_Config_Registry::rebind (const ACE_CString
& name
,
49 TAO_DTP_Definition
&entry
)
51 return registry_
.rebind (name
, entry
);
54 //-------------------------------------------------------------------------
56 TAO_DTP_Config::TAO_DTP_Config ()
60 TAO_DTP_Config::~TAO_DTP_Config ()
65 TAO_DTP_Config::init (int argc
, ACE_TCHAR
* argv
[])
67 TAO_DTP_Definition entry
;
70 bool overwrite
= false;
75 for (curarg
= 0; curarg
< argc
; ++curarg
)
78 if ((r
= this->parse_string (curarg
,
81 ACE_TEXT("-DTPName"),name
)) != 0)
88 else if ((r
= this->parse_bool (curarg
,
91 ACE_TEXT("-DTPOverwrite"),
99 else if ((r
= this->parse_long (curarg
,
109 entry
.min_threads_
= val
;
111 else if ((r
= this->parse_long (curarg
,
114 ACE_TEXT("-DTPInit"),
121 entry
.init_threads_
= val
;
123 else if ((r
= this->parse_long (curarg
,
133 entry
.max_threads_
= val
;
135 else if ((r
= this->parse_long (curarg
,
138 ACE_TEXT("-DTPStack"),
145 entry
.stack_size_
= val
;
147 else if ((r
= this->parse_long (curarg
,
150 ACE_TEXT("-DTPTImeout"),
157 entry
.timeout_
= val
;
159 else if ((r
= this->parse_long (curarg
,
162 ACE_TEXT("-DTPQueue"),
169 entry
.queue_depth_
= val
;
173 if (TAO_debug_level
> 0)
175 TAOLIB_DEBUG ((LM_DEBUG
,
176 ACE_TEXT ("TAO (%P|%t) - DTP_Config - ")
177 ACE_TEXT ("Unrecognized argv[%d], %C\n"),
178 curarg
, argv
[curarg
]));
184 if ((entry
.max_threads_
!= -1 && entry
.max_threads_
< entry
.init_threads_
) ||
185 (entry
.min_threads_
> entry
.init_threads_
))
187 if (TAO_debug_level
> 0)
189 TAOLIB_DEBUG ((LM_DEBUG
,
190 ACE_TEXT ("TAO (%P|%t) - DTP_Config - ")
191 ACE_TEXT ("thread count constraint ")
192 ACE_TEXT ("violated, min: %d <= init: %d <= max: ")
193 ACE_TEXT ("%d or max = -1\n"),
196 entry
.max_threads_
));
201 ACE_CString name_str
= ACE_TEXT_ALWAYS_CHAR (name
);
202 ACE_Service_Gestalt
*current
= ACE_Service_Config::current();
203 TAO_DTP_Config_Registry
* registry
=
204 ACE_Dynamic_Service
<TAO_DTP_Config_Registry
>::instance
205 (current
, "DTP_Config_Registry", true);
209 current
->process_directive (ace_svc_desc_TAO_DTP_Config_Registry
);
210 registry
= ACE_Dynamic_Service
<TAO_DTP_Config_Registry
>::instance
211 (current
, "DTP_Config_Registry", true);
214 if (TAO_debug_level
> 0)
216 TAOLIB_DEBUG((LM_DEBUG
,
217 ACE_TEXT ("TAO (%P|%t) - DTP_Config - ")
218 ACE_TEXT ("cannot initialize registry\n")));
226 return registry
->bind(name_str
, entry
);
230 return registry
->rebind(name_str
, entry
);
236 TAO_DTP_Config::parse_long (int &curarg
,
237 int argc
, ACE_TCHAR
*argv
[],
238 const ACE_TCHAR
*match
, long &value
)
241 int result
= this->parse_string (curarg
, argc
, argv
, match
, str
);
246 value
= ACE_OS::strtol (str
, &err
, 10);
247 if (err
&& *err
!= 0)
249 this->report_option_value_error (match
, str
);
256 TAO_DTP_Config::parse_bool (int &curarg
,
257 int argc
, ACE_TCHAR
*argv
[],
258 const ACE_TCHAR
*match
, bool &value
)
261 int result
= this->parse_long (curarg
, argc
, argv
, match
, num
);
271 TAO_DTP_Config::parse_string (int &curarg
,
272 int argc
, ACE_TCHAR
*argv
[],
273 const ACE_TCHAR
*match
, ACE_TCHAR
*&value
)
275 if (ACE_OS::strcasecmp (argv
[curarg
], match
) != 0)
281 this->report_option_value_error (match
, ACE_TEXT("<missing>"));
285 value
= argv
[curarg
];
291 TAO_DTP_Config::report_option_value_error (const ACE_TCHAR
* option_name
,
292 const ACE_TCHAR
* option_value
)
294 if (TAO_debug_level
> 0)
296 TAOLIB_DEBUG((LM_DEBUG
,
297 ACE_TEXT ("TAO (%P|%t) - DTP_Config - unknown ")
298 ACE_TEXT ("argument <%s> for <%s>\n"),
299 option_value
, option_name
));
304 /////////////////////////////////////////////////////////////////////
306 ACE_FACTORY_DEFINE (TAO_Dynamic_TP
, TAO_DTP_Config_Registry
)
307 ACE_STATIC_SVC_DEFINE (TAO_DTP_Config_Registry
,
308 ACE_TEXT ("DTP_Config_Registry"),
310 &ACE_SVC_NAME (TAO_DTP_Config_Registry
),
311 ACE_Service_Type::DELETE_THIS
312 | ACE_Service_Type::DELETE_OBJ
,
314 ACE_FACTORY_DEFINE (TAO_Dynamic_TP
, TAO_DTP_Config
)
315 ACE_STATIC_SVC_DEFINE (TAO_DTP_Config
,
316 ACE_TEXT ("DTP_Config"),
318 &ACE_SVC_NAME (TAO_DTP_Config
),
319 ACE_Service_Type::DELETE_THIS
320 | ACE_Service_Type::DELETE_OBJ
,
322 TAO_END_VERSIONED_NAMESPACE_DECL
324 #endif /* (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0 */