Supplies common server operations for dynamic and static configuration of services. More...
#include <Service_Gestalt.h>

Classes | |
| struct | Processed_Static_Svc |
Static Public Member Functions | |
| static void | intrusive_add_ref (ACE_Service_Gestalt *) |
| static void | intrusive_remove_ref (ACE_Service_Gestalt *) |
Protected Types | |
| typedef ACE_Unbounded_Queue < ACE_TString > | ACE_SVC_QUEUE |
| typedef ACE_Unbounded_Queue_Iterator < ACE_TString > | ACE_SVC_QUEUE_ITERATOR |
| typedef ACE_Unbounded_Set < ACE_Static_Svc_Descriptor * > | ACE_STATIC_SVCS |
| Maintain a set of the statically linked service descriptors. | |
| typedef ACE_Unbounded_Set_Iterator < ACE_Static_Svc_Descriptor * > | ACE_STATIC_SVCS_ITERATOR |
| typedef ACE_Unbounded_Set < Processed_Static_Svc * > | ACE_PROCESSED_STATIC_SVCS |
| typedef ACE_Unbounded_Set_Iterator < Processed_Static_Svc * > | ACE_PROCESSED_STATIC_SVCS_ITERATOR |
Protected Member Functions | |
| int | parse_args_i (int, ACE_TCHAR *argv[], bool &ignore_default_svc_conf_file) |
| int | open_i (const ACE_TCHAR program_name[], const ACE_TCHAR *logger_key=0, bool ignore_static_svcs=true, bool ignore_default_svc_conf_file=false, bool ignore_debug_flag=false) |
| int | init_svc_conf_file_queue (void) |
Initialize the svc_conf_file_queue_ if necessary. | |
| int | load_static_svcs (void) |
| int | process_commandline_directives (void) |
| int | process_directive_i (const ACE_Static_Svc_Descriptor &ssd, bool force_replace=false) |
| int | process_directives_i (ACE_Svc_Conf_Param *param) |
| ACE_XML_Svc_Conf * | get_xml_svc_conf (ACE_DLL &d) |
| int | initialize_i (const ACE_Service_Type *sr, const ACE_TCHAR *parameters) |
| const ACE_Static_Svc_Descriptor * | find_processed_static_svc (const ACE_TCHAR *) |
| void | add_processed_static_svc (const ACE_Static_Svc_Descriptor *) |
| Captures a list of the direcives processed (explicitely) for this Gestalt so that services can be replicated in other repositories upon their first initialization. | |
| int | init_i (void) |
Protected Attributes | |
| bool | svc_repo_is_owned_ |
| size_t | svc_repo_size_ |
| int | is_opened_ |
| const ACE_TCHAR * | logger_key_ |
| bool | no_static_svcs_ |
| Should we avoid loading the static services? | |
| ACE_SVC_QUEUE * | svc_queue_ |
| Queue of services specified on the command-line. | |
| ACE_SVC_QUEUE * | svc_conf_file_queue_ |
| ACE_Service_Repository * | repo_ |
| The service repository to hold the services. | |
| ACE_STATIC_SVCS * | static_svcs_ |
| Repository of statically linked services. | |
| ACE_PROCESSED_STATIC_SVCS * | processed_static_svcs_ |
| ACE_Atomic_Op< ACE_SYNCH_MUTEX, long > | refcnt_ |
| Support for intrusive reference counting. | |
Private Types | |
| enum | { DEFAULT_SIZE = ACE_DEFAULT_SERVICE_GESTALT_SIZE } |
Private Member Functions | |
| ACE_UNIMPLEMENTED_FUNC (ACE_Service_Gestalt(const ACE_Service_Gestalt &)) ACE_UNIMPLEMENTED_FUNC(ACE_Service_Gestalt &operator | |
| ACE_Service_Gestalt (size_t size=DEFAULT_SIZE, bool svc_repo_is_owned=true, bool no_static_svcs=true) | |
| ~ACE_Service_Gestalt (void) | |
| void | dump (void) const |
| Dump the state of an object. | |
| int | open (const ACE_TCHAR program_name[], const ACE_TCHAR *logger_key=0, bool ignore_static_svcs=true, bool ignore_default_svc_conf_file=false, bool ignore_debug_flag=false) |
| int | open (int argc, ACE_TCHAR *argv[], const ACE_TCHAR *logger_key=0, bool ignore_static_svcs=true, bool ignore_default_svc_conf_file=false, bool ignore_debug_flag=false) |
| int | is_opened (void) |
| int | process_directive (const ACE_TCHAR directive[]) |
| int | process_directive (const ACE_Static_Svc_Descriptor &ssd, bool force_replace=false) |
| Process one static service definition. | |
| int | process_file (const ACE_TCHAR file[]) |
| int | find (const ACE_TCHAR name[], const ACE_Service_Type **srp=0, bool ignore_suspended=true) const |
| Searches for a service object declaration in the local repo, only. | |
| int | parse_args (int argc, ACE_TCHAR *argv[]) |
| int | process_directives (bool ignore_default_svc_conf_file) |
| int | close (void) |
| int | insert (ACE_Static_Svc_Descriptor *stsd) |
| Registers a service descriptor for a static service object. | |
| int | initialize (const ACE_Service_Type_Factory *, const ACE_TCHAR *parameters) |
| int | initialize (const ACE_Service_Type *, const ACE_TCHAR *parameters) |
| int | initialize (const ACE_TCHAR *svc_name, const ACE_TCHAR *parameters) |
| Initialize and activate a statically svc_name service. | |
| int | resume (const ACE_TCHAR svc_name[]) |
| int | suspend (const ACE_TCHAR svc_name[]) |
| int | remove (const ACE_TCHAR svc_name[]) |
| int | find_static_svc_descriptor (const ACE_TCHAR *name, ACE_Static_Svc_Descriptor **ssd=0) const |
| Find a static service descriptor by name. | |
| ACE_Service_Repository * | current_service_repository (void) |
| Get the current ACE_Service_Repository held by this object. | |
Private Attributes | |
| ACE_ALLOC_HOOK_DECLARE | |
| Declare the dynamic allocation hooks. | |
Friends | |
| class | ACE_Dynamic_Service_Base |
| class | ACE_Service_Object |
| class | ACE_Service_Config |
| class | ACE_Service_Config_Guard |
Supplies common server operations for dynamic and static configuration of services.
The Gestalt embodies the concept of configuration context. On one hand, it is a flat namespace, where names correspond to a Service Object instance. A Gestalt owns the Service Repository instance, which in turn owns the Service Object instances.
Another aspect of a Gestalt is its responsibility for record-keeping and accounting for the meta-data, necessary for locating, removing or instantiating a service.
A repository underlies an instance of a gestalt and its lifetime may or may not be bounded by the lifetime of the gestalt, that owns it. This feature is important for the derived classes and the Service Config in particular.
Definition at line 70 of file Service_Gestalt.h.
typedef ACE_Unbounded_Set<Processed_Static_Svc *> ACE_Service_Gestalt::ACE_PROCESSED_STATIC_SVCS [protected] |
Definition at line 400 of file Service_Gestalt.h.
typedef ACE_Unbounded_Set_Iterator<Processed_Static_Svc *> ACE_Service_Gestalt::ACE_PROCESSED_STATIC_SVCS_ITERATOR [protected] |
Definition at line 403 of file Service_Gestalt.h.
typedef ACE_Unbounded_Set<ACE_Static_Svc_Descriptor *> ACE_Service_Gestalt::ACE_STATIC_SVCS [protected] |
Maintain a set of the statically linked service descriptors.
Definition at line 394 of file Service_Gestalt.h.
typedef ACE_Unbounded_Set_Iterator<ACE_Static_Svc_Descriptor *> ACE_Service_Gestalt::ACE_STATIC_SVCS_ITERATOR [protected] |
Definition at line 397 of file Service_Gestalt.h.
typedef ACE_Unbounded_Queue<ACE_TString> ACE_Service_Gestalt::ACE_SVC_QUEUE [protected] |
Maintain a queue of services to be configured from the command-line.
Definition at line 389 of file Service_Gestalt.h.
typedef ACE_Unbounded_Queue_Iterator<ACE_TString> ACE_Service_Gestalt::ACE_SVC_QUEUE_ITERATOR [protected] |
Definition at line 390 of file Service_Gestalt.h.
anonymous enum [private] |
Definition at line 85 of file Service_Gestalt.h.
00086 { 00087 DEFAULT_SIZE = ACE_DEFAULT_SERVICE_GESTALT_SIZE 00088 };
| ACE_Service_Gestalt::ACE_Service_Gestalt | ( | size_t | size = DEFAULT_SIZE, |
|
| bool | svc_repo_is_owned = true, |
|||
| bool | no_static_svcs = true | |||
| ) | [private] |
Constructor either associates the instance with the process-wide singleton instance of ACE_Service_Repository, or creates and manages its own instance of the specified size.
Definition at line 210 of file Service_Gestalt.cpp.
00213 : svc_repo_is_owned_ (svc_repo_is_owned) 00214 , svc_repo_size_ (size) 00215 , is_opened_ (0) 00216 , logger_key_ (ACE_DEFAULT_LOGGER_KEY) 00217 , no_static_svcs_ (no_static_svcs) 00218 , svc_queue_ (0) 00219 , svc_conf_file_queue_ (0) 00220 , repo_ (0) 00221 , static_svcs_ (0) 00222 , processed_static_svcs_ (0) 00223 , refcnt_ (0) 00224 { 00225 (void)this->init_i (); 00226 00227 #ifndef ACE_NLOGGING 00228 if (ACE::debug ()) 00229 ACE_DEBUG ((LM_DEBUG, 00230 ACE_TEXT ("ACE (%P|%t) SG::ctor - this = %@, pss = %@\n"), 00231 this, this->processed_static_svcs_)); 00232 #endif 00233 }
| ACE_Service_Gestalt::~ACE_Service_Gestalt | ( | void | ) | [private] |
Perform user-specified close activities and remove dynamic memory.
Definition at line 172 of file Service_Gestalt.cpp.
00173 { 00174 00175 if (this->svc_repo_is_owned_) 00176 delete this->repo_; 00177 00178 this->repo_ =0; 00179 00180 delete this->static_svcs_; 00181 this->static_svcs_ = 0; 00182 00183 // Delete the dynamically allocated static_svcs instance. 00184 #ifndef ACE_NLOGGING 00185 if (ACE::debug ()) 00186 ACE_DEBUG ((LM_DEBUG, 00187 ACE_TEXT ("ACE (%P|%t) SG::~SG - this=%@, pss = %@\n"), 00188 this, this->processed_static_svcs_)); 00189 #endif 00190 00191 if (this->processed_static_svcs_ && 00192 !this->processed_static_svcs_->is_empty()) 00193 { 00194 Processed_Static_Svc **pss = 0; 00195 for (ACE_PROCESSED_STATIC_SVCS_ITERATOR iter (*this->processed_static_svcs_); 00196 iter.next (pss) != 0; 00197 iter.advance ()) 00198 { 00199 delete *pss; 00200 } 00201 } 00202 00203 delete this->processed_static_svcs_; 00204 this->processed_static_svcs_ = 0; 00205 00206 delete this->svc_conf_file_queue_; 00207 this->svc_conf_file_queue_ = 0; 00208 }
| ACE_Service_Gestalt::ACE_UNIMPLEMENTED_FUNC | ( | ACE_Service_Gestalt(const ACE_Service_Gestalt &) | ) | [private] |
Not implemented to enforce no copying
| void ACE_Service_Gestalt::add_processed_static_svc | ( | const ACE_Static_Svc_Descriptor * | assd | ) | [protected] |
Captures a list of the direcives processed (explicitely) for this Gestalt so that services can be replicated in other repositories upon their first initialization.
This is part of the mechanism ensuring distinct local instances for static service objects, loaded in another repository.
When process_directive(Static_Svc_Descriptor&) is called, it associates a service object with the Gestalt and makes the resource (a Service Object) local to the repository. This is but the first step in using such SO. The next is the "initialization" step. It is typicaly done through a "static" service configuration directive.
In contrast a "dynamic" directive, when processed through the overloaded process_directives(string) both creates the SO locally and initializes it, where the statics directive must first locate the SO and then calls the init() method. This means that durig the "static" initialization there's no specific information about the hosting repository and the gestalt must employ some lookup strategy to find it elsewhere.
Definition at line 373 of file Service_Gestalt.cpp.
00374 { 00375 00376 /// When process_directive(Static_Svc_Descriptor&) is called, it 00377 /// associates a service object with the Gestalt and makes the 00378 /// resource (a Service Object) local to the repository. This is but 00379 /// the first step in using such SO. The next is the 00380 /// "initialization" step. It is typicaly done through a "static" 00381 /// service configuration directive. 00382 /// 00383 /// In contrast a "dynamic" directive, when processed through the 00384 /// overloaded process_directives(string) both creates the SO 00385 /// locally and initializes it, where the statics directive must 00386 /// first locate the SO and then calls the init() method. This means 00387 /// that durig the "static" initialization there's no specific 00388 /// information about the hosting repository and the gestalt must 00389 /// employ some lookup strategy to find it elsewhere. 00390 00391 if (this->processed_static_svcs_ == 0) 00392 ACE_NEW (this->processed_static_svcs_, 00393 ACE_PROCESSED_STATIC_SVCS); 00394 00395 Processed_Static_Svc **pss = 0; 00396 for (ACE_PROCESSED_STATIC_SVCS_ITERATOR iter (*this->processed_static_svcs_); 00397 iter.next (pss) != 0; 00398 iter.advance ()) 00399 { 00400 if (ACE_OS::strcmp ((*pss)->name_, assd->name_) == 0) 00401 { 00402 (*pss)->assd_ = assd; 00403 return; 00404 } 00405 } 00406 Processed_Static_Svc *tmp = 0; 00407 ACE_NEW (tmp,Processed_Static_Svc(assd)); 00408 this->processed_static_svcs_->insert(tmp); 00409 00410 if (ACE::debug ()) 00411 ACE_DEBUG ((LM_DEBUG, 00412 ACE_TEXT ("ACE (%P|%t) SG::add_processed_static_svc, ") 00413 ACE_TEXT ("repo=%@ - %s\n"), 00414 this->repo_, 00415 assd->name_)); 00416 }
| int ACE_Service_Gestalt::close | ( | void | ) | [private] |
Tidy up and perform last rites when ACE_Service_Config is shut down. This method calls close_svcs. Returns 0.
Definition at line 1266 of file Service_Gestalt.cpp.
01267 { 01268 ACE_TRACE ("ACE_Service_Gestalt::close"); 01269 01270 if (!this->is_opened_ || --this->is_opened_ != 0) 01271 return 0; 01272 01273 // Delete the list fo svc.conf files 01274 delete this->svc_conf_file_queue_; 01275 this->svc_conf_file_queue_ = 0; 01276 01277 if (this->processed_static_svcs_ && 01278 !this->processed_static_svcs_->is_empty()) 01279 { 01280 Processed_Static_Svc **pss = 0; 01281 for (ACE_PROCESSED_STATIC_SVCS_ITERATOR iter (*this->processed_static_svcs_); 01282 iter.next (pss) != 0; 01283 iter.advance ()) 01284 { 01285 delete *pss; 01286 } 01287 } 01288 delete this->processed_static_svcs_; 01289 this->processed_static_svcs_ = 0; 01290 01291 #ifndef ACE_NLOGGING 01292 if (ACE::debug ()) 01293 ACE_DEBUG ((LM_DEBUG, 01294 ACE_TEXT ("ACE (%P|%t) SG::close - complete this=%@, repo=%@, owned=%d\n"), 01295 this, this->repo_, this->svc_repo_is_owned_)); 01296 #endif 01297 01298 if (this->svc_repo_is_owned_) 01299 delete this->repo_; 01300 01301 this->repo_ = 0; 01302 01303 return 0; 01304 } /* close () */
| ACE_Service_Repository * ACE_Service_Gestalt::current_service_repository | ( | void | ) | [private] |
Get the current ACE_Service_Repository held by this object.
Definition at line 71 of file Service_Gestalt.inl.
00072 { 00073 return this->repo_; 00074 }
| void ACE_Service_Gestalt::dump | ( | void | ) | const [private] |
Dump the state of an object.
Definition at line 440 of file Service_Gestalt.cpp.
00441 { 00442 #if defined (ACE_HAS_DUMP) 00443 ACE_TRACE ("ACE_Service_Gestalt::dump"); 00444 #endif /* ACE_HAS_DUMP */ 00445 }
| int ACE_Service_Gestalt::find | ( | const ACE_TCHAR | name[], | |
| const ACE_Service_Type ** | srp = 0, |
|||
| bool | ignore_suspended = true | |||
| ) | const [private] |
Searches for a service object declaration in the local repo, only.
Locate an entry with name in the table. If ignore_suspended is set then only consider services marked as resumed. If the caller wants the located entry, pass back a pointer to the located entry via srp. If name is not found, -1 is returned. If name is found, but it is suspended and the caller wants to ignore suspended services a -2 is returned.
Definition at line 56 of file Service_Gestalt.inl.
00059 { 00060 // Closing the gestalt will have disassociated it from the 00061 // repository. If the repository used to be owned by the gestalt, it 00062 // will also have been destroyed - so just check for repo_ before 00063 // doing anything with it. 00064 if (this->repo_ != 0) 00065 return this->repo_->find (name, srp, ignore_suspended); 00066 00067 return 0; 00068 }
| const ACE_Static_Svc_Descriptor * ACE_Service_Gestalt::find_processed_static_svc | ( | const ACE_TCHAR * | name | ) | [protected] |
Definition at line 347 of file Service_Gestalt.cpp.
00348 { 00349 if (this->processed_static_svcs_ == 0 || name == 0) 00350 return 0; 00351 00352 Processed_Static_Svc **pss = 0; 00353 for (ACE_PROCESSED_STATIC_SVCS_ITERATOR iter (*this->processed_static_svcs_); 00354 iter.next (pss) != 0; 00355 iter.advance ()) 00356 { 00357 if (ACE_OS::strcmp ((*pss)->name_, name) == 0) 00358 return (*pss)->assd_; 00359 } 00360 return 0; 00361 }
| int ACE_Service_Gestalt::find_static_svc_descriptor | ( | const ACE_TCHAR * | name, | |
| ACE_Static_Svc_Descriptor ** | ssd = 0 | |||
| ) | const [private] |
Find a static service descriptor by name.
Using the supplied name, finds and (if needed) returns a pointer to a static service descriptor. Returns 0 for success and -1 for failure
Definition at line 320 of file Service_Gestalt.cpp.
00322 { 00323 ACE_TRACE ("ACE_Service_Gestalt::find_static_svc_descriptor"); 00324 00325 if (this->static_svcs_ == 0) 00326 return -1; 00327 00328 ACE_Static_Svc_Descriptor **ssdp = 0; 00329 for (ACE_STATIC_SVCS_ITERATOR iter ( *this->static_svcs_); 00330 iter.next (ssdp) != 0; 00331 iter.advance ()) 00332 { 00333 if (ACE_OS::strcmp ((*ssdp)->name_, name) == 0) 00334 { 00335 if (ssd != 0) 00336 *ssd = *ssdp; 00337 00338 return 0; 00339 } 00340 } 00341 00342 return -1; 00343 }
| ACE_XML_Svc_Conf * ACE_Service_Gestalt::get_xml_svc_conf | ( | ACE_DLL & | d | ) | [protected] |
Helper function to dynamically link in the XML Service Configurator parser.
Definition at line 845 of file Service_Gestalt.cpp.
00846 { 00847 if (xmldll.open (ACE_TEXT ("ACEXML_XML_Svc_Conf_Parser")) == -1) 00848 ACE_ERROR_RETURN ((LM_ERROR, 00849 ACE_TEXT ("ACE (%P|%t) Failure to open ACEXML_XML_Svc_Conf_Parser: %p\n"), 00850 ACE_TEXT("ACE_Service_Config::get_xml_svc_conf")), 00851 0); 00852 00853 void * foo = 00854 xmldll.symbol (ACE_TEXT ("_ACEXML_create_XML_Svc_Conf_Object")); 00855 00856 #if defined (ACE_OPENVMS) && (!defined (__INITIAL_POINTER_SIZE) || (__INITIAL_POINTER_SIZE < 64)) 00857 int const temp_p = reinterpret_cast<int> (foo); 00858 #else 00859 intptr_t const temp_p = reinterpret_cast<intptr_t> (foo); 00860 #endif 00861 00862 ACE_XML_Svc_Conf::Factory factory = reinterpret_cast<ACE_XML_Svc_Conf::Factory> (temp_p); 00863 00864 if (factory == 0) 00865 ACE_ERROR_RETURN ((LM_ERROR, 00866 ACE_TEXT ("ACE (%P|%t) Unable to resolve factory: %p\n"), 00867 xmldll.error ()), 00868 0); 00869 00870 return factory (); 00871 }
| int ACE_Service_Gestalt::init_i | ( | void | ) | [protected] |
Performs the common initialization tasks for a new or previously closed instance. Must not be virtual, as it is called from the constructor.
Performs the common initialization tasks for a new or previously closed instance. Must not be virtual, as it is also called from the constructor.
Definition at line 239 of file Service_Gestalt.cpp.
00240 { 00241 // Only initialize the repo_ if (a) we are being constructed, or; 00242 // (b) we're being open()-ed, perhaps after previously having been 00243 // close()-ed. In both cases: repo_ == 0 and we need a repository. 00244 if (this->repo_ == 0) 00245 { 00246 if (this->svc_repo_is_owned_) 00247 { 00248 ACE_NEW_RETURN (this->repo_, 00249 ACE_Service_Repository (this->svc_repo_size_), 00250 -1); 00251 } 00252 else 00253 { 00254 this->repo_ = 00255 ACE_Service_Repository::instance (this->svc_repo_size_); 00256 } 00257 } 00258 00259 if (init_svc_conf_file_queue () == -1) 00260 return -1; 00261 00262 if ( svc_conf_file_queue_->is_empty ()) 00263 { 00264 // Check if the default file exists before attempting to queue it 00265 // for processing 00266 FILE *fp = ACE_OS::fopen (ACE_DEFAULT_SVC_CONF, 00267 ACE_TEXT ("r")); 00268 bool skip_static_svcs = (fp == 0); 00269 if (fp != 0) 00270 ACE_OS::fclose (fp); 00271 00272 if (!skip_static_svcs) { 00273 // Load the default "svc.conf" entry here if there weren't 00274 // overriding -f arguments in <parse_args>. 00275 if (svc_conf_file_queue_->enqueue_tail 00276 (ACE_TString (ACE_DEFAULT_SVC_CONF)) == -1) 00277 { 00278 ACE_ERROR_RETURN ((LM_ERROR, 00279 ACE_TEXT ("%p\n"), 00280 ACE_TEXT ("enqueuing ") 00281 ACE_DEFAULT_SVC_CONF 00282 ACE_TEXT(" file")), 00283 -1); 00284 } 00285 } 00286 } 00287 00288 return 0; 00289 }
| int ACE_Service_Gestalt::init_svc_conf_file_queue | ( | void | ) | [protected] |
Initialize the svc_conf_file_queue_ if necessary.
Definition at line 992 of file Service_Gestalt.cpp.
00993 { 00994 if (this->svc_conf_file_queue_ == 0) 00995 { 00996 ACE_SVC_QUEUE *tmp = 0; 00997 ACE_NEW_RETURN (tmp, 00998 ACE_SVC_QUEUE, 00999 -1); 01000 this->svc_conf_file_queue_ = tmp; 01001 } 01002 01003 #ifndef ACE_NLOGGING 01004 if (ACE::debug ()) 01005 ACE_DEBUG ((LM_DEBUG, 01006 ACE_TEXT ("ACE (%P|%t) SG::init_svc_conf_file_queue ") 01007 ACE_TEXT ("- this=%@, repo=%@\n"), 01008 this, this->repo_)); 01009 #endif 01010 01011 return 0; 01012 01013 } /* init_svc_conf_file_queue () */
| int ACE_Service_Gestalt::initialize | ( | const ACE_TCHAR * | svc_name, | |
| const ACE_TCHAR * | parameters | |||
| ) | [private] |
Initialize and activate a statically svc_name service.
If initialization fails ...
Definition at line 448 of file Service_Gestalt.cpp.
00450 { 00451 ACE_TRACE ("ACE_Service_Gestalt_Base::initialize (repo)"); 00452 ACE_ARGV args (parameters); 00453 00454 #ifndef ACE_NLOGGING 00455 if (ACE::debug ()) 00456 { 00457 ACE_DEBUG ((LM_DEBUG, 00458 ACE_TEXT ("ACE (%P|%t) SG::initialize - () repo=%@, ") 00459 ACE_TEXT ("looking up static ") 00460 ACE_TEXT ("service \'%s\' to initialize\n"), 00461 this->repo_, 00462 svc_name)); 00463 } 00464 #endif 00465 00466 const ACE_Service_Type *srp = 0; 00467 for (int i = 0; this->find (svc_name, &srp) == -1 && i < 2; i++) 00468 // if (this->repo_->find (svc_name, &srp) == -1) 00469 { 00470 const ACE_Static_Svc_Descriptor *assd = 00471 ACE_Service_Config::global()->find_processed_static_svc(svc_name); 00472 if (assd != 0) 00473 { 00474 this->process_directive_i(*assd, 0); 00475 } 00476 else 00477 { 00478 ACE_ERROR_RETURN ((LM_ERROR, 00479 ACE_TEXT ("ACE (%P|%t) ERROR: SG::initialize - service \'%s\'") 00480 ACE_TEXT (" was not located.\n"), 00481 svc_name), 00482 -1); 00483 } 00484 } 00485 if (srp == 0) 00486 ACE_ERROR_RETURN ((LM_ERROR, 00487 ACE_TEXT ("ACE (%P|%t) ERROR: SG::initialize - service \'%s\'") 00488 ACE_TEXT (" was not located.\n"), 00489 svc_name), 00490 -1); 00491 00492 /// If initialization fails ... 00493 if (srp->type ()->init (args.argc (), 00494 args.argv ()) == -1) 00495 { 00496 // ... report and remove this entry. 00497 ACE_ERROR ((LM_ERROR, 00498 ACE_TEXT ("ACE (%P|%t) ERROR: SG::initialize - static init of \'%s\'") 00499 ACE_TEXT (" failed (%p)\n"), 00500 svc_name, ACE_TEXT ("error"))); 00501 this->repo_->remove (svc_name); 00502 return -1; 00503 } 00504 00505 // If everything is ok, activate it 00506 const_cast<ACE_Service_Type *>(srp)->active (1); 00507 return 0; 00508 }
| int ACE_Service_Gestalt::initialize | ( | const ACE_Service_Type * | sr, | |
| const ACE_TCHAR * | parameters | |||
| ) | [private] |
Dynamically link the shared object file and retrieve a pointer to the designated shared object in this file.
Dynamically link the shared object file and retrieve a pointer to the designated shared object in this file.
Definition at line 607 of file Service_Gestalt.cpp.
00609 { 00610 ACE_TRACE ("ACE_Service_Gestalt::initialize"); 00611 00612 if (ACE::debug ()) 00613 ACE_DEBUG ((LM_DEBUG, 00614 ACE_TEXT ("ACE (%P|%t) SG::initialize - repo=%@, name=%s") 00615 ACE_TEXT (" - looking up in the repo\n"), 00616 this->repo_, 00617 sr->name ())); 00618 00619 ACE_Service_Type *srp = 0; 00620 if (this->repo_->find (sr->name (), 00621 (const ACE_Service_Type **) &srp) >= 0) 00622 { 00623 #ifndef ACE_NLOGGING 00624 ACE_DEBUG ((LM_WARNING, 00625 ACE_TEXT ("ACE (%P|%t) SG::initialize - repo=%@, name=%s") 00626 ACE_TEXT (" - removing a pre-existing namesake.\n"), 00627 this->repo_, 00628 sr->name ())); 00629 #endif 00630 this->repo_->remove (sr->name ()); 00631 } 00632 00633 return this->initialize_i (sr, parameters); 00634 00635 }
| int ACE_Service_Gestalt::initialize | ( | const ACE_Service_Type_Factory * | , | |
| const ACE_TCHAR * | parameters | |||
| ) | [private] |
Dynamically link the shared object file and retrieve a pointer to the designated shared object in this file. Also account for the possiblity to have static services registered when loading the DLL, by ensuring that the dynamic sevice is registered before any of its subordibnate static services. Thus avoiding any finalization order problems.
| int ACE_Service_Gestalt::initialize_i | ( | const ACE_Service_Type * | sr, | |
| const ACE_TCHAR * | parameters | |||
| ) | [protected] |
Dynamically link the shared object file and retrieve a pointer to the designated shared object in this file.
Definition at line 640 of file Service_Gestalt.cpp.
00642 { 00643 ACE_TRACE ("ACE_Service_Gestalt::initialize_i"); 00644 ACE_ARGV args (parameters); 00645 if (sr->type ()->init (args.argc (), 00646 args.argv ()) == -1) 00647 { 00648 // We just get ps to avoid having remove() delete it. 00649 ACE_Service_Type *ps = 0; 00650 this->repo_->remove (sr->name (), &ps); 00651 00652 #ifndef ACE_NLOGGING 00653 // Not using LM_ERROR here to avoid confusing the test harness 00654 if (ACE::debug ()) 00655 ACE_ERROR_RETURN ((LM_WARNING, 00656 ACE_TEXT ("ACE (%P|%t) SG::initialize_i -") 00657 ACE_TEXT (" repo=%@, name=%s - remove failed: %m\n"), 00658 this->repo_, 00659 sr->name ()), 00660 -1); 00661 #endif 00662 return -1; 00663 } 00664 00665 if (this->repo_->insert (sr) == -1) 00666 { 00667 #ifndef ACE_NLOGGING 00668 // Not using LM_ERROR here to avoid confusing the test harness 00669 if (ACE::debug ()) 00670 ACE_ERROR_RETURN ((LM_WARNING, 00671 ACE_TEXT ("ACE (%P|%t) SG::initialize_i -") 00672 ACE_TEXT (" repo=%@, name=%s - insert failed: %m\n"), 00673 this->repo_, 00674 sr->name ()), 00675 -1); 00676 #endif 00677 return -1; 00678 } 00679 00680 return 0; 00681 }
| int ACE_Service_Gestalt::insert | ( | ACE_Static_Svc_Descriptor * | stsd | ) | [private] |
Registers a service descriptor for a static service object.
Queues a static service object descriptor which, during open() will be given to process_directive() to create the Service Object. Normally, only called from static initializers, prior to calling open() but loading a service from a DLL can cause it too.
Definition at line 425 of file Service_Gestalt.cpp.
00426 { 00427 if (this->static_svcs_ == 0) 00428 ACE_NEW_RETURN (this->static_svcs_, 00429 ACE_STATIC_SVCS, 00430 -1); 00431 00432 return this->static_svcs_->insert (stsd); 00433 }
| void ACE_Service_Gestalt::intrusive_add_ref | ( | ACE_Service_Gestalt * | g | ) | [static] |
Definition at line 151 of file Service_Gestalt.cpp.
| void ACE_Service_Gestalt::intrusive_remove_ref | ( | ACE_Service_Gestalt * | g | ) | [static] |
Definition at line 161 of file Service_Gestalt.cpp.
00162 { 00163 if (g != 0) 00164 { 00165 long tmp = --g->refcnt_; 00166 if (tmp <= 0) delete g; 00167 ACE_ASSERT (tmp >= 0); 00168 } 00169 }
| int ACE_Service_Gestalt::is_opened | ( | void | ) | [private] |
Has it been opened? Returns the difference between the times open and close have been called on this instance
Definition at line 1120 of file Service_Gestalt.cpp.
01121 { 01122 return this->is_opened_; 01123 }
| int ACE_Service_Gestalt::load_static_svcs | ( | void | ) | [protected] |
Add the default statically-linked services to the ACE_Service_Repository.
Add the default statically-linked services to the Service Repository.
Definition at line 295 of file Service_Gestalt.cpp.
00296 { 00297 ACE_TRACE ("ACE_Service_Gestalt::load_static_svcs"); 00298 00299 if (this->static_svcs_ == 0) 00300 return 0; // Nothing to do 00301 00302 ACE_Static_Svc_Descriptor **ssdp = 0; 00303 for (ACE_STATIC_SVCS_ITERATOR iter (*this->static_svcs_); 00304 iter.next (ssdp) != 0; 00305 iter.advance ()) 00306 { 00307 ACE_Static_Svc_Descriptor *ssd = *ssdp; 00308 00309 if (this->process_directive (*ssd, 1) == -1) 00310 return -1; 00311 } 00312 return 0; 00313 00314 } /* load_static_svcs () */
| int ACE_Service_Gestalt::open | ( | int | argc, | |
| ACE_TCHAR * | argv[], | |||
| const ACE_TCHAR * | logger_key = 0, |
|||
| bool | ignore_static_svcs = true, |
|||
| bool | ignore_default_svc_conf_file = false, |
|||
| bool | ignore_debug_flag = false | |||
| ) | [private] |
This is the primary entry point into the ACE_Service_Config (the constructor just handles simple initializations). It parses arguments passed in from argc and argv parameters. The arguments that are valid in a call to this method include:
chroot() to the appropriate directory. | argc | The number of commandline arguments. | |
| argv | The array with commandline arguments | |
| logger_key | Indicates where to write the logging output, which is typically either a STREAM pipe or a socket address. | |
| ignore_static_svcs | If true then static services are not loaded, otherwise, they are loaded. | |
| ignore_default_svc_conf_file | If false then the svc.conf configuration file will be ignored. | |
| ignore_debug_flag | If false then the application is responsible for setting the ACE_Log_Msg::priority_mask appropriately. |
| -1 | The configuration file is not found or cannot be opened (errno is set accordingly). | |
| 0 | Success. | |
| >0 | The number of errors encountered while processing the service configuration file(s). |
Definition at line 30 of file Service_Gestalt.inl.
00036 { 00037 ACE_TRACE ("ACE_Service_Gestalt::open"); 00038 00039 this->no_static_svcs_ = ignore_static_svcs; 00040 00041 if (this->parse_args_i (argc, 00042 argv, 00043 ignore_default_svc_conf) == -1) 00044 return -1; 00045 00046 return this->open_i (argv == 0 ? 0 : argv[0], 00047 logger_key, 00048 ignore_static_svcs, 00049 ignore_default_svc_conf, 00050 ignore_debug_flag); 00051 }
| int ACE_Service_Gestalt::open | ( | const ACE_TCHAR | program_name[], | |
| const ACE_TCHAR * | logger_key = 0, |
|||
| bool | ignore_static_svcs = true, |
|||
| bool | ignore_default_svc_conf_file = false, |
|||
| bool | ignore_debug_flag = false | |||
| ) | [private] |
Performs an open without parsing command-line arguments. The logger_key indicates where to write the logging output, which is typically either a STREAM pipe or a socket address. If ignore_static_svcs is true then static services are not loaded, otherwise, they are loaded. If ignore_default_svc_conf_file is true then the svc.conf configuration file will be ignored. Returns zero upon success, -1 if the file is not found or cannot be opened (errno is set accordingly), otherwise returns the number of errors encountered loading the services in the specified svc.conf configuration file. If ignore_debug_flag is true then the application is responsible for setting the ACE_Log_Msg::priority_mask appropriately.
Definition at line 13 of file Service_Gestalt.inl.
00018 { 00019 ACE_TRACE ("ACE_Service_Gestalt::open"); 00020 this->no_static_svcs_ = ignore_static_svcs; 00021 00022 return this->open_i (program_name, 00023 logger_key, 00024 ignore_static_svcs, 00025 ignore_default_svc_conf, 00026 ignore_debug_flag); 00027 }
| int ACE_Service_Gestalt::open_i | ( | const ACE_TCHAR | program_name[], | |
| const ACE_TCHAR * | logger_key = 0, |
|||
| bool | ignore_static_svcs = true, |
|||
| bool | ignore_default_svc_conf_file = false, |
|||
| bool | ignore_debug_flag = false | |||
| ) | [protected] |
Performs an open without parsing command-line arguments. The logger_key indicates where to write the logging output, which is typically either a STREAM pipe or a socket address. If ignore_default_svc_conf_file is non-0 then the "svc.conf" file will be ignored. If ignore_debug_flag is non-0 then the application is responsible for setting the ACE_Log_Msg::priority_mask() appropriately. Returns number of errors that occurred on failure and 0 otherwise.
Definition at line 1017 of file Service_Gestalt.cpp.
01022 { 01023 ACE_TRACE ("ACE_Service_Gestalt::open_i"); 01024 int result = 0; 01025 ACE_Log_Msg *log_msg = ACE_LOG_MSG; 01026 01027 this->no_static_svcs_ = ignore_static_svcs; 01028 01029 // Record the current log setting upon entering this thread. 01030 u_long old_process_mask = log_msg->priority_mask 01031 (ACE_Log_Msg::PROCESS); 01032 01033 u_long old_thread_mask = log_msg->priority_mask 01034 (ACE_Log_Msg::THREAD); 01035 01036 #ifndef ACE_NLOGGING 01037 if (ACE::debug ()) 01038 ACE_DEBUG ((LM_DEBUG, 01039 ACE_TEXT ("ACE (%P|%t) SG::open_i - this=%@, ") 01040 ACE_TEXT ("opened=%d, loadstatics=%d\n"), 01041 this, this->is_opened_, this->no_static_svcs_)); 01042 #endif 01043 01044 // Guard against reentrant processing. For example, 01045 // if the singleton gestalt (ubergestalt) was already open, 01046 // do not open it again... 01047 if (this->is_opened_++ != 0) 01048 return 0; 01049 01050 if (this->init_i () != 0) 01051 return -1; 01052 01053 u_long flags = log_msg->flags (); 01054 01055 // Only use STDERR if the caller hasn't already set the flags. 01056 if (flags == 0) 01057 flags = (u_long) ACE_Log_Msg::STDERR; 01058 01059 const ACE_TCHAR *key = logger_key; 01060 01061 if (key == 0 || ACE_OS::strcmp (key, ACE_DEFAULT_LOGGER_KEY) == 0) 01062 { 01063 // Only use the static <logger_key_> if the caller doesn't 01064 // override it in the parameter list or if the key supplied is 01065 // equal to the default static logger key. 01066 key = this->logger_key_; 01067 } 01068 else 01069 { 01070 ACE_SET_BITS (flags, ACE_Log_Msg::LOGGER); 01071 } 01072 01073 if (log_msg->open (program_name, 01074 flags, 01075 key) == -1) 01076 return -1; 01077 01078 if (!ignore_debug_flag) 01079 { 01080 // If -d was included as a startup parameter, the user wants debug 01081 // information printed during service initialization. 01082 if (ACE::debug ()) 01083 ACE_Log_Msg::enable_debug_messages (); 01084 else 01085 // The user has requested no debugging info. 01086 ACE_Log_Msg::disable_debug_messages (); 01087 } 01088 01089 // See if we need to load the static services. 01090 if (this->no_static_svcs_ == 0 01091 && this->load_static_svcs () == -1) 01092 result = -1; 01093 else 01094 { 01095 if (this->process_commandline_directives () == -1) 01096 result = -1; 01097 else 01098 result = this->process_directives (ignore_default_svc_conf_file); 01099 } 01100 01101 01102 // Reset debugging back to the way it was when we came into 01103 // into <open_i>. 01104 { 01105 // Make sure to save/restore errno properly. 01106 ACE_Errno_Guard error (errno); 01107 01108 if (!ignore_debug_flag) 01109 { 01110 log_msg->priority_mask (old_process_mask, ACE_Log_Msg::PROCESS); 01111 log_msg->priority_mask (old_thread_mask, ACE_Log_Msg::THREAD); 01112 } 01113 } 01114 01115 return result; 01116 } /* open_i () */
| int ACE_Service_Gestalt::parse_args | ( | int | argc, | |
| ACE_TCHAR * | argv[] | |||
| ) | [private] |
Handle the command-line options intended for the ACE_Service_Gestalt. Note that argv[0] is assumed to be the program name.
The arguments that are valid in a call to this method are
Definition at line 1156 of file Service_Gestalt.cpp.
01157 { 01158 ACE_TRACE ("ACE_Service_Gestalt::parse_args"); 01159 bool unused_ignore_default_svc_conf = true; 01160 return parse_args_i (argc, argv, unused_ignore_default_svc_conf); 01161 }
| int ACE_Service_Gestalt::parse_args_i | ( | int | argc, | |
| ACE_TCHAR * | argv[], | |||
| bool & | ignore_default_svc_conf_file | |||
| ) | [protected] |
Definition at line 1164 of file Service_Gestalt.cpp.
01167 { 01168 ACE_TRACE ("ACE_Service_Gestalt::parse_args_i"); 01169 ACE_Get_Opt get_opt (argc, 01170 argv, 01171 ACE_TEXT ("df:k:nyS:"), 01172 1); // Start at argv[1]. 01173 01174 if (this->init_svc_conf_file_queue () == -1) 01175 return -1; 01176 01177 for (int c; (argc != 0) && ((c = get_opt ()) != -1); ) 01178 switch (c) 01179 { 01180 case 'd': 01181 ACE::debug (1); 01182 break; 01183 case 'f': 01184 if (this->svc_conf_file_queue_->enqueue_tail (ACE_TString (get_opt.opt_arg ())) == -1) 01185 ACE_ERROR_RETURN ((LM_ERROR, 01186 ACE_TEXT ("%p\n"), 01187 ACE_TEXT ("enqueue_tail")), 01188 -1); 01189 ignore_default_svc_conf_file = true; 01190 break; 01191 case 'k': 01192 /* 01193 * @TODO: Is this always a static storage? Shouldn't we copy 01194 * & gain ownership of the value? 01195 */ 01196 this->logger_key_ = get_opt.opt_arg (); 01197 break; 01198 case 'n': 01199 this->no_static_svcs_ = 1; 01200 break; 01201 case 'y': 01202 this->no_static_svcs_ = 0; 01203 break; 01204 case 'S': 01205 if (this->svc_queue_ == 0) 01206 { 01207 ACE_NEW_RETURN (this->svc_queue_, 01208 ACE_SVC_QUEUE, 01209 -1); 01210 } 01211 01212 if (this->svc_queue_->enqueue_tail (ACE_TString (get_opt.opt_arg ())) == -1) 01213 ACE_ERROR_RETURN ((LM_ERROR, 01214 ACE_TEXT ("%p\n"), 01215 ACE_TEXT ("enqueue_tail")), 01216 -1); 01217 break; 01218 default: 01219 if (ACE::debug ()) 01220 ACE_DEBUG ((LM_DEBUG, 01221 ACE_TEXT ("ACE (%P|%t) %c is not a ACE_Service_Config option\n"), 01222 c)); 01223 } 01224 01225 return 0; 01226 } /* parse_args_i () */
| int ACE_Service_Gestalt::process_commandline_directives | ( | void | ) | [protected] |
Process service configuration requests that were provided on the command-line. Returns the number of errors that occurred.
Definition at line 1126 of file Service_Gestalt.cpp.
01127 { 01128 int result = 0; 01129 if (this->svc_queue_ != 0) 01130 { 01131 ACE_TString *sptr = 0; 01132 for (ACE_SVC_QUEUE_ITERATOR iter (*this->svc_queue_); 01133 iter.next (sptr) != 0; 01134 iter.advance ()) 01135 { 01136 // Process just a single directive. 01137 if (this->process_directive ((sptr->fast_rep ())) != 0) 01138 { 01139 ACE_ERROR ((LM_ERROR, 01140 ACE_TEXT ("ACE (%P|%t) %p\n"), 01141 ACE_TEXT ("process_directive"))); 01142 result = -1; 01143 } 01144 } 01145 01146 delete this->svc_queue_; 01147 this->svc_queue_ = 0; 01148 } 01149 01150 return result; 01151 01152 } /* process_commandline_directives () */
| int ACE_Service_Gestalt::process_directive | ( | const ACE_Static_Svc_Descriptor & | ssd, | |
| bool | force_replace = false | |||
| ) | [private] |
Process one static service definition.
Load a new static service.
| ssd | Service descriptor, see the document of ACE_Static_Svc_Descriptor for more details. | |
| force_replace | If set the new service descriptor replaces any previous instance in the repository. |
Definition at line 726 of file Service_Gestalt.cpp.
00728 { 00729 int const result = process_directive_i (ssd, force_replace); 00730 if (result == 0) 00731 { 00732 this->add_processed_static_svc(&ssd); 00733 } 00734 return result; 00735 }
| int ACE_Service_Gestalt::process_directive | ( | const ACE_TCHAR | directive[] | ) | [private] |
Process one service configuration directive, which is passed as a string. Returns the number of errors that occurred.
Definition at line 950 of file Service_Gestalt.cpp.
00951 { 00952 ACE_TRACE ("ACE_Service_Gestalt::process_directive"); 00953 00954 #ifndef ACE_NLOGGING 00955 if (ACE::debug ()) 00956 ACE_DEBUG ((LM_DEBUG, 00957 ACE_TEXT ("ACE (%P|%t) SG::process_directive, repo=%@ - %s\n"), 00958 this->repo_, 00959 directive)); 00960 #endif 00961 00962 #if (ACE_USES_CLASSIC_SVC_CONF == 1) 00963 ACE_UNUSED_ARG (directive); 00964 00965 ACE_Svc_Conf_Param d (this, directive); 00966 00967 return this->process_directives_i (&d); 00968 #else 00969 ACE_DLL dll; 00970 00971 auto_ptr<ACE_XML_Svc_Conf> 00972 xml_svc_conf (this->get_xml_svc_conf (dll)); 00973 00974 if (xml_svc_conf.get () == 0) 00975 return -1; 00976 00977 // Temporarily (for the duration of this call) make sure that *any* static 00978 // service registrations will happen with this instance. Such registrations 00979 // are possible as a side-effect of dynamically loading a DLL, which has 00980 // other static services registered. Thus this instance will own both the 00981 // DLL and those static services, which implies that their finalization 00982 // will be performed in the correct order, i.e. prior to finalizing the DLL 00983 ACE_Service_Config_Guard guard (this); 00984 00985 return xml_svc_conf->parse_string (directive); 00986 #endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */ 00987 00988 } /* process_directive () */
| int ACE_Service_Gestalt::process_directive_i | ( | const ACE_Static_Svc_Descriptor & | ssd, | |
| bool | force_replace = false | |||
| ) | [protected] |
Process a static directive without also inserting its descriptor the global table. This avoids multiple additions when processing directives in non-global gestalts.
Definition at line 738 of file Service_Gestalt.cpp.
00740 { 00741 if (this->repo_ == 0) 00742 return -1; 00743 00744 if (!force_replace) 00745 { 00746 if (this->repo_->find (ssd.name_, 0, 0) >= 0) 00747 { 00748 // The service is already there, just return 00749 return 0; 00750 } 00751 } 00752 00753 00754 ACE_Service_Object_Exterminator gobbler; 00755 void *sym = (ssd.alloc_)(&gobbler); 00756 00757 ACE_Service_Type_Impl *stp = 00758 ACE_Service_Config::create_service_type_impl (ssd.name_, 00759 ssd.type_, 00760 sym, 00761 ssd.flags_, 00762 gobbler); 00763 if (stp == 0) 00764 return 0; 00765 00766 ACE_Service_Type *service_type = 0; 00767 00768 // This is just a temporary to force the compiler to use the right 00769 // constructor in ACE_Service_Type. Note that, in cases where we are 00770 // called from a static initializer which is part of a DLL, there is 00771 // not enough information about the actuall DLL in this context. 00772 ACE_DLL tmp_dll; 00773 00774 ACE_NEW_RETURN (service_type, 00775 ACE_Service_Type (ssd.name_, 00776 stp, 00777 tmp_dll, 00778 ssd.active_), 00779 -1); 00780 00781 #ifndef ACE_NLOGGING 00782 if (ACE::debug ()) 00783 ACE_DEBUG ((LM_DEBUG, 00784 ACE_TEXT ("ACE (%P|%t) SG::process_directive_i, ") 00785 ACE_TEXT ("repo=%@ - %s, dll=%s, force=%d\n"), 00786 this->repo_, 00787 ssd.name_, 00788 (tmp_dll.dll_name_ == 0) ? ACE_TEXT ("<null>") : tmp_dll.dll_name_, 00789 force_replace)); 00790 #endif 00791 00792 return this->repo_->insert (service_type); 00793 }
| int ACE_Service_Gestalt::process_directives | ( | bool | ignore_default_svc_conf_file | ) | [private] |
Process (or re-process) service configuration requests that are provided in the svc.conf file(s). Returns the number of errors that occurred.
Definition at line 1233 of file Service_Gestalt.cpp.
01234 { 01235 ACE_TRACE ("ACE_Service_Gestalt::process_directives"); 01236 01237 if (this->svc_conf_file_queue_ == 0 01238 || this->svc_conf_file_queue_->is_empty ()) 01239 return 0; 01240 01241 ACE_TString *sptr = 0; 01242 ACE_TString default_svc_conf (ACE_DEFAULT_SVC_CONF); 01243 01244 int failed = 0; 01245 01246 // Iterate through all the svc.conf files. 01247 for (ACE_SVC_QUEUE_ITERATOR iter (*this->svc_conf_file_queue_); 01248 iter.next (sptr) != 0; 01249 iter.advance ()) 01250 { 01251 if (*sptr == default_svc_conf && ignore_default_svc_conf_file) 01252 continue; 01253 01254 int result = this->process_file (sptr->fast_rep ()); 01255 if (result < 0) 01256 return result; 01257 failed += result; 01258 } 01259 01260 return failed; 01261 01262 } /* process_directives () */
| int ACE_Service_Gestalt::process_directives_i | ( | ACE_Svc_Conf_Param * | param | ) | [protected] |
This is the implementation function that process_directives() and process_directive() both call. Returns the number of errors that occurred.
| int ACE_Service_Gestalt::process_file | ( | const ACE_TCHAR | file[] | ) | [private] |
Process a file containing a list of service configuration directives.
Definition at line 875 of file Service_Gestalt.cpp.
00876 { 00877 ACE_TRACE ("ACE_Service_Gestalt::process_file"); 00878 00879 // To avoid recursive processing of the same file and the same repository 00880 // we maintain an implicit stack of dummy "services" named after the file 00881 // being processed. Anytime we have to open a new file, we then can check 00882 // to see if it is not already being processed by searching for a dummy 00883 // service with a matching name. 00884 if (this->repo_->find (file, 0, 0) >=0) 00885 { 00886 ACE_DEBUG ((LM_WARNING, 00887 ACE_TEXT ("ACE (%P|%t) Configuration file %s is currently") 00888 ACE_TEXT (" being processed. Ignoring recursive process_file().\n"), 00889 file)); 00890 return 0; 00891 } 00892 00893 // Register a dummy service as a forward decl, using the file name as name. 00894 // The entry will be automaticaly removed once the thread exits this block. 00895 ACE_Service_Type_Dynamic_Guard recursion_guard (*this->repo_, 00896 file); 00897 00898 /* 00899 * @TODO: Test with ACE_USES_CLASSIC_SVC_CONF turned off! 00900 */ 00901 #if (ACE_USES_CLASSIC_SVC_CONF == 1) 00902 int result = 0; 00903 00904 FILE *fp = ACE_OS::fopen (file, 00905 ACE_TEXT ("r")); 00906 00907 if (fp == 0) 00908 { 00909 // Invalid svc.conf file. We'll report it here and break out of 00910 // the method. 00911 if (ACE::debug ()) 00912 ACE_DEBUG ((LM_ERROR, 00913 ACE_TEXT ("ACE (%P|%t): %p\n"), 00914 file)); 00915 00916 // Use stat to find out if the file exists. I didn't use access() 00917 // because stat is better supported on most non-unix platforms. 00918 ACE_stat exists; 00919 if (ACE_OS::stat (file, &exists) == 0) 00920 // If it exists, but we couldn't open it for reading then we 00921 // must not have permission to read it. 00922 errno = EPERM; 00923 else 00924 errno = ENOENT; 00925 result = -1; 00926 } 00927 else 00928 { 00929 ACE_Svc_Conf_Param f (this, fp); 00930 00931 // Keep track of the number of errors. 00932 result = this->process_directives_i (&f); 00933 00934 (void) ACE_OS::fclose (fp); 00935 } 00936 return result; 00937 #else 00938 ACE_DLL dll; 00939 00940 auto_ptr<ACE_XML_Svc_Conf> xml_svc_conf (this->get_xml_svc_conf (dll)); 00941 00942 if (xml_svc_conf.get () == 0) 00943 return -1; 00944 00945 return xml_svc_conf->parse_file (file); 00946 #endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */ 00947 }
| int ACE_Service_Gestalt::remove | ( | const ACE_TCHAR | svc_name[] | ) | [private] |
Totally remove svc_name from the daemon by removing it from the ACE_Reactor, and unlinking it if necessary.
Definition at line 687 of file Service_Gestalt.cpp.
| int ACE_Service_Gestalt::resume | ( | const ACE_TCHAR | svc_name[] | ) | [private] |
Resume a svc_name that was previously suspended or has not yet been resumed (e.g., a static service).
Definition at line 715 of file Service_Gestalt.cpp.
| int ACE_Service_Gestalt::suspend | ( | const ACE_TCHAR | svc_name[] | ) | [private] |
Suspend svc_name. Note that this will not unlink the service from the daemon if it was dynamically linked, it will mark it as being suspended in the Service Repository and call the suspend() member function on the appropriate ACE_Service_Object. A service can be resumed later on by calling the resume() member function...
Suspend svc_name. Note that this will not unlink the service from the daemon if it was dynamically linked, it will mark it as being suspended in the Service Repository and call the <suspend> member function on the appropriate <ACE_Service_Object>. A service can be resumed later on by calling the <resume> method...
Definition at line 702 of file Service_Gestalt.cpp.
friend class ACE_Dynamic_Service_Base [friend] |
Definition at line 405 of file Service_Gestalt.h.
friend class ACE_Service_Config [friend] |
Definition at line 407 of file Service_Gestalt.h.
friend class ACE_Service_Config_Guard [friend] |
Definition at line 408 of file Service_Gestalt.h.
friend class ACE_Service_Object [friend] |
Definition at line 406 of file Service_Gestalt.h.
Declare the dynamic allocation hooks.
Definition at line 186 of file Service_Gestalt.h.
int ACE_Service_Gestalt::is_opened_ [protected] |
Keep track of the number of times the instance has been initialized (opened). "If so, we can't allow <yyparse> to be called since it's not reentrant" is the original motivation, but that does not seem to be the case anymore. This variable is incremented by the <ACE_Service_Gestalt::open> method and decremented by the <ACE_Service_Gestalt::close> method.
Definition at line 426 of file Service_Gestalt.h.
const ACE_TCHAR* ACE_Service_Gestalt::logger_key_ [protected] |
Indicates where to write the logging output. This is typically either a STREAM pipe or a socket
Definition at line 430 of file Service_Gestalt.h.
bool ACE_Service_Gestalt::no_static_svcs_ [protected] |
Should we avoid loading the static services?
Definition at line 433 of file Service_Gestalt.h.
Repository of statically linked services for which process directive was called, but the service is not already a member of the static_svcs_ list.
Definition at line 453 of file Service_Gestalt.h.
ACE_Atomic_Op<ACE_SYNCH_MUTEX, long> ACE_Service_Gestalt::refcnt_ [protected] |
Support for intrusive reference counting.
Definition at line 456 of file Service_Gestalt.h.
ACE_Service_Repository* ACE_Service_Gestalt::repo_ [protected] |
The service repository to hold the services.
Definition at line 445 of file Service_Gestalt.h.
ACE_STATIC_SVCS* ACE_Service_Gestalt::static_svcs_ [protected] |
Repository of statically linked services.
Definition at line 448 of file Service_Gestalt.h.
ACE_SVC_QUEUE* ACE_Service_Gestalt::svc_conf_file_queue_ [protected] |
Queue of svc.conf files specified on the command-line. @ This should probably be made to handle unicode filenames...
Definition at line 442 of file Service_Gestalt.h.
ACE_SVC_QUEUE* ACE_Service_Gestalt::svc_queue_ [protected] |
Queue of services specified on the command-line.
Definition at line 436 of file Service_Gestalt.h.
bool ACE_Service_Gestalt::svc_repo_is_owned_ [protected] |
Do we own the service repository instance, or have only been given a ptr to the singleton?
Definition at line 414 of file Service_Gestalt.h.
size_t ACE_Service_Gestalt::svc_repo_size_ [protected] |
Repository size is necessary, so that we can close (which may destroy the repository instance), and then re-open again.
Definition at line 418 of file Service_Gestalt.h.
1.6.1