TAO_Default_Server_Strategy_Factory Class Reference

This is the default strategy factory for CORBA servers. It allows developers to choose strategies via argument flags. This design gives substantial freedom for experimentation. More...

#include <default_server.h>

Inheritance diagram for TAO_Default_Server_Strategy_Factory:

Inheritance graph
[legend]
Collaboration diagram for TAO_Default_Server_Strategy_Factory:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_Default_Server_Strategy_Factory (void)
virtual ~TAO_Default_Server_Strategy_Factory (void)
virtual int init (int argc, ACE_TCHAR *argv[])
virtual int open (TAO_ORB_Core *)
virtual int enable_poa_locking (void)
 Enable POA locking?

virtual int activate_server_connections (void)
 Are server connections active (i.e. run in their own thread).

virtual int thread_per_connection_timeout (ACE_Time_Value &timeout)
virtual int server_connection_thread_flags (void)
 The thread activation parameters.

virtual int server_connection_thread_count (void)
int parse_args (int argc, ACE_TCHAR *argv[])

Protected Types

enum  Lock_Type { TAO_NULL_LOCK, TAO_THREAD_LOCK }

Protected Member Functions

void tokenize (ACE_TCHAR *flag_string)
void report_option_value_error (const ACE_TCHAR *option_name, const ACE_TCHAR *option_value)

Protected Attributes

int activate_server_connections_
 Should the server connection handlers run in their own thread?

int thread_flags_
 Default thread flags passed to thr_create().

Lock_Type poa_lock_type_
 The type of lock to be returned by <create_poa_lock()>.

int thread_per_connection_use_timeout_
 The timeout flag and value for the thread-per-connection model.

ACE_Time_Value thread_per_connection_timeout_

Detailed Description

This is the default strategy factory for CORBA servers. It allows developers to choose strategies via argument flags. This design gives substantial freedom for experimentation.

Definition at line 38 of file default_server.h.


Member Enumeration Documentation

enum TAO_Default_Server_Strategy_Factory::Lock_Type [protected]
 

Enumeration values:
TAO_NULL_LOCK 
TAO_THREAD_LOCK 

Definition at line 75 of file default_server.h.

00076   {
00077     TAO_NULL_LOCK,
00078     TAO_THREAD_LOCK
00079   };


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_Default_Server_Strategy_Factory::TAO_Default_Server_Strategy_Factory void   ) 
 

Definition at line 14 of file default_server.cpp.

00015   : activate_server_connections_ (0),
00016     thread_flags_ (THR_BOUND | THR_DETACHED),
00017     poa_lock_type_ (TAO_THREAD_LOCK),
00018     thread_per_connection_use_timeout_ (-1)
00019 {
00020 }

TAO_Default_Server_Strategy_Factory::~TAO_Default_Server_Strategy_Factory void   )  [virtual]
 

Definition at line 22 of file default_server.cpp.

00023 {
00024   // Perform appropriate cleanup.
00025 }


Member Function Documentation

int TAO_Default_Server_Strategy_Factory::activate_server_connections void   )  [virtual]
 

Are server connections active (i.e. run in their own thread).

Reimplemented from TAO_Server_Strategy_Factory.

Definition at line 41 of file default_server.cpp.

References activate_server_connections_.

00042 {
00043   return this->activate_server_connections_;
00044 }

int TAO_Default_Server_Strategy_Factory::enable_poa_locking void   )  [virtual]
 

Enable POA locking?

Reimplemented from TAO_Server_Strategy_Factory.

Definition at line 28 of file default_server.cpp.

References poa_lock_type_.

00029 {
00030   switch (this->poa_lock_type_)
00031     {
00032     case TAO_NULL_LOCK:
00033       return 0;
00034     case TAO_THREAD_LOCK:
00035     default:
00036       return 1;
00037     }
00038 }

int TAO_Default_Server_Strategy_Factory::init int  argc,
ACE_TCHAR argv[]
[virtual]
 

Reimplemented from ACE_Shared_Object.

Definition at line 98 of file default_server.cpp.

References parse_args().

00099 {
00100   return this->parse_args (argc, argv);
00101 }

int TAO_Default_Server_Strategy_Factory::open TAO_ORB_Core  )  [virtual]
 

Call on various strategies. This is not performed in so that the other portions of the ORB have a chance to "settle" in their initialization since the streategies herein might need some of that information.

