#include <Locator_Repository.h>
Collaboration diagram for Locator_Repository:
Public Types | |
typedef ACE_Hash_Map_Manager_Ex< ACE_CString, Server_Info_Ptr, ACE_Hash< ACE_CString >, ACE_Equal_To< ACE_CString >, ACE_Null_Mutex > | SIMap |
typedef ACE_Hash_Map_Manager_Ex< ACE_CString, Activator_Info_Ptr, ACE_Hash< ACE_CString >, ACE_Equal_To< ACE_CString >, ACE_Null_Mutex > | AIMap |
Public Member Functions | |
Locator_Repository () | |
int | init (const Options &opts) |
Initializes the Server Repository. | |
int | add_server (const ACE_CString &name, const ACE_CString &aname, const ACE_CString &startup_command, const ImplementationRepository::EnvironmentList &environment_vars, const ACE_CString &working_dir, ImplementationRepository::ActivationMode activation, int start_limit, const ACE_CString &partial_ior=ACE_CString(""), const ACE_CString &ior=ACE_CString(""), ImplementationRepository::ServerObject_ptr svrobj=ImplementationRepository::ServerObject::_nil()) |
Add a new server to the Repository. | |
int | add_activator (const ACE_CString &name, const CORBA::Long token, const ACE_CString &ior=ACE_CString(""), ImplementationRepository::Activator_ptr act=ImplementationRepository::Activator::_nil()) |
Add a new activator to the Repository. | |
int | update_server (const Server_Info &info) |
Update the associated information. | |
int | update_activator (const Activator_Info &info) |
Update the associated information. | |
Server_Info_Ptr | get_server (const ACE_CString &name) |
Returns information related to startup. | |
Activator_Info_Ptr | get_activator (const ACE_CString &name) |
Returns information related to startup. | |
bool | has_activator (const ACE_CString &name) |
int | remove_server (const ACE_CString &name) |
Removes the server from the Repository. | |
int | remove_activator (const ACE_CString &name) |
Removes the activator from the Repository. | |
SIMap & | servers (void) |
Returns the internal hash map containing the server information. | |
AIMap & | activators (void) |
Returns the internal hash map containing the activator information. | |
const char * | repo_mode () |
Private Attributes | |
Options::RepoMode | rmode_ |
SIMap | server_infos_ |
AIMap | activator_infos_ |
ACE_Auto_Ptr< ACE_Configuration > | config_ |
ACE_CString | fname_ |
Definition at line 37 of file Locator_Repository.h.
|
Definition at line 50 of file Locator_Repository.h. Referenced by loadActivatorsAsBinary(). |
|
Definition at line 44 of file Locator_Repository.h. Referenced by loadServersAsBinary(). |
|
Definition at line 276 of file Locator_Repository.cpp.
|
|
Returns the internal hash map containing the activator information.
Definition at line 555 of file Locator_Repository.cpp. References activator_infos_. Referenced by add_activator(), get_activator(), has_activator(), loadAsBinary(), Server_Repo_XML_Callback::next_activator(), remove_activator(), and saveAsXML().
00556 { 00557 return activator_infos_; 00558 } |
|
Add a new activator to the Repository.
Definition at line 377 of file Locator_Repository.cpp. References Activator_Info_Ptr, activators(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::bind(), lcase(), and update_activator().
00381 { 00382 Activator_Info_Ptr info (new Activator_Info (name, token, ior, act)); 00383 00384 int err = activators ().bind (lcase (name), info); 00385 if (err != 0) 00386 { 00387 return err; 00388 } 00389 this->update_activator (*info); 00390 return 0; 00391 } |
|
Add a new server to the Repository.
Definition at line 352 of file Locator_Repository.cpp. References ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::bind(), Server_Info_Ptr, servers(), and update_server().
00362 { 00363 int limit = start_limit < 1 ? 1 : start_limit; 00364 Server_Info_Ptr info(new Server_Info (name, aname, startup_command, 00365 env_vars, working_dir, activation, limit, partial_ior, ior, svrobj)); 00366 00367 int err = servers ().bind (name, info); 00368 if (err != 0) 00369 { 00370 return err; 00371 } 00372 this->update_server (*info); 00373 return 0; 00374 } |
|
Returns information related to startup.
Definition at line 478 of file Locator_Repository.cpp. References Activator_Info_Ptr, activators(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find(), and lcase(). Referenced by ImR_Locator_i::get_activator().
00479 { 00480 Activator_Info_Ptr activator (0); 00481 activators ().find (lcase (name), activator); 00482 return activator; 00483 } |
|
Returns information related to startup.
Definition at line 470 of file Locator_Repository.cpp. References ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find(), Server_Info_Ptr, and servers().
00471 { 00472 Server_Info_Ptr server (0); 00473 servers ().find (name, server); 00474 return server; 00475 } |
|
Definition at line 486 of file Locator_Repository.cpp. References Activator_Info_Ptr, activators(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find(), and lcase(). Referenced by ImR_Locator_i::is_alive_i().
00487 { 00488 Activator_Info_Ptr activator (0); 00489 return activators().find (lcase (name), activator) == 0; 00490 } |
|
Initializes the Server Repository.
Definition at line 283 of file Locator_Repository.cpp. References ACE_ASSERT, ACE_ERROR, fname_, LM_ERROR, loadAsBinary(), loadAsXML(), ACE_Configuration_Heap::open(), ACE_Configuration_Win32Registry::open_section(), Options::persist_file_name(), ACE_Configuration_Win32Registry::remove_section(), Options::repository_erase(), Options::repository_mode(), ACE_Auto_Basic_Ptr< X >::reset(), ACE_Configuration_Win32Registry::resolve_key(), rmode_, ACE_Configuration::root_section(), ACE_OS::unlink(), and WIN32_REG_KEY. Referenced by ImR_Locator_i::init_with_orb().
00284 { 00285 this->rmode_ = opts.repository_mode (); 00286 this->fname_ = opts.persist_file_name (); 00287 00288 int err = 0; 00289 switch (this->rmode_) 00290 { 00291 case Options::REPO_NONE: 00292 { 00293 break; 00294 } 00295 case Options::REPO_HEAP_FILE: 00296 { 00297 if (opts.repository_erase ()) 00298 { 00299 ACE_OS::unlink ( this->fname_.c_str () ); 00300 } 00301 ACE_Configuration_Heap* heap = new ACE_Configuration_Heap (); 00302 this->config_.reset (heap); 00303 err = heap->open (this->fname_.c_str ()); 00304 if (err == 0) 00305 { 00306 loadAsBinary (*this->config_, *this); 00307 } 00308 break; 00309 } 00310 case Options::REPO_REGISTRY: 00311 { 00312 #if defined (ACE_WIN32) 00313 if (opts.repository_erase ()) 00314 { 00315 ACE_Configuration_Win32Registry config ( HKEY_LOCAL_MACHINE ); 00316 ACE_Configuration_Section_Key root; 00317 config.open_section (config.root_section(), "Software\\TAO", 0, root); 00318 config.remove_section (root, "ImplementationRepository", 1); 00319 } 00320 HKEY root = ACE_Configuration_Win32Registry:: 00321 resolve_key (HKEY_LOCAL_MACHINE, WIN32_REG_KEY); 00322 this->config_.reset (new ACE_Configuration_Win32Registry( root)); 00323 loadAsBinary (*this->config_, *this); 00324 #else 00325 ACE_ERROR ((LM_ERROR, "Registry persistence is only " 00326 "supported on Windows\n")); 00327 err = -1; 00328 #endif 00329 break; 00330 } 00331 case Options::REPO_XML_FILE: 00332 { 00333 if (opts.repository_erase ()) 00334 { 00335 ACE_OS::unlink ( this->fname_.c_str() ); 00336 } 00337 err = loadAsXML (this->fname_, *this); 00338 break; 00339 } 00340 default: 00341 { 00342 bool invalid_rmode_specified = false; 00343 ACE_ASSERT (invalid_rmode_specified); 00344 ACE_UNUSED_ARG (invalid_rmode_specified); 00345 err = -1; 00346 } 00347 } 00348 return err; 00349 } |
|
Removes the activator from the Repository.
Definition at line 521 of file Locator_Repository.cpp. References ACE_ASSERT, activators(), ACTIVATORS_ROOT_KEY, lcase(), ACE_Configuration::open_section(), ACE_Configuration::remove_section(), rmode_, ACE_Configuration::root_section(), saveAsXML(), and ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::unbind(). Referenced by ImR_Locator_i::unregister_activator_i().
00522 { 00523 int ret = activators().unbind (lcase(name)); 00524 if (ret != 0) 00525 { 00526 return ret; 00527 } 00528 00529 if (rmode_ == Options::REPO_HEAP_FILE || rmode_ == Options::REPO_REGISTRY) 00530 { 00531 ACE_ASSERT (this->config_.get () != 0); 00532 ACE_Configuration& cfg = *this->config_; 00533 ACE_Configuration_Section_Key root; 00534 int err = cfg.open_section (cfg.root_section (), ACTIVATORS_ROOT_KEY, 0, root); 00535 if (err != 0) 00536 { 00537 return 0; // Already gone. 00538 } 00539 ret = cfg.remove_section (root, name.c_str (), 1); 00540 } 00541 else if (rmode_ == Options::REPO_XML_FILE) 00542 { 00543 saveAsXML (this->fname_, *this); 00544 } 00545 return ret; 00546 } |
|
Removes the server from the Repository.
Definition at line 493 of file Locator_Repository.cpp. References ACE_ASSERT, ACE_Configuration::open_section(), ACE_Configuration::remove_section(), rmode_, ACE_Configuration::root_section(), saveAsXML(), servers(), SERVERS_ROOT_KEY, and ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::unbind().
00494 { 00495 int ret = this->servers().unbind (name); 00496 if (ret != 0) 00497 { 00498 return ret; 00499 } 00500 00501 if (rmode_ == Options::REPO_HEAP_FILE || rmode_ == Options::REPO_REGISTRY) 00502 { 00503 ACE_ASSERT (this->config_.get() != 0); 00504 ACE_Configuration& cfg = *this->config_; 00505 ACE_Configuration_Section_Key root; 00506 int err = cfg.open_section (cfg.root_section (), SERVERS_ROOT_KEY, 0, root); 00507 if (err != 0) 00508 { 00509 return 0; // Already gone. 00510 } 00511 ret = cfg.remove_section (root, name.c_str (), 1); 00512 } 00513 else if (rmode_ == Options::REPO_XML_FILE) 00514 { 00515 saveAsXML (this->fname_, *this); 00516 } 00517 return ret; 00518 } |
|
Definition at line 561 of file Locator_Repository.cpp. References fname_, and rmode_. Referenced by ImR_Locator_i::run().
00562 { 00563 switch (rmode_) 00564 { 00565 case Options::REPO_XML_FILE: 00566 case Options::REPO_HEAP_FILE: 00567 return fname_.c_str (); 00568 case Options::REPO_REGISTRY: 00569 return "Registry"; 00570 case Options::REPO_NONE: 00571 return "Disabled"; 00572 } 00573 return "Disabled"; 00574 } |
|
Returns the internal hash map containing the server information.
Definition at line 549 of file Locator_Repository.cpp. References server_infos_. Referenced by add_server(), ImR_Locator_i::auto_start_servers(), get_server(), loadAsBinary(), Server_Repo_XML_Callback::next_server(), remove_server(), and saveAsXML().
00550 { 00551 return server_infos_; 00552 } |
|
Update the associated information.
Definition at line 436 of file Locator_Repository.cpp. References ACE_ASSERT, ACE_ERROR, ACTIVATORS_ROOT_KEY, Activator_Info::ior, IOR, LM_ERROR, Activator_Info::name, ACE_Configuration::open_section(), rmode_, ACE_Configuration::root_section(), saveAsXML(), ACE_Configuration::set_integer_value(), ACE_Configuration::set_string_value(), Activator_Info::token, and TOKEN. Referenced by add_activator().
00437 { 00438 if (rmode_ == Options::REPO_HEAP_FILE || rmode_ == Options::REPO_REGISTRY) 00439 { 00440 ACE_ASSERT(this->config_.get () != 0); 00441 00442 ACE_Configuration& cfg = *this->config_; 00443 00444 ACE_Configuration_Section_Key root; 00445 ACE_Configuration_Section_Key key; 00446 int err = cfg.open_section (cfg.root_section(), ACTIVATORS_ROOT_KEY, 1, root); 00447 if (err != 0) 00448 { 00449 ACE_ERROR((LM_ERROR, "Unable to open config section:%s\n", ACTIVATORS_ROOT_KEY)); 00450 return err; 00451 } 00452 err = cfg.open_section (root, info.name.c_str (), 1, key); 00453 if (err != 0) 00454 { 00455 ACE_ERROR((LM_ERROR, "Unable to open config section:%s\n", info.name.c_str())); 00456 return err; 00457 } 00458 00459 cfg.set_integer_value (key, TOKEN, info.token); 00460 cfg.set_string_value (key, IOR, info.ior.c_str ()); 00461 } 00462 else if (rmode_ == Options::REPO_XML_FILE) 00463 { 00464 saveAsXML( this->fname_, *this); 00465 } 00466 return 0; 00467 } |
|
Update the associated information.
Definition at line 394 of file Locator_Repository.cpp. References ACE_ASSERT, ACE_CString, ACE_ERROR, ACTIVATION, Server_Info::activation_mode, Server_Info::activator, ACTIVATOR, Server_Info::cmdline, Server_Info::dir, Server_Info::env_vars, ENVIRONMENT, ImR_Utils::envListToString(), Server_Info::ior, IOR, LM_ERROR, Server_Info::name, ACE_Configuration::open_section(), Server_Info::partial_ior, PARTIAL_IOR, rmode_, ACE_Configuration::root_section(), saveAsXML(), SERVERS_ROOT_KEY, ACE_Configuration::set_integer_value(), ACE_Configuration::set_string_value(), Server_Info::start_limit, START_LIMIT, STARTUP_COMMAND, and WORKING_DIR. Referenced by add_server().
00395 { 00396 if (rmode_ == Options::REPO_HEAP_FILE || rmode_ == Options::REPO_REGISTRY) 00397 { 00398 ACE_ASSERT (this->config_.get () != 0); 00399 00400 ACE_Configuration& cfg = *this->config_; 00401 00402 ACE_Configuration_Section_Key root; 00403 ACE_Configuration_Section_Key key; 00404 int err = cfg.open_section (cfg.root_section(), SERVERS_ROOT_KEY, 1, root); 00405 if (err != 0) 00406 { 00407 ACE_ERROR ((LM_ERROR, "Unable to open config section:%s\n", SERVERS_ROOT_KEY)); 00408 return err; 00409 } 00410 err = cfg.open_section (root, info.name.c_str (), 1, key); 00411 if (err != 0) 00412 { 00413 ACE_ERROR((LM_ERROR, "Unable to open config section:%s\n", info.name.c_str())); 00414 return err; 00415 } 00416 00417 ACE_CString envstr = ImR_Utils::envListToString(info.env_vars); 00418 00419 cfg.set_string_value (key, ACTIVATOR, info.activator.c_str ()); 00420 cfg.set_string_value (key, STARTUP_COMMAND, info.cmdline.c_str ()); 00421 cfg.set_string_value (key, WORKING_DIR, info.dir.c_str ()); 00422 cfg.set_string_value (key, ENVIRONMENT, envstr); 00423 cfg.set_integer_value (key, ACTIVATION, info.activation_mode); 00424 cfg.set_integer_value (key, START_LIMIT, info.start_limit); 00425 cfg.set_string_value (key, PARTIAL_IOR, info.partial_ior.c_str ()); 00426 cfg.set_string_value (key, IOR, info.ior.c_str()); 00427 } 00428 else if (rmode_ == Options::REPO_XML_FILE) 00429 { 00430 saveAsXML (this->fname_, *this); 00431 } 00432 return 0; 00433 } |
|
Definition at line 106 of file Locator_Repository.h. Referenced by activators(). |
|
Definition at line 108 of file Locator_Repository.h. |
|
Definition at line 110 of file Locator_Repository.h. Referenced by init(), and repo_mode(). |
|
Definition at line 102 of file Locator_Repository.h. Referenced by init(), remove_activator(), remove_server(), repo_mode(), update_activator(), and update_server(). |
|
Definition at line 104 of file Locator_Repository.h. Referenced by servers(). |