diff options
author | giovannd <giovannd@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2006-01-04 16:10:11 +0000 |
---|---|---|
committer | giovannd <giovannd@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2006-01-04 16:10:11 +0000 |
commit | 68c0c4582658b5b35e346a925c8bf9f29efd064c (patch) | |
tree | 6e43dbbcd722f3d11b7fa02a1103d6ee99229334 /TAO/orbsvcs/ImplRepo_Service | |
parent | 1debeb99df0b8ceddab39c62f8a7e63f50fd79a3 (diff) | |
download | ATCD-68c0c4582658b5b35e346a925c8bf9f29efd064c.tar.gz |
*** empty log message ***
Diffstat (limited to 'TAO/orbsvcs/ImplRepo_Service')
25 files changed, 1678 insertions, 1619 deletions
diff --git a/TAO/orbsvcs/ImplRepo_Service/Activator_Loader.cpp b/TAO/orbsvcs/ImplRepo_Service/Activator_Loader.cpp index 4429f6eba49..1b2a4b5d228 100644 --- a/TAO/orbsvcs/ImplRepo_Service/Activator_Loader.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/Activator_Loader.cpp @@ -4,27 +4,27 @@ #include "ace/Dynamic_Service.h" #include "ace/Task.h" -class ImR_Activator_ORB_Runner : public ACE_Task_Base +class ImR_Activator_ORB_Runner : public ACE_Task_Base { ImR_Activator_Loader& service_; public: - ImR_Activator_ORB_Runner(ImR_Activator_Loader& service) - : service_(service) + ImR_Activator_ORB_Runner (ImR_Activator_Loader& service) + : service_ (service) { } - virtual int svc() + virtual int svc () { // Block until service_.fini() calls orb->destroy() - this->service_.run(); + this->service_.run (); return 0; } }; -ImR_Activator_Loader::ImR_Activator_Loader(void) +ImR_Activator_Loader::ImR_Activator_Loader (void) { } -// For now, we will assume that it's sufficient to start +// For now, we will assume that it's sufficient to start // the service in its own thread. Later, if necessary, we // can add a command line option to allow the imr to use // the same orb as other tao services, however the imr @@ -35,20 +35,20 @@ ImR_Activator_Loader::init (int argc, ACE_TCHAR *argv[] ACE_ENV_ARG_DECL) { ACE_TRY { - int err = this->opts_.init(argc, argv); - if (err != 0) + int err = this->opts_.init (argc, argv); + if (err != 0) return -1; // Creates it's own internal orb, which we must run later - err = this->service_.init(this->opts_ ACE_ENV_ARG_PARAMETER); + err = this->service_.init (this->opts_ ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; if (err != 0) return -1; // Create a thread in which to run the service - ACE_ASSERT(this->runner_.get() == 0); - this->runner_.reset(new ImR_Activator_ORB_Runner(*this)); - this->runner_->activate(); + ACE_ASSERT (this->runner_.get () == 0); + this->runner_.reset (new ImR_Activator_ORB_Runner (*this)); + this->runner_->activate (); } ACE_CATCHANY { @@ -61,21 +61,21 @@ ImR_Activator_Loader::init (int argc, ACE_TCHAR *argv[] ACE_ENV_ARG_DECL) int ImR_Activator_Loader::fini (void) { - ACE_ASSERT(this->runner_.get() != 0); + ACE_ASSERT (this->runner_.get() != 0); ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY - { - int ret = this->service_.fini(ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + { + int ret = this->service_.fini (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; - this->runner_->wait(); - this->runner_.reset(0); - return ret; - } + this->runner_->wait (); + this->runner_.reset (0); + return ret; + } ACE_CATCHANY - { - return -1; - } + { + return -1; + } ACE_ENDTRY; return -1; } @@ -87,26 +87,25 @@ ImR_Activator_Loader::create_object (CORBA::ORB_ptr, ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { - ACE_THROW_RETURN(CORBA::NO_IMPLEMENT(), CORBA::Object::_nil()); + ACE_THROW_RETURN(CORBA::NO_IMPLEMENT (), CORBA::Object::_nil ()); } int -ImR_Activator_Loader::run(void) +ImR_Activator_Loader::run (void) { ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY - { - return this->service_.run(ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - } + { + return this->service_.run (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } ACE_CATCHALL - { - ACE_ERROR((LM_ERROR, "Exception in ImR_Locator_ORB_Runner()\n")); - return -1; - } + { + ACE_ERROR ((LM_ERROR, "Exception in ImR_Locator_ORB_Runner()\n")); + return -1; + } ACE_ENDTRY; return 0; } ACE_FACTORY_DEFINE (Activator, ImR_Activator_Loader) - diff --git a/TAO/orbsvcs/ImplRepo_Service/Activator_NT_Service.cpp b/TAO/orbsvcs/ImplRepo_Service/Activator_NT_Service.cpp index 4f672896791..eac94f086bb 100644 --- a/TAO/orbsvcs/ImplRepo_Service/Activator_NT_Service.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/Activator_NT_Service.cpp @@ -63,10 +63,10 @@ Activator_NT_Service::svc (void) Activator_Options opts; if (opts.init_from_registry() != 0) - { - report_status (SERVICE_STOPPED); - return -1; - } + { + report_status (SERVICE_STOPPED); + return -1; + } ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY diff --git a/TAO/orbsvcs/ImplRepo_Service/Activator_Options.cpp b/TAO/orbsvcs/ImplRepo_Service/Activator_Options.cpp index 463fa913844..072ca61ba38 100644 --- a/TAO/orbsvcs/ImplRepo_Service/Activator_Options.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/Activator_Options.cpp @@ -36,7 +36,7 @@ int Activator_Options::parse_args (int &argc, char *argv[]) { ACE_Arg_Shifter shifter (argc, argv); - + while (shifter.is_anything_left ()) { if (ACE_OS::strcasecmp (shifter.get_current (), @@ -53,25 +53,25 @@ Activator_Options::parse_args (int &argc, char *argv[]) if (ACE_OS::strcasecmp (shifter.get_current (), ACE_TEXT ("install")) == 0) - { - this->service_command_ = SC_INSTALL; - } + { + this->service_command_ = SC_INSTALL; + } else if (ACE_OS::strcasecmp (shifter.get_current (), ACE_TEXT ("remove")) == 0) - { - this->service_command_ = SC_REMOVE; - } + { + this->service_command_ = SC_REMOVE; + } else if (ACE_OS::strcasecmp (shifter.get_current (), ACE_TEXT ("install_no_imr")) == 0) - { - this->service_command_ = SC_INSTALL_NO_LOCATOR; - } + { + this->service_command_ = SC_INSTALL_NO_LOCATOR; + } else - { - ACE_ERROR((LM_ERROR, "Error: Unknown service command : %s\n", shifter.get_current())); - this->print_usage (); - return -1; - } + { + ACE_ERROR((LM_ERROR, "Error: Unknown service command : %s\n", shifter.get_current())); + this->print_usage (); + return -1; + } } else if (ACE_OS::strcasecmp (shifter.get_current (), ACE_TEXT ("-d")) == 0) @@ -98,7 +98,7 @@ Activator_Options::parse_args (int &argc, char *argv[]) this->print_usage (); return -1; } - this->ior_output_file_ = shifter.get_current(); + this->ior_output_file_ = shifter.get_current (); } else if (ACE_OS::strcasecmp (shifter.get_current (), ACE_TEXT ("-s")) == 0) @@ -124,7 +124,7 @@ Activator_Options::parse_args (int &argc, char *argv[]) this->print_usage (); return -1; } - this->name_ = shifter.get_current(); + this->name_ = shifter.get_current (); } else if (ACE_OS::strcasecmp (shifter.get_current (), ACE_TEXT ("-l")) == 0) @@ -149,14 +149,14 @@ Activator_Options::init (int argc, char *argv[]) // This may also run the commands to install or remove the nt service. int result = this->parse_args (argc, argv); if (result != 0) - { - return result; - } + { + return result; + } for (int i = 0; i < argc; ++i) - { - this->cmdline_ += ACE_CString(argv[i]) + ACE_CString(" "); - } + { + this->cmdline_ += ACE_CString (argv[i]) + ACE_CString (" "); + } return 0; } @@ -201,32 +201,33 @@ Activator_Options::save_registry_options() &key, NULL ); - if (err != ERROR_SUCCESS) { - return -1; - } - err = ACE_TEXT_RegSetValueEx(key, "ORBInitOptions", 0, REG_SZ, - (LPBYTE) this->cmdline_.c_str(), this->cmdline_.length() + 1); - ACE_ASSERT(err == ERROR_SUCCESS); + if (err != ERROR_SUCCESS) + { + return -1; + } + err = ACE_TEXT_RegSetValueEx (key, "ORBInitOptions", 0, REG_SZ, + (LPBYTE) this->cmdline_.c_str (), this->cmdline_.length () + 1); + ACE_ASSERT (err == ERROR_SUCCESS); - err = ACE_TEXT_RegSetValueEx(key, "IORFile", 0, REG_SZ, - (LPBYTE) this->ior_output_file_.c_str(), this->ior_output_file_.length() + 1); - ACE_ASSERT(err == ERROR_SUCCESS); + err = ACE_TEXT_RegSetValueEx (key, "IORFile", 0, REG_SZ, + (LPBYTE) this->ior_output_file_.c_str (), this->ior_output_file_.length () + 1); + ACE_ASSERT (err == ERROR_SUCCESS); - err = ACE_TEXT_RegSetValueEx(key, "DebugLevel", 0, REG_DWORD, - (LPBYTE) &this->debug_ , sizeof(this->debug_)); - ACE_ASSERT(err == ERROR_SUCCESS); + err = ACE_TEXT_RegSetValueEx (key, "DebugLevel", 0, REG_DWORD, + (LPBYTE) &this->debug_ , sizeof (this->debug_)); + ACE_ASSERT (err == ERROR_SUCCESS); - err = ACE_TEXT_RegSetValueEx(key, "Name", 0, REG_SZ, - (LPBYTE) this->name_.c_str(), this->name_.length() + 1); - ACE_ASSERT(err == ERROR_SUCCESS); + err = ACE_TEXT_RegSetValueEx( key, "Name", 0, REG_SZ, + (LPBYTE) this->name_.c_str (), this->name_.length () + 1); + ACE_ASSERT (err == ERROR_SUCCESS); DWORD tmpint = this->notify_imr_; - err = ACE_TEXT_RegSetValueEx(key, "NotifyImR", 0, REG_DWORD, - (LPBYTE) &tmpint , sizeof(tmpint)); - ACE_ASSERT(err == ERROR_SUCCESS); + err = ACE_TEXT_RegSetValueEx (key, "NotifyImR", 0, REG_DWORD, + (LPBYTE) &tmpint , sizeof (tmpint)); + ACE_ASSERT (err == ERROR_SUCCESS); - err = ::RegCloseKey(key); - ACE_ASSERT(err == ERROR_SUCCESS); + err = ::RegCloseKey (key); + ACE_ASSERT (err == ERROR_SUCCESS); #endif return 0; } @@ -243,56 +244,62 @@ Activator_Options::load_registry_options () KEY_READ, &key ); - if (err != ERROR_SUCCESS) { - // If there aren't any saved parameters, then that's ok. - return 0; - } + if (err != ERROR_SUCCESS) + { + // If there aren't any saved parameters, then that's ok. + return 0; + } char tmpstr[4096]; - DWORD sz = sizeof(tmpstr); + DWORD sz = sizeof (tmpstr); DWORD type = 0; - err = ACE_TEXT_RegQueryValueEx(key, "ORBInitOptions", 0, &type, + err = ACE_TEXT_RegQueryValueEx (key, "ORBInitOptions", 0, &type, (LPBYTE) tmpstr, &sz); - if (err == ERROR_SUCCESS) { - ACE_ASSERT(type == REG_SZ); - tmpstr[sz - 1] = '\0'; - this->cmdline_ = tmpstr; - } + if (err == ERROR_SUCCESS) + { + ACE_ASSERT (type == REG_SZ); + tmpstr[sz - 1] = '\0'; + this->cmdline_ = tmpstr; + } sz = sizeof(tmpstr); - err = ACE_TEXT_RegQueryValueEx(key, "IORFile", 0, &type, + err = ACE_TEXT_RegQueryValueEx (key, "IORFile", 0, &type, (LPBYTE) tmpstr, &sz); - if (err == ERROR_SUCCESS) { - ACE_ASSERT(type == REG_SZ); - tmpstr[sz - 1] = '\0'; - this->ior_output_file_ = tmpstr; - } + if (err == ERROR_SUCCESS) + { + ACE_ASSERT (type == REG_SZ); + tmpstr[sz - 1] = '\0'; + this->ior_output_file_ = tmpstr; + } sz = sizeof(debug_); - err = ACE_TEXT_RegQueryValueEx(key, "DebugLevel", 0, &type, + err = ACE_TEXT_RegQueryValueEx (key, "DebugLevel", 0, &type, (LPBYTE) &this->debug_ , &sz); - if (err == ERROR_SUCCESS) { - ACE_ASSERT(type == REG_DWORD); - } + if (err == ERROR_SUCCESS) + { + ACE_ASSERT (type == REG_DWORD); + } sz = sizeof(tmpstr); - err = ACE_TEXT_RegQueryValueEx(key, "Name", 0, &type, + err = ACE_TEXT_RegQueryValueEx (key, "Name", 0, &type, (LPBYTE) tmpstr, &sz); - if (err == ERROR_SUCCESS) { - ACE_ASSERT(type == REG_SZ); - tmpstr[sz - 1] = '\0'; - this->name_ = tmpstr; - } + if (err == ERROR_SUCCESS) + { + ACE_ASSERT (type == REG_SZ); + tmpstr[sz - 1] = '\0'; + this->name_ = tmpstr; + } DWORD tmpint = 0; sz = sizeof(tmpint); - err = ACE_TEXT_RegQueryValueEx(key, "NotifyImR", 0, &type, + err = ACE_TEXT_RegQueryValueEx (key, "NotifyImR", 0, &type, (LPBYTE) &tmpint , &sz); - if (err == ERROR_SUCCESS) { - ACE_ASSERT(type == REG_DWORD); - } + if (err == ERROR_SUCCESS) + { + ACE_ASSERT (type == REG_DWORD); + } this->notify_imr_ = tmpint != 0; - err = ::RegCloseKey(key); + err = ::RegCloseKey (key); ACE_ASSERT(err == ERROR_SUCCESS); #endif /* ACE_WIN32 */ return 0; @@ -323,17 +330,19 @@ Activator_Options::ior_filename (void) const } Activator_Options::SERVICE_COMMAND -Activator_Options::service_command(void) const +Activator_Options::service_command (void) const { return this->service_command_; } const char* -Activator_Options::cmdline(void) const { +Activator_Options::cmdline (void) const +{ return this->cmdline_.c_str (); } const ACE_CString& -Activator_Options::name(void) const { +Activator_Options::name (void) const +{ return this->name_; } diff --git a/TAO/orbsvcs/ImplRepo_Service/Activator_Options.h b/TAO/orbsvcs/ImplRepo_Service/Activator_Options.h index b9819d1d7d3..45f351a0f44 100644 --- a/TAO/orbsvcs/ImplRepo_Service/Activator_Options.h +++ b/TAO/orbsvcs/ImplRepo_Service/Activator_Options.h @@ -32,7 +32,7 @@ class Activator_Export Activator_Options { public: - + enum SERVICE_COMMAND { SC_NONE, SC_INSTALL, @@ -50,7 +50,7 @@ public: /// Service Mode bool service (void) const; - /// Notify the ImR when server processes die. + /// Notify the ImR when server processes die. /// Note : Currently this only works on Unix. bool notify_imr (void) const; diff --git a/TAO/orbsvcs/ImplRepo_Service/Adapter_Activator.cpp b/TAO/orbsvcs/ImplRepo_Service/Adapter_Activator.cpp index 04cf4f5e647..e68bdbcf4f9 100644 --- a/TAO/orbsvcs/ImplRepo_Service/Adapter_Activator.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/Adapter_Activator.cpp @@ -13,13 +13,13 @@ #include "ace/Log_Msg.h" -ImR_Adapter::ImR_Adapter(void) -: servant_locator_(0) +ImR_Adapter::ImR_Adapter (void) +: servant_locator_ (0) { } void -ImR_Adapter::init(PortableServer::ServantLocator_ptr servant) +ImR_Adapter::init (PortableServer::ServantLocator_ptr servant) { servant_locator_ = servant; } @@ -30,8 +30,8 @@ ImR_Adapter::unknown_adapter (PortableServer::POA_ptr parent, ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { - ACE_ASSERT(! CORBA::is_nil(parent)); - ACE_ASSERT(name != 0); + ACE_ASSERT (! CORBA::is_nil(parent)); + ACE_ASSERT (name != 0); CORBA::PolicyList policies (2); policies.length (2); @@ -76,7 +76,7 @@ ImR_Adapter::unknown_adapter (PortableServer::POA_ptr parent, ACE_TRY_CHECK; exception_message = "While unknown_adapter, set_servant_manager"; - child->set_servant_manager(this->servant_locator_ ACE_ENV_ARG_PARAMETER); + child->set_servant_manager (this->servant_locator_ ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; } ACE_CATCHANY diff --git a/TAO/orbsvcs/ImplRepo_Service/AsyncStartupWaiter_i.cpp b/TAO/orbsvcs/ImplRepo_Service/AsyncStartupWaiter_i.cpp index dded9d60d2b..2cebbc590bd 100644 --- a/TAO/orbsvcs/ImplRepo_Service/AsyncStartupWaiter_i.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/AsyncStartupWaiter_i.cpp @@ -7,18 +7,19 @@ using namespace ImplementationRepository; -AsyncStartupWaiter_i::PendingData::PendingData(const char* p, const char* i) -: partial_ior(p) -, ior(i) +AsyncStartupWaiter_i::PendingData::PendingData (const char* p, const char* i) +: partial_ior (p) +, ior( i) { } -AsyncStartupWaiter_i::PendingData::PendingData() +AsyncStartupWaiter_i::PendingData::PendingData () { } -void AsyncStartupWaiter_i::debug(bool dbg) { +void AsyncStartupWaiter_i::debug (bool dbg) +{ debug_ = dbg; } @@ -27,32 +28,35 @@ void AsyncStartupWaiter_i::wait_for_startup (AMH_AsyncStartupWaiterResponseHandl { PendingListPtr plst; pending_.find(name, plst); - if (! plst.null() && plst->size() > 0) { - PendingList& tmp = *plst; - PendingData& pd = tmp[tmp.size() - 1]; - tmp.pop_back(); - - if (debug_) - ACE_DEBUG((LM_DEBUG, "ImR: Skipping wait due to queued startup info for <%s>.\n", name)); - - send_response(*rh, name, pd.partial_ior.c_str(), pd.ior.c_str()); - - } else { - RHListPtr lst; - waiting_.find(name, lst); - if (lst.null()) + if (! plst.null () && plst->size () > 0) + { + PendingList& tmp = *plst; + PendingData& pd = tmp[tmp.size () - 1]; + tmp.pop_back (); + + if (debug_) + ACE_DEBUG ((LM_DEBUG, "ImR: Skipping wait due to queued startup info for <%s>.\n", name)); + + send_response (*rh, name, pd.partial_ior.c_str(), pd.ior.c_str()); + + } + else { - lst = RHListPtr(new RHList); - int err = waiting_.bind(name, lst); - ACE_ASSERT(err == 0); - ACE_UNUSED_ARG(err); + RHListPtr lst; + waiting_.find (name, lst); + if (lst.null ()) + { + lst = RHListPtr (new RHList); + int err = waiting_.bind (name, lst); + ACE_ASSERT (err == 0); + ACE_UNUSED_ARG (err); + } + lst->push_back (AMH_AsyncStartupWaiterResponseHandler::_duplicate (rh)); } - lst->push_back(AMH_AsyncStartupWaiterResponseHandler::_duplicate(rh)); - } } void -AsyncStartupWaiter_i::send_response(ImplementationRepository::AMH_AsyncStartupWaiterResponseHandler& rh, +AsyncStartupWaiter_i::send_response (ImplementationRepository::AMH_AsyncStartupWaiterResponseHandler& rh, const char* name, const char* partial_ior, const char* ior) { StartupInfo_var si = new StartupInfo(); @@ -62,51 +66,52 @@ AsyncStartupWaiter_i::send_response(ImplementationRepository::AMH_AsyncStartupWa ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY - { - rh.wait_for_startup(si.in() ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } + { + rh.wait_for_startup (si.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } ACE_CATCHANY - { - if (debug_) - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "AsyncStartupWaiter_i::send_response()"); - } + { + if (debug_) + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "AsyncStartupWaiter_i::send_response ()"); + } ACE_ENDTRY; } void -AsyncStartupWaiter_i::unblock_one(const char* name, const char* partial_ior, const char* ior, bool queue) { +AsyncStartupWaiter_i::unblock_one (const char* name, const char* partial_ior, const char* ior, bool queue) { ImplementationRepository::AMH_AsyncStartupWaiterResponseHandler_var rh = get_one_waiter(name); - if (! CORBA::is_nil(rh.in())) { - - send_response(*rh.in (), name, partial_ior, ior); - - } else if (queue) { - - if (debug_) - ACE_DEBUG((LM_DEBUG, "ImR: Queuing startup info.\n")); - - PendingListPtr lst; - pending_.find(name, lst); - if (lst.null()) { - lst = PendingListPtr(new PendingList); - int err = pending_.bind(name, lst); - ACE_ASSERT(err == 0); - ACE_UNUSED_ARG(err); + if (! CORBA::is_nil(rh.in ())) + { + send_response (*rh.in (), name, partial_ior, ior); + } + else if (queue) + { + if (debug_) + ACE_DEBUG((LM_DEBUG, "ImR: Queuing startup info.\n")); + + PendingListPtr lst; + pending_.find (name, lst); + if (lst.null ()) + { + lst = PendingListPtr (new PendingList); + int err = pending_.bind (name, lst); + ACE_ASSERT (err == 0); + ACE_UNUSED_ARG (err); + } + lst->push_back (PendingData (partial_ior, ior)); } - lst->push_back(PendingData(partial_ior, ior)); - } } void -AsyncStartupWaiter_i::unblock_all(const char* name) { +AsyncStartupWaiter_i::unblock_all (const char* name) { RHList tmp; - get_all_waiters(name, tmp); + get_all_waiters (name, tmp); // This startup info should be ignored when unblocking all, because we // don't know the ior or partial_ior at this point. - StartupInfo_var si = new StartupInfo(); + StartupInfo_var si = new StartupInfo (); si->name = name; // Note : This method may be called when there are no waiters. @@ -115,48 +120,52 @@ AsyncStartupWaiter_i::unblock_all(const char* name) { { ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY - { - ImplementationRepository::AMH_AsyncStartupWaiterResponseHandler_var& rh = tmp[i]; - - rh->wait_for_startup(si.in() ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } + { + ImplementationRepository::AMH_AsyncStartupWaiterResponseHandler_var& rh = tmp[i]; + + rh->wait_for_startup (si.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } ACE_CATCHANY - { - if (debug_) - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "AsyncStartupWaiter_i::unblock_all()"); - } + { + if (debug_) + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "AsyncStartupWaiter_i::unblock_all ()"); + } ACE_ENDTRY; } } ImplementationRepository::AMH_AsyncStartupWaiterResponseHandler_ptr -AsyncStartupWaiter_i::get_one_waiter(const char* name) { +AsyncStartupWaiter_i::get_one_waiter (const char* name) +{ RHListPtr lst; - waiting_.find(name, lst); - if (! lst.null() && lst->size() > 0) { - RHList& rhlst = *lst; - ImplementationRepository::AMH_AsyncStartupWaiterResponseHandler_var& tmp = rhlst[rhlst.size() - 1]; - ImplementationRepository::AMH_AsyncStartupWaiterResponseHandler_ptr ret = tmp._retn(); - rhlst.pop_back(); - return ret; - } - return ImplementationRepository::AMH_AsyncStartupWaiterResponseHandler::_nil(); + waiting_.find (name, lst); + if (! lst.null() && lst->size () > 0) + { + RHList& rhlst = *lst; + ImplementationRepository::AMH_AsyncStartupWaiterResponseHandler_var& tmp = rhlst[rhlst.size () - 1]; + ImplementationRepository::AMH_AsyncStartupWaiterResponseHandler_ptr ret = tmp._retn (); + rhlst.pop_back (); + return ret; + } + return ImplementationRepository::AMH_AsyncStartupWaiterResponseHandler::_nil (); } void -AsyncStartupWaiter_i::get_all_waiters(const char* name, RHList& ret) { +AsyncStartupWaiter_i::get_all_waiters (const char* name, RHList& ret) +{ RHListPtr lst; - waiting_.find(name, lst); - if (! lst.null()) { - for (size_t i = 0; i < lst->size(); ++i) { - RHList& tmp = *lst; - ret.push_back(tmp[i]); - // The ACE_Vector will not destruct the elements when cleared, so we must - // make sure to do so here. - tmp[i] = ImplementationRepository::AMH_AsyncStartupWaiterResponseHandler::_nil(); - } - lst->clear(); + waiting_.find (name, lst); + if (! lst.null ()) { + for (size_t i = 0; i < lst->size (); ++i) + { + RHList& tmp = *lst; + ret.push_back (tmp[i]); + // The ACE_Vector will not destruct the elements when cleared, so we must + // make sure to do so here. + tmp[i] = ImplementationRepository::AMH_AsyncStartupWaiterResponseHandler::_nil (); + } + lst->clear (); } } diff --git a/TAO/orbsvcs/ImplRepo_Service/AsyncStartupWaiter_i.h b/TAO/orbsvcs/ImplRepo_Service/AsyncStartupWaiter_i.h index ba65d51b561..b4b527e1d40 100644 --- a/TAO/orbsvcs/ImplRepo_Service/AsyncStartupWaiter_i.h +++ b/TAO/orbsvcs/ImplRepo_Service/AsyncStartupWaiter_i.h @@ -45,7 +45,7 @@ class Locator_Export AsyncStartupWaiter_i : public virtual POA_ImplementationRep ACE_Null_Mutex> WaitingMap; public: - + void wait_for_startup ( ImplementationRepository::AMH_AsyncStartupWaiterResponseHandler_ptr rh, const char* name ACE_ENV_ARG_DECL) diff --git a/TAO/orbsvcs/ImplRepo_Service/Forwarder.cpp b/TAO/orbsvcs/ImplRepo_Service/Forwarder.cpp index 991e1012870..7337af511e9 100644 --- a/TAO/orbsvcs/ImplRepo_Service/Forwarder.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/Forwarder.cpp @@ -33,24 +33,24 @@ ImR_Forwarder::ImR_Forwarder (ImR_Locator_i& imr_impl) } void -ImR_Forwarder::init(CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) +ImR_Forwarder::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) { - ACE_ASSERT(! CORBA::is_nil(orb)); + ACE_ASSERT (! CORBA::is_nil(orb)); this->orb_ = orb; ACE_TRY_NEW_ENV - { - CORBA::Object_var tmp = - orb->resolve_initial_references ("POACurrent" ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - this->poa_current_var_ = - PortableServer::Current::_narrow (tmp.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } + { + CORBA::Object_var tmp = + orb->resolve_initial_references ("POACurrent" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + this->poa_current_var_ = + PortableServer::Current::_narrow (tmp.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } ACE_CATCHANY - { - ACE_DEBUG((LM_DEBUG, "ImR_Forwarder::init() Exception ignored.\n")); - } + { + ACE_DEBUG ((LM_DEBUG, "ImR_Forwarder::init() Exception ignored.\n")); + } ACE_ENDTRY; ACE_CHECK; ACE_ASSERT (!CORBA::is_nil (this->poa_current_var_.in ())); @@ -72,71 +72,71 @@ ImR_Forwarder::preinvoke (const PortableServer::ObjectId &, ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, PortableServer::ForwardRequest)) { - ACE_ASSERT(! CORBA::is_nil(poa)); + ACE_ASSERT (! CORBA::is_nil(poa)); CORBA::Object_var forward_obj; ACE_TRY - { - CORBA::String_var server_name = poa->the_name(); - - if (locator_.debug() > 1) - ACE_DEBUG ((LM_DEBUG, "ImR: Activating server <%s>.\n", server_name.in())); - - // The activator stores a partial ior with each server. We can - // just tack on the current ObjectKey to get a valid ior for - // the desired server. - CORBA::String_var pior = locator_.activate_server_by_name(server_name.in(), false ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - ACE_CString ior = pior.in(); - - // Check that the returned ior is the expected partial ior with - // missing ObjectKey. - if (ior.find("corbaloc:") != 0 || ior[ior.length() - 1] != '/') { - ACE_ERROR((LM_ERROR, "ImR_Forwarder::preinvoke() Invalid corbaloc ior.\n\t<%s>\n", ior.c_str())); - ACE_TRY_THROW (CORBA::OBJECT_NOT_EXIST ( + CORBA::String_var server_name = poa->the_name(); + + if (locator_.debug() > 1) + ACE_DEBUG ((LM_DEBUG, "ImR: Activating server <%s>.\n", server_name.in())); + + // The activator stores a partial ior with each server. We can + // just tack on the current ObjectKey to get a valid ior for + // the desired server. + CORBA::String_var pior = locator_.activate_server_by_name (server_name.in (), false ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_CString ior = pior.in (); + + // Check that the returned ior is the expected partial ior with + // missing ObjectKey. + if (ior.find ("corbaloc:") != 0 || ior[ior.length () - 1] != '/') + { + ACE_ERROR ((LM_ERROR, "ImR_Forwarder::preinvoke () Invalid corbaloc ior.\n\t<%s>\n", ior.c_str())); + ACE_TRY_THROW (CORBA::OBJECT_NOT_EXIST ( + CORBA::SystemException::_tao_minor_code (TAO_IMPLREPO_MINOR_CODE, 0), + CORBA::COMPLETED_NO)); + } + + CORBA::String_var key_str; + // Unlike POA Current, this implementation cannot be cached. + TAO::Portable_Server::POA_Current* tao_current = + dynamic_cast <TAO::Portable_Server::POA_Current*> (this->poa_current_var_.in ()); + + ACE_ASSERT(tao_current != 0); + TAO::Portable_Server::POA_Current_Impl* impl = tao_current->implementation (); + TAO::ObjectKey::encode_sequence_to_string (key_str.out (), impl->object_key ()); + + ior += key_str.in(); + + if (locator_.debug() > 0) + ACE_DEBUG ((LM_DEBUG, "ImR: Forwarding invocation on <%s> to <%s>\n", server_name.in(), ior.c_str())); + + forward_obj = + this->orb_->string_to_object (ior.c_str () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCH (ImplementationRepository::CannotActivate, ex) + { + ACE_TRY_THROW (CORBA::TRANSIENT ( CORBA::SystemException::_tao_minor_code (TAO_IMPLREPO_MINOR_CODE, 0), CORBA::COMPLETED_NO)); } - - CORBA::String_var key_str; - // Unlike POA Current, this implementation cannot be cached. - TAO::Portable_Server::POA_Current* tao_current = - dynamic_cast <TAO::Portable_Server::POA_Current*> (this->poa_current_var_.in ()); - - ACE_ASSERT(tao_current != 0); - TAO::Portable_Server::POA_Current_Impl* impl = tao_current->implementation (); - TAO::ObjectKey::encode_sequence_to_string (key_str.out(), impl->object_key ()); - - ior += key_str.in(); - - if (locator_.debug() > 0) - ACE_DEBUG ((LM_DEBUG, "ImR: Forwarding invocation on <%s> to <%s>\n", server_name.in(), ior.c_str())); - - forward_obj = - this->orb_->string_to_object (ior.c_str () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } - ACE_CATCH (ImplementationRepository::CannotActivate, ex) - { - ACE_TRY_THROW (CORBA::TRANSIENT ( - CORBA::SystemException::_tao_minor_code (TAO_IMPLREPO_MINOR_CODE, 0), - CORBA::COMPLETED_NO)); - } ACE_CATCH (ImplementationRepository::NotFound, ex) - { - ACE_TRY_THROW (CORBA::TRANSIENT ( - CORBA::SystemException::_tao_minor_code (TAO_IMPLREPO_MINOR_CODE, 0), - CORBA::COMPLETED_NO)); - } + { + ACE_TRY_THROW (CORBA::TRANSIENT ( + CORBA::SystemException::_tao_minor_code (TAO_IMPLREPO_MINOR_CODE, 0), + CORBA::COMPLETED_NO)); + } ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Forwarder"); - ACE_TRY_THROW (CORBA::TRANSIENT ( - CORBA::SystemException::_tao_minor_code (TAO_IMPLREPO_MINOR_CODE, 0), - CORBA::COMPLETED_NO)); - } + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Forwarder"); + ACE_TRY_THROW (CORBA::TRANSIENT ( + CORBA::SystemException::_tao_minor_code (TAO_IMPLREPO_MINOR_CODE, 0), + CORBA::COMPLETED_NO)); + } ACE_ENDTRY; ACE_CHECK_RETURN (0); @@ -150,8 +150,7 @@ ImR_Forwarder::preinvoke (const PortableServer::ObjectId &, } void -ImR_Forwarder::postinvoke ( - const PortableServer::ObjectId &, +ImR_Forwarder::postinvoke (const PortableServer::ObjectId &, PortableServer::POA_ptr, const char *, PortableServer::ServantLocator::Cookie, diff --git a/TAO/orbsvcs/ImplRepo_Service/INS_Locator.cpp b/TAO/orbsvcs/ImplRepo_Service/INS_Locator.cpp index 600024e1c80..7234e583b30 100644 --- a/TAO/orbsvcs/ImplRepo_Service/INS_Locator.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/INS_Locator.cpp @@ -23,43 +23,43 @@ char * INS_Locator::locate (const char* object_key ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, IORTable::NotFound)) { - ACE_ASSERT(object_key != 0); + ACE_ASSERT (object_key != 0); ACE_TRY - { - ACE_CString key(object_key); - ssize_t poaidx = key.find('/'); - if (poaidx >= 0) { - key = key.substring(0, poaidx); - } + ACE_CString key (object_key); + ssize_t poaidx = key.find ('/'); + if (poaidx >= 0) + { + key = key.substring (0, poaidx); + } - if (imr_locator_.debug() > 1) - ACE_DEBUG ((LM_DEBUG, "ImR: Activating server <%s>.\n", key.c_str())); + if (imr_locator_.debug () > 1) + ACE_DEBUG ((LM_DEBUG, "ImR: Activating server <%s>.\n", key.c_str ())); - CORBA::String_var located = - this->imr_locator_.activate_server_by_object(key.c_str() ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + CORBA::String_var located = + this->imr_locator_.activate_server_by_object (key.c_str () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; - ACE_CString tmp = located.in(); - tmp += object_key; + ACE_CString tmp = located.in (); + tmp += object_key; - if (imr_locator_.debug() > 0) - ACE_DEBUG ((LM_DEBUG, "ImR: Forwarding invocation on <%s> to <%s>\n", key.c_str(), tmp.c_str())); + if (imr_locator_.debug () > 0) + ACE_DEBUG ((LM_DEBUG, "ImR: Forwarding invocation on <%s> to <%s>\n", key.c_str (), tmp.c_str())); - return CORBA::string_dup(tmp.c_str()); - } - ACE_CATCH(ImplementationRepository::CannotActivate, ex) - { - ACE_TRY_THROW (CORBA::TRANSIENT ( - CORBA::SystemException::_tao_minor_code (TAO_IMPLREPO_MINOR_CODE, 0), - CORBA::COMPLETED_NO)); - } - ACE_CATCH(ImplementationRepository::NotFound, ex) - { - ACE_TRY_THROW (CORBA::TRANSIENT ( - CORBA::SystemException::_tao_minor_code (TAO_IMPLREPO_MINOR_CODE, 0), - CORBA::COMPLETED_NO)); - } + return CORBA::string_dup (tmp.c_str ()); + } + ACE_CATCH (ImplementationRepository::CannotActivate, ex) + { + ACE_TRY_THROW (CORBA::TRANSIENT ( + CORBA::SystemException::_tao_minor_code (TAO_IMPLREPO_MINOR_CODE, 0), + CORBA::COMPLETED_NO)); + } + ACE_CATCH (ImplementationRepository::NotFound, ex) + { + ACE_TRY_THROW (CORBA::TRANSIENT ( + CORBA::SystemException::_tao_minor_code (TAO_IMPLREPO_MINOR_CODE, 0), + CORBA::COMPLETED_NO)); + } ACE_ENDTRY; return 0; } diff --git a/TAO/orbsvcs/ImplRepo_Service/ImR_Activator.cpp b/TAO/orbsvcs/ImplRepo_Service/ImR_Activator.cpp index 37eb23a1884..34da1320caf 100644 --- a/TAO/orbsvcs/ImplRepo_Service/ImR_Activator.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/ImR_Activator.cpp @@ -10,7 +10,7 @@ class ImR_Activator_Shutdown : public Shutdown_Functor { public: - ImR_Activator_Shutdown(ImR_Activator_i& act); + ImR_Activator_Shutdown (ImR_Activator_i& act); void operator() (int which_signal); private: @@ -28,7 +28,7 @@ ImR_Activator_Shutdown::operator() (int /*which_signal*/) ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY { - this->act_.shutdown(true ACE_ENV_ARG_PARAMETER); + this->act_.shutdown (true ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; } ACE_CATCHANY @@ -44,7 +44,7 @@ run_standalone (Activator_Options& opts) ImR_Activator_i server; ImR_Activator_Shutdown killer (server); - Service_Shutdown kill_contractor(killer); + Service_Shutdown kill_contractor (killer); ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY @@ -117,56 +117,59 @@ run_service (void) static int run_service_command (Activator_Options& opts) { - if (opts.service_command() == Activator_Options::SC_NONE) + if (opts.service_command () == Activator_Options::SC_NONE) return 0; #if defined (ACE_WIN32) SERVICE::instance()->name (IMR_ACTIVATOR_SERVICE_NAME, IMR_ACTIVATOR_DISPLAY_NAME); - if (opts.service_command() == Activator_Options::SC_INSTALL || - opts.service_command() == Activator_Options::SC_INSTALL_NO_LOCATOR) - { - const DWORD MAX_PATH_LENGTH = 4096; - char pathname[MAX_PATH_LENGTH]; - - DWORD length = ACE_TEXT_GetModuleFileName(NULL, pathname, MAX_PATH_LENGTH); - if (length == 0 || length >= MAX_PATH_LENGTH - sizeof(" -s")) + if (opts.service_command () == Activator_Options::SC_INSTALL || + opts.service_command () == Activator_Options::SC_INSTALL_NO_LOCATOR) + { + const DWORD MAX_PATH_LENGTH = 4096; + char pathname[MAX_PATH_LENGTH]; + + DWORD length = ACE_TEXT_GetModuleFileName(NULL, pathname, MAX_PATH_LENGTH); + if (length == 0 || length >= MAX_PATH_LENGTH - sizeof(" -s")) + { + ACE_ERROR ((LM_ERROR, "Error: Could not get module file name\n")); + return -1; + } + + // Append the command used for running the implrepo as a service + ACE_OS::strcat (pathname, ACE_TEXT (" -s")); + int ret = -1; + if (opts.service_command () == Activator_Options::SC_INSTALL) + { + const char* DEPENDS_ON = "TAOImR"; // Must match Locator_NT_Service.h + + ret = SERVICE::instance ()->insert (SERVICE_DEMAND_START, + SERVICE_ERROR_NORMAL, + pathname, + 0, // group + 0, // tag + DEPENDS_ON + ); + } + else + { + ret = SERVICE::instance ()->insert (SERVICE_DEMAND_START, + SERVICE_ERROR_NORMAL, + pathname); + } + if (ret != -1) { - ACE_ERROR ((LM_ERROR, "Error: Could not get module file name\n")); - return -1; + ACE_DEBUG ((LM_DEBUG, "ImR Activator: Service installed.\n")); + opts.save_registry_options (); } - - // Append the command used for running the implrepo as a service - ACE_OS::strcat (pathname, ACE_TEXT (" -s")); - int ret = -1; - if (opts.service_command() == Activator_Options::SC_INSTALL) - { - const char* DEPENDS_ON = "TAOImR"; // Must match Locator_NT_Service.h - - ret = SERVICE::instance ()->insert (SERVICE_DEMAND_START, - SERVICE_ERROR_NORMAL, - pathname, - 0, // group - 0, // tag - DEPENDS_ON - ); - } else - { - ret = SERVICE::instance ()->insert (SERVICE_DEMAND_START, - SERVICE_ERROR_NORMAL, - pathname); - } - if (ret != -1) { - ACE_DEBUG ((LM_DEBUG, "ImR Activator: Service installed.\n")); - opts.save_registry_options(); - } else { - ACE_ERROR((LM_ERROR, "Error: Failed to install service.\n")); - } + { + ACE_ERROR ((LM_ERROR, "Error: Failed to install service.\n")); + } if (ret == 0) return 1; } - else if (opts.service_command() == Activator_Options::SC_REMOVE) + else if (opts.service_command () == Activator_Options::SC_REMOVE) { int ret = SERVICE::instance ()->remove (); ACE_DEBUG ((LM_DEBUG, "ImR Activator: Service removed.\n")); @@ -174,11 +177,11 @@ run_service_command (Activator_Options& opts) return 1; // If successfull, then we don't want to continue. } else - { - ACE_ERROR ((LM_ERROR, "Error: Unknown service command :%d \n", - opts.service_command())); - return -1; - } + { + ACE_ERROR ((LM_ERROR, "Error: Unknown service command :%d \n", + opts.service_command ())); + return -1; + } return -1; @@ -199,14 +202,14 @@ main (int argc, char *argv[]) else if (result > 0) return 0; // No error, but we should exit anyway. - result = run_service_command(opts); + result = run_service_command (opts); if (result < 0) return 1; // Error else if (result > 0) return 0; // No error, but we should exit anyway. - if (opts.service()) - return run_service(); + if (opts.service ()) + return run_service (); return run_standalone (opts); } diff --git a/TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.cpp b/TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.cpp index 2e2604c5d85..85de6cc0b6d 100644 --- a/TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.cpp @@ -12,7 +12,7 @@ #include "ace/OS_NS_stdio.h" #include "ace/os_include/os_netdb.h" -static ACE_CString getHostName() +static ACE_CString getHostName () { char host_name[MAXHOSTNAMELEN]; ACE_OS::hostname (host_name, MAXHOSTNAMELEN); @@ -23,172 +23,172 @@ ImR_Activator_i::ImR_Activator_i (void) : registration_token_(0) , debug_(0) , notify_imr_ (false) -, name_(getHostName()) +, name_ (getHostName ()) { } static PortableServer::POA_ptr -createPersistentPOA(PortableServer::POA_ptr root_poa, const char* poa_name ACE_ENV_ARG_DECL) { - +createPersistentPOA (PortableServer::POA_ptr root_poa, const char* poa_name ACE_ENV_ARG_DECL) +{ PortableServer::LifespanPolicy_var life = - root_poa->create_lifespan_policy(PortableServer::PERSISTENT ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN(PortableServer::POA::_nil()); + root_poa->create_lifespan_policy (PortableServer::PERSISTENT ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (PortableServer::POA::_nil ()); PortableServer::IdAssignmentPolicy_var assign = - root_poa->create_id_assignment_policy(PortableServer::USER_ID ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN(PortableServer::POA::_nil()); + root_poa->create_id_assignment_policy (PortableServer::USER_ID ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (PortableServer::POA::_nil ()); CORBA::PolicyList pols; - pols.length(2); - pols[0] = PortableServer::LifespanPolicy::_duplicate(life.in()); - pols[1] = PortableServer::IdAssignmentPolicy::_duplicate(assign.in()); + pols.length (2); + pols[0] = PortableServer::LifespanPolicy::_duplicate (life.in ()); + pols[1] = PortableServer::IdAssignmentPolicy::_duplicate (assign.in ()); - PortableServer::POAManager_var mgr = root_poa->the_POAManager(); + PortableServer::POAManager_var mgr = root_poa->the_POAManager (); PortableServer::POA_var poa = - root_poa->create_POA(poa_name, mgr.in(), pols ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN(PortableServer::POA::_nil()); + root_poa->create_POA(poa_name, mgr.in (), pols ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN(PortableServer::POA::_nil ()); - life->destroy(ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK_RETURN(PortableServer::POA::_nil()); - assign->destroy(ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK_RETURN(PortableServer::POA::_nil()); + life->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (PortableServer::POA::_nil ()); + assign->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (PortableServer::POA::_nil ()); - return poa._retn(); + return poa._retn (); } // It's ok if we can't register with the ImR. It just // means we won't be able to notify it of any events // (Currently, just that we're shutting down.) void -ImR_Activator_i::register_with_imr(ImplementationRepository::Activator_ptr activator) +ImR_Activator_i::register_with_imr (ImplementationRepository::Activator_ptr activator) { ACE_TRY_NEW_ENV - { - if (this->debug_ > 1) - ACE_DEBUG((LM_DEBUG, "ImR Activator: Contacting ImplRepoService...\n")); + { + if (this->debug_ > 1) + ACE_DEBUG( (LM_DEBUG, "ImR Activator: Contacting ImplRepoService...\n")); - // First, resolve the ImR, without this we can go no further - CORBA::Object_var obj = - orb_->resolve_initial_references ("ImplRepoService" ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + // First, resolve the ImR, without this we can go no further + CORBA::Object_var obj = + orb_->resolve_initial_references ("ImplRepoService" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; - this->process_mgr_.open (ACE_Process_Manager::DEFAULT_SIZE, - this->orb_->orb_core ()->reactor ()); + this->process_mgr_.open (ACE_Process_Manager::DEFAULT_SIZE, + this->orb_->orb_core ()->reactor ()); - locator_ = ImplementationRepository::Locator::_narrow (obj.in() ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + locator_ = ImplementationRepository::Locator::_narrow (obj.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; - this->registration_token_ = - locator_->register_activator (name_.c_str(), activator ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + this->registration_token_ = + locator_->register_activator (name_.c_str (), activator ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; - if (debug_ > 0) - ACE_DEBUG((LM_DEBUG, "ImR Activator: Registered with ImR.\n")); + if (debug_ > 0) + ACE_DEBUG((LM_DEBUG, "ImR Activator: Registered with ImR.\n")); - return; - } + return; + } ACE_CATCHANY - { - if (debug_ > 1) - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "ImR Activator: Can't register with ImR."); - } + { + if (debug_ > 1) + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "ImR Activator: Can't register with ImR."); + } ACE_ENDTRY; if (debug_ > 0) - ACE_DEBUG((LM_DEBUG, "ImR Activator: Not registered with ImR.\n")); + ACE_DEBUG ((LM_DEBUG, "ImR Activator: Not registered with ImR.\n")); } int -ImR_Activator_i::init_with_orb(CORBA::ORB_ptr orb, const Activator_Options& opts ACE_ENV_ARG_DECL) +ImR_Activator_i::init_with_orb (CORBA::ORB_ptr orb, const Activator_Options& opts ACE_ENV_ARG_DECL) { - ACE_ASSERT(! CORBA::is_nil(orb)); - orb_ = CORBA::ORB::_duplicate(orb); - debug_ = opts.debug(); - notify_imr_ = opts.notify_imr(); - if (opts.name().length() > 0) - { - name_ = opts.name(); - } - - ACE_TRY - { - CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA" ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - ACE_ASSERT(! CORBA::is_nil(obj.in())); - this->root_poa_ = PortableServer::POA::_narrow (obj.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - ACE_ASSERT(! CORBA::is_nil(this->root_poa_.in())); - - // The activator must use a persistent POA so that it can be started before the - // locator in some scenarios, such as when the locator persists its database, and - // wants to reconnect to running activators to auto_start some servers. - this->imr_poa_ = createPersistentPOA(this->root_poa_.in(), - "ImR_Activator" ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - ACE_ASSERT(! CORBA::is_nil(this->imr_poa_.in())); - - // Activate ourself - PortableServer::ObjectId_var id = PortableServer::string_to_ObjectId ("ImR_Activator"); - this->imr_poa_->activate_object_with_id(id.in(), this ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - obj = this->imr_poa_->id_to_reference (id.in() ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - ImplementationRepository::Activator_var activator = - ImplementationRepository::Activator::_narrow(obj.in() ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - ACE_ASSERT(! CORBA::is_nil(activator.in())); - - CORBA::String_var ior = this->orb_->object_to_string(activator.in() ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (this->debug_ > 0) - ACE_DEBUG((LM_DEBUG, "ImR Activator: Starting %s\n", name_.c_str())); - - // initialize our process manager. - // This requires a reactor that has signal handling. - ACE_Reactor *reactor = ACE_Reactor::instance (); - if (reactor != 0) + ACE_ASSERT(! CORBA::is_nil (orb)); + orb_ = CORBA::ORB::_duplicate (orb); + debug_ = opts.debug (); + notify_imr_ = opts.notify_imr (); + if (opts.name ().length () > 0) { - if (this->process_mgr_.open (ACE_Process_Manager::DEFAULT_SIZE, reactor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "The ACE_Process_Manager didnt get initialized\n"), -1); - } + name_ = opts.name(); } - this->register_with_imr(activator.in()); // no throw - - PortableServer::POAManager_var poaman = - this->root_poa_->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - poaman->activate (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (this->debug_ > 1) + ACE_TRY { - ACE_DEBUG ((LM_DEBUG, - "ImR Activator: The Activator IOR is: <%s>\n", ior.in ())); + CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + ACE_ASSERT (! CORBA::is_nil (obj.in ())); + this->root_poa_ = PortableServer::POA::_narrow (obj.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + ACE_ASSERT (! CORBA::is_nil(this->root_poa_.in ())); + + // The activator must use a persistent POA so that it can be started before the + // locator in some scenarios, such as when the locator persists its database, and + // wants to reconnect to running activators to auto_start some servers. + this->imr_poa_ = createPersistentPOA (this->root_poa_.in (), + "ImR_Activator" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + ACE_ASSERT (! CORBA::is_nil(this->imr_poa_.in ())); + + // Activate ourself + PortableServer::ObjectId_var id = PortableServer::string_to_ObjectId ("ImR_Activator"); + this->imr_poa_->activate_object_with_id (id.in (), this ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + obj = this->imr_poa_->id_to_reference (id.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + ImplementationRepository::Activator_var activator = + ImplementationRepository::Activator::_narrow (obj.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + ACE_ASSERT(! CORBA::is_nil (activator.in ())); + + CORBA::String_var ior = this->orb_->object_to_string (activator.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (this->debug_ > 0) + ACE_DEBUG((LM_DEBUG, "ImR Activator: Starting %s\n", name_.c_str ())); + + // initialize our process manager. + // This requires a reactor that has signal handling. + ACE_Reactor *reactor = ACE_Reactor::instance (); + if (reactor != 0) + { + if (this->process_mgr_.open (ACE_Process_Manager::DEFAULT_SIZE, reactor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "The ACE_Process_Manager didnt get initialized\n"), -1); + } + } + + this->register_with_imr (activator.in ()); // no throw + + PortableServer::POAManager_var poaman = + this->root_poa_->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + poaman->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (this->debug_ > 1) + { + ACE_DEBUG ((LM_DEBUG, + "ImR Activator: The Activator IOR is: <%s>\n", ior.in ())); + } + + // The last thing we do is write out the ior so that a test program can assume + // that the activator is ready to go as soon as the ior is written. + if (opts.ior_filename ().length () > 0) + { + FILE* fp = ACE_OS::fopen (opts.ior_filename ().c_str (), "w"); + if (fp == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "ImR Activator: Could not open file: %s\n", opts.ior_filename ().c_str ()), -1); + } + ACE_OS::fprintf (fp, "%s", ior.in ()); + ACE_OS::fclose (fp); + } } - - // The last thing we do is write out the ior so that a test program can assume - // that the activator is ready to go as soon as the ior is written. - if (opts.ior_filename().length() > 0) + ACE_CATCHANY { - FILE* fp = ACE_OS::fopen(opts.ior_filename().c_str(), "w"); - if (fp == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "ImR Activator: Could not open file: %s\n", opts.ior_filename().c_str()), -1); - } - ACE_OS::fprintf(fp, "%s", ior.in()); - ACE_OS::fclose(fp); + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "ImR_Activator_i::init_with_orb"); + ACE_RE_THROW; } - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "ImR_Activator_i::init_with_orb"); - ACE_RE_THROW; - } ACE_ENDTRY; ACE_CHECK_RETURN (-1); return 0; @@ -201,14 +201,14 @@ ImR_Activator_i::init (Activator_Options& opts ACE_ENV_ARG_DECL) // Must use IOR style objrefs, because URLs sometimes get mangled when passed // to ACE_Process::spawn(). cmdline += "-ORBUseImR 0 -ORBObjRefStyle IOR "; - ACE_ARGV av(cmdline.c_str()); - int argc = av.argc(); + ACE_ARGV av (cmdline.c_str ()); + int argc = av.argc (); CORBA::ORB_var orb = - CORBA::ORB_init(argc, av.argv(), "TAO_ImR_Activator" ACE_ENV_ARG_PARAMETER); + CORBA::ORB_init (argc, av.argv (), "TAO_ImR_Activator" ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN(-1); - int ret = this->init_with_orb(orb.in(), opts ACE_ENV_ARG_PARAMETER); + int ret = this->init_with_orb(orb.in (), opts ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN(-1); return ret; @@ -217,54 +217,54 @@ ImR_Activator_i::init (Activator_Options& opts ACE_ENV_ARG_DECL) int ImR_Activator_i::fini (ACE_ENV_SINGLE_ARG_DECL) { - ACE_TRY_EX(try_block_1) - { - if (debug_ > 1) - ACE_DEBUG((LM_DEBUG, "ImR Activator: Shutting down...\n")); + ACE_TRY_EX (try_block_1) + { + if (debug_ > 1) + ACE_DEBUG ((LM_DEBUG, "ImR Activator: Shutting down...\n")); - this->process_mgr_.close(); + this->process_mgr_.close (); - this->root_poa_->destroy (1, 1 ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX(try_block_1); + this->root_poa_->destroy (1, 1 ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK_EX (try_block_1); - if (! CORBA::is_nil(this->locator_.in()) && this->registration_token_ != 0) - { - this->locator_->unregister_activator (name_.c_str(), - this->registration_token_ ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX(try_block_1); + if (! CORBA::is_nil (this->locator_.in ()) && this->registration_token_ != 0) + { + this->locator_->unregister_activator (name_.c_str(), + this->registration_token_ ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK_EX (try_block_1); + } } - } ACE_CATCH(CORBA::COMM_FAILURE, ex) - { - if (debug_ > 1) - ACE_DEBUG((LM_DEBUG, "ImR Activator: Unable to unregister from ImR.\n")); - } + { + if (debug_ > 1) + ACE_DEBUG ((LM_DEBUG, "ImR Activator: Unable to unregister from ImR.\n")); + } ACE_CATCH(CORBA::TRANSIENT, ex) - { - if (debug_ > 1) - ACE_DEBUG((LM_DEBUG, "ImR Activator: Unable to unregister from ImR.\n")); - } + { + if (debug_ > 1) + ACE_DEBUG ((LM_DEBUG, "ImR Activator: Unable to unregister from ImR.\n")); + } ACE_CATCHANY { ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "ImR Activator: fini"); - ACE_RE_THROW_EX(try_block_1); + ACE_RE_THROW_EX (try_block_1); } ACE_ENDTRY; ACE_CHECK_RETURN (-1); - ACE_TRY_EX(try_block_2) - { - this->orb_->destroy(ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK_EX(try_block_2); + ACE_TRY_EX (try_block_2) + { + this->orb_->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK_EX (try_block_2); - if (debug_ > 0) - ACE_DEBUG((LM_DEBUG, "ImR Activator: Shut down successfully.\n")); - } + if (debug_ > 0) + ACE_DEBUG ((LM_DEBUG, "ImR Activator: Shut down successfully.\n")); + } ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "ImR Activator: fini 2"); - ACE_RE_THROW_EX(try_block_2); - } + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "ImR Activator: fini 2"); + ACE_RE_THROW_EX (try_block_2); + } ACE_ENDTRY; ACE_CHECK_RETURN (-1); return 0; @@ -273,7 +273,7 @@ ImR_Activator_i::fini (ACE_ENV_SINGLE_ARG_DECL) int ImR_Activator_i::run (ACE_ENV_SINGLE_ARG_DECL) { - this->orb_->run(ACE_ENV_SINGLE_ARG_PARAMETER); + this->orb_->run (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (-1); return 0; } @@ -282,13 +282,13 @@ void ImR_Activator_i::shutdown (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { - shutdown(false ACE_ENV_ARG_PARAMETER); + shutdown (false ACE_ENV_ARG_PARAMETER); } void ImR_Activator_i::shutdown (bool wait_for_completion ACE_ENV_ARG_DECL) { - this->orb_->shutdown(wait_for_completion ACE_ENV_ARG_PARAMETER); + this->orb_->shutdown (wait_for_completion ACE_ENV_ARG_PARAMETER); } void @@ -312,47 +312,48 @@ ImR_Activator_i::start_server(const char* name, // handles. This includes stdin, stdout, logs, etc. proc_opts.handle_inheritence (0); - proc_opts.setenv("TAO_USE_IMR", "1"); + proc_opts.setenv ("TAO_USE_IMR", "1"); if (!CORBA::is_nil (this->locator_.in ())) - { - CORBA::String_var ior = orb_->object_to_string(locator_.in()); - proc_opts.setenv("ImplRepoServiceIOR", ior.in()); - } + { + CORBA::String_var ior = orb_->object_to_string (locator_.in ()); + proc_opts.setenv ("ImplRepoServiceIOR", ior.in()); + } - for (CORBA::ULong i = 0; i < env.length(); ++i) { - proc_opts.setenv (env[i].name.in(), env[i].value.in()); - } + for (CORBA::ULong i = 0; i < env.length (); ++i) + { + proc_opts.setenv (env[i].name.in (), env[i].value.in ()); + } int pid = this->process_mgr_.spawn (proc_opts); if (pid == ACE_INVALID_PID) - { - ACE_ERROR ((LM_ERROR, - "ImR Activator: Cannot start server <%s> using <%s>\n", name, cmdline)); + { + ACE_ERROR ((LM_ERROR, + "ImR Activator: Cannot start server <%s> using <%s>\n", name, cmdline)); - ACE_THROW(ImplementationRepository::CannotActivate(CORBA::string_dup ("Process Creation Failed"))); - return; - } + ACE_THROW(ImplementationRepository::CannotActivate(CORBA::string_dup ("Process Creation Failed"))); + return; + } else - { - if (debug_ > 1) { - ACE_DEBUG((LM_DEBUG, - "ImR Activator: register death handler for process %d\n", pid)); + if (debug_ > 1) + { + ACE_DEBUG((LM_DEBUG, + "ImR Activator: register death handler for process %d\n", pid)); + } + this->process_mgr_.register_handler (this, pid); + + // We only bind to the process_map_ if we want to notify + // the locator of a process' death. + if (notify_imr_) + { + this->process_map_.rebind (pid, name); + } } - this->process_mgr_.register_handler (this, pid); - // We only bind to the process_map_ if we want to notify - // the locator of a process' death. - if (notify_imr_) + if (debug_ > 0) { - this->process_map_.rebind (pid, name); + ACE_DEBUG ((LM_DEBUG, "ImR Activator: Successfully started <%s>. \n", name)); } - } - - if (debug_ > 0) - { - ACE_DEBUG((LM_DEBUG, "ImR Activator: Successfully started <%s>. \n", name)); - } } int @@ -363,29 +364,29 @@ ImR_Activator_i::handle_exit (ACE_Process * process) // when this happens. if (debug_ > 0) - { - ACE_DEBUG - ((LM_DEBUG, - ACE_TEXT ("Process %d exited with exit code %d\n"), - process->getpid (), process->return_value ())); - } + { + ACE_DEBUG + ((LM_DEBUG, + ACE_TEXT ("Process %d exited with exit code %d\n"), + process->getpid (), process->return_value ())); + } ACE_CString name; if (this->process_map_.find (process->getpid (), name) == 0) - { - this->process_map_.unbind (process->getpid ()); - - if (!CORBA::is_nil (this->locator_.in ())) { - if (debug_ > 1) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("ImR Activator: Notifying ImR that %s has exited.\n"), - name.c_str())); - } - this->locator_->notify_child_death(name.c_str()); + this->process_map_.unbind (process->getpid ()); + + if (!CORBA::is_nil (this->locator_.in ())) + { + if (debug_ > 1) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("ImR Activator: Notifying ImR that %s has exited.\n"), + name.c_str())); + } + this->locator_->notify_child_death (name.c_str()); + } } - } return 0; } diff --git a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator.cpp b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator.cpp index b8d88642125..12be58dd8cd 100644 --- a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator.cpp @@ -8,7 +8,7 @@ class ImR_Locator_Shutdown : public Shutdown_Functor { public: - ImR_Locator_Shutdown(ImR_Locator_i& imr); + ImR_Locator_Shutdown (ImR_Locator_i& imr); void operator() (int which_signal); private: @@ -21,18 +21,18 @@ ImR_Locator_Shutdown::ImR_Locator_Shutdown (ImR_Locator_i &imr) } void -ImR_Locator_Shutdown::operator() (int /*which_signal*/) +ImR_Locator_Shutdown::operator () (int /*which_signal*/) { ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY - { - this->imr_.shutdown(true ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } + { + this->imr_.shutdown (true ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "ImR: "); - } + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "ImR: "); + } ACE_ENDTRY; } @@ -116,18 +116,18 @@ run_service (void) static int run_service_command (Options& opts) { - if (opts.service_command() == Options::SC_NONE) + if (opts.service_command () == Options::SC_NONE) return 0; #if defined (ACE_WIN32) SERVICE::instance()->name (IMR_LOCATOR_SERVICE_NAME, IMR_LOCATOR_DISPLAY_NAME); - if (opts.service_command() == Options::SC_INSTALL) + if (opts.service_command () == Options::SC_INSTALL) { const DWORD MAX_PATH_LENGTH = 4096; char pathname[MAX_PATH_LENGTH]; - DWORD length = ACE_TEXT_GetModuleFileName(NULL, pathname, MAX_PATH_LENGTH); + DWORD length = ACE_TEXT_GetModuleFileName (NULL, pathname, MAX_PATH_LENGTH); if (length == 0 || length >= MAX_PATH_LENGTH - sizeof(" -s")) { ACE_ERROR ((LM_ERROR, "Error: Could not get module file name\n")); @@ -140,16 +140,19 @@ run_service_command (Options& opts) int ret = SERVICE::instance ()->insert (SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, pathname); - if (ret != -1) { - ACE_DEBUG ((LM_DEBUG, "ImR: Service installed.\n")); - opts.save_registry_options(); - } else { - ACE_ERROR((LM_ERROR, "Error: Failed to install service. error:%d\n", errno)); - } + if (ret != -1) + { + ACE_DEBUG ((LM_DEBUG, "ImR: Service installed.\n")); + opts.save_registry_options (); + } + else + { + ACE_ERROR ((LM_ERROR, "Error: Failed to install service. error:%d\n", errno)); + } if (ret == 0) return 1; } - else if (opts.service_command() == Options::SC_REMOVE) + else if (opts.service_command () == Options::SC_REMOVE) { int ret = SERVICE::instance ()->remove (); ACE_DEBUG ((LM_DEBUG, "ImR: Service removed.\n")); @@ -157,11 +160,11 @@ run_service_command (Options& opts) return 1; // If successfull, then we don't want to continue. } else - { - ACE_ERROR ((LM_ERROR, "Error: Unknown service command :%d \n", - opts.service_command())); - return -1; - } + { + ACE_ERROR ((LM_ERROR, "Error: Unknown service command :%d \n", + opts.service_command ())); + return -1; + } return -1; @@ -188,7 +191,7 @@ main (int argc, char *argv[]) else if (result > 0) return 0; // No error, but we should exit anyway. - if (opts.service()) + if (opts.service ()) { return run_service (); } diff --git a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator.idl b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator.idl index 3fced0b1150..acae98bb07f 100644 --- a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator.idl +++ b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator.idl @@ -10,7 +10,7 @@ module ImplementationRepository { // returns a token that can be used (along with activator name) to unregister the activator. long register_activator (in string name, in Activator act); - + // You must pass in the token returned from register_activator. void unregister_activator (in string name, in long token); diff --git a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp index 6cbd3f40f5a..4c0564f0886 100644 --- a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp @@ -1339,7 +1339,8 @@ ImR_Locator_i::connect_server (Server_Info& info) bool ImR_Locator_i::is_alive (Server_Info& info) { - size_t table_size = sizeof (PING_RETRY_SCHEDULE) / sizeof (*PING_RETRY_SCHEDULE); + const size_t table_size = sizeof (PING_RETRY_SCHEDULE) / + sizeof (*PING_RETRY_SCHEDULE); for (size_t i = 0; i < table_size; ++i) { diff --git a/TAO/orbsvcs/ImplRepo_Service/Iterator.cpp b/TAO/orbsvcs/ImplRepo_Service/Iterator.cpp index 4afae0cfc76..1ed369991c2 100644 --- a/TAO/orbsvcs/ImplRepo_Service/Iterator.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/Iterator.cpp @@ -30,49 +30,49 @@ ImR_Iterator::next_n (CORBA::ULong how_many, ImplementationRepository::ServerInformationList(0), CORBA::NO_MEMORY()); Locator_Repository::SIMap::ENTRY* entry = 0; - Locator_Repository::SIMap::ITERATOR it(this->repo_.servers()); + Locator_Repository::SIMap::ITERATOR it (this->repo_.servers ()); // Number of servers that will go into the server_list. CORBA::ULong n = this->repo_.servers().current_size(); if (n <= this->count_) - { - return 0; // We already finished. - } + { + return 0; // We already finished. + } else - { - n -= this->count_; - } + { + n -= this->count_; + } if (how_many > 0 && n > how_many) - { - n = how_many; + { + n = how_many; } - server_list->length(n); + server_list->length (n); CORBA::ULong i = 0; for (; i < this->count_; ++i) - { - it.advance(); - } + { + it.advance (); + } for (i = 0; i < n; ++i) - { - it.next(entry); - it.advance(); - ACE_ASSERT(entry != 0); - - Server_Info_Ptr info = entry->int_id_; - - server_list[i].server = info->name.c_str(); - server_list[i].startup.command_line = info->cmdline.c_str(); - server_list[i].startup.environment = info->env_vars; - server_list[i].startup.working_directory = info->dir.c_str(); - server_list[i].startup.activation = info->activation_mode; - server_list[i].startup.activator = info->activator.c_str(); - server_list[i].startup.start_limit = info->start_limit; - server_list[i].partial_ior = info->partial_ior.c_str(); - } + { + it.next (entry); + it.advance (); + ACE_ASSERT(entry != 0); + + Server_Info_Ptr info = entry->int_id_; + + server_list[i].server = info->name.c_str (); + server_list[i].startup.command_line = info->cmdline.c_str (); + server_list[i].startup.environment = info->env_vars; + server_list[i].startup.working_directory = info->dir.c_str (); + server_list[i].startup.activation = info->activation_mode; + server_list[i].startup.activator = info->activator.c_str (); + server_list[i].startup.start_limit = info->start_limit; + server_list[i].partial_ior = info->partial_ior.c_str (); + } this->count_ += n; @@ -84,7 +84,7 @@ void ImR_Iterator::destroy (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { - PortableServer::ObjectId_var oid = poa_->servant_to_id(this ACE_ENV_ARG_PARAMETER); + PortableServer::ObjectId_var oid = poa_->servant_to_id (this ACE_ENV_ARG_PARAMETER); ACE_CHECK; poa_->deactivate_object (oid.in() ACE_ENV_ARG_PARAMETER); ACE_CHECK; diff --git a/TAO/orbsvcs/ImplRepo_Service/Locator_Loader.cpp b/TAO/orbsvcs/ImplRepo_Service/Locator_Loader.cpp index 9811c2be488..42b58195655 100644 --- a/TAO/orbsvcs/ImplRepo_Service/Locator_Loader.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/Locator_Loader.cpp @@ -4,23 +4,24 @@ #include "ace/Dynamic_Service.h" #include "ace/Task.h" -class ImR_Locator_ORB_Runner : public ACE_Task_Base +class ImR_Locator_ORB_Runner : public ACE_Task_Base { - ImR_Locator_Loader& service_; public: - ImR_Locator_ORB_Runner(ImR_Locator_Loader& service) - : service_(service) + ImR_Locator_ORB_Runner (ImR_Locator_Loader& service) + : service_ (service) { } - virtual int svc() + virtual int svc () { - // Block until service_.fini() calls orb->destroy() - this->service_.run(); + // Block until service_.fini () calls orb->destroy () + this->service_.run (); return 0; } +private: + ImR_Locator_Loader& service_; }; -ImR_Locator_Loader::ImR_Locator_Loader() +ImR_Locator_Loader::ImR_Locator_Loader() { } @@ -30,19 +31,19 @@ ImR_Locator_Loader::init (int argc, ACE_TCHAR *argv[]) ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY { - int err = this->opts_.init(argc, argv); - if (err != 0) + int err = this->opts_.init (argc, argv); + if (err != 0) return -1; - err = this->service_.init(this->opts_ ACE_ENV_ARG_PARAMETER); + err = this->service_.init (this->opts_ ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; if (err != 0) return -1; // Create a thread in which to run the service - ACE_ASSERT(this->runner_.get() == 0); - this->runner_.reset(new ImR_Locator_ORB_Runner(*this)); - this->runner_->activate(); + ACE_ASSERT(this->runner_.get () == 0); + this->runner_.reset(new ImR_Locator_ORB_Runner (*this)); + this->runner_->activate (); } ACE_CATCHANY { @@ -55,20 +56,20 @@ ImR_Locator_Loader::init (int argc, ACE_TCHAR *argv[]) int ImR_Locator_Loader::fini (void) { - ACE_ASSERT(this->runner_.get() != 0); + ACE_ASSERT(this->runner_.get () != 0); ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY - { - int ret = this->service_.fini(ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + { + int ret = this->service_.fini (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; - this->runner_->wait(); - this->runner_.reset(0); - return ret; - } + this->runner_->wait (); + this->runner_.reset (0); + return ret; + } ACE_CATCHANY - { - } + { + } ACE_ENDTRY; return -1; } @@ -80,7 +81,7 @@ ImR_Locator_Loader::create_object (CORBA::ORB_ptr, ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) { - ACE_THROW_RETURN(CORBA::NO_IMPLEMENT(), CORBA::Object::_nil()); + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT(), CORBA::Object::_nil ()); } int @@ -88,15 +89,15 @@ ImR_Locator_Loader::run(void) { ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY - { - return this->service_.run(ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - } + { + return this->service_.run (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } ACE_CATCHALL - { - ACE_ERROR((LM_ERROR, "Exception in ImR_Locator_ORB_Runner()\n")); - return -1; - } + { + ACE_ERROR((LM_ERROR, "Exception in ImR_Locator_ORB_Runner ()\n")); + return -1; + } ACE_ENDTRY; return 0; } diff --git a/TAO/orbsvcs/ImplRepo_Service/Locator_Loader.h b/TAO/orbsvcs/ImplRepo_Service/Locator_Loader.h index 67e1ce8c294..ca90c61c6fb 100644 --- a/TAO/orbsvcs/ImplRepo_Service/Locator_Loader.h +++ b/TAO/orbsvcs/ImplRepo_Service/Locator_Loader.h @@ -32,7 +32,7 @@ public: ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)); - // Unlike other service objects, we have our own orb. + // Unlike other service objects, we have our own orb. int run(void); private: diff --git a/TAO/orbsvcs/ImplRepo_Service/Locator_NT_Service.cpp b/TAO/orbsvcs/ImplRepo_Service/Locator_NT_Service.cpp index 8cc1728b610..e13a4f8080f 100644 --- a/TAO/orbsvcs/ImplRepo_Service/Locator_NT_Service.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/Locator_NT_Service.cpp @@ -62,11 +62,11 @@ Locator_NT_Service::svc (void) ImR_Locator_i server; Options opts; - if (opts.init_from_registry() != 0) - { - report_status (SERVICE_STOPPED); - return -1; - } + if (opts.init_from_registry () != 0) + { + report_status (SERVICE_STOPPED); + return -1; + } ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY diff --git a/TAO/orbsvcs/ImplRepo_Service/Locator_Options.cpp b/TAO/orbsvcs/ImplRepo_Service/Locator_Options.cpp index 152d21939ae..810649d2bb5 100644 --- a/TAO/orbsvcs/ImplRepo_Service/Locator_Options.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/Locator_Options.cpp @@ -62,20 +62,20 @@ Options::parse_args (int &argc, char *argv[]) if (ACE_OS::strcasecmp (shifter.get_current (), ACE_TEXT ("install")) == 0) - { - this->service_command_ = SC_INSTALL; - } + { + this->service_command_ = SC_INSTALL; + } else if (ACE_OS::strcasecmp (shifter.get_current (), ACE_TEXT ("remove")) == 0) - { - this->service_command_ = SC_REMOVE; - } + { + this->service_command_ = SC_REMOVE; + } else - { - ACE_ERROR((LM_ERROR, "Error: Unknown service command : %s\n", shifter.get_current())); - this->print_usage (); - return -1; - } + { + ACE_ERROR((LM_ERROR, "Error: Unknown service command : %s\n", shifter.get_current())); + this->print_usage (); + return -1; + } } else if (ACE_OS::strcasecmp (shifter.get_current (), ACE_TEXT ("-d")) == 0) @@ -215,21 +215,21 @@ Options::init (int argc, char *argv[]) // This may also run the commands to install or remove the nt service. int result = this->parse_args (argc, argv); if (result != 0) - { - return result; - } + { + return result; + } for (int i = 0; i < argc; ++i) - { - this->cmdline_ += ACE_CString(argv[i]) + ACE_CString(" "); - } + { + this->cmdline_ += ACE_CString (argv[i]) + ACE_CString (" "); + } return 0; } int Options::init_from_registry (void) { - this->load_registry_options(); + this->load_registry_options (); return 0; } @@ -256,7 +256,7 @@ Options::print_usage (void) const } int -Options::save_registry_options() +Options::save_registry_options () { #if defined (ACE_WIN32) HKEY key = 0; @@ -271,52 +271,53 @@ Options::save_registry_options() &key, NULL ); - if (err != ERROR_SUCCESS) { - return -1; - } - err = ACE_TEXT_RegSetValueEx(key, "ORBInitOptions", 0, REG_SZ, - (LPBYTE) this->cmdline_.c_str(), this->cmdline_.length() + 1); - ACE_ASSERT(err == ERROR_SUCCESS); + if (err != ERROR_SUCCESS) + { + return -1; + } + err = ACE_TEXT_RegSetValueEx (key, "ORBInitOptions", 0, REG_SZ, + (LPBYTE) this->cmdline_.c_str (), this->cmdline_.length () + 1); + ACE_ASSERT (err == ERROR_SUCCESS); - err = ACE_TEXT_RegSetValueEx(key, "IORFile", 0, REG_SZ, - (LPBYTE) ior_output_file_.c_str(), ior_output_file_.length() + 1); - ACE_ASSERT(err == ERROR_SUCCESS); + err = ACE_TEXT_RegSetValueEx (key, "IORFile", 0, REG_SZ, + (LPBYTE) ior_output_file_.c_str (), ior_output_file_.length () + 1); + ACE_ASSERT (err == ERROR_SUCCESS); - err = ACE_TEXT_RegSetValueEx(key, "DebugLevel", 0, REG_DWORD, - (LPBYTE) &debug_ , sizeof(debug_)); + err = ACE_TEXT_RegSetValueEx (key, "DebugLevel", 0, REG_DWORD, + (LPBYTE) &debug_ , sizeof (debug_)); ACE_ASSERT(err == ERROR_SUCCESS); - err = ACE_TEXT_RegSetValueEx(key, "PersistFile", 0, REG_SZ, - (LPBYTE) this->persist_file_name_.c_str(), this->persist_file_name_.length() + 1); - ACE_ASSERT(err == ERROR_SUCCESS); + err = ACE_TEXT_RegSetValueEx (key, "PersistFile", 0, REG_SZ, + (LPBYTE) this->persist_file_name_.c_str (), this->persist_file_name_.length () + 1); + ACE_ASSERT (err == ERROR_SUCCESS); - DWORD tmp = this->ping_interval_.msec(); - err = ACE_TEXT_RegSetValueEx(key, "PingInterval", 0, REG_DWORD, - (LPBYTE) &tmp, sizeof(DWORD)); - ACE_ASSERT(err == ERROR_SUCCESS); + DWORD tmp = this->ping_interval_.msec (); + err = ACE_TEXT_RegSetValueEx (key, "PingInterval", 0, REG_DWORD, + (LPBYTE) &tmp, sizeof (DWORD)); + ACE_ASSERT (err == ERROR_SUCCESS); tmp = this->readonly_ ? 1 : 0; - err = ACE_TEXT_RegSetValueEx(key, "Lock", 0, REG_DWORD, - (LPBYTE) &tmp, sizeof(DWORD)); - ACE_ASSERT(err == ERROR_SUCCESS); + err = ACE_TEXT_RegSetValueEx (key, "Lock", 0, REG_DWORD, + (LPBYTE) &tmp, sizeof (DWORD)); + ACE_ASSERT (err == ERROR_SUCCESS); tmp = this->repo_mode_; - err = ACE_TEXT_RegSetValueEx(key, "PersistType", 0, REG_DWORD, - (LPBYTE) &tmp, sizeof(DWORD)); - ACE_ASSERT(err == ERROR_SUCCESS); + err = ACE_TEXT_RegSetValueEx (key, "PersistType", 0, REG_DWORD, + (LPBYTE) &tmp, sizeof (DWORD)); + ACE_ASSERT (err == ERROR_SUCCESS); tmp = this->startup_timeout_.sec(); - err = ACE_TEXT_RegSetValueEx(key, "Timeout", 0, REG_DWORD, - (LPBYTE) &tmp, sizeof(DWORD)); - ACE_ASSERT(err == ERROR_SUCCESS); + err = ACE_TEXT_RegSetValueEx (key, "Timeout", 0, REG_DWORD, + (LPBYTE) &tmp, sizeof (DWORD)); + ACE_ASSERT (err == ERROR_SUCCESS); tmp = multicast_ ? 1 : 0; - err = ACE_TEXT_RegSetValueEx(key, "Multicast", 0, REG_DWORD, - (LPBYTE) &tmp, sizeof(DWORD)); - ACE_ASSERT(err == ERROR_SUCCESS); + err = ACE_TEXT_RegSetValueEx (key, "Multicast", 0, REG_DWORD, + (LPBYTE) &tmp, sizeof (DWORD)); + ACE_ASSERT (err == ERROR_SUCCESS); - err = ::RegCloseKey(key); - ACE_ASSERT(err == ERROR_SUCCESS); + err = ::RegCloseKey (key); + ACE_ASSERT (err == ERROR_SUCCESS); #endif return 0; } @@ -333,91 +334,101 @@ Options::load_registry_options () KEY_READ, &key ); - if (err != ERROR_SUCCESS) { - // If there aren't any saved parameters, then that's ok. - return 0; - } + if (err != ERROR_SUCCESS) + { + // If there aren't any saved parameters, then that's ok. + return 0; + } ACE_TCHAR tmpstr[4096]; - DWORD sz = sizeof(tmpstr); + DWORD sz = sizeof (tmpstr); DWORD type = 0; - err = ACE_TEXT_RegQueryValueEx(key, "ORBInitOptions", 0, &type, + err = ACE_TEXT_RegQueryValueEx (key, "ORBInitOptions", 0, &type, (LPBYTE) tmpstr, &sz); - if (err == ERROR_SUCCESS) { - ACE_ASSERT(type == REG_SZ); - tmpstr[sz - 1] = '\0'; - this->cmdline_ = tmpstr; - } + if (err == ERROR_SUCCESS) + { + ACE_ASSERT (type == REG_SZ); + tmpstr[sz - 1] = '\0'; + this->cmdline_ = tmpstr; + } sz = sizeof(tmpstr); - err = ACE_TEXT_RegQueryValueEx(key, "IORFile", 0, &type, + err = ACE_TEXT_RegQueryValueEx (key, "IORFile", 0, &type, (LPBYTE) tmpstr, &sz); - if (err == ERROR_SUCCESS) { - ACE_ASSERT(type == REG_SZ); - tmpstr[sz - 1] = '\0'; - this->ior_output_file_ = tmpstr; - } + if (err == ERROR_SUCCESS) + { + ACE_ASSERT (type == REG_SZ); + tmpstr[sz - 1] = '\0'; + this->ior_output_file_ = tmpstr; + } sz = sizeof(debug_); - err = ACE_TEXT_RegQueryValueEx(key, "DebugLevel", 0, &type, + err = ACE_TEXT_RegQueryValueEx (key, "DebugLevel", 0, &type, (LPBYTE) &this->debug_ , &sz); - if (err == ERROR_SUCCESS) { - ACE_ASSERT(type == REG_DWORD); - } + if (err == ERROR_SUCCESS) + { + ACE_ASSERT (type == REG_DWORD); + } DWORD tmp = 0; sz = sizeof(tmp); - err = ACE_TEXT_RegQueryValueEx(key, "PingInterval", 0, &type, + err = ACE_TEXT_RegQueryValueEx (key, "PingInterval", 0, &type, (LPBYTE) &tmp, &sz); - if (err == ERROR_SUCCESS) { - ACE_ASSERT(type == REG_DWORD); - ping_interval_.msec(tmp); - } + if (err == ERROR_SUCCESS) + { + ACE_ASSERT (type == REG_DWORD); + ping_interval_.msec (tmp); + } tmp = 0; sz = sizeof(tmp); - err = ACE_TEXT_RegQueryValueEx(key, "Lock", 0, &type, + err = ACE_TEXT_RegQueryValueEx (key, "Lock", 0, &type, (LPBYTE) &tmp, &sz); - if (err == ERROR_SUCCESS) { - ACE_ASSERT(type == REG_DWORD); - readonly_ = tmp != 0; - } + if (err == ERROR_SUCCESS) + { + ACE_ASSERT (type == REG_DWORD); + readonly_ = tmp != 0; + } sz = sizeof(this->repo_mode_); - err = ACE_TEXT_RegQueryValueEx(key, "PersistType", 0, &type, + err = ACE_TEXT_RegQueryValueEx (key, "PersistType", 0, &type, (LPBYTE) &this->repo_mode_, &sz); - if (err == ERROR_SUCCESS) { - ACE_ASSERT(type == REG_DWORD); - } + if (err == ERROR_SUCCESS) + { + ACE_ASSERT (type == REG_DWORD); + } tmp = 0; sz = sizeof(tmp); - err = ACE_TEXT_RegQueryValueEx(key, "Timeout", 0, &type, + err = ACE_TEXT_RegQueryValueEx (key, "Timeout", 0, &type, (LPBYTE) &tmp, &sz); - if (err == ERROR_SUCCESS) { - ACE_ASSERT(type == REG_DWORD); - this->startup_timeout_.sec(tmp); - } + if (err == ERROR_SUCCESS) + { + ACE_ASSERT (type == REG_DWORD); + this->startup_timeout_.sec (tmp); + } tmp = 0; sz = sizeof(tmp); - err = ACE_TEXT_RegQueryValueEx(key, "Multicast", 0, &type, + err = ACE_TEXT_RegQueryValueEx (key, "Multicast", 0, &type, (LPBYTE) &tmp, &sz); - if (err == ERROR_SUCCESS) { - ACE_ASSERT(type == REG_DWORD); - this->multicast_ = tmp != 0; - } + if (err == ERROR_SUCCESS) + { + ACE_ASSERT (type == REG_DWORD); + this->multicast_ = tmp != 0; + } sz = sizeof(tmpstr); - err = ACE_TEXT_RegQueryValueEx(key, "PersistFile", 0, &type, + err = ACE_TEXT_RegQueryValueEx (key, "PersistFile", 0, &type, (LPBYTE) tmpstr, &sz); - if (err == ERROR_SUCCESS) { - ACE_ASSERT(type == REG_SZ); - tmpstr[sz - 1] = '\0'; - this->persist_file_name_ = tmpstr; - } + if (err == ERROR_SUCCESS) + { + ACE_ASSERT (type == REG_SZ); + tmpstr[sz - 1] = '\0'; + this->persist_file_name_ = tmpstr; + } - err = ::RegCloseKey(key); - ACE_ASSERT(err == ERROR_SUCCESS); + err = ::RegCloseKey (key); + ACE_ASSERT (err == ERROR_SUCCESS); #endif return 0; } diff --git a/TAO/orbsvcs/ImplRepo_Service/Locator_Options.h b/TAO/orbsvcs/ImplRepo_Service/Locator_Options.h index 17f40bddcac..4d7019bccf3 100644 --- a/TAO/orbsvcs/ImplRepo_Service/Locator_Options.h +++ b/TAO/orbsvcs/ImplRepo_Service/Locator_Options.h @@ -127,7 +127,7 @@ private: /// The amount of time between successive "are you started yet?" pings. ACE_Time_Value ping_interval_; - + /// The amount of time to wait for a server to response after starting it. ACE_Time_Value startup_timeout_; diff --git a/TAO/orbsvcs/ImplRepo_Service/Locator_Repository.cpp b/TAO/orbsvcs/ImplRepo_Service/Locator_Repository.cpp index 51b2afbbd6e..ed44f22f9ad 100644 --- a/TAO/orbsvcs/ImplRepo_Service/Locator_Repository.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/Locator_Repository.cpp @@ -27,159 +27,163 @@ static const char* TOKEN = "Token"; static const char* WIN32_REG_KEY = "Software\\TAO\\ImplementationRepository"; #endif -static ACE_CString lcase(const ACE_CString& s) { +static ACE_CString lcase (const ACE_CString& s) +{ ACE_CString ret(s); - for (size_t i = 0; i < ret.length(); ++i) { - ret[i] = static_cast<char>(ACE_OS::ace_tolower(s[i])); - } + for (size_t i = 0; i < ret.length (); ++i) + { + ret[i] = static_cast<char>(ACE_OS::ace_tolower (s[i])); + } return ret; } -static void loadActivatorsAsBinary(ACE_Configuration& config, Locator_Repository::AIMap& map) +static void loadActivatorsAsBinary (ACE_Configuration& config, Locator_Repository::AIMap& map) { ACE_Configuration_Section_Key root; - int err = config.open_section(config.root_section(), ACTIVATORS_ROOT_KEY, 0, root); + int err = config.open_section (config.root_section (), ACTIVATORS_ROOT_KEY, 0, root); if (err == 0) - { - int index = 0; - ACE_CString name; - while (config.enumerate_sections (root, index, name) == 0) { - ACE_CString ior; - u_int token; + int index = 0; + ACE_CString name; + while (config.enumerate_sections (root, index, name) == 0) + { + ACE_CString ior; + u_int token; - ACE_Configuration_Section_Key key; + ACE_Configuration_Section_Key key; - // Can't fail, because we're enumerating - config.open_section(root, name.c_str(), 0, key); + // Can't fail, because we're enumerating + config.open_section (root, name.c_str(), 0, key); - config.get_string_value (key, IOR, ior); - config.get_integer_value(key, TOKEN, token); + config.get_string_value (key, IOR, ior); + config.get_integer_value (key, TOKEN, token); - Activator_Info_Ptr info(new Activator_Info(name, token, ior)); - map.bind (lcase(name), info); - index++; + Activator_Info_Ptr info (new Activator_Info (name, token, ior)); + map.bind (lcase (name), info); + index++; + } } - } } static void loadServersAsBinary(ACE_Configuration& config, Locator_Repository::SIMap& map) { ACE_Configuration_Section_Key root; - int err = config.open_section(config.root_section(), SERVERS_ROOT_KEY, 0, root); + int err = config.open_section (config.root_section (), SERVERS_ROOT_KEY, 0, root); if (err == 0) - { - int index = 0; - ACE_CString name; - while (config.enumerate_sections (root, index, name) == 0) { - ACE_CString cmdline, dir, envstr, partial_ior, ior, aname; - u_int amodeint = ImplementationRepository::MANUAL; - u_int start_limit; - - ACE_Configuration_Section_Key key; - - // Can't fail, because we're enumerating - config.open_section(root, name.c_str(), 0, key); - - // Ignore any missing values. Server name is enough on its own. - config.get_string_value (key, ACTIVATOR, aname); - config.get_string_value (key, STARTUP_COMMAND, cmdline); - config.get_string_value (key, WORKING_DIR, dir); - config.get_string_value (key, ENVIRONMENT, envstr); - config.get_integer_value(key, ACTIVATION, amodeint); - config.get_string_value (key, PARTIAL_IOR, partial_ior); - config.get_string_value (key, IOR, ior); - config.get_integer_value(key, START_LIMIT, start_limit); - - ImplementationRepository::ActivationMode amode = - static_cast <ImplementationRepository::ActivationMode> (amodeint); - - ImplementationRepository::EnvironmentList env_vars = - ImR_Utils::parseEnvList(envstr); - - Server_Info_Ptr info(new Server_Info(name, aname, cmdline, - env_vars, dir, amode, start_limit, partial_ior, ior)); - map.bind (name, info); - index++; + int index = 0; + ACE_CString name; + while (config.enumerate_sections (root, index, name) == 0) + { + ACE_CString cmdline, dir, envstr, partial_ior, ior, aname; + u_int amodeint = ImplementationRepository::MANUAL; + u_int start_limit; + + ACE_Configuration_Section_Key key; + + // Can't fail, because we're enumerating + config.open_section (root, name.c_str (), 0, key); + + // Ignore any missing values. Server name is enough on its own. + config.get_string_value (key, ACTIVATOR, aname); + config.get_string_value (key, STARTUP_COMMAND, cmdline); + config.get_string_value (key, WORKING_DIR, dir); + config.get_string_value (key, ENVIRONMENT, envstr); + config.get_integer_value(key, ACTIVATION, amodeint); + config.get_string_value (key, PARTIAL_IOR, partial_ior); + config.get_string_value (key, IOR, ior); + config.get_integer_value(key, START_LIMIT, start_limit); + + ImplementationRepository::ActivationMode amode = + static_cast <ImplementationRepository::ActivationMode> (amodeint); + + ImplementationRepository::EnvironmentList env_vars = + ImR_Utils::parseEnvList (envstr); + + Server_Info_Ptr info (new Server_Info(name, aname, cmdline, + env_vars, dir, amode, start_limit, partial_ior, ior)); + map.bind (name, info); + index++; + } } - } } -static void loadAsBinary(ACE_Configuration& config, Locator_Repository& repo) +static void loadAsBinary (ACE_Configuration& config, Locator_Repository& repo) { - loadServersAsBinary(config, repo.servers()); - loadActivatorsAsBinary(config, repo.activators()); + loadServersAsBinary (config, repo.servers ()); + loadActivatorsAsBinary (config, repo.activators ()); } // Note : There is no saveAsBinary(), because the ACE_Configuration class // supports saving of individual entries. -static void convertEnvList(const Locator_XMLHandler::EnvList& in, ImplementationRepository::EnvironmentList& out) +static void convertEnvList (const Locator_XMLHandler::EnvList& in, ImplementationRepository::EnvironmentList& out) { - CORBA::ULong sz = in.size(); - out.length(sz); + CORBA::ULong sz = in.size (); + out.length (sz); for (CORBA::ULong i = 0; i < sz; ++i) - { - out[i].name = in[i].name.c_str(); - out[i].value = in[i].value.c_str(); - } + { + out[i].name = in[i].name.c_str (); + out[i].value = in[i].value.c_str (); + } } -class Server_Repo_XML_Callback : public Locator_XMLHandler::Callback { - Locator_Repository& repo_; +class Server_Repo_XML_Callback : public Locator_XMLHandler::Callback +{ public: Server_Repo_XML_Callback(Locator_Repository& repo) - : repo_(repo) + : repo_ (repo) { } - virtual void next_server(const ACE_CString& name, + virtual void next_server (const ACE_CString& name, const ACE_CString& aname, const ACE_CString& cmdline, const Locator_XMLHandler::EnvList& envlst, const ACE_CString& dir, const ACE_CString& amodestr, int start_limit, const ACE_CString& partial_ior, const ACE_CString& ior) { ImplementationRepository::ActivationMode amode = - ImR_Utils::parseActivationMode(amodestr); + ImR_Utils::parseActivationMode (amodestr); ImplementationRepository::EnvironmentList env_vars; - convertEnvList(envlst, env_vars); + convertEnvList (envlst, env_vars); int limit = start_limit < 1 ? 1 : start_limit; - Server_Info_Ptr si(new Server_Info(name, aname, cmdline, + Server_Info_Ptr si (new Server_Info (name, aname, cmdline, env_vars, dir, amode, limit, partial_ior, ior)); - this->repo_.servers().bind(name, si); + this->repo_.servers ().bind (name, si); } virtual void next_activator (const ACE_CString& aname, long token, const ACE_CString& ior) { - Activator_Info_Ptr si(new Activator_Info(aname, token, ior)); - this->repo_.activators().bind(lcase(aname), si); + Activator_Info_Ptr si (new Activator_Info (aname, token, ior)); + this->repo_.activators ().bind (lcase (aname), si); } +private: + Locator_Repository& repo_; }; -static int loadAsXML(const ACE_CString& fname, Locator_Repository& repo) { - +static int loadAsXML (const ACE_CString& fname, Locator_Repository& repo) +{ ACEXML_FileCharStream* fstm = new ACEXML_FileCharStream; // xml input source will take ownership - if (fstm->open(fname.c_str()) != 0) - { - // This is not a real error. The xml file may not exist yet. - delete fstm; - return 0; - } + if (fstm->open (fname.c_str()) != 0) + { + // This is not a real error. The xml file may not exist yet. + delete fstm; + return 0; + } - Server_Repo_XML_Callback cb(repo); + Server_Repo_XML_Callback cb (repo); - Locator_XMLHandler handler(cb); + Locator_XMLHandler handler (cb); ACEXML_Parser parser; // InputSource takes ownership - ACEXML_InputSource input(fstm); + ACEXML_InputSource input (fstm); parser.setContentHandler (&handler); parser.setDTDHandler (&handler); @@ -187,156 +191,160 @@ static int loadAsXML(const ACE_CString& fname, Locator_Repository& repo) { parser.setEntityResolver (&handler); ACEXML_TRY_NEW_ENV - { - parser.parse (&input ACEXML_ENV_ARG_PARAMETER); - ACEXML_TRY_CHECK; - } + { + parser.parse (&input ACEXML_ENV_ARG_PARAMETER); + ACEXML_TRY_CHECK; + } ACEXML_CATCH (ACEXML_Exception, ex) - { - ACE_ERROR((LM_ERROR, "Error during load of ImR persistence xml file.")); - ex.print(); - return -1; - } + { + ACE_ERROR ((LM_ERROR, "Error during load of ImR persistence xml file.")); + ex.print (); + return -1; + } ACEXML_ENDTRY; return 0; } // Note : Would pass servers by const&, but ACE hash map const_iterator is broken. -static void saveAsXML(const ACE_CString& fname, Locator_Repository& repo) { - FILE* fp = ACE_OS::fopen (fname.c_str(), "w"); +static void saveAsXML (const ACE_CString& fname, Locator_Repository& repo) +{ + FILE* fp = ACE_OS::fopen (fname.c_str (), "w"); if (fp == 0) - { - ACE_ERROR((LM_ERROR, "Couldn't write to file %s\n", fname.c_str())); - return; - } - ACE_OS::fprintf(fp,"<?xml version=\"1.0\"?>\n"); - ACE_OS::fprintf(fp,"<%s>\n", Locator_XMLHandler::ROOT_TAG); + { + ACE_ERROR ((LM_ERROR, "Couldn't write to file %s\n", fname.c_str())); + return; + } + ACE_OS::fprintf (fp,"<?xml version=\"1.0\"?>\n"); + ACE_OS::fprintf (fp,"<%s>\n", Locator_XMLHandler::ROOT_TAG); // Save servers Locator_Repository::SIMap::ENTRY* sientry = 0; - Locator_Repository::SIMap::ITERATOR siit(repo.servers()); - for (; siit.next(sientry); siit.advance()) { - Server_Info_Ptr& info = sientry->int_id_; - - ACE_CString name = ACEXML_escape_string(info->name); - ACE_CString activator = ACEXML_escape_string(info->activator); - ACE_CString cmdline = ACEXML_escape_string(info->cmdline); - ACE_CString wdir = ACEXML_escape_string(info->dir); - ACE_CString partial_ior = ACEXML_escape_string(info->partial_ior); - ACE_CString ior = ACEXML_escape_string(info->ior); - - ACE_OS::fprintf(fp,"\t<%s", Locator_XMLHandler::SERVER_INFO_TAG); - ACE_OS::fprintf(fp," name=\"%s\"", name.c_str()); - ACE_OS::fprintf(fp," activator=\"%s\"", activator.c_str()); - ACE_OS::fprintf(fp," command_line=\"%s\"", cmdline.c_str()); - ACE_OS::fprintf(fp," working_dir=\"%s\"", wdir.c_str()); - ACE_CString amodestr = ImR_Utils::activationModeToString(info->activation_mode); - ACE_OS::fprintf(fp," activation_mode=\"%s\"", amodestr.c_str()); - ACE_OS::fprintf(fp," start_limit=\"%d\"", info->start_limit); - ACE_OS::fprintf(fp," partial_ior=\"%s\"", partial_ior.c_str()); - ACE_OS::fprintf(fp," ior=\"%s\"", ior.c_str()); - ACE_OS::fprintf(fp,">\n"); - - for (CORBA::ULong i = 0; i < info->env_vars.length(); ++i) + Locator_Repository::SIMap::ITERATOR siit (repo.servers ()); + for (; siit.next (sientry); siit.advance() ) { - ACE_OS::fprintf(fp,"\t\t<%s", Locator_XMLHandler::ENVIRONMENT_TAG); - ACE_OS::fprintf(fp," name=\"%s\"", info->env_vars[i].name.in()); - ACE_CString val = ACEXML_escape_string(info->env_vars[i].value.in()); - ACE_OS::fprintf(fp," value=\"%s\"", val.c_str()); - ACE_OS::fprintf(fp,"/>\n"); + Server_Info_Ptr& info = sientry->int_id_; + + ACE_CString name = ACEXML_escape_string (info->name); + ACE_CString activator = ACEXML_escape_string (info->activator); + ACE_CString cmdline = ACEXML_escape_string (info->cmdline); + ACE_CString wdir = ACEXML_escape_string (info->dir); + ACE_CString partial_ior = ACEXML_escape_string (info->partial_ior); + ACE_CString ior = ACEXML_escape_string (info->ior); + + ACE_OS::fprintf (fp,"\t<%s", Locator_XMLHandler::SERVER_INFO_TAG); + ACE_OS::fprintf (fp," name=\"%s\"", name.c_str ()); + ACE_OS::fprintf (fp," activator=\"%s\"", activator.c_str ()); + ACE_OS::fprintf (fp," command_line=\"%s\"", cmdline.c_str ()); + ACE_OS::fprintf (fp," working_dir=\"%s\"", wdir.c_str ()); + ACE_CString amodestr = ImR_Utils::activationModeToString (info->activation_mode); + ACE_OS::fprintf (fp," activation_mode=\"%s\"", amodestr.c_str ()); + ACE_OS::fprintf (fp," start_limit=\"%d\"", info->start_limit); + ACE_OS::fprintf (fp," partial_ior=\"%s\"", partial_ior.c_str ()); + ACE_OS::fprintf (fp," ior=\"%s\"", ior.c_str ()); + ACE_OS::fprintf (fp,">\n"); + + for (CORBA::ULong i = 0; i < info->env_vars.length (); ++i) + { + ACE_OS::fprintf (fp,"\t\t<%s", Locator_XMLHandler::ENVIRONMENT_TAG); + ACE_OS::fprintf (fp," name=\"%s\"", info->env_vars[i].name.in ()); + ACE_CString val = ACEXML_escape_string (info->env_vars[i].value.in ()); + ACE_OS::fprintf (fp," value=\"%s\"", val.c_str ()); + ACE_OS::fprintf (fp,"/>\n"); + } + + ACE_OS::fprintf (fp,"\t</%s>\n", Locator_XMLHandler::SERVER_INFO_TAG); } - ACE_OS::fprintf(fp,"\t</%s>\n", Locator_XMLHandler::SERVER_INFO_TAG); - } - // Save Activators Locator_Repository::AIMap::ENTRY* aientry = 0; - Locator_Repository::AIMap::ITERATOR aiit(repo.activators()); - for (; aiit.next(aientry); aiit.advance()) { - ACE_CString aname = aientry->ext_id_; - Activator_Info_Ptr& info = aientry->int_id_; - ACE_OS::fprintf(fp,"\t<%s", Locator_XMLHandler::ACTIVATOR_INFO_TAG); - ACE_OS::fprintf(fp," name=\"%s\"", aname.c_str()); - ACE_OS::fprintf(fp," token=\"%d\"", info->token); - ACE_OS::fprintf(fp," ior=\"%s\"", info->ior.c_str ()); - ACE_OS::fprintf(fp,"/>\n"); - } + Locator_Repository::AIMap::ITERATOR aiit (repo.activators ()); + for (; aiit.next (aientry); aiit.advance ()) + { + ACE_CString aname = aientry->ext_id_; + Activator_Info_Ptr& info = aientry->int_id_; + ACE_OS::fprintf (fp,"\t<%s", Locator_XMLHandler::ACTIVATOR_INFO_TAG); + ACE_OS::fprintf( fp," name=\"%s\"", aname.c_str ()); + ACE_OS::fprintf (fp," token=\"%d\"", info->token); + ACE_OS::fprintf (fp," ior=\"%s\"", info->ior.c_str ()); + ACE_OS::fprintf (fp,"/>\n"); + } - ACE_OS::fprintf(fp,"</%s>\n", Locator_XMLHandler::ROOT_TAG); - ACE_OS::fclose(fp); + ACE_OS::fprintf (fp,"</%s>\n", Locator_XMLHandler::ROOT_TAG); + ACE_OS::fclose (fp); } -Locator_Repository::Locator_Repository() -: rmode_(Options::REPO_NONE) -, config_(0) +Locator_Repository::Locator_Repository () +: rmode_ (Options::REPO_NONE) +, config_ (0) { } int Locator_Repository::init(const Options& opts) { - this->rmode_ = opts.repository_mode(); - this->fname_ = opts.persist_file_name(); + this->rmode_ = opts.repository_mode (); + this->fname_ = opts.persist_file_name (); int err = 0; - switch (this->rmode_) { - case Options::REPO_NONE: + switch (this->rmode_) { - break; - } - case Options::REPO_HEAP_FILE: - { - if (opts.repository_erase()) + case Options::REPO_NONE: { - ACE_OS::unlink( this->fname_.c_str() ); + break; } - ACE_Configuration_Heap* heap = new ACE_Configuration_Heap(); - this->config_.reset(heap); - err = heap->open(this->fname_.c_str()); - if (err == 0) + case Options::REPO_HEAP_FILE: { - loadAsBinary(*this->config_, *this); + if (opts.repository_erase ()) + { + ACE_OS::unlink ( this->fname_.c_str () ); + } + ACE_Configuration_Heap* heap = new ACE_Configuration_Heap (); + this->config_.reset (heap); + err = heap->open (this->fname_.c_str ()); + if (err == 0) + { + loadAsBinary (*this->config_, *this); + } + break; } - break; - } - case Options::REPO_REGISTRY: - { -#if defined (ACE_WIN32) - if (opts.repository_erase()) + case Options::REPO_REGISTRY: { - ACE_Configuration_Win32Registry config( HKEY_LOCAL_MACHINE ); - ACE_Configuration_Section_Key root; - config.open_section( config.root_section(), "Software\\TAO", 0, root ); - config.remove_section( root, "ImplementationRepository", 1 ); - } - HKEY root = ACE_Configuration_Win32Registry:: - resolve_key(HKEY_LOCAL_MACHINE, WIN32_REG_KEY); - this->config_.reset(new ACE_Configuration_Win32Registry(root)); - loadAsBinary(*this->config_, *this); +#if defined (ACE_WIN32) + if (opts.repository_erase ()) + { + ACE_Configuration_Win32Registry config ( HKEY_LOCAL_MACHINE ); + ACE_Configuration_Section_Key root; + config.open_section (config.root_section(), "Software\\TAO", 0, root); + config.remove_section (root, "ImplementationRepository", 1); + } + HKEY root = ACE_Configuration_Win32Registry:: + resolve_key (HKEY_LOCAL_MACHINE, WIN32_REG_KEY); + this->config_.reset (new ACE_Configuration_Win32Registry( root)); + loadAsBinary (*this->config_, *this); #else - ACE_ERROR ((LM_ERROR, "Registry persistence is only " - "supported on Windows\n")); - err = -1; + ACE_ERROR ((LM_ERROR, "Registry persistence is only " + "supported on Windows\n")); + err = -1; #endif - break; - } - case Options::REPO_XML_FILE: - { - if (opts.repository_erase()) + break; + } + case Options::REPO_XML_FILE: { - ACE_OS::unlink( this->fname_.c_str() ); + if (opts.repository_erase ()) + { + ACE_OS::unlink ( this->fname_.c_str() ); + } + err = loadAsXML (this->fname_, *this); + break; + } + default: + { + bool invalid_rmode_specified = false; + ACE_ASSERT (invalid_rmode_specified); + ACE_UNUSED_ARG (invalid_rmode_specified); + err = -1; } - err = loadAsXML(this->fname_, *this); - break; - } - default: - { - bool invalid_rmode_specified = false; - ACE_ASSERT(invalid_rmode_specified); - ACE_UNUSED_ARG(invalid_rmode_specified); - err = -1; } - } return err; } @@ -353,15 +361,15 @@ Locator_Repository::add_server (const ACE_CString& name, ImplementationRepository::ServerObject_ptr svrobj) { int limit = start_limit < 1 ? 1 : start_limit; - Server_Info_Ptr info(new Server_Info(name, aname, startup_command, + Server_Info_Ptr info(new Server_Info (name, aname, startup_command, env_vars, working_dir, activation, limit, partial_ior, ior, svrobj)); - int err = servers().bind (name, info); + int err = servers ().bind (name, info); if (err != 0) - { - return err; - } - this->update_server(*info); + { + return err; + } + this->update_server (*info); return 0; } @@ -371,14 +379,14 @@ Locator_Repository::add_activator (const ACE_CString& name, const ACE_CString& ior, ImplementationRepository::Activator_ptr act) { - Activator_Info_Ptr info(new Activator_Info(name, token, ior, act)); + Activator_Info_Ptr info (new Activator_Info (name, token, ior, act)); - int err = activators().bind (lcase(name), info); + int err = activators ().bind (lcase (name), info); if (err != 0) - { - return err; - } - this->update_activator(*info); + { + return err; + } + this->update_activator (*info); return 0; } @@ -386,41 +394,41 @@ int Locator_Repository::update_server (const Server_Info& info) { if (rmode_ == Options::REPO_HEAP_FILE || rmode_ == Options::REPO_REGISTRY) - { - ACE_ASSERT(this->config_.get() != 0); + { + ACE_ASSERT (this->config_.get () != 0); - ACE_Configuration& cfg = *this->config_; + ACE_Configuration& cfg = *this->config_; - ACE_Configuration_Section_Key root; - ACE_Configuration_Section_Key key; - int err = cfg.open_section (cfg.root_section(), SERVERS_ROOT_KEY, 1, root); - if (err != 0) - { - ACE_ERROR((LM_ERROR, "Unable to open config section:%s\n", SERVERS_ROOT_KEY)); - return err; + ACE_Configuration_Section_Key root; + ACE_Configuration_Section_Key key; + int err = cfg.open_section (cfg.root_section(), SERVERS_ROOT_KEY, 1, root); + if (err != 0) + { + ACE_ERROR ((LM_ERROR, "Unable to open config section:%s\n", SERVERS_ROOT_KEY)); + return err; + } + err = cfg.open_section (root, info.name.c_str (), 1, key); + if (err != 0) + { + ACE_ERROR((LM_ERROR, "Unable to open config section:%s\n", info.name.c_str())); + return err; + } + + ACE_CString envstr = ImR_Utils::envListToString(info.env_vars); + + cfg.set_string_value (key, ACTIVATOR, info.activator.c_str ()); + cfg.set_string_value (key, STARTUP_COMMAND, info.cmdline.c_str ()); + cfg.set_string_value (key, WORKING_DIR, info.dir.c_str ()); + cfg.set_string_value (key, ENVIRONMENT, envstr); + cfg.set_integer_value (key, ACTIVATION, info.activation_mode); + cfg.set_integer_value (key, START_LIMIT, info.start_limit); + cfg.set_string_value (key, PARTIAL_IOR, info.partial_ior.c_str ()); + cfg.set_string_value (key, IOR, info.ior.c_str()); } - err = cfg.open_section (root, info.name.c_str(), 1, key); - if (err != 0) + else if (rmode_ == Options::REPO_XML_FILE) { - ACE_ERROR((LM_ERROR, "Unable to open config section:%s\n", info.name.c_str())); - return err; + saveAsXML (this->fname_, *this); } - - ACE_CString envstr = ImR_Utils::envListToString(info.env_vars); - - cfg.set_string_value (key, ACTIVATOR, info.activator.c_str()); - cfg.set_string_value (key, STARTUP_COMMAND, info.cmdline.c_str()); - cfg.set_string_value (key, WORKING_DIR, info.dir.c_str()); - cfg.set_string_value (key, ENVIRONMENT, envstr); - cfg.set_integer_value (key, ACTIVATION, info.activation_mode); - cfg.set_integer_value (key, START_LIMIT, info.start_limit); - cfg.set_string_value (key, PARTIAL_IOR, info.partial_ior.c_str()); - cfg.set_string_value (key, IOR, info.ior.c_str()); - } - else if (rmode_ == Options::REPO_XML_FILE) - { - saveAsXML(this->fname_, *this); - } return 0; } @@ -428,57 +436,57 @@ int Locator_Repository::update_activator (const Activator_Info& info) { if (rmode_ == Options::REPO_HEAP_FILE || rmode_ == Options::REPO_REGISTRY) - { - ACE_ASSERT(this->config_.get() != 0); + { + ACE_ASSERT(this->config_.get () != 0); - ACE_Configuration& cfg = *this->config_; + ACE_Configuration& cfg = *this->config_; - ACE_Configuration_Section_Key root; - ACE_Configuration_Section_Key key; - int err = cfg.open_section (cfg.root_section(), ACTIVATORS_ROOT_KEY, 1, root); - if (err != 0) - { - ACE_ERROR((LM_ERROR, "Unable to open config section:%s\n", ACTIVATORS_ROOT_KEY)); - return err; + ACE_Configuration_Section_Key root; + ACE_Configuration_Section_Key key; + int err = cfg.open_section (cfg.root_section(), ACTIVATORS_ROOT_KEY, 1, root); + if (err != 0) + { + ACE_ERROR((LM_ERROR, "Unable to open config section:%s\n", ACTIVATORS_ROOT_KEY)); + return err; + } + err = cfg.open_section (root, info.name.c_str (), 1, key); + if (err != 0) + { + ACE_ERROR((LM_ERROR, "Unable to open config section:%s\n", info.name.c_str())); + return err; + } + + cfg.set_integer_value (key, TOKEN, info.token); + cfg.set_string_value (key, IOR, info.ior.c_str ()); } - err = cfg.open_section (root, info.name.c_str(), 1, key); - if (err != 0) + else if (rmode_ == Options::REPO_XML_FILE) { - ACE_ERROR((LM_ERROR, "Unable to open config section:%s\n", info.name.c_str())); - return err; + saveAsXML( this->fname_, *this); } - - cfg.set_integer_value (key, TOKEN, info.token); - cfg.set_string_value (key, IOR, info.ior.c_str()); - } - else if (rmode_ == Options::REPO_XML_FILE) - { - saveAsXML(this->fname_, *this); - } return 0; } Server_Info_Ptr Locator_Repository::get_server (const ACE_CString& name) { - Server_Info_Ptr server(0); - servers().find (name, server); + Server_Info_Ptr server (0); + servers ().find (name, server); return server; } Activator_Info_Ptr Locator_Repository::get_activator (const ACE_CString& name) { - Activator_Info_Ptr activator(0); - activators().find (lcase(name), activator); + Activator_Info_Ptr activator (0); + activators ().find (lcase (name), activator); return activator; } bool Locator_Repository::has_activator (const ACE_CString& name) { - Activator_Info_Ptr activator(0); - return activators().find (lcase(name), activator) == 0; + Activator_Info_Ptr activator (0); + return activators().find (lcase (name), activator) == 0; } int @@ -486,26 +494,26 @@ Locator_Repository::remove_server (const ACE_CString& name) { int ret = this->servers().unbind (name); if (ret != 0) - { - return ret; - } + { + return ret; + } if (rmode_ == Options::REPO_HEAP_FILE || rmode_ == Options::REPO_REGISTRY) - { - ACE_ASSERT(this->config_.get() != 0); - ACE_Configuration& cfg = *this->config_; - ACE_Configuration_Section_Key root; - int err = cfg.open_section (cfg.root_section(), SERVERS_ROOT_KEY, 0, root); - if (err != 0) { - return 0; // Already gone. + ACE_ASSERT (this->config_.get() != 0); + ACE_Configuration& cfg = *this->config_; + ACE_Configuration_Section_Key root; + int err = cfg.open_section (cfg.root_section (), SERVERS_ROOT_KEY, 0, root); + if (err != 0) + { + return 0; // Already gone. + } + ret = cfg.remove_section (root, name.c_str (), 1); } - ret = cfg.remove_section (root, name.c_str(), 1); - } else if (rmode_ == Options::REPO_XML_FILE) - { - saveAsXML(this->fname_, *this); - } + { + saveAsXML (this->fname_, *this); + } return ret; } @@ -514,49 +522,49 @@ Locator_Repository::remove_activator (const ACE_CString& name) { int ret = activators().unbind (lcase(name)); if (ret != 0) - { - return ret; - } + { + return ret; + } if (rmode_ == Options::REPO_HEAP_FILE || rmode_ == Options::REPO_REGISTRY) - { - ACE_ASSERT(this->config_.get() != 0); - ACE_Configuration& cfg = *this->config_; - ACE_Configuration_Section_Key root; - int err = cfg.open_section (cfg.root_section(), ACTIVATORS_ROOT_KEY, 0, root); - if (err != 0) { - return 0; // Already gone. + ACE_ASSERT (this->config_.get () != 0); + ACE_Configuration& cfg = *this->config_; + ACE_Configuration_Section_Key root; + int err = cfg.open_section (cfg.root_section (), ACTIVATORS_ROOT_KEY, 0, root); + if (err != 0) + { + return 0; // Already gone. + } + ret = cfg.remove_section (root, name.c_str (), 1); } - ret = cfg.remove_section (root, name.c_str(), 1); - } else if (rmode_ == Options::REPO_XML_FILE) { - saveAsXML(this->fname_, *this); + saveAsXML (this->fname_, *this); } return ret; } Locator_Repository::SIMap& -Locator_Repository::servers(void) +Locator_Repository::servers (void) { return server_infos_; } Locator_Repository::AIMap& -Locator_Repository::activators(void) +Locator_Repository::activators (void) { return activator_infos_; } const char* -Locator_Repository::repo_mode() +Locator_Repository::repo_mode () { switch (rmode_) { case Options::REPO_XML_FILE: case Options::REPO_HEAP_FILE: - return fname_.c_str(); + return fname_.c_str (); case Options::REPO_REGISTRY: return "Registry"; case Options::REPO_NONE: diff --git a/TAO/orbsvcs/ImplRepo_Service/Locator_XMLHandler.cpp b/TAO/orbsvcs/ImplRepo_Service/Locator_XMLHandler.cpp index 0970b42978e..a1ddcf0b3d9 100644 --- a/TAO/orbsvcs/ImplRepo_Service/Locator_XMLHandler.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/Locator_XMLHandler.cpp @@ -10,8 +10,8 @@ const char* Locator_XMLHandler::SERVER_INFO_TAG = "Servers"; const char* Locator_XMLHandler::ACTIVATOR_INFO_TAG = "Activators"; const char* Locator_XMLHandler::ENVIRONMENT_TAG = "EnvironmentVariables"; -Locator_XMLHandler::Locator_XMLHandler(Callback& cb) -: callback_(cb) +Locator_XMLHandler::Locator_XMLHandler (Callback& cb) +: callback_ (cb) { } @@ -22,48 +22,48 @@ Locator_XMLHandler::startElement (const ACEXML_Char*, ACEXML_Attributes* attrs ACEXML_ENV_ARG_DECL_NOT_USED) ACE_THROW_SPEC ((ACEXML_SAXException)) { - ACE_ASSERT(qName != 0); + ACE_ASSERT (qName != 0); if (ACE_OS::strcasecmp (qName, SERVER_INFO_TAG) == 0) - { - // We'll use this as a key to determine if we've got a valid record - this->server_name_ = ""; - this->env_vars_.clear(); - - if (attrs != 0 && attrs->getLength () == 8) { - this->server_name_ = attrs->getValue((size_t)0); - this->activator_name_ = attrs->getValue((size_t)1); - this->command_line_ = attrs->getValue((size_t)2); - this->working_dir_ = attrs->getValue((size_t)3); - this->activation_ = attrs->getValue((size_t)4); + // We'll use this as a key to determine if we've got a valid record + this->server_name_ = ""; this->env_vars_.clear(); - int limit = ACE_OS::atoi (attrs->getValue((size_t)5)); - this->start_limit_ = limit; - this->partial_ior_ = attrs->getValue((size_t)6); - this->server_object_ior_ = attrs->getValue((size_t)7); + + if (attrs != 0 && attrs->getLength () == 8) + { + this->server_name_ = attrs->getValue ((size_t)0); + this->activator_name_ = attrs->getValue ((size_t)1); + this->command_line_ = attrs->getValue ((size_t)2); + this->working_dir_ = attrs->getValue ((size_t)3); + this->activation_ = attrs->getValue ((size_t)4); + this->env_vars_.clear (); + int limit = ACE_OS::atoi (attrs->getValue ((size_t)5)); + this->start_limit_ = limit; + this->partial_ior_ = attrs->getValue ((size_t)6); + this->server_object_ior_ = attrs->getValue ((size_t)7); + } } - } else if (ACE_OS::strcasecmp (qName, ACTIVATOR_INFO_TAG) == 0) { if (attrs != 0 && attrs->getLength () == 3) - { - ACE_CString aname = attrs->getValue((size_t)0); - ACE_CString token_str = attrs->getValue((size_t)1); - long token = ACE_OS::atoi (token_str.c_str()); - ACE_CString ior = attrs->getValue((size_t)2); - this->callback_.next_activator(aname, token, ior); - } + { + ACE_CString aname = attrs->getValue ((size_t)0); + ACE_CString token_str = attrs->getValue ((size_t)1); + long token = ACE_OS::atoi (token_str.c_str ()); + ACE_CString ior = attrs->getValue ((size_t)2); + this->callback_.next_activator (aname, token, ior); + } } else if (ACE_OS::strcasecmp (qName, ENVIRONMENT_TAG) == 0) - { - if (attrs != 0 && attrs->getLength() == 2) { - EnvVar ev; - ev.name = attrs->getValue((size_t)0); - ev.value = attrs->getValue((size_t)1); - this->env_vars_.push_back(ev); + if (attrs != 0 && attrs->getLength () == 2) + { + EnvVar ev; + ev.name = attrs->getValue ((size_t)0); + ev.value = attrs->getValue ((size_t)1); + this->env_vars_.push_back (ev); + } } - } } void @@ -74,9 +74,9 @@ Locator_XMLHandler::endElement (const ACEXML_Char*, { ACE_ASSERT(qName != 0); if (ACE_OS::strcasecmp (qName, SERVER_INFO_TAG) == 0 - && this->server_name_.length() > 0) + && this->server_name_.length () > 0) { - this->callback_.next_server(this->server_name_, + this->callback_.next_server (this->server_name_, this->activator_name_, this->command_line_, this->env_vars_, this->working_dir_, this->activation_, this->start_limit_, this->partial_ior_, this->server_object_ior_); @@ -85,12 +85,12 @@ Locator_XMLHandler::endElement (const ACEXML_Char*, } bool -Locator_XMLHandler::EnvVar::operator==(const EnvVar& rhs) const +Locator_XMLHandler::EnvVar::operator== (const EnvVar& rhs) const { return name == rhs.name && value == rhs.value; } bool -Locator_XMLHandler::EnvVar::operator!=(const EnvVar& rhs) const +Locator_XMLHandler::EnvVar::operator!= (const EnvVar& rhs) const { return ! (rhs == *this); } diff --git a/TAO/orbsvcs/ImplRepo_Service/Locator_XMLHandler.h b/TAO/orbsvcs/ImplRepo_Service/Locator_XMLHandler.h index 98526ac5acf..ff8691d0a78 100644 --- a/TAO/orbsvcs/ImplRepo_Service/Locator_XMLHandler.h +++ b/TAO/orbsvcs/ImplRepo_Service/Locator_XMLHandler.h @@ -44,7 +44,7 @@ public: struct Callback { virtual ~Callback() {} - + virtual void next_server (const ACE_CString& server_name, const ACE_CString& aname, const ACE_CString& startup_cmd, const EnvList& env_vars, const ACE_CString& working_dir, diff --git a/TAO/orbsvcs/ImplRepo_Service/Server_Info.cpp b/TAO/orbsvcs/ImplRepo_Service/Server_Info.cpp index 70ed15854f9..91f8d7fa1be 100644 --- a/TAO/orbsvcs/ImplRepo_Service/Server_Info.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/Server_Info.cpp @@ -14,52 +14,53 @@ Server_Info::Server_Info const ACE_CString& server_ior, ImplementationRepository::ServerObject_ptr svrobj ) - : name(server_name) - , activator(aname) - , cmdline(cmdline) - , env_vars(env) - , dir(working_dir) - , activation_mode(amode) + : name (server_name) + , activator (aname) + , cmdline( cmdline) + , env_vars (env) + , dir (working_dir) + , activation_mode (amode) , start_limit (limit) - , partial_ior(partial_ior) - , ior(server_ior) - , server(ImplementationRepository::ServerObject::_duplicate(svrobj)) - , start_count(0) - , waiting_clients(0) - , starting(false) + , partial_ior (partial_ior) + , ior (server_ior) + , server(ImplementationRepository::ServerObject::_duplicate (svrobj)) + , start_count (0) + , waiting_clients (0) + , starting (false) { } ImplementationRepository::ServerInformation* -Server_Info::createImRServerInfo(ACE_ENV_SINGLE_ARG_DECL) +Server_Info::createImRServerInfo (ACE_ENV_SINGLE_ARG_DECL) { ImplementationRepository::ServerInformation* info; - ACE_NEW_THROW_EX (info, ImplementationRepository::ServerInformation, CORBA::NO_MEMORY()); + ACE_NEW_THROW_EX (info, ImplementationRepository::ServerInformation, CORBA::NO_MEMORY ()); - info->server = name.c_str(); - info->startup.command_line = cmdline.c_str(); + info->server = name.c_str (); + info->startup.command_line = cmdline.c_str (); info->startup.environment = env_vars; - info->startup.working_directory = dir.c_str(); + info->startup.working_directory = dir.c_str (); info->startup.activation = activation_mode; - info->startup.activator = activator.c_str(); - if (start_count >= start_limit) { - info->startup.start_limit = -start_limit; - } + info->startup.activator = activator.c_str (); + if (start_count >= start_limit) + { + info->startup.start_limit = -start_limit; + } else - { - info->startup.start_limit = start_limit; - } + { + info->startup.start_limit = start_limit; + } info->partial_ior = partial_ior.c_str(); return info; } void -Server_Info::reset(void) +Server_Info::reset (void) { ior = ""; partial_ior = ""; last_ping = ACE_Time_Value::zero; - server = ImplementationRepository::ServerObject::_nil(); + server = ImplementationRepository::ServerObject::_nil (); // start_count = 0; Note : We can't do this, because it would be reset during startup. } diff --git a/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.cpp b/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.cpp index c7fbddcb83e..9febb1ae406 100644 --- a/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.cpp @@ -26,11 +26,11 @@ TAO_IMR_i::~TAO_IMR_i (void) int TAO_IMR_i::run () { - if (this->op_.get() == 0) - { - ACE_ERROR ((LM_ERROR, "Unknown operation")); - return TAO_IMR_Op::UNKNOWN; - } + if (this->op_.get () == 0) + { + ACE_ERROR ((LM_ERROR, "Unknown operation")); + return TAO_IMR_Op::UNKNOWN; + } return this->op_->run (); } @@ -45,46 +45,46 @@ TAO_IMR_i::init (int argc, char **argv) ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY - { - // Retrieve the ORB. - this->orb_ = CORBA::ORB_init (this->argc_, this->argv_, "tao_imr_i" ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + { + // Retrieve the ORB. + this->orb_ = CORBA::ORB_init (this->argc_, this->argv_, "tao_imr_i" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; - // Parse command line and verify parameters. - if (this->parse_args () == -1) - return -1; + // Parse command line and verify parameters. + if (this->parse_args () == -1) + return -1; - // Get the ImplRepo object - CORBA::Object_var obj = - orb_->resolve_initial_references ("ImplRepoService" ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + // Get the ImplRepo object + CORBA::Object_var obj = + orb_->resolve_initial_references ("ImplRepoService" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; - if (CORBA::is_nil (obj.in ())) - { - ACE_ERROR ((LM_ERROR, "Unable to resolve the ImR.\n")); - return -1; - } + if (CORBA::is_nil (obj.in ())) + { + ACE_ERROR ((LM_ERROR, "Unable to resolve the ImR.\n")); + return -1; + } + + exception_message = "While narrowing ImR"; - exception_message = "While narrowing ImR"; + this->imr_ = + ImplementationRepository::Administration::_narrow (obj.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; - this->imr_ = - ImplementationRepository::Administration::_narrow (obj.in() ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + if (CORBA::is_nil (imr_.in ())) + { + ACE_ERROR ((LM_ERROR, "Unable to narrow the ImR.\n")); + return -1; + } - if (CORBA::is_nil (imr_.in ())) + this->op_->set_imr (this->imr_.in ()); + } + ACE_CATCHANY { - ACE_ERROR ((LM_ERROR, "Unable to narrow the ImR.\n")); + ACE_ERROR ((LM_ERROR, "TAO_IMR_i::init - %s\n", exception_message)); + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Exception"); return -1; } - - this->op_->set_imr(this->imr_.in ()); - } - ACE_CATCHANY - { - ACE_ERROR ((LM_ERROR, "TAO_IMR_i::init - %s\n", exception_message)); - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Exception"); - return -1; - } ACE_ENDTRY; return 0; @@ -98,22 +98,22 @@ TAO_IMR_i::parse_args (void) { // Make sure one command was given if (this->argc_ < 2) - { - ACE_ERROR((LM_ERROR, "Error: No operation specified.\n")); - this->print_usage (); - return -1; - } + { + ACE_ERROR((LM_ERROR, "Error: No operation specified.\n")); + this->print_usage (); + return -1; + } - this->op_.reset(TAO_IMR_Op::make_op (this->argv_[1])); + this->op_.reset (TAO_IMR_Op::make_op (this->argv_[1])); // Check for unrecognized operation - if (this->op_.get() == 0) - { - ACE_ERROR((LM_ERROR, "Error: Unknown operation '%s'.\n", this->argv_[1])); - this->print_usage (); - return -1; - } + if (this->op_.get () == 0) + { + ACE_ERROR((LM_ERROR, "Error: Unknown operation '%s'.\n", this->argv_[1])); + this->print_usage (); + return -1; + } // Adjust argc and argv so only the command specific args are passed return this->op_->parse (this->argc_ - 1, this->argv_ + 1); @@ -147,10 +147,10 @@ TAO_IMR_Op * TAO_IMR_Op::make_op (const ACE_TCHAR *op_name) { if (ACE_OS::strcasecmp (op_name, ACE_TEXT ("activate")) == 0) - { - ACE_ERROR((LM_ERROR, "Warning: The activate option has been renamed to start.\n")); - return new TAO_IMR_Op_Activate (); - } + { + ACE_ERROR((LM_ERROR, "Warning: The activate option has been renamed to start.\n")); + return new TAO_IMR_Op_Activate (); + } else if (ACE_OS::strcasecmp (op_name, ACE_TEXT ("start")) == 0) return new TAO_IMR_Op_Activate (); else if (ACE_OS::strcasecmp (op_name, ACE_TEXT ("add")) == 0) @@ -206,10 +206,10 @@ TAO_IMR_Op::display_server_information (const ImplementationRepository::ServerIn int limit = info.startup.start_limit; if (info.startup.start_limit < 0) - { - limit = -limit; - locked_out = " Locked Out\n"; - } + { + limit = -limit; + locked_out = " Locked Out\n"; + } ACE_DEBUG ((LM_DEBUG, " Activator: %s\n" @@ -230,14 +230,15 @@ TAO_IMR_Op::display_server_information (const ImplementationRepository::ServerIn info.startup.environment[i].value.in ())); if (info.startup.activation == ImplementationRepository::PER_CLIENT) - ACE_DEBUG ((LM_DEBUG, " No running info available for PER_CLIENT mode\n")); - else if (ACE_OS::strlen (info.partial_ior.in()) > 0) ACE_DEBUG ((LM_DEBUG, - " Running at endpoint: %s\n", - info.partial_ior.in ())); + " No running info available for PER_CLIENT mode\n")); + else if (ACE_OS::strlen (info.partial_ior.in ()) > 0) + ACE_DEBUG ((LM_DEBUG, + " Running at endpoint: %s\n", + info.partial_ior.in ())); else // I am assuming that a blank partial_ior means currently not running. ACE_DEBUG ((LM_DEBUG, - " Not currently running\n")); + " Not currently running\n")); ACE_DEBUG ((LM_DEBUG, "\n")); } @@ -278,10 +279,10 @@ TAO_IMR_Op_Activate::parse (int argc, ACE_TCHAR **argv) { // Check for enough arguments (we need at least one for the server name) if (argc < 2) - { - this->print_usage (); - return -1; - } + { + this->print_usage (); + return -1; + } // Skip both the program name and the "activate" command ACE_Get_Opt get_opts (argc, argv, "h"); @@ -290,17 +291,18 @@ TAO_IMR_Op_Activate::parse (int argc, ACE_TCHAR **argv) int c; while ((c = get_opts ()) != -1) - switch (c) - { - case 'h': - this->print_usage (); - return -1; - default: - ACE_ERROR((LM_ERROR, "ERROR : Unknown option '%c'\n", (char) c)); - this->print_usage (); - return -1; + { + switch (c) + { + case 'h': + this->print_usage (); + return -1; + default: + ACE_ERROR((LM_ERROR, "ERROR : Unknown option '%c'\n", (char) c)); + this->print_usage (); + return -1; + } } - return 0; } @@ -321,17 +323,18 @@ TAO_IMR_Op_Autostart::parse (int argc, ACE_TCHAR **argv) int c; while ((c = get_opts ()) != -1) - switch (c) - { - case 'h': // display help - this->print_usage (); - return -1; - default: - ACE_ERROR((LM_ERROR, "ERROR : Unknown option '%c'\n", (char) c)); - this->print_usage (); - return -1; - } - + { + switch (c) + { + case 'h': // display help + this->print_usage (); + return -1; + default: + ACE_ERROR((LM_ERROR, "ERROR : Unknown option '%c'\n", (char) c)); + this->print_usage (); + return -1; + } + } return 0; } @@ -355,39 +358,40 @@ TAO_IMR_Op_IOR::parse (int argc, ACE_TCHAR **argv) { // Check for enough arguments (we need at least one for the server name) if (argc < 2) - { - this->print_usage (); - return -1; - } + { + this->print_usage (); + return -1; + } // Skip both the program name and the "ior" command ACE_Get_Opt get_opts (argc, argv, "hf:"); this->server_name_ = argv[1]; if (this->server_name_.length() == 0 || this->server_name_[0] == '-') - { - ACE_ERROR((LM_ERROR, "ERROR : name is required.\n")); - this->print_usage (); - return -1; - } + { + ACE_ERROR((LM_ERROR, "ERROR : name is required.\n")); + this->print_usage (); + return -1; + } int c; while ((c = get_opts ()) != -1) - switch (c) - { - case 'f': // File name - this->filename_ = get_opts.opt_arg (); - break; - case 'h': // display help - this->print_usage(); - return -1; - default: - ACE_ERROR((LM_ERROR, "ERROR : Unknown option '%c'\n", (char) c)); - this->print_usage (); - return -1; - } - + { + switch (c) + { + case 'f': // File name + this->filename_ = get_opts.opt_arg (); + break; + case 'h': // display help + this->print_usage (); + return -1; + default: + ACE_ERROR((LM_ERROR, "ERROR : Unknown option '%c'\n", (char) c)); + this->print_usage (); + return -1; + } + } return 0; } @@ -422,20 +426,21 @@ TAO_IMR_Op_List::parse (int argc, ACE_TCHAR **argv) int c; while ((c = get_opts ()) != -1) - switch (c) - { - case 'v': // verbose server display - this->verbose_server_information_ = 1; - break; - case 'h': // display help - this->print_usage (); - return -1; - default: - ACE_ERROR((LM_ERROR, "ERROR : Unknown option '%c'\n", (char) c)); - this->print_usage (); - return -1; - } - + { + switch (c) + { + case 'v': // verbose server display + this->verbose_server_information_ = 1; + break; + case 'h': // display help + this->print_usage (); + return -1; + default: + ACE_ERROR((LM_ERROR, "ERROR : Unknown option '%c'\n", (char) c)); + this->print_usage (); + return -1; + } + } return 0; } @@ -455,10 +460,10 @@ TAO_IMR_Op_Remove::parse (int argc, ACE_TCHAR **argv) { // Check for enough arguments (we need at least one for the server name) if (argc < 2) - { - this->print_usage (); - return -1; - } + { + this->print_usage (); + return -1; + } // Skip both the program name and the "remove" command ACE_Get_Opt get_opts (argc, argv, "h"); @@ -467,17 +472,18 @@ TAO_IMR_Op_Remove::parse (int argc, ACE_TCHAR **argv) int c; while ((c = get_opts ()) != -1) - switch (c) - { - case 'h': - this->print_usage (); - return -1; - default: - ACE_ERROR((LM_ERROR, "ERROR : Unknown option '%c'\n", (char) c)); - this->print_usage (); - return -1; - } - + { + switch (c) + { + case 'h': + this->print_usage (); + return -1; + default: + ACE_ERROR((LM_ERROR, "ERROR : Unknown option '%c'\n", (char) c)); + this->print_usage (); + return -1; + } + } return 0; } @@ -497,10 +503,10 @@ TAO_IMR_Op_Shutdown::parse (int argc, ACE_TCHAR **argv) { // Check for enough arguments (we need at least one for the server name) if (argc < 2) - { - this->print_usage (); - return -1; - } + { + this->print_usage (); + return -1; + } // Skip both the program name and the "shutdown" command ACE_Get_Opt get_opts (argc, argv, "h"); @@ -509,17 +515,18 @@ TAO_IMR_Op_Shutdown::parse (int argc, ACE_TCHAR **argv) int c; while ((c = get_opts ()) != -1) - switch (c) - { - case 'h': - this->print_usage (); - return -1; - default: - ACE_ERROR((LM_ERROR, "ERROR : Unknown option '%c'\n", (char) c)); - this->print_usage (); - return -1; - } - + { + switch (c) + { + case 'h': + this->print_usage (); + return -1; + default: + ACE_ERROR((LM_ERROR, "ERROR : Unknown option '%c'\n", (char) c)); + this->print_usage (); + return -1; + } + } return 0; } @@ -544,10 +551,10 @@ TAO_IMR_Op_ShutdownRepo::parse (int argc, ACE_TCHAR **argv) { // Check for enough arguments (we need at least one for the server name) if (argc < 1) - { - this->print_usage (); - return -1; - } + { + this->print_usage (); + return -1; + } // Skip both the program name and the "shutdown-repo" command ACE_Get_Opt get_opts (argc, argv, "ha"); @@ -555,21 +562,21 @@ TAO_IMR_Op_ShutdownRepo::parse (int argc, ACE_TCHAR **argv) int c; while ((c = get_opts ()) != -1) - { - switch (c) { - case 'h': - this->print_usage (); - return -1; - case 'a': - activators_ = true; - break; - default: - ACE_ERROR((LM_ERROR, "ERROR : Unknown option '%c'\n", (char) c)); - this->print_usage (); - return -1; + switch (c) + { + case 'h': + this->print_usage (); + return -1; + case 'a': + activators_ = true; + break; + default: + ACE_ERROR((LM_ERROR, "ERROR : Unknown option '%c'\n", (char) c)); + this->print_usage (); + return -1; + } } - } return 0; } @@ -613,11 +620,11 @@ TAO_IMR_Op_Register::parse (int argc, ACE_TCHAR **argv) { // Check for enough arguments (we need at least one for the server name) if (argc < 2) - { - ACE_ERROR((LM_ERROR, "Error: Must supply at least a server name.\n")); - this->print_usage (); - return -1; - } + { + ACE_ERROR((LM_ERROR, "Error: Must supply at least a server name.\n")); + this->print_usage (); + return -1; + } // Skip both the program name and the "update" command ACE_Get_Opt get_opts (argc, argv, "hc:w:a:e:r:R:l:"); @@ -626,58 +633,59 @@ TAO_IMR_Op_Register::parse (int argc, ACE_TCHAR **argv) int c; while ((c = get_opts ()) != -1) - switch (c) - { - case 'c': // Command line arguments - this->set_command_line_ = true; - this->command_line_ = get_opts.opt_arg (); - break; - case 'e': // set environment variables - this->set_environment_vars_ = true; - this->addenv( get_opts.opt_arg () ); - break; - case 'w': // Working Directory - this->set_working_dir_ = true; - this->working_dir_ = get_opts.opt_arg (); - break; - case 'a': // Activation Mode - this->set_activation_ = true; - if (ACE_OS::strcasecmp (get_opts.opt_arg (), "NORMAL") == 0) - this->activation_ = ImplementationRepository::NORMAL; - else if (ACE_OS::strcasecmp (get_opts.opt_arg (), "MANUAL") == 0) - this->activation_ = ImplementationRepository::MANUAL; - else if (ACE_OS::strcasecmp (get_opts.opt_arg (), "PER_CLIENT") == 0) - this->activation_ = ImplementationRepository::PER_CLIENT; - else if (ACE_OS::strcasecmp (get_opts.opt_arg (), "AUTO_START") == 0) - this->activation_ = ImplementationRepository::AUTO_START; - else - ACE_ERROR_RETURN ((LM_ERROR, - "Unknown Activation Mode <%s>.\n", - get_opts.opt_arg ()), - -1); - break; - case 'r': - case 'R': // startup/ping Retry Count + { + switch (c) { - this->set_retry_count_ = true; - int rc = ACE_OS::atoi(get_opts.optarg); - if (rc > 0) - this->retry_count_ = rc; + case 'c': // Command line arguments + this->set_command_line_ = true; + this->command_line_ = get_opts.opt_arg (); + break; + case 'e': // set environment variables + this->set_environment_vars_ = true; + this->addenv( get_opts.opt_arg () ); + break; + case 'w': // Working Directory + this->set_working_dir_ = true; + this->working_dir_ = get_opts.opt_arg (); + break; + case 'a': // Activation Mode + this->set_activation_ = true; + if (ACE_OS::strcasecmp (get_opts.opt_arg (), "NORMAL") == 0) + this->activation_ = ImplementationRepository::NORMAL; + else if (ACE_OS::strcasecmp (get_opts.opt_arg (), "MANUAL") == 0) + this->activation_ = ImplementationRepository::MANUAL; + else if (ACE_OS::strcasecmp (get_opts.opt_arg (), "PER_CLIENT") == 0) + this->activation_ = ImplementationRepository::PER_CLIENT; + else if (ACE_OS::strcasecmp (get_opts.opt_arg (), "AUTO_START") == 0) + this->activation_ = ImplementationRepository::AUTO_START; + else + ACE_ERROR_RETURN ((LM_ERROR, + "Unknown Activation Mode <%s>.\n", + get_opts.opt_arg ()), + -1); + break; + case 'r': + case 'R': // startup/ping Retry Count + { + this->set_retry_count_ = true; + int rc = ACE_OS::atoi(get_opts.optarg); + if (rc > 0) + this->retry_count_ = rc; + } + break; + case 'l': /// hostname of the activator + this->activator_ = get_opts.optarg; + this->set_activator_ = true; + break; + case 'h': // display help + this->print_usage (); + return -1; + default: + ACE_ERROR((LM_ERROR, "ERROR : Unknown option '%c'\n", (char) c)); + this->print_usage (); + return -1; } - break; - case 'l': /// hostname of the activator - this->activator_ = get_opts.optarg; - this->set_activator_ = true; - break; - case 'h': // display help - this->print_usage (); - return -1; - default: - ACE_ERROR((LM_ERROR, "ERROR : Unknown option '%c'\n", (char) c)); - this->print_usage (); - return -1; - } - + } return 0; } @@ -692,34 +700,34 @@ TAO_IMR_Op_Activate::run (void) ACE_ASSERT(! CORBA::is_nil(imr_)); ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY - { - this->imr_->activate_server (this->server_name_.c_str() ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, - "Successfully Activated server <%s>\n", - this->server_name_.c_str ())); - } + { + this->imr_->activate_server (this->server_name_.c_str () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + ACE_DEBUG ((LM_DEBUG, + "Successfully Activated server <%s>\n", + this->server_name_.c_str ())); + } ACE_CATCH (ImplementationRepository::CannotActivate, ex) - { - ACE_ERROR ((LM_ERROR, "Cannot activate server <%s>, reason: <%s>\n", - this->server_name_.c_str (), - ex.reason.in ())); - return TAO_IMR_Op::CANNOT_ACTIVATE; - } + { + ACE_ERROR ((LM_ERROR, "Cannot activate server <%s>, reason: <%s>\n", + this->server_name_.c_str (), + ex.reason.in ())); + return TAO_IMR_Op::CANNOT_ACTIVATE; + } ACE_CATCH (ImplementationRepository::NotFound, ex) - { - ACE_ERROR ((LM_ERROR, "Could not find server <%s>.\n", this->server_name_.c_str ())); - return TAO_IMR_Op::NOT_FOUND; - } + { + ACE_ERROR ((LM_ERROR, "Could not find server <%s>.\n", this->server_name_.c_str ())); + return TAO_IMR_Op::NOT_FOUND; + } ACE_CATCH (PortableServer::ForwardRequest, ex) - { - ACE_RE_THROW; - } + { + ACE_RE_THROW; + } ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Activating Server"); - return TAO_IMR_Op::UNKNOWN; - } + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Activating Server"); + return TAO_IMR_Op::UNKNOWN; + } ACE_ENDTRY; return TAO_IMR_Op::NORMAL; @@ -728,43 +736,43 @@ TAO_IMR_Op_Activate::run (void) int TAO_IMR_Op_Autostart::run (void) { - ACE_ASSERT(! CORBA::is_nil(imr_)); + ACE_ASSERT(! CORBA::is_nil (imr_)); ImplementationRepository::ServerInformationList_var server_list; ImplementationRepository::ServerInformationIterator_var server_iter; ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY - { - this->imr_->list (0, - server_list, - server_iter - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - ACE_ASSERT(CORBA::is_nil(server_iter.in())); - - CORBA::ULong len = server_list->length (); - for (CORBA::ULong i = 0; i < len; ++i) { - ACE_TRY_EX (inside) - { - this->imr_->activate_server(server_list[i].server.in() ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK_EX (inside); - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, server_list[i].server.in ()); - // Ignore exception - } - ACE_ENDTRY; + this->imr_->list (0, + server_list, + server_iter + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_ASSERT(CORBA::is_nil (server_iter.in ())); + + CORBA::ULong len = server_list->length (); + for (CORBA::ULong i = 0; i < len; ++i) + { + ACE_TRY_EX (inside) + { + this->imr_->activate_server (server_list[i].server.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK_EX (inside); + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, server_list[i].server.in ()); + // Ignore exception + } + ACE_ENDTRY; + } } - } ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "autostart"); - return TAO_IMR_Op::UNKNOWN; - } + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "autostart"); + return TAO_IMR_Op::UNKNOWN; + } ACE_ENDTRY; return TAO_IMR_Op::NORMAL; @@ -773,79 +781,79 @@ TAO_IMR_Op_Autostart::run (void) int TAO_IMR_Op_IOR::run (void) { - ACE_ASSERT(! CORBA::is_nil(imr_)); + ACE_ASSERT (! CORBA::is_nil(imr_)); // Create a corbaloc string // Todo : Most of this logic duplicates that in the POA.cpp ACE_TRY_NEW_ENV - { - if (CORBA::is_nil (this->imr_) - || !this->imr_->_stubobj () - || !this->imr_->_stubobj ()->profile_in_use ()) { - ACE_ERROR_RETURN (( - LM_ERROR, - ACE_TEXT ("Invalid ImR IOR.\n") - ), -1); - } + if (CORBA::is_nil (this->imr_) + || !this->imr_->_stubobj () + || !this->imr_->_stubobj ()->profile_in_use ()) + { + ACE_ERROR_RETURN (( + LM_ERROR, + ACE_TEXT ("Invalid ImR IOR.\n") + ), -1); + } - CORBA::String_var imr_str = - this->imr_->_stubobj ()-> - profile_in_use ()->to_string (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + CORBA::String_var imr_str = + this->imr_->_stubobj ()-> + profile_in_use ()->to_string (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; - // Search for "corbaloc:" alone, without the protocol. This code - // should be protocol neutral. - const char corbaloc[] = "corbaloc:"; - char *pos = ACE_OS::strstr (imr_str.inout (), corbaloc); + // Search for "corbaloc:" alone, without the protocol. This code + // should be protocol neutral. + const char corbaloc[] = "corbaloc:"; + char *pos = ACE_OS::strstr (imr_str.inout (), corbaloc); - if (pos == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, "Could not parse IMR IOR.\n"), -1); - } - else - { - pos = ACE_OS::strchr (pos + sizeof (corbaloc), ':'); - pos = ACE_OS::strchr (pos + 1, - this->imr_->_stubobj ()->profile_in_use ()->object_key_delimiter ()); - - if (pos) + if (pos == 0) { - *(pos + 1) = 0; // Crop the string + ACE_ERROR_RETURN ((LM_ERROR, "Could not parse IMR IOR.\n"), -1); } else { - ACE_ERROR_RETURN ((LM_ERROR, "Could not parse IMR IOR.\n"), -1); + pos = ACE_OS::strchr (pos + sizeof (corbaloc), ':'); + pos = ACE_OS::strchr (pos + 1, + this->imr_->_stubobj ()->profile_in_use ()->object_key_delimiter ()); + + if (pos) + { + *(pos + 1) = 0; // Crop the string + } + else + { + ACE_ERROR_RETURN ((LM_ERROR, "Could not parse IMR IOR.\n"), -1); + } } - } - ACE_CString ior (imr_str.in ()); - - // Add the key - ior += this->server_name_; + ACE_CString ior (imr_str.in ()); - ACE_DEBUG ((LM_DEBUG, "%s\n", ior.c_str ())); + // Add the key + ior += this->server_name_; - if (this->filename_.length () > 0) - { - FILE *file = ACE_OS::fopen (this->filename_.c_str (), "w"); + ACE_DEBUG ((LM_DEBUG, "%s\n", ior.c_str ())); - if (file == 0) + if (this->filename_.length () > 0) { - ACE_ERROR_RETURN ((LM_ERROR, - "Error: Unable to open %s for writing: %p\n", - this->filename_.c_str ()), - -1); + FILE *file = ACE_OS::fopen (this->filename_.c_str (), "w"); + + if (file == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Error: Unable to open %s for writing: %p\n", + this->filename_.c_str ()), + -1); + } + + ACE_OS::fprintf (file, "%s", ior.c_str ()); + ACE_OS::fclose (file); } - - ACE_OS::fprintf (file, "%s", ior.c_str ()); - ACE_OS::fclose (file); } - } ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "IOR"); - return TAO_IMR_Op::UNKNOWN; - } + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "IOR"); + return TAO_IMR_Op::UNKNOWN; + } ACE_ENDTRY; return TAO_IMR_Op::NORMAL; @@ -854,57 +862,57 @@ TAO_IMR_Op_IOR::run (void) int TAO_IMR_Op_List::run (void) { - ACE_ASSERT(! CORBA::is_nil(imr_)); + ACE_ASSERT (! CORBA::is_nil(imr_)); ImplementationRepository::ServerInformationList_var server_list; ImplementationRepository::ServerInformationIterator_var server_iter; ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY - { - // If there is a server name, list only that server. Otherwise, look - // at all of them. - if (this->server_name_.length () == 0) { - this->imr_->list (0, - server_list.out(), - server_iter.out() - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + // If there is a server name, list only that server. Otherwise, look + // at all of them. + if (this->server_name_.length () == 0) + { + this->imr_->list (0, + server_list.out(), + server_iter.out() + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (server_list->length() == 0) + { + ACE_DEBUG((LM_DEBUG, "No servers found.\n")); + return TAO_IMR_Op::NORMAL; + } + + for (CORBA::ULong i = 0; i < server_list->length (); i++) + this->display_server_information (server_list[i]); + + ACE_ASSERT (CORBA::is_nil (server_iter.in ())); + } + else + { + ImplementationRepository::ServerInformation_var si; - if (server_list->length() == 0) - { - ACE_DEBUG((LM_DEBUG, "No servers found.\n")); - return TAO_IMR_Op::NORMAL; - } + this->imr_->find (this->server_name_.c_str (), si ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; - for (CORBA::ULong i = 0; i < server_list->length (); i++) - this->display_server_information (server_list[i]); + this->verbose_server_information_ = 1; - ACE_ASSERT (CORBA::is_nil (server_iter.in ())); + this->display_server_information (si.in ()); + } } - else + ACE_CATCH (ImplementationRepository::NotFound, ex) { - ImplementationRepository::ServerInformation_var si; - - this->imr_->find (this->server_name_.c_str (), si ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - this->verbose_server_information_ = 1; - - this->display_server_information (si.in ()); + ACE_ERROR ((LM_ERROR, "Could not find server <%s>.\n", this->server_name_.c_str ())); + return TAO_IMR_Op::NOT_FOUND; } - } - ACE_CATCH (ImplementationRepository::NotFound, ex) - { - ACE_ERROR ((LM_ERROR, "Could not find server <%s>.\n", this->server_name_.c_str ())); - return TAO_IMR_Op::NOT_FOUND; - } ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "List"); - return TAO_IMR_Op::UNKNOWN; - } + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "List"); + return TAO_IMR_Op::UNKNOWN; + } ACE_ENDTRY; return TAO_IMR_Op::NORMAL; @@ -913,33 +921,33 @@ TAO_IMR_Op_List::run (void) int TAO_IMR_Op_Remove::run (void) { - ACE_ASSERT(! CORBA::is_nil(imr_)); + ACE_ASSERT (! CORBA::is_nil(imr_)); ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY - { - this->imr_->remove_server (this->server_name_.c_str() ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + { + this->imr_->remove_server (this->server_name_.c_str () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, "Successfully removed server <%s>\n", - this->server_name_.c_str ())); - } + ACE_DEBUG ((LM_DEBUG, "Successfully removed server <%s>\n", + this->server_name_.c_str ())); + } ACE_CATCH (ImplementationRepository::NotFound, ex) - { - ACE_ERROR ((LM_ERROR, "Could not find server <%s>.\n", - this->server_name_.c_str ())); - return TAO_IMR_Op::NOT_FOUND; - } + { + ACE_ERROR ((LM_ERROR, "Could not find server <%s>.\n", + this->server_name_.c_str ())); + return TAO_IMR_Op::NOT_FOUND; + } ACE_CATCH (CORBA::NO_PERMISSION, ex) - { - ACE_ERROR ((LM_ERROR, "No Permission: ImplRepo is in Locked mode\n")); - return TAO_IMR_Op::NO_PERMISSION; - } + { + ACE_ERROR ((LM_ERROR, "No Permission: ImplRepo is in Locked mode\n")); + return TAO_IMR_Op::NO_PERMISSION; + } ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Removing Server"); - return TAO_IMR_Op::UNKNOWN; - } + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Removing Server"); + return TAO_IMR_Op::UNKNOWN; + } ACE_ENDTRY; return TAO_IMR_Op::NORMAL; @@ -948,32 +956,32 @@ TAO_IMR_Op_Remove::run (void) int TAO_IMR_Op_Shutdown::run (void) { - ACE_ASSERT(! CORBA::is_nil(imr_)); + ACE_ASSERT (! CORBA::is_nil(imr_)); ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY - { - this->imr_->shutdown_server (this->server_name_.c_str () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + { + this->imr_->shutdown_server (this->server_name_.c_str () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, "Successfully shut down server <%s>\n", - this->server_name_.c_str ())); - } + ACE_DEBUG ((LM_DEBUG, "Successfully shut down server <%s>\n", + this->server_name_.c_str ())); + } ACE_CATCH (ImplementationRepository::NotFound, ex) - { - ACE_ERROR ((LM_ERROR, "Server <%s> already shut down.\n", this->server_name_.c_str ())); - return TAO_IMR_Op::NOT_FOUND; - } + { + ACE_ERROR ((LM_ERROR, "Server <%s> already shut down.\n", this->server_name_.c_str ())); + return TAO_IMR_Op::NOT_FOUND; + } ACE_CATCH(CORBA::TIMEOUT, ex) - { - ACE_DEBUG ((LM_DEBUG, "Timeout waiting for <%s> to shutdown.\n", - this->server_name_.c_str ())); - } + { + ACE_DEBUG ((LM_DEBUG, "Timeout waiting for <%s> to shutdown.\n", + this->server_name_.c_str ())); + } ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Shutting Down Server"); - return TAO_IMR_Op::UNKNOWN; - } + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Shutting Down Server"); + return TAO_IMR_Op::UNKNOWN; + } ACE_ENDTRY; return TAO_IMR_Op::NORMAL; @@ -986,22 +994,22 @@ TAO_IMR_Op_ShutdownRepo::run (void) ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY - { - bool servers = false; // not implemented yet, if ever - this->imr_->shutdown(activators_, servers ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + { + bool servers = false; // not implemented yet, if ever + this->imr_->shutdown (activators_, servers ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, "ImR shutdown initiated.\n")); - } + ACE_DEBUG ((LM_DEBUG, "ImR shutdown initiated.\n")); + } ACE_CATCH(CORBA::TIMEOUT, ex) - { - ACE_DEBUG ((LM_DEBUG, "Timeout waiting for ImR shutdown.\n")); - } + { + ACE_DEBUG ((LM_DEBUG, "Timeout waiting for ImR shutdown.\n")); + } ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Shutting Down ImR"); - return TAO_IMR_Op::UNKNOWN; - } + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Shutting Down ImR"); + return TAO_IMR_Op::UNKNOWN; + } ACE_ENDTRY; return TAO_IMR_Op::NORMAL; @@ -1010,7 +1018,7 @@ TAO_IMR_Op_ShutdownRepo::run (void) int TAO_IMR_Op_Register::run (void) { - ACE_ASSERT(! CORBA::is_nil(imr_)); + ACE_ASSERT (! CORBA::is_nil(imr_)); ImplementationRepository::ServerInformation_var server_information; ImplementationRepository::StartupOptions local; @@ -1018,67 +1026,73 @@ TAO_IMR_Op_Register::run (void) ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY - { - this->imr_->find(this->server_name_.c_str (), - server_information.out() ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (server_name_ == server_information->server.in()) { - if (is_add_) - { - ACE_DEBUG((LM_DEBUG, "Server <%s> already registered.\n", this->server_name_.c_str())); - return ALREADY_REGISTERED; - } - options = &server_information->startup; - } - else - { - is_add_ = true; - options = &local; - } - - if (this->set_command_line_) - options->command_line = CORBA::string_dup (this->command_line_.c_str ()); - - if (this->set_environment_vars_) - options->environment = this->environment_vars_; - - if (this->set_working_dir_) - options->working_directory = CORBA::string_dup (this->working_dir_.c_str ()); - - if (this->set_activation_ || is_add_) - options->activation = this->activation_; + this->imr_->find(this->server_name_.c_str (), + server_information.out() ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; - if (this->set_retry_count_ || is_add_) - options->start_limit = this->retry_count_ + 1; + if (server_name_ == server_information->server.in()) + { + if (is_add_) + { + ACE_DEBUG((LM_DEBUG, "Server <%s> already registered.\n", this->server_name_.c_str ())); + return ALREADY_REGISTERED; + } + options = &server_information->startup; + } + else // not found + { + if (!is_add_) + { + ACE_DEBUG((LM_DEBUG, "Adding Server <%s> on update command.\n", this->server_name_.c_str ())); + is_add_ = true; + } + options = &local; + } + + if (this->set_command_line_) + options->command_line = CORBA::string_dup (this->command_line_.c_str ()); + + if (this->set_environment_vars_) + options->environment = this->environment_vars_; + + if (this->set_working_dir_) + options->working_directory = CORBA::string_dup (this->working_dir_.c_str ()); + + if (this->set_activation_ || is_add_) + options->activation = this->activation_; + + if (this->set_retry_count_ || is_add_) + options->start_limit = this->retry_count_ + 1; + + if (this->set_activator_) + options->activator = CORBA::string_dup(this->activator_.c_str ()); + // If the command line is set, we must have an activator + else if (this->set_command_line_ && + (options->activator.in () == 0 || *options->activator.in () == 0)) + { + char host_name[MAXHOSTNAMELEN + 1]; + ACE_OS::hostname (host_name, MAXHOSTNAMELEN); + options->activator = CORBA::string_dup (host_name); + ACE_DEBUG ((LM_DEBUG, "Updating Server <%s> with default activator of <%s>.\n", + this->server_name_.c_str (), options->activator.in ())); + } + + this->imr_->add_or_update_server (this->server_name_.c_str (), *options ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; - if (this->set_activator_) - { - options->activator = CORBA::string_dup(this->activator_.c_str()); - } - else if (is_add_) - { - char host_name[MAXHOSTNAMELEN + 1]; - ACE_OS::hostname (host_name, MAXHOSTNAMELEN); - options->activator = CORBA::string_dup (host_name); + ACE_DEBUG((LM_DEBUG, "Successfully registered <%s>.\n", this->server_name_.c_str ())); } - - this->imr_->add_or_update_server (this->server_name_.c_str (), *options ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - ACE_DEBUG((LM_DEBUG, "Successfully registered <%s>.\n", this->server_name_.c_str ())); - } ACE_CATCH (CORBA::NO_PERMISSION, ex) - { - ACE_ERROR ((LM_ERROR, "No Permission: ImplRepo is in Locked mode\n")); - return TAO_IMR_Op::NO_PERMISSION; - } + { + ACE_ERROR ((LM_ERROR, "No Permission: ImplRepo is in Locked mode\n")); + return TAO_IMR_Op::NO_PERMISSION; + } ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Updating server"); - return TAO_IMR_Op::UNKNOWN; - } + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Updating server"); + return TAO_IMR_Op::UNKNOWN; + } ACE_ENDTRY; return TAO_IMR_Op::NORMAL; |