Reimplemented from TAO_Server_Strategy_Factory.

Definition at line 104 of file default_server.cpp.

00105 {
00106   return 0;
00107 }

int TAO_Default_Server_Strategy_Factory::parse_args int  argc,
ACE_TCHAR argv[]
 

Parse the arguments, check the documentation in $TAO_ROOT/docs/Options.html for details

Definition at line 110 of file default_server.cpp.

References ACE_DEBUG, ACE_ERROR, ACE_TCHAR, ACE_TEXT, ACE_TRACE, activate_server_connections_, ACE_OS::atoi(), LM_DEBUG, LM_ERROR, poa_lock_type_, report_option_value_error(), ACE_Time_Value::set(), ACE_OS::strcasecmp(), ACE_OS::strncmp(), ACE_OS::strtoul(), TAO_ACTIVE_DEMUX, TAO_DYNAMIC_HASH, TAO_LINEAR, thread_per_connection_timeout_, thread_per_connection_use_timeout_, and tokenize().

Referenced by init().

00111 {
00112   ACE_TRACE ("TAO_Default_Server_Strategy_Factory::parse_args");
00113 
00114   int curarg;
00115 
00116   for (curarg = 0; curarg < argc && argv[curarg]; ++curarg)
00117     if (ACE_OS::strcasecmp (argv[curarg],
00118                             ACE_TEXT("-ORBConcurrency")) == 0)
00119       {
00120         ++curarg;
00121         if (curarg < argc)
00122           {
00123             ACE_TCHAR* name = argv[curarg];
00124 
00125             if (ACE_OS::strcasecmp (name,
00126                                     ACE_TEXT("reactive")) == 0)
00127               this->activate_server_connections_ = 0;
00128             else if (ACE_OS::strcasecmp (name,
00129                                          ACE_TEXT("thread-per-connection")) == 0)
00130               this->activate_server_connections_ = 1;
00131             else
00132               this->report_option_value_error (ACE_TEXT("-ORBConcurrency"), name);
00133           }
00134       }
00135 
00136     else if (ACE_OS::strcasecmp (argv[curarg],
00137                                  ACE_TEXT("-ORBThreadPerConnectionTimeout")) == 0)
00138       {
00139         ++curarg;
00140         if (curarg < argc)
00141           {
00142             ACE_TCHAR* name = argv[curarg];
00143 
00144             if (ACE_OS::strcasecmp (name,
00145                                     ACE_TEXT("infinite")) == 0)
00146               {
00147                 this->thread_per_connection_use_timeout_ = 0;
00148               }
00149             else
00150               {
00151                 this->thread_per_connection_use_timeout_ = 1;
00152                 int milliseconds = ACE_OS::atoi (name);
00153                 this->thread_per_connection_timeout_.set (0,
00154                                                           1000 * milliseconds);
00155               }
00156           }
00157       }
00158 
00159     else if (ACE_OS::strcasecmp (argv[curarg],
00160                                  ACE_TEXT("-ORBTableSize")) == 0
00161              || ACE_OS::strcasecmp (argv[curarg],
00162                                     ACE_TEXT("-ORBActiveObjectMapSize")) == 0)
00163       {
00164         ++curarg;
00165         if (curarg < argc)
00166           this->active_object_map_creation_parameters_.active_object_map_size_ =
00167             ACE_OS::strtoul (argv[curarg],
00168                              0,
00169                              10);
00170       }
00171     else if (ACE_OS::strcasecmp (argv[curarg],
00172                                  ACE_TEXT("-ORBPOAMapSize")) == 0)
00173       {
00174         ++curarg;
00175         if (curarg < argc)
00176           this->active_object_map_creation_parameters_.poa_map_size_ =
00177             ACE_OS::strtoul (argv[curarg],
00178                              0,
00179                              10);
00180       }
00181     else if (ACE_OS::strcasecmp (argv[curarg],
00182                                  ACE_TEXT("-ORBActiveHintInIds")) == 0)
00183       {
00184         ++curarg;
00185         if (curarg < argc)
00186           {
00187             ACE_TCHAR* value = argv[curarg];
00188 
00189             this->active_object_map_creation_parameters_.use_active_hint_in_ids_ =
00190               ACE_OS::atoi (value);
00191           }
00192       }
00193     else if (ACE_OS::strcasecmp (argv[curarg],
00194                                  ACE_TEXT("-ORBActiveHintInPOANames")) == 0)
00195       {
00196         ++curarg;
00197         if (curarg < argc)
00198           {
00199             ACE_TCHAR* value = argv[curarg];
00200 
00201             this->active_object_map_creation_parameters_.use_active_hint_in_poa_names_ =
00202               ACE_OS::atoi (value);
00203           }
00204       }
00205     else if (ACE_OS::strcasecmp (argv[curarg],
00206                                  ACE_TEXT("-ORBAllowReactivationOfSystemids")) == 0)
00207       {
00208         ++curarg;
00209         if (curarg < argc)
00210           {
00211             ACE_TCHAR* value = argv[curarg];
00212 
00213             this->active_object_map_creation_parameters_.allow_reactivation_of_system_ids_ =
00214               ACE_OS::atoi (value);
00215           }
00216       }
00217     else if (ACE_OS::strcasecmp (argv[curarg],
00218                                  ACE_TEXT("-ORBUseridPolicyDemuxStrategy")) == 0)
00219       {
00220         ++curarg;
00221         if (curarg < argc)
00222           {
00223             ACE_TCHAR* name = argv[curarg];
00224 
00225             // Active demux not supported with user id policy.
00226             if (ACE_OS::strcasecmp (name,
00227                                     ACE_TEXT("dynamic")) == 0)
00228               this->active_object_map_creation_parameters_.object_lookup_strategy_for_user_id_policy_ =
00229                 TAO_DYNAMIC_HASH;
00230             else if (ACE_OS::strcasecmp (name,
00231                                          ACE_TEXT("linear")) == 0)
00232               this->active_object_map_creation_parameters_.object_lookup_strategy_for_user_id_policy_ =
00233                 TAO_LINEAR;
00234             else
00235               this->report_option_value_error (ACE_TEXT("-ORBUseridPolicyDemuxStrategy"), name);
00236           }
00237       }
00238     else if (ACE_OS::strcasecmp (argv[curarg],
00239                                  ACE_TEXT("-ORBSystemidPolicyDemuxStrategy")) == 0)
00240       {
00241         ++curarg;
00242         if (curarg < argc)
00243           {
00244             ACE_TCHAR* name = argv[curarg];
00245 
00246             if (ACE_OS::strcasecmp (name,
00247                                     ACE_TEXT("dynamic")) == 0)
00248               this->active_object_map_creation_parameters_.object_lookup_strategy_for_system_id_policy_ =
00249                 TAO_DYNAMIC_HASH;
00250             else if (ACE_OS::strcasecmp (name,
00251                                          ACE_TEXT("linear")) == 0)
00252               this->active_object_map_creation_parameters_.object_lookup_strategy_for_system_id_policy_ =
00253                 TAO_LINEAR;
00254             else if (ACE_OS::strcasecmp (name,
00255                                          ACE_TEXT("active")) == 0)
00256               this->active_object_map_creation_parameters_.object_lookup_strategy_for_system_id_policy_ =
00257                 TAO_ACTIVE_DEMUX;
00258             else
00259               this->report_option_value_error (ACE_TEXT("-ORBSystemidPolicyDemuxStrategy"), name);
00260           }
00261       }
00262     else if (ACE_OS::strcasecmp (argv[curarg],
00263                                  ACE_TEXT("-ORBPersistentidPolicyDemuxStrategy")) == 0)
00264       {
00265         ++curarg;
00266         if (curarg < argc)
00267           {
00268             ACE_TCHAR* name = argv[curarg];
00269 
00270             // Active demux not supported with user id policy.
00271             if (ACE_OS::strcasecmp (name,
00272                                     ACE_TEXT("dynamic")) == 0)
00273               this->active_object_map_creation_parameters_.poa_lookup_strategy_for_persistent_id_policy_ =
00274                 TAO_DYNAMIC_HASH;
00275             else if (ACE_OS::strcasecmp (name,
00276                                          ACE_TEXT("linear")) == 0)
00277               this->active_object_map_creation_parameters_.poa_lookup_strategy_for_persistent_id_policy_ =
00278                 TAO_LINEAR;
00279             else
00280               this->report_option_value_error (ACE_TEXT("-ORBPersistentidPolicyDemuxStrategy"), name);
00281           }
00282       }
00283     else if (ACE_OS::strcasecmp (argv[curarg],
00284                                  ACE_TEXT("-ORBTransientidPolicyDemuxStrategy")) == 0)
00285       {
00286         ++curarg;
00287         if (curarg < argc)
00288           {
00289             ACE_TCHAR* name = argv[curarg];
00290 
00291             if (ACE_OS::strcasecmp (name,
00292                                     ACE_TEXT("dynamic")) == 0)
00293               this->active_object_map_creation_parameters_.poa_lookup_strategy_for_transient_id_policy_ =
00294                 TAO_DYNAMIC_HASH;
00295             else if (ACE_OS::strcasecmp (name,
00296                                          ACE_TEXT("linear")) == 0)
00297               this->active_object_map_creation_parameters_.poa_lookup_strategy_for_transient_id_policy_ =
00298                 TAO_LINEAR;
00299             else if (ACE_OS::strcasecmp (name,
00300                                          ACE_TEXT("active")) == 0)
00301               this->active_object_map_creation_parameters_.poa_lookup_strategy_for_transient_id_policy_ =
00302                 TAO_ACTIVE_DEMUX;
00303             else
00304               this->report_option_value_error (ACE_TEXT("-ORBTransientidPolicyDemuxStrategy"), name);
00305           }
00306       }
00307     else if (ACE_OS::strcasecmp (argv[curarg],
00308                                  ACE_TEXT("-ORBUniqueidPolicyReverseDemuxStrategy")) == 0)
00309       {
00310         ++curarg;
00311         if (curarg < argc)
00312           {
00313             ACE_TCHAR* name = argv[curarg];
00314 
00315             if (ACE_OS::strcasecmp (name,
00316                                     ACE_TEXT("dynamic")) == 0)
00317               this->active_object_map_creation_parameters_.reverse_object_lookup_strategy_for_unique_id_policy_ =
00318                 TAO_DYNAMIC_HASH;
00319             else if (ACE_OS::strcasecmp (name,
00320                                          ACE_TEXT("linear")) == 0)
00321               this->active_object_map_creation_parameters_.reverse_object_lookup_strategy_for_unique_id_policy_ =
00322                 TAO_LINEAR;
00323             else
00324               this->report_option_value_error (ACE_TEXT("-ORBUniqueidPolicyReverseDemuxStrategy"), name);
00325           }
00326       }
00327     else if (ACE_OS::strcasecmp (argv[curarg],
00328                                  ACE_TEXT("-ORBPOALock")) == 0)
00329       {
00330         ++curarg;
00331         if (curarg < argc)
00332           {
00333             ACE_TCHAR* name = argv[curarg];
00334 
00335             if (ACE_OS::strcasecmp (name,
00336                                     ACE_TEXT("thread")) == 0)
00337               this->poa_lock_type_ = TAO_THREAD_LOCK;
00338             else if (ACE_OS::strcasecmp (name,
00339                                          ACE_TEXT("null")) == 0)
00340               this->poa_lock_type_ = TAO_NULL_LOCK;
00341             else
00342               this->report_option_value_error (ACE_TEXT("-ORBPOALock"), name);
00343           }
00344       }
00345     else if (ACE_OS::strcasecmp (argv[curarg],
00346                                  ACE_TEXT("-ORBThreadFlags")) == 0)
00347       {
00348         ++curarg;
00349 
00350         if (curarg < argc)
00351           this->tokenize (argv[curarg]);
00352       }
00353 
00354     else if (ACE_OS::strncmp (argv[curarg], ACE_TEXT("-ORB"), 4) == 0)
00355       {
00356         // Can we assume there is an argument after the option?
00357         // ++curarg;
00358         ACE_ERROR ((LM_ERROR,
00359                     ACE_TEXT("Server_Strategy_Factory - ")
00360                     ACE_TEXT("unknown option <%s>\n"),
00361                     argv[curarg]));
00362       }
00363     else
00364       {
00365         ACE_DEBUG ((LM_DEBUG,
00366                     ACE_TEXT("Server_Strategy_Factory - ")
00367                     ACE_TEXT("ignoring option <%s>\n"),
00368                     argv[curarg]));
00369       }
00370 
00371   return 0;
00372 }

