Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

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 Methods

 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? More...

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

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

virtual int server_connection_thread_count (void)
int parse_args (int argc, ACE_TCHAR *argv[])
 Parse the arguments, check the documentation in $TAO_ROOT/docs/Options.html for details. More...


Protected Types

enum  Lock_Type { TAO_NULL_LOCK, TAO_THREAD_LOCK }

Protected Methods

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? More...

u_long thread_flags_
 Default thread flags passed to thr_create(). More...

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

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

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 34 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 70 of file default_server.h.

00071   {
00072     TAO_NULL_LOCK,
00073     TAO_THREAD_LOCK
00074   };


Constructor & Destructor Documentation

TAO_Default_Server_Strategy_Factory::TAO_Default_Server_Strategy_Factory void   
 

Definition at line 13 of file default_server.cpp.

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

TAO_Default_Server_Strategy_Factory::~TAO_Default_Server_Strategy_Factory void    [virtual]
 

Definition at line 21 of file default_server.cpp.

00022 {
00023   // Perform appropriate cleanup.
00024 }


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 40 of file default_server.cpp.

References activate_server_connections_.

00041 {
00042   return this->activate_server_connections_;
00043 }

int TAO_Default_Server_Strategy_Factory::enable_poa_locking void    [virtual]
 

Enable POA locking?

Reimplemented from TAO_Server_Strategy_Factory.

Definition at line 27 of file default_server.cpp.

References poa_lock_type_, TAO_NULL_LOCK, and TAO_THREAD_LOCK.

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

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

Reimplemented from ACE_Shared_Object.

Definition at line 97 of file default_server.cpp.

References ACE_TCHAR, and parse_args.

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

int TAO_Default_Server_Strategy_Factory::open TAO_ORB_Core   [virtual]
 

Call <open> on various strategies. This is not performed in <init> 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 103 of file default_server.cpp.

00104 {
00105   return 0;
00106 }

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 109 of file default_server.cpp.

References ACE_DEBUG, ACE_ERROR, ACE_LIB_TEXT, ACE_TCHAR, ACE_TRACE, activate_server_connections_, TAO_Server_Strategy_Factory::active_object_map_creation_parameters_, ACE_OS::atoi, LM_DEBUG, LM_ERROR, poa_lock_type_, report_option_value_error, ACE_Time_Value::set, ACE_OS_String::strcasecmp, ACE_OS_String::strncmp, ACE_OS_String::strtoul, TAO_ACTIVE_DEMUX, TAO_DYNAMIC_HASH, TAO_LINEAR, TAO_NULL_LOCK, TAO_THREAD_LOCK, thread_per_connection_timeout_, thread_per_connection_use_timeout_, and tokenize.

Referenced by init.

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

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

Definition at line 374 of file default_server.cpp.

References ACE_DEBUG, ACE_TCHAR, ACE_TEXT, and LM_DEBUG.

Referenced by parse_args.

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

int TAO_Default_Server_Strategy_Factory::server_connection_thread_count void    [virtual]
 

Reimplemented from TAO_Server_Strategy_Factory.

Definition at line 59 of file default_server.cpp.

00060 {
00061   return 1;
00062 }

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 53 of file default_server.cpp.

References thread_flags_.

00054 {
00055   return this->thread_flags_;
00056 }

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 46 of file default_server.cpp.

References thread_per_connection_timeout_, and thread_per_connection_use_timeout_.

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

void TAO_Default_Server_Strategy_Factory::tokenize ACE_TCHAR   flag_string [protected]
 

Definition at line 72 of file default_server.cpp.

References ACE_LIB_TEXT, ACE_TCHAR, ACE_OS_String::strtok_r, TAO_BEGINCHECK, TAO_CHECKANDSET, and TAO_ENDCHECK.

Referenced by parse_args.

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


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 65 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 77 of file default_server.h.

Referenced by enable_poa_locking, and parse_args.

u_long TAO_Default_Server_Strategy_Factory::thread_flags_ [protected]
 

Default thread flags passed to thr_create().

Definition at line 68 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 81 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 80 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 Mon Jun 16 15:13:49 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002