#include <Service_Gestalt.h>
Inheritance diagram for ACE_Service_Gestalt:
Public Types | |
enum | { MAX_SERVICES = ACE_DEFAULT_SERVICE_REPOSITORY_SIZE } |
Public Member Functions | |
ACE_Service_Gestalt (size_t size=1024, bool svc_repo_is_owned=true, bool no_static_svcs=true) | |
virtual | ~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=ACE_DEFAULT_LOGGER_KEY, 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=ACE_DEFAULT_LOGGER_KEY, 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, int force_replace=0) |
Process one static service definition. | |
int | process_file (const ACE_TCHAR file[]) |
int | find (const ACE_TCHAR name[], const ACE_Service_Type **srp=0, int ignore_suspended=1) const |
Searches for a service object declaration in the local repo, only. | |
int | parse_args (int, ACE_TCHAR *argv[]) |
int | process_directives (void) |
int | close (void) |
int | insert (ACE_Static_Svc_Descriptor *stsd) |
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. | |
Public Attributes | |
ACE_ALLOC_HOOK_DECLARE | |
Declare the dynamic allocation hooks. | |
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 |
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 | |
virtual int | parse_args_i (int, ACE_TCHAR *argv[]) |
virtual int | open_i (const ACE_TCHAR program_name[], const ACE_TCHAR *logger_key=ACE_DEFAULT_LOGGER_KEY, 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 if necessary. | |
int | load_static_svcs (void) |
int | process_commandline_directives (void) |
int | process_directive_i (const ACE_Static_Svc_Descriptor &ssd, int force_replace=0) |
int | process_directives_i (ACE_Svc_Conf_Param *param) |
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_ |
Private Member Functions | |
ACE_Service_Gestalt (const ACE_Service_Gestalt &) | |
ACE_Service_Gestalt & | operator= (const ACE_Service_Gestalt &) |
Friends | |
class | ACE_Dynamic_Service_Base |
class | ACE_Service_Object |
class | ACE_Service_Config_Guard |
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 68 of file Service_Gestalt.h.
|
Definition at line 397 of file Service_Gestalt.h. Referenced by add_processed_static_svc(). |
|
Definition at line 400 of file Service_Gestalt.h. Referenced by add_processed_static_svc(), close(), find_processed_static_svc(), and ~ACE_Service_Gestalt(). |
|
Definition at line 391 of file Service_Gestalt.h. Referenced by insert(). |
|
Definition at line 394 of file Service_Gestalt.h. Referenced by find_static_svc_descriptor(), and load_static_svcs(). |
|
Definition at line 386 of file Service_Gestalt.h. Referenced by init_svc_conf_file_queue(), and parse_args_i(). |
|
Definition at line 387 of file Service_Gestalt.h. Referenced by process_commandline_directives(), and process_directives(). |
|
Definition at line 78 of file Service_Gestalt.h.
00079 { 00080 MAX_SERVICES = ACE_DEFAULT_SERVICE_REPOSITORY_SIZE 00081 }; |
|
Not implemented to enforce no copying |
|
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 232 of file Service_Gestalt.cpp. References ACE_DEBUG, ACE_DEFAULT_LOGGER_KEY, ACE_TEXT, ACE::debug(), init_i(), and LM_DEBUG.
00235 : svc_repo_is_owned_ (svc_repo_is_owned) 00236 , svc_repo_size_ (size) 00237 , is_opened_ (0) 00238 , logger_key_ (ACE_DEFAULT_LOGGER_KEY) 00239 , no_static_svcs_ (no_static_svcs) 00240 , svc_queue_ (0) 00241 , svc_conf_file_queue_ (0) 00242 , repo_ (0) 00243 , static_svcs_ (0) 00244 , processed_static_svcs_ (0) 00245 { 00246 (void)this->init_i (); 00247 00248 #ifndef ACE_NLOGGING 00249 if (ACE::debug ()) 00250 ACE_DEBUG ((LM_DEBUG, 00251 ACE_TEXT ("ACE (%P|%t) SG::ctor - this = %@, pss = %@\n"), 00252 this, this->processed_static_svcs_)); 00253 #endif 00254 } |
|
Perform user-specified close activities and remove dynamic memory. Definition at line 199 of file Service_Gestalt.cpp. References ACE_DEBUG, ACE_PROCESSED_STATIC_SVCS_ITERATOR, ACE_TEXT, ACE_Unbounded_Set_Iterator< T >::advance(), ACE::debug(), ACE_Unbounded_Set< T >::is_empty(), LM_DEBUG, ACE_Unbounded_Set_Iterator< T >::next(), processed_static_svcs_, repo_, static_svcs_, and svc_repo_is_owned_.
00200 { 00201 if (this->svc_repo_is_owned_) 00202 delete this->repo_; 00203 00204 this->repo_ =0; 00205 00206 delete this->static_svcs_; 00207 this->static_svcs_ = 0; 00208 00209 // Delete the dynamically allocated static_svcs instance. 00210 #ifndef ACE_NLOGGING 00211 if (ACE::debug ()) 00212 ACE_DEBUG ((LM_DEBUG, 00213 ACE_TEXT ("ACE (%P|%t) SG::dtor - this=%@, pss = %@\n"), 00214 this, this->processed_static_svcs_)); 00215 #endif 00216 00217 if (this->processed_static_svcs_ && 00218 !this->processed_static_svcs_->is_empty()) 00219 { 00220 Processed_Static_Svc **pss = 0; 00221 for (ACE_PROCESSED_STATIC_SVCS_ITERATOR iter (*this->processed_static_svcs_); 00222 iter.next (pss) != 0; 00223 iter.advance ()) 00224 { 00225 delete *pss; 00226 } 00227 } 00228 delete this->processed_static_svcs_; 00229 this->processed_static_svcs_ = 0; 00230 } |
|
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 369 of file Service_Gestalt.cpp. References ACE_DEBUG, ACE_NEW, ACE_PROCESSED_STATIC_SVCS, ACE_PROCESSED_STATIC_SVCS_ITERATOR, ACE_TEXT, ACE_Unbounded_Set_Iterator< T >::advance(), ACE::debug(), LM_DEBUG, ACE_Unbounded_Set_Iterator< T >::next(), and ACE_OS::strcmp(). Referenced by process_directive().
00370 { 00371 00372 /// When process_directive(Static_Svc_Descriptor&) is called, it 00373 /// associates a service object with the Gestalt and makes the 00374 /// resource (a Service Object) local to the repository. This is but 00375 /// the first step in using such SO. The next is the 00376 /// "initialization" step. It is typicaly done through a "static" 00377 /// service configuration directive. 00378 /// 00379 /// In contrast a "dynamic" directive, when processed through the 00380 /// overloaded process_directives(string) both creates the SO 00381 /// locally and initializes it, where the statics directive must 00382 /// first locate the SO and then calls the init() method. This means 00383 /// that durig the "static" initialization there's no specific 00384 /// information about the hosting repository and the gestalt must 00385 /// employ some lookup strategy to find it elsewhere. 00386 00387 if (this->processed_static_svcs_ == 0) 00388 ACE_NEW (this->processed_static_svcs_, 00389 ACE_PROCESSED_STATIC_SVCS); 00390 00391 Processed_Static_Svc **pss = 0; 00392 for (ACE_PROCESSED_STATIC_SVCS_ITERATOR iter (*this->processed_static_svcs_); 00393 iter.next (pss) != 0; 00394 iter.advance ()) 00395 { 00396 if (ACE_OS::strcmp ((*pss)->name_, assd->name_) == 0) 00397 { 00398 (*pss)->assd_ = assd; 00399 return; 00400 } 00401 } 00402 Processed_Static_Svc *tmp = 0; 00403 ACE_NEW (tmp,Processed_Static_Svc(assd)); 00404 this->processed_static_svcs_->insert(tmp); 00405 00406 if (ACE::debug ()) 00407 ACE_DEBUG ((LM_DEBUG, 00408 ACE_TEXT ("ACE (%P|%t) SG::add_processed_statisc_svc, ") 00409 ACE_TEXT ("repo=%@ - %s\n"), 00410 this->repo_, 00411 assd->name_)); 00412 } |
|
Tidy up and perform last rites when ACE_Service_Config is shut down. This method calls . Returns 0. Reimplemented in ACE_Service_Config. Definition at line 1233 of file Service_Gestalt.cpp. References ACE_DEBUG, ACE_PROCESSED_STATIC_SVCS_ITERATOR, ACE_TEXT, ACE_TRACE, ACE_Unbounded_Set_Iterator< T >::advance(), ACE::debug(), ACE_Unbounded_Set< T >::is_empty(), is_opened_, LM_DEBUG, ACE_Unbounded_Set_Iterator< T >::next(), processed_static_svcs_, repo_, svc_conf_file_queue_, and svc_repo_is_owned_. Referenced by ACE_Service_Config::close().
01234 { 01235 ACE_TRACE ("ACE_Service_Gestalt::close"); 01236 01237 if (!this->is_opened_ || --this->is_opened_ != 0) 01238 return 0; 01239 01240 // Delete the list fo svc.conf files 01241 delete this->svc_conf_file_queue_; 01242 this->svc_conf_file_queue_ = 0; 01243 01244 if (this->processed_static_svcs_ && 01245 !this->processed_static_svcs_->is_empty()) 01246 { 01247 Processed_Static_Svc **pss = 0; 01248 for (ACE_PROCESSED_STATIC_SVCS_ITERATOR iter (*this->processed_static_svcs_); 01249 iter.next (pss) != 0; 01250 iter.advance ()) 01251 { 01252 delete *pss; 01253 } 01254 } 01255 delete this->processed_static_svcs_; 01256 this->processed_static_svcs_ = 0; 01257 01258 #ifndef ACE_NLOGGING 01259 if (ACE::debug ()) 01260 ACE_DEBUG ((LM_DEBUG, 01261 ACE_TEXT ("ACE (%P|%t) SG::close - complete this=%@, repo=%@, owned=%d\n"), 01262 this, this->repo_, this->svc_repo_is_owned_)); 01263 #endif 01264 01265 if (this->svc_repo_is_owned_) 01266 delete this->repo_; 01267 01268 this->repo_ = 0; 01269 return 0; 01270 01271 } /* close () */ |
|
Get the current ACE_Service_Repository held by this object.
Definition at line 69 of file Service_Gestalt.inl. References repo_.
00070 { 00071 return this->repo_; 00072 } |
|
Dump the state of an object.
Reimplemented in ACE_Service_Config. Definition at line 436 of file Service_Gestalt.cpp. References ACE_TRACE.
00437 { 00438 #if defined (ACE_HAS_DUMP) 00439 ACE_TRACE ("ACE_Service_Gestalt::dump"); 00440 #endif /* ACE_HAS_DUMP */ 00441 } |
|
Searches for a service object declaration in the local repo, only. Locate an entry with name in the table. If 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 . 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 54 of file Service_Gestalt.inl. References ACE_TCHAR, ACE_Service_Repository::find(), and repo_. Referenced by ACE_Dynamic_Service_Base::find_i(), and initialize().
00057 { 00058 // Closing the gestalt will have disassociated it from the 00059 // repository. If the repository used to be owned by the gestalt, it 00060 // will also have been destroyed - so just check for repo_ before 00061 // doing anything with it. 00062 if (this->repo_ != 0) 00063 return this->repo_->find (name, srp, ignore_suspended); 00064 00065 return 0; 00066 } |
|
Definition at line 342 of file Service_Gestalt.cpp. References ACE_PROCESSED_STATIC_SVCS_ITERATOR, ACE_TCHAR, ACE_Unbounded_Set_Iterator< T >::advance(), ACE_Unbounded_Set_Iterator< T >::next(), processed_static_svcs_, and ACE_OS::strcmp(). Referenced by initialize().
00343 { 00344 if (this->processed_static_svcs_ == 0 || name == 0) 00345 return 0; 00346 00347 Processed_Static_Svc **pss = 0; 00348 for (ACE_PROCESSED_STATIC_SVCS_ITERATOR iter (*this->processed_static_svcs_); 00349 iter.next (pss) != 0; 00350 iter.advance ()) 00351 { 00352 if (ACE_OS::strcmp ((*pss)->name_, name) == 0) 00353 return (*pss)->assd_; 00354 } 00355 return 0; 00356 } |
|
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 314 of file Service_Gestalt.cpp. References ACE_STATIC_SVCS_ITERATOR, ACE_TCHAR, ACE_TRACE, ACE_Unbounded_Set_Iterator< T >::advance(), ACE_Unbounded_Set_Iterator< T >::next(), static_svcs_, and ACE_OS::strcmp().
00316 { 00317 ACE_TRACE ("ACE_Service_Gestalt::find_static_svc_descriptor"); 00318 00319 if (this->static_svcs_ == 0) 00320 return -1; 00321 00322 ACE_Static_Svc_Descriptor **ssdp = 0; 00323 for (ACE_STATIC_SVCS_ITERATOR iter ( *this->static_svcs_); 00324 iter.next (ssdp) != 0; 00325 iter.advance ()) 00326 { 00327 if (ACE_OS::strcmp ((*ssdp)->name_, name) == 0) 00328 { 00329 if (ssd != 0) 00330 *ssd = *ssdp; 00331 00332 return 0; 00333 } 00334 } 00335 00336 return -1; 00337 } |
|
Performs the common initialization tasks for a new or previously closed instance. Must not be virtual, as it is called from the constructor. Definition at line 260 of file Service_Gestalt.cpp. References ACE_NEW_NORETURN, ACE_Service_Repository::instance(), repo_, and svc_repo_is_owned_. Referenced by ACE_Service_Gestalt(), and open_i().
00261 { 00262 // Only initialize the repo_ if (a) we are being constructed, or; 00263 // (b) we're being open()-ed, perhaps after previously having been 00264 // close()-ed. In both cases: repo_ == 0 and we need a repository. 00265 if (this->repo_ == 0) 00266 { 00267 if (this->svc_repo_is_owned_) 00268 { 00269 ACE_NEW_NORETURN (this->repo_, 00270 ACE_Service_Repository (this->svc_repo_size_)); 00271 if (this->repo_ == 0) 00272 return -1; 00273 } 00274 else 00275 { 00276 this->repo_ = 00277 ACE_Service_Repository::instance (this->svc_repo_size_); 00278 } 00279 } 00280 return 0; 00281 } |
|
Initialize the if necessary.
Definition at line 985 of file Service_Gestalt.cpp. References ACE_DEBUG, ACE_NEW_RETURN, ACE_SVC_QUEUE, ACE_TEXT, ACE::debug(), LM_DEBUG, and svc_conf_file_queue_. Referenced by ACE_Service_Config::open_i(), and parse_args_i().
00986 { 00987 if (this->svc_conf_file_queue_ == 0) 00988 { 00989 ACE_SVC_QUEUE *tmp = 0; 00990 ACE_NEW_RETURN (tmp, 00991 ACE_SVC_QUEUE, 00992 -1); 00993 delete this->svc_conf_file_queue_; 00994 this->svc_conf_file_queue_ = tmp; 00995 } 00996 00997 #ifndef ACE_NLOGGING 00998 if (ACE::debug ()) 00999 ACE_DEBUG ((LM_DEBUG, 01000 ACE_TEXT ("ACE (%P|%t) SG::init_svc_conf_file_queue ") 01001 ACE_TEXT ("- this=%@, repo=%@\n"), 01002 this, this->repo_)); 01003 #endif 01004 01005 return 0; 01006 01007 } /* init_svc_conf_file_queue () */ |
|
Initialize and activate a statically svc_name service. If initialization fails ... Reimplemented in ACE_Service_Config. Definition at line 448 of file Service_Gestalt.cpp. References ACE_ARGV, ACE_DEBUG, ACE_ERROR, ACE_ERROR_RETURN, ACE_TCHAR, ACE_TEXT, ACE_TRACE, ACE_ARGV_T< CHAR_TYPE >::argc(), ACE_ARGV_T< CHAR_TYPE >::argv(), ACE::debug(), find(), find_processed_static_svc(), ACE_Service_Config::global(), ACE_Service_Type_Impl::init(), LM_DEBUG, LM_ERROR, process_directive_i(), ACE_Service_Repository::remove(), repo_, and ACE_Service_Type::type().
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 } |
|
Reimplemented in ACE_Service_Config. Definition at line 612 of file Service_Gestalt.cpp. References ACE_DEBUG, ACE_ERROR_RETURN, ACE_TCHAR, ACE_TEXT, ACE_TRACE, ACE::debug(), ACE_Service_Repository::find(), initialize_i(), LM_DEBUG, LM_WARNING, ACE_Service_Type::name(), and repo_.
00614 { 00615 ACE_TRACE ("ACE_Service_Gestalt::initialize"); 00616 00617 if (ACE::debug ()) 00618 ACE_DEBUG ((LM_DEBUG, 00619 ACE_TEXT ("ACE (%P|%t) SG::initialize - looking up dynamic ") 00620 ACE_TEXT (" service %s to initialize, repo=%@\n"), 00621 sr->name (), this->repo_)); 00622 00623 ACE_Service_Type *srp = 0; 00624 if (this->repo_->find (sr->name (), 00625 (const ACE_Service_Type **) &srp) >= 0) 00626 ACE_ERROR_RETURN ((LM_WARNING, 00627 ACE_TEXT ("ACE (%P|%t) SG::initialize - \'%s\' ") 00628 ACE_TEXT ("has already been installed. ") 00629 ACE_TEXT ("Remove before reinstalling\n"), 00630 sr->name ()), 00631 0); 00632 00633 return this->initialize_i (sr, parameters); 00634 00635 } |
|
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. Definition at line 513 of file Service_Gestalt.cpp. References ACE_DEBUG, ACE_ERROR_RETURN, ACE_TCHAR, ACE_TEXT, ACE_TRACE, ACE::debug(), ACE_Service_Repository::find(), ACE_Auto_Basic_Ptr< X >::get(), initialize_i(), LM_DEBUG, LM_WARNING, ACE_Auto_Basic_Ptr< X >::release(), repo_, and ACE_Service_Type::type(). Referenced by ACE_Service_Config::initialize().
00515 { 00516 ACE_TRACE ("ACE_Service_Gestalt::initialize"); 00517 00518 #ifndef ACE_NLOGGING 00519 if (ACE::debug ()) 00520 ACE_DEBUG ((LM_DEBUG, 00521 ACE_TEXT ("ACE (%P|%t) SG::initialize - repo=%@, looking up dynamic ") 00522 ACE_TEXT ("service \'%s\' to initialize\n"), 00523 this->repo_, 00524 stf->name ())); 00525 #endif 00526 00527 ACE_Service_Type *srp = 0; 00528 int const retv = this->repo_->find (stf->name (), 00529 (const ACE_Service_Type **) &srp); 00530 00531 // If there is an active service already, it must first be removed, 00532 // before it could be re-installed. 00533 // IJ: This used to be the behavior, before allowing multiple 00534 // independent service repositories. Should that still be required? 00535 if (retv >= 0) 00536 { 00537 #ifndef ACE_NLOGGING 00538 if (ACE::debug ()) 00539 ACE_ERROR_RETURN ((LM_WARNING, 00540 ACE_TEXT ("ACE (%P|%t) SG::initialize - repo=%@,") 00541 ACE_TEXT (" %s is already initialized.") 00542 ACE_TEXT (" Remove before re-initializing.\n"), 00543 this->repo_, 00544 stf->name ()), 00545 0); 00546 #endif 00547 return 0; 00548 } 00549 00550 // If there is an inactive service by that name it may have been 00551 // either inactivated, or just a forward declaration for a service, 00552 // that is in the process of being initialized. If it is the latter, 00553 // then we have detected an attempt to initialize the same dynamic 00554 // service while still processing previous attempt. This can lock up 00555 // the process, because the ACE_DLL_Manager::open () is not 00556 // re-entrant - it uses a Singleton lock to serialize concurent 00557 // invocations. This use case must be handled here, because if the 00558 // DLL_Manager was re-entrant we would have entered an infinite 00559 // recursion here. 00560 if (retv == -2 && srp->type () == 0) 00561 ACE_ERROR_RETURN ((LM_WARNING, 00562 ACE_TEXT ("ACE (%P|%t) SG::initialize - repo=%@,") 00563 ACE_TEXT (" %s is forward-declared.") 00564 ACE_TEXT (" Recursive initialization requests are") 00565 ACE_TEXT (" not supported.\n"), 00566 this->repo_, 00567 stf->name ()), 00568 -1); 00569 00570 // Reserve a spot for the dynamic service by inserting an incomplete 00571 // service declaration, i.e. one that can not produce a service 00572 // object if asked (a forward declaration). This declaration 00573 // ensures maintaining the proper partial ordering of the services 00574 // with respect to their finalization. For example, dependent static 00575 // services must be registered *after* the dynamic service that 00576 // loads them, so that their finalization is complete *before* 00577 // finalizing the dynamic service. 00578 ACE_Service_Type_Dynamic_Guard dummy (*this->repo_, 00579 stf->name ()); 00580 00581 // make_service_type() is doing the dynamic loading and also runs 00582 // any static initializers 00583 ACE_Auto_Ptr<ACE_Service_Type> tmp (stf->make_service_type (this)); 00584 00585 if (tmp.get () != 0 && 00586 this->initialize_i (tmp.get (), parameters) == 0) 00587 { 00588 // All good. Tthe ACE_Service_Type instance is now owned by the 00589 // repository and we should make sure it is not destroyed upon 00590 // exit from this method. 00591 tmp.release (); 00592 return 0; 00593 } 00594 00595 return -1; 00596 } |
|
Definition at line 640 of file Service_Gestalt.cpp. References ACE_ARGV, ACE_ERROR_RETURN, ACE_TCHAR, ACE_TEXT, ACE_TRACE, ACE_ARGV_T< CHAR_TYPE >::argc(), ACE_ARGV_T< CHAR_TYPE >::argv(), ACE::debug(), ACE_Service_Type_Impl::init(), ACE_Service_Repository::insert(), LM_WARNING, ACE_Service_Type::name(), ACE_Service_Repository::remove(), repo_, and ACE_Service_Type::type(). Referenced by initialize().
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 ("failed for %s: %m\n"), 00658 sr->name ()), 00659 -1); 00660 #endif 00661 return -1; 00662 } 00663 00664 if (this->repo_->insert (sr) == -1) 00665 { 00666 #ifndef ACE_NLOGGING 00667 // Not using LM_ERROR here to avoid confusing the test harness 00668 if (ACE::debug ()) 00669 ACE_ERROR_RETURN ((LM_WARNING, 00670 ACE_TEXT ("ACE (%P|%t) SG - repository insert ") 00671 ACE_TEXT ("failed for %s: %m\n"), 00672 sr->name ()), 00673 -1); 00674 #endif 00675 return -1; 00676 } 00677 00678 return 0; 00679 } |
|
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. Reimplemented in ACE_Service_Config. Definition at line 421 of file Service_Gestalt.cpp. References ACE_NEW_RETURN, ACE_STATIC_SVCS, ACE_Unbounded_Set< T >::insert(), and static_svcs_. Referenced by ACE_Service_Config::insert().
00422 { 00423 if (this->static_svcs_ == 0) 00424 ACE_NEW_RETURN (this->static_svcs_, 00425 ACE_STATIC_SVCS, 00426 -1); 00427 00428 return this->static_svcs_->insert (stsd); 00429 } |
|
Has it been opened? Returns the difference between the times open and close have been called on this instance Definition at line 1087 of file Service_Gestalt.cpp. References is_opened_.
01088 { 01089 return this->is_opened_; 01090 } |
|
Add the default statically-linked services to the ACE_Service_Repository. Reimplemented in ACE_Service_Config. Definition at line 288 of file Service_Gestalt.cpp. References ACE_STATIC_SVCS_ITERATOR, ACE_TRACE, ACE_Unbounded_Set_Iterator< T >::advance(), ACE_Unbounded_Set_Iterator< T >::next(), process_directive(), and static_svcs_. Referenced by open_i().
00289 { 00290 ACE_TRACE ("ACE_Service_Gestalt::load_static_svcs"); 00291 00292 if (this->static_svcs_ == 0) 00293 return 0; // Nothing to do 00294 00295 ACE_Static_Svc_Descriptor **ssdp = 0; 00296 for (ACE_STATIC_SVCS_ITERATOR iter (*this->static_svcs_); 00297 iter.next (ssdp) != 0; 00298 iter.advance ()) 00299 { 00300 ACE_Static_Svc_Descriptor *ssd = *ssdp; 00301 00302 if (this->process_directive (*ssd, 1) == -1) 00303 return -1; 00304 } 00305 return 0; 00306 00307 } /* load_static_svcs () */ |
|
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:
Reimplemented in ACE_Service_Config. Definition at line 30 of file Service_Gestalt.inl. References ACE_TCHAR, ACE_TRACE, no_static_svcs_, open_i(), and parse_args_i().
00036 { 00037 ACE_TRACE ("ACE_Service_Gestalt::open"); 00038 this->no_static_svcs_ = ignore_static_svcs; 00039 00040 if (this->parse_args_i (argc, 00041 argv) == -1) 00042 return -1; 00043 else 00044 return this->open_i (argv == 0 ? 0 : argv[0], 00045 logger_key, 00046 ignore_static_svcs, 00047 ignore_default_svc_conf, 00048 ignore_debug_flag); 00049 } |
|
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. Reimplemented in ACE_Service_Config. Definition at line 13 of file Service_Gestalt.inl. References ACE_TCHAR, ACE_TRACE, no_static_svcs_, and open_i(). Referenced by ACE_Service_Config::open().
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 } |
|
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 Reimplemented in ACE_Service_Config. Definition at line 1011 of file Service_Gestalt.cpp. References ACE_DEBUG, ACE_LOG_MSG, ACE_TCHAR, ACE_TEXT, ACE_TRACE, ACE::debug(), ACE_Log_Msg::disable_debug_messages(), ACE_Log_Msg::enable_debug_messages(), init_i(), is_opened_, LM_DEBUG, load_static_svcs(), no_static_svcs_, ACE_Log_Msg::priority_mask(), process_commandline_directives(), and process_directives(). Referenced by open(), and ACE_Service_Config::open_i().
01016 { 01017 ACE_TRACE ("ACE_Service_Gestalt::open_i"); 01018 int result = 0; 01019 ACE_Log_Msg *log_msg = ACE_LOG_MSG; 01020 01021 // Record the current log setting upon entering this thread. 01022 u_long old_process_mask = log_msg->priority_mask 01023 (ACE_Log_Msg::PROCESS); 01024 01025 u_long old_thread_mask = log_msg->priority_mask 01026 (ACE_Log_Msg::THREAD); 01027 01028 #ifndef ACE_NLOGGING 01029 if (ACE::debug ()) 01030 ACE_DEBUG ((LM_DEBUG, 01031 ACE_TEXT ("ACE (%P|%t) SG::open_i - this=%@, ") 01032 ACE_TEXT ("opened=%d, loadstatics=%d\n"), 01033 this, this->is_opened_, this->no_static_svcs_)); 01034 #endif 01035 01036 // Guard against reentrant processing. For example, 01037 // if the singleton gestalt (ubergestalt) was already open, 01038 // do not open it again... 01039 if (this->is_opened_++ != 0) 01040 return 0; 01041 01042 if (this->init_i () != 0) 01043 return -1; 01044 01045 if (!ignore_debug_flag) 01046 { 01047 // If -d was included as a startup parameter, the user wants debug 01048 // information printed during service initialization. 01049 if (ACE::debug ()) 01050 ACE_Log_Msg::enable_debug_messages (); 01051 else 01052 // The user has requested no debugging info. 01053 ACE_Log_Msg::disable_debug_messages (); 01054 } 01055 01056 // See if we need to load the static services. 01057 if (this->no_static_svcs_ == 0 01058 && this->load_static_svcs () == -1) 01059 result = -1; 01060 else 01061 { 01062 if (this->process_commandline_directives () == -1) 01063 result = -1; 01064 else 01065 result = this->process_directives (); 01066 } 01067 01068 01069 // Reset debugging back to the way it was when we came into 01070 // into <open_i>. 01071 { 01072 // Make sure to save/restore errno properly. 01073 ACE_Errno_Guard error (errno); 01074 01075 if (!ignore_debug_flag) 01076 { 01077 log_msg->priority_mask (old_process_mask, ACE_Log_Msg::PROCESS); 01078 log_msg->priority_mask (old_thread_mask, ACE_Log_Msg::THREAD); 01079 } 01080 } 01081 01082 return result; 01083 } /* open_i () */ |
|
|
|
Handle the command-line options intended for the . Note that <argv[0]> is assumed to be the program name. The arguments that are valid in a call to this method are
Reimplemented in ACE_Service_Config. Definition at line 1123 of file Service_Gestalt.cpp. References ACE_TCHAR, ACE_TRACE, and parse_args_i(). Referenced by ACE_Service_Config::parse_args().
01124 { 01125 ACE_TRACE ("ACE_Service_Gestalt::parse_args"); 01126 return parse_args_i (argc, argv); 01127 } |
|
Reimplemented in ACE_Service_Config. Definition at line 1130 of file Service_Gestalt.cpp. References ACE_DEBUG, ACE_ERROR_RETURN, ACE_NEW_RETURN, ACE_SVC_QUEUE, ACE_TCHAR, ACE_TEXT, ACE_TRACE, ACE_TString, ACE::debug(), ACE_Unbounded_Queue< T >::enqueue_tail(), init_svc_conf_file_queue(), LM_DEBUG, LM_ERROR, no_static_svcs_, svc_conf_file_queue_, and svc_queue_. Referenced by open(), parse_args(), and ACE_Service_Config::parse_args_i().
01131 { 01132 ACE_TRACE ("ACE_Service_Gestalt::parse_args_i"); 01133 //FUZZ: disable check_for_lack_ACE_OS 01134 ACE_Get_Opt getopt (argc, 01135 argv, 01136 ACE_TEXT ("df:k:nyS:"), 01137 1); // Start at argv[1]. 01138 //FUZZ: enable check_for_lack_ACE_OS 01139 01140 if (this->init_svc_conf_file_queue () == -1) 01141 return -1; 01142 01143 //FUZZ: disable check_for_lack_ACE_OS 01144 for (int c; (argc != 0) && ((c = getopt ()) != -1); ) 01145 //FUZZ: enable check_for_lack_ACE_OS 01146 switch (c) 01147 { 01148 case 'd': 01149 ACE::debug (1); 01150 break; 01151 case 'f': 01152 if (this->svc_conf_file_queue_->enqueue_tail (ACE_TString (getopt.opt_arg ())) == -1) 01153 ACE_ERROR_RETURN ((LM_ERROR, 01154 ACE_TEXT ("%p\n"), 01155 ACE_TEXT ("enqueue_tail")), 01156 -1); 01157 break; 01158 case 'k': 01159 /* 01160 * @TODO: Is this always a static storage? Shouldn't we copy 01161 * & gain ownership of the value? 01162 */ 01163 this->logger_key_ = getopt.opt_arg (); 01164 break; 01165 case 'n': 01166 this->no_static_svcs_ = 1; 01167 break; 01168 case 'y': 01169 this->no_static_svcs_ = 0; 01170 break; 01171 case 'S': 01172 if (this->svc_queue_ == 0) 01173 { 01174 ACE_NEW_RETURN (this->svc_queue_, 01175 ACE_SVC_QUEUE, 01176 -1); 01177 } 01178 01179 if (this->svc_queue_->enqueue_tail (ACE_TString (getopt.opt_arg ())) == -1) 01180 ACE_ERROR_RETURN ((LM_ERROR, 01181 ACE_TEXT ("%p\n"), 01182 ACE_TEXT ("enqueue_tail")), 01183 -1); 01184 break; 01185 default: 01186 if (ACE::debug ()) 01187 ACE_DEBUG ((LM_DEBUG, 01188 ACE_TEXT ("ACE (%P|%t) %c is not a ACE_Service_Config option\n"), 01189 c)); 01190 } 01191 01192 return 0; 01193 } /* parse_args_i () */ |
|
Process service configuration requests that were provided on the command-line. Returns the number of errors that occurred. Reimplemented in ACE_Service_Config. Definition at line 1093 of file Service_Gestalt.cpp. References ACE_ERROR, ACE_SVC_QUEUE_ITERATOR, ACE_TEXT, ACE_TString, ACE_Unbounded_Queue_Iterator< T >::advance(), ACE_String_Base< CHAR >::fast_rep(), LM_ERROR, ACE_Unbounded_Queue_Iterator< T >::next(), process_directive(), and svc_queue_. Referenced by open_i().
01094 { 01095 int result = 0; 01096 if (this->svc_queue_ != 0) 01097 { 01098 ACE_TString *sptr = 0; 01099 for (ACE_SVC_QUEUE_ITERATOR iter (*this->svc_queue_); 01100 iter.next (sptr) != 0; 01101 iter.advance ()) 01102 { 01103 // Process just a single directive. 01104 if (this->process_directive ((sptr->fast_rep ())) != 0) 01105 { 01106 ACE_ERROR ((LM_ERROR, 01107 ACE_TEXT ("ACE (%P|%t) %p\n"), 01108 ACE_TEXT ("process_directive"))); 01109 result = -1; 01110 } 01111 } 01112 01113 delete this->svc_queue_; 01114 this->svc_queue_ = 0; 01115 } 01116 01117 return result; 01118 01119 } /* process_commandline_directives () */ |
|
Process one static service definition. Load a new static service.
Reimplemented in ACE_Service_Config. Definition at line 725 of file Service_Gestalt.cpp. References add_processed_static_svc(), and process_directive_i().
00727 { 00728 int const result = process_directive_i (ssd, force_replace); 00729 if (result == 0) 00730 { 00731 this->add_processed_static_svc(&ssd); 00732 } 00733 return result; 00734 } |
|
Process one service configuration directive, which is passed as a string. Returns the number of errors that occurred. Reimplemented in ACE_Service_Config. Definition at line 943 of file Service_Gestalt.cpp. References ACE_DEBUG, ACE_TCHAR, ACE_TEXT, ACE_TRACE, ACE::debug(), ACE_Auto_Basic_Ptr< X >::get(), LM_DEBUG, and process_directives_i(). Referenced by load_static_svcs(), process_commandline_directives(), and ACE_Service_Config::process_directive().
00944 { 00945 ACE_TRACE ("ACE_Service_Gestalt::process_directive"); 00946 00947 #ifndef ACE_NLOGGING 00948 if (ACE::debug ()) 00949 ACE_DEBUG ((LM_DEBUG, 00950 ACE_TEXT ("ACE (%P|%t) SG::process_directive, repo=%@ - %s\n"), 00951 this->repo_, 00952 directive)); 00953 #endif 00954 00955 #if (ACE_USES_CLASSIC_SVC_CONF == 1) 00956 ACE_UNUSED_ARG (directive); 00957 00958 ACE_Svc_Conf_Param d (this, directive); 00959 00960 return this->process_directives_i (&d); 00961 #else 00962 ACE_DLL dll; 00963 00964 auto_ptr<ACE_XML_Svc_Conf> 00965 xml_svc_conf (this->get_xml_svc_conf (dll)); 00966 00967 if (xml_svc_conf.get () == 0) 00968 return -1; 00969 00970 // Temporarily (for the duration of this call) make sure that *any* static 00971 // service registrations will happen with this instance. Such registrations 00972 // are possible as a side-effect of dynamically loading a DLL, which has 00973 // other static services registered. Thus this instance will own both the 00974 // DLL and those static services, which implies that their finalization 00975 // will be performed in the correct order, i.e. prior to finalizing the DLL 00976 ACE_Service_Config_Guard guard (this); 00977 00978 return xml_svc_conf->parse_string (directive); 00979 #endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */ 00980 00981 } /* process_directive () */ |
|
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 737 of file Service_Gestalt.cpp. References ACE_DEBUG, ACE_NEW_RETURN, ACE_Service_Object_Exterminator, ACE_TEXT, ACE_Static_Svc_Descriptor::active_, ACE_Static_Svc_Descriptor::alloc_, ACE_Service_Config::create_service_type_impl(), ACE::debug(), ACE_DLL::dll_name_, ACE_Service_Repository::find(), ACE_Static_Svc_Descriptor::flags_, ACE_Service_Repository::insert(), LM_DEBUG, ACE_Static_Svc_Descriptor::name_, repo_, and ACE_Static_Svc_Descriptor::type_. Referenced by initialize(), and process_directive().
00739 { 00740 if (this->repo_ == 0) 00741 return -1; 00742 00743 if (!force_replace) 00744 { 00745 if (this->repo_->find (ssd.name_, 0, 0) >= 0) 00746 { 00747 // The service is already there, just return 00748 return 0; 00749 } 00750 } 00751 00752 00753 ACE_Service_Object_Exterminator gobbler; 00754 void *sym = (ssd.alloc_)(&gobbler); 00755 00756 ACE_Service_Type_Impl *stp = 00757 ACE_Service_Config::create_service_type_impl (ssd.name_, 00758 ssd.type_, 00759 sym, 00760 ssd.flags_, 00761 gobbler); 00762 if (stp == 0) 00763 return 0; 00764 00765 ACE_Service_Type *service_type = 0; 00766 00767 // This is just a temporary to force the compiler to use the right 00768 // constructor in ACE_Service_Type. Note that, in cases where we are 00769 // called from a static initializer which is part of a DLL, there is 00770 // not enough information about the actuall DLL in this context. 00771 ACE_DLL tmp_dll; 00772 00773 ACE_NEW_RETURN (service_type, 00774 ACE_Service_Type (ssd.name_, 00775 stp, 00776 tmp_dll, 00777 ssd.active_), 00778 -1); 00779 00780 #ifndef ACE_NLOGGING 00781 if (ACE::debug ()) 00782 ACE_DEBUG ((LM_DEBUG, 00783 ACE_TEXT ("ACE (%P|%t) SG::process_directive_i, ") 00784 ACE_TEXT ("repo=%@ - %s, dll=%s, force=%d\n"), 00785 this->repo_, 00786 ssd.name_, 00787 (tmp_dll.dll_name_ == 0) ? ACE_TEXT ("<null>") : tmp_dll.dll_name_, 00788 force_replace)); 00789 #endif 00790 00791 return this->repo_->insert (service_type); 00792 } |
|
Process (or re-process) service configuration requests that are provided in the svc.conf file(s). Returns the number of errors that occurred. Reimplemented in ACE_Service_Config. Definition at line 1200 of file Service_Gestalt.cpp. References ACE_SVC_QUEUE_ITERATOR, ACE_TRACE, ACE_TString, ACE_Unbounded_Queue_Iterator< T >::advance(), ACE_String_Base< CHAR >::fast_rep(), ACE_Unbounded_Queue_Iterator< T >::next(), process_file(), and svc_conf_file_queue_. Referenced by open_i(), and ACE_Service_Config::process_directives().
01201 { 01202 ACE_TRACE ("ACE_Service_Gestalt::process_directives"); 01203 01204 int result = 0; 01205 01206 if (this->svc_conf_file_queue_ != 0) 01207 { 01208 ACE_TString *sptr = 0; 01209 01210 // Iterate through all the svc.conf files. 01211 for (ACE_SVC_QUEUE_ITERATOR iter (*this->svc_conf_file_queue_); 01212 iter.next (sptr) != 0; 01213 iter.advance ()) 01214 { 01215 int r = this->process_file (sptr->fast_rep ()); 01216 01217 if (r < 0) 01218 { 01219 result = r; 01220 break; 01221 } 01222 01223 result += r; 01224 } 01225 } 01226 01227 return result; 01228 01229 } /* process_directives () */ |
|
This is the implementation function that process_directives() and process_directive() both call. Returns the number of errors that occurred. Reimplemented in ACE_Service_Config. Definition at line 797 of file Service_Gestalt.cpp. References ACE_ASSERT, ACE_DEBUG, ACE_NO_HEAP_CHECK, ACE_TEXT, ACE_Svc_Conf_Param::config, ACE::debug(), ACE_OS::last_error(), LM_DEBUG, ACE_Svc_Conf_Param::source, ACE_Svc_Conf_Param::type, and ACE_Svc_Conf_Param::yyerrno. Referenced by process_directive(), and process_file().
00798 { 00799 // AC 970827 Skip the heap check because yacc allocates a buffer 00800 // here which will be reported as a memory leak for some reason. 00801 ACE_NO_HEAP_CHECK 00802 00803 // Were we called in the context of the current instance? 00804 ACE_ASSERT (this == param->config); 00805 00806 // Temporarily (for the duration of this call) make sure that *any* static 00807 // service registrations will happen with this instance. Such registrations 00808 // are possible as a side-effect of dynamically loading a DLL, which has 00809 // other static services registered. Thus this instance will own both the 00810 // DLL and those static services, which implies that their finalization 00811 // will be performed in the correct order, i.e. prior to finalizing the DLL 00812 ACE_Service_Config_Guard guard (this); 00813 00814 #ifndef ACE_NLOGGING 00815 if (ACE::debug ()) 00816 ACE_DEBUG ((LM_DEBUG, 00817 ACE_TEXT ("ACE (%P|%t) SG::process_directives_i, ") 00818 ACE_TEXT ("repo=%@ - %s\n"), 00819 this->repo_, 00820 (param->type == ACE_Svc_Conf_Param::SVC_CONF_FILE) 00821 ? ACE_TEXT ("<from file>") 00822 : param->source.directive)); 00823 #endif 00824 00825 ::ace_yyparse (param); 00826 00827 // This is a hack, better errors should be provided... 00828 if (param->yyerrno > 0) 00829 { 00830 // Always set the last error if ace_yyparse() fails. 00831 // Other code may use errno to determine the type 00832 // of problem that occurred from processing directives. 00833 ACE_OS::last_error (EINVAL); 00834 return param->yyerrno; 00835 } 00836 else 00837 return 0; 00838 } |
|
Process a file containing a list of service configuration directives. Reimplemented in ACE_Service_Config. Definition at line 867 of file Service_Gestalt.cpp. References ACE_DEBUG, ACE_stat, ACE_TCHAR, ACE_TEXT, ACE_TRACE, ACE::debug(), EPERM, ACE_OS::fclose(), ACE_Service_Repository::find(), ACE_OS::fopen(), ACE_Auto_Basic_Ptr< X >::get(), LM_ERROR, LM_WARNING, process_directives_i(), repo_, and ACE_OS::stat(). Referenced by process_directives(), and ACE_Service_Config::process_file().
00868 { 00869 ACE_TRACE ("ACE_Service_Gestalt::process_file"); 00870 00871 // To avoid recursive processing of the same file and the same repository 00872 // we maintain an implicit stack of dummy "services" named after the file 00873 // being processed. Anytime we have to open a new file, we then can check 00874 // to see if it is not already being processed by searching for a dummy 00875 // service with a matching name. 00876 if (this->repo_->find (file, 0, 0) >=0) 00877 { 00878 ACE_DEBUG ((LM_WARNING, 00879 ACE_TEXT ("ACE (%P|%t) Configuration file %s is currently") 00880 ACE_TEXT (" being processed. Ignoring recursive process_file().\n"), 00881 file)); 00882 return 0; 00883 } 00884 00885 // Register a dummy service as a forward decl, using the file name as name. 00886 // The entry will be automaticaly removed once the thread exits this block. 00887 ACE_Service_Type_Dynamic_Guard recursion_guard (*this->repo_, 00888 file); 00889 00890 /* 00891 * @TODO: Test with ACE_USES_CLASSIC_SVC_CONF turned off! 00892 */ 00893 #if (ACE_USES_CLASSIC_SVC_CONF == 1) 00894 int result = 0; 00895 00896 FILE *fp = ACE_OS::fopen (file, 00897 ACE_TEXT ("r")); 00898 00899 if (fp == 0) 00900 { 00901 // Invalid svc.conf file. We'll report it here and break out of 00902 // the method. 00903 if (ACE::debug ()) 00904 ACE_DEBUG ((LM_ERROR, 00905 ACE_TEXT ("ACE (%P|%t): %p\n"), 00906 file)); 00907 00908 // Use stat to find out if the file exists. I didn't use access() 00909 // because stat is better supported on most non-unix platforms. 00910 ACE_stat exists; 00911 if (ACE_OS::stat (file, &exists) == 0) 00912 // If it exists, but we couldn't open it for reading then we 00913 // must not have permission to read it. 00914 errno = EPERM; 00915 else 00916 errno = ENOENT; 00917 result = -1; 00918 } 00919 else 00920 { 00921 ACE_Svc_Conf_Param f (this, fp); 00922 00923 // Keep track of the number of errors. 00924 result = this->process_directives_i (&f); 00925 00926 (void) ACE_OS::fclose (fp); 00927 } 00928 return result; 00929 #else 00930 ACE_DLL dll; 00931 00932 auto_ptr<ACE_XML_Svc_Conf> 00933 xml_svc_conf (this->get_xml_svc_conf (dll)); 00934 00935 if (xml_svc_conf.get () == 0) 00936 return -1; 00937 00938 return xml_svc_conf->parse_file (file); 00939 #endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */ 00940 } |
|
Totally remove svc_name from the daemon by removing it from the ACE_Reactor, and unlinking it if necessary. Reimplemented in ACE_Service_Config. Definition at line 685 of file Service_Gestalt.cpp. References ACE_TCHAR, ACE_TRACE, ACE_Service_Repository::remove(), and repo_.
|
|
Resume a svc_name that was previously suspended or has not yet been resumed (e.g., a static service). Reimplemented in ACE_Service_Config. Definition at line 714 of file Service_Gestalt.cpp. References ACE_TCHAR, ACE_TRACE, repo_, and ACE_Service_Repository::resume().
|
|
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 member function on the appropriate . A service can be resumed later on by calling the member function... Reimplemented in ACE_Service_Config. Definition at line 701 of file Service_Gestalt.cpp. References ACE_TCHAR, ACE_TRACE, repo_, and ACE_Service_Repository::suspend().
|
|
Definition at line 402 of file Service_Gestalt.h. |
|
Reimplemented in ACE_Service_Config. Definition at line 404 of file Service_Gestalt.h. |
|
Definition at line 403 of file Service_Gestalt.h. |
|
Declare the dynamic allocation hooks.
Reimplemented in ACE_Service_Config. Definition at line 179 of file Service_Gestalt.h. |
|
Keep track of the number of times the instance has been initialized (opened). "If so, we can't allow 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 422 of file Service_Gestalt.h. Referenced by close(), is_opened(), and open_i(). |
|
Indicates where to write the logging output. This is typically either a STREAM pipe or a socket Definition at line 426 of file Service_Gestalt.h. |
|
Should we avoid loading the static services?
Definition at line 429 of file Service_Gestalt.h. Referenced by open(), open_i(), and parse_args_i(). |
|
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 448 of file Service_Gestalt.h. Referenced by close(), find_processed_static_svc(), and ~ACE_Service_Gestalt(). |
|
The service repository to hold the services.
Definition at line 440 of file Service_Gestalt.h. Referenced by ACE_Service_Config_Guard::ACE_Service_Config_Guard(), close(), current_service_repository(), find(), init_i(), initialize(), initialize_i(), ACE_Dynamic_Service_Base::instance(), process_directive_i(), process_file(), remove(), resume(), suspend(), and ~ACE_Service_Gestalt(). |
|
Repository of statically linked services.
Definition at line 443 of file Service_Gestalt.h. Referenced by find_static_svc_descriptor(), insert(), load_static_svcs(), and ~ACE_Service_Gestalt(). |
|
Queue of svc.conf files specified on the command-line. @ This should probably be made to handle unicode filenames... Definition at line 437 of file Service_Gestalt.h. Referenced by close(), init_svc_conf_file_queue(), parse_args_i(), and process_directives(). |
|
Queue of services specified on the command-line.
Definition at line 432 of file Service_Gestalt.h. Referenced by parse_args_i(), and process_commandline_directives(). |
|
Do we own the service repository instance, or have only been given a ptr to the singleton? Definition at line 410 of file Service_Gestalt.h. Referenced by close(), init_i(), and ~ACE_Service_Gestalt(). |
|
Repository size is necessary, so that we can close (which may destroy the repository instance), and then re-open again. Definition at line 414 of file Service_Gestalt.h. |