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

default_server.cpp

Go to the documentation of this file.
00001 #include "tao_pch.h"
00002 // $Id: default_server.cpp,v 1.1.1.4.2.1 2003/03/14 16:05:16 chad Exp $
00003 
00004 #include "tao/default_server.h"
00005 #include "tao/ORB_Core.h"
00006 
00007 #if !defined (__ACE_INLINE__)
00008 # include "tao/default_client.i"
00009 #endif /* ! __ACE_INLINE__ */
00010 
00011 ACE_RCSID(tao, default_server, "$Id: default_server.cpp,v 1.1.1.4.2.1 2003/03/14 16:05:16 chad Exp $")
00012 
00013 TAO_Default_Server_Strategy_Factory::TAO_Default_Server_Strategy_Factory (void)
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 }
00020 
00021 TAO_Default_Server_Strategy_Factory::~TAO_Default_Server_Strategy_Factory (void)
00022 {
00023   // Perform appropriate cleanup.
00024 }
00025 
00026 int
00027 TAO_Default_Server_Strategy_Factory::enable_poa_locking (void)
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 }
00038 
00039 int
00040 TAO_Default_Server_Strategy_Factory::activate_server_connections (void)
00041 {
00042   return this->activate_server_connections_;
00043 }
00044 
00045 int
00046 TAO_Default_Server_Strategy_Factory::thread_per_connection_timeout (ACE_Time_Value &timeout)
00047 {
00048   timeout = this->thread_per_connection_timeout_;
00049   return this->thread_per_connection_use_timeout_;
00050 }
00051 
00052 int
00053 TAO_Default_Server_Strategy_Factory::server_connection_thread_flags (void)
00054 {
00055   return this->thread_flags_;
00056 }
00057 
00058 int
00059 TAO_Default_Server_Strategy_Factory::server_connection_thread_count (void)
00060 {
00061   return 1;
00062 }
00063 
00064 // Evil macros b/c I'm lazy!
00065 #define TAO_BEGINCHECK  if (0)
00066 #define TAO_CHECKANDSET(sym) \
00067   else if (ACE_OS::strcmp (const_cast<const ACE_TCHAR *>(flag), ACE_LIB_TEXT(#sym)) == 0) \
00068   ACE_SET_BITS (this->thread_flags_, sym)
00069 #define TAO_ENDCHECK
00070 
00071 void
00072 TAO_Default_Server_Strategy_Factory::tokenize (ACE_TCHAR* flag_string)
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 }
00095 
00096 int
00097 TAO_Default_Server_Strategy_Factory::init (int argc, ACE_TCHAR* argv[])
00098 {
00099   return this->parse_args (argc, argv);
00100 }
00101 
00102 int
00103 TAO_Default_Server_Strategy_Factory::open (TAO_ORB_Core *)
00104 {
00105   return 0;
00106 }
00107 
00108 int
00109 TAO_Default_Server_Strategy_Factory::parse_args (int argc, ACE_TCHAR* argv[])
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 }
00372 
00373 void
00374 TAO_Default_Server_Strategy_Factory::report_option_value_error (
00375                                  const ACE_TCHAR* option_name,
00376                                  const ACE_TCHAR* option_value)
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 }
00383 
00384 #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
00385 #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
00386 #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
00387 
00388 ACE_STATIC_SVC_DEFINE (TAO_Default_Server_Strategy_Factory,
00389                        ACE_TEXT ("Server_Strategy_Factory"),
00390                        ACE_SVC_OBJ_T,
00391                        &ACE_SVC_NAME (TAO_Default_Server_Strategy_Factory),
00392                        ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
00393                        0)
00394 ACE_FACTORY_DEFINE (TAO, TAO_Default_Server_Strategy_Factory)

Generated on Mon Jun 16 13:48:14 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002