void TAO_Default_Server_Strategy_Factory::report_option_value_error const ACE_TCHAR option_name,
const ACE_TCHAR option_value
[protected]
 

Definition at line 375 of file default_server.cpp.

References ACE_DEBUG, ACE_TEXT, and LM_DEBUG.

Referenced by parse_args().

00378 {
00379   ACE_DEBUG((LM_DEBUG,
00380              ACE_TEXT ("Server_Strategy_Factory - unknown argument")
00381              ACE_TEXT (" <%s> for <%s>\n"),
00382              option_value, option_name));
00383 }

int TAO_Default_Server_Strategy_Factory::server_connection_thread_count void   )  [virtual]
 

Reimplemented from TAO_Server_Strategy_Factory.

Definition at line 60 of file default_server.cpp.

00061 {
00062   return 1;
00063 }

int TAO_Default_Server_Strategy_Factory::server_connection_thread_flags void   )  [virtual]
 

The thread activation parameters.

Reimplemented from TAO_Server_Strategy_Factory.

Definition at line 54 of file default_server.cpp.

References thread_flags_.

00055 {
00056   return this->thread_flags_;
00057 }

int TAO_Default_Server_Strategy_Factory::thread_per_connection_timeout ACE_Time_Value timeout  )  [virtual]
 

Obtain the timeout value used by the thread-per-connection server threads to poll the shutdown flag in the ORB. Return -1 if the ORB should use the compile-time defaults. If the return value is zero then the threads block without timeouts.

Reimplemented from TAO_Server_Strategy_Factory.

Definition at line 47 of file default_server.cpp.

References thread_per_connection_timeout_, and thread_per_connection_use_timeout_.

00048 {
00049   timeout = this->thread_per_connection_timeout_;
00050   return this->thread_per_connection_use_timeout_;
00051 }

void TAO_Default_Server_Strategy_Factory::tokenize ACE_TCHAR flag_string  )  [protected]
 

Definition at line 73 of file default_server.cpp.

References ACE_TCHAR, ACE_TEXT, ACE_OS::strtok_r(), TAO_BEGINCHECK, TAO_CHECKANDSET, and TAO_ENDCHECK.

Referenced by parse_args().

00074 {
00075   ACE_TCHAR* lasts = 0;
00076 
00077   for (ACE_TCHAR* flag = ACE_OS::strtok_r (flag_string,
00078                                       ACE_TEXT("|"),
00079                                       &lasts);
00080        flag != 0;
00081        flag = ACE_OS::strtok_r (0,
00082                                 ACE_TEXT("|"),
00083                                 &lasts))
00084     {
00085       TAO_BEGINCHECK;
00086       TAO_CHECKANDSET (THR_DETACHED);
00087       TAO_CHECKANDSET (THR_BOUND);
00088       TAO_CHECKANDSET (THR_NEW_LWP);
00089       TAO_CHECKANDSET (THR_SUSPENDED);
00090 #if !defined (ACE_WIN32)
00091       TAO_CHECKANDSET (THR_DAEMON);
00092 #endif /* ACE_WIN32 */
00093       TAO_ENDCHECK;
00094     }
00095 }


Member Data Documentation

int TAO_Default_Server_Strategy_Factory::activate_server_connections_ [protected]
 

Should the server connection handlers run in their own thread?

Definition at line 70 of file default_server.h.

Referenced by activate_server_connections(), and parse_args().

Lock_Type TAO_Default_Server_Strategy_Factory::poa_lock_type_ [protected]
 

The type of lock to be returned by <create_poa_lock()>.

Definition at line 82 of file default_server.h.

Referenced by enable_poa_locking(), and parse_args().

int TAO_Default_Server_Strategy_Factory::thread_flags_ [protected]
 

Default thread flags passed to thr_create().

Definition at line 73 of file default_server.h.

Referenced by server_connection_thread_flags().

ACE_Time_Value TAO_Default_Server_Strategy_Factory::thread_per_connection_timeout_ [protected]
 

Definition at line 86 of file default_server.h.

Referenced by parse_args(), and thread_per_connection_timeout().

int TAO_Default_Server_Strategy_Factory::thread_per_connection_use_timeout_ [protected]
 

The timeout flag and value for the thread-per-connection model.

Definition at line 85 of file default_server.h.

Referenced by parse_args(), and thread_per_connection_timeout().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 12:13:22 2006 for TAO by doxygen 1.3.6