📄 tao_imr_i.cpp
字号:
// Success
return TAO_IMR_Op::NORMAL;
}
int
TAO_IMR_Op_Autostart::run (void)
{
ImplementationRepository::ServerInformationList_var server_list;
ImplementationRepository::ServerInformationIterator_var server_iter;
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
{
this->imr_locator_->list (0,
server_list,
server_iter
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
// Check for more to be displayed
if (!CORBA::is_nil (server_iter.in ()))
{
int flag = 1;
while (flag)
{
server_iter->next_n (IR_LIST_CHUNK,
server_list
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
CORBA::ULong list_length = server_list->length ();
if (list_length > 0)
{
for (CORBA::ULong i = 0; i < list_length; i++)
{
ACE_TRY_EX (inside)
{
this->imr_locator_->activate_server_in_activator (
server_list[i].server.in (),
server_list[i].startup.activator.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;
}
}
else
{
flag = 0;
}
}
// We are done with the iterator, so it can go away now.
server_iter->destroy ();
} else {
ACE_DEBUG((LM_DEBUG, "There were no servers to start.\n"));
}
}
ACE_CATCHANY
{
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "autostart");
return TAO_IMR_Op::UNKNOWN;
}
ACE_ENDTRY;
return TAO_IMR_Op::NORMAL;
}
int
TAO_IMR_Op_IOR::run (void)
{
// Todo : Most of this logic duplicates that in the POA.cpp
ACE_TRY_NEW_ENV
{
if (CORBA::is_nil (this->imr_locator_)
|| !this->imr_locator_->_stubobj ()
|| !this->imr_locator_->_stubobj ()->profile_in_use ())
{
ACE_ERROR_RETURN ((
LM_ERROR,
ACE_TEXT ("Invalid ImR Locator IOR\n")
),
-1
);
}
CORBA::String_var imr_str =
this->imr_locator_->_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);
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_locator_->_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_DEBUG ((LM_DEBUG, "%s\n", ior.c_str ()));
if (this->filename_.length () > 0)
{
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_CATCHANY
{
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Ior");
return TAO_IMR_Op::UNKNOWN;
}
ACE_ENDTRY;
return TAO_IMR_Op::NORMAL;
}
int
TAO_IMR_Op_List::run (void)
{
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_locator_->list (IR_LIST_CHUNK,
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]);
// Check for more to be displayed
if (!CORBA::is_nil (server_iter.in ()))
{
int flag = 1;
while (flag)
{
server_iter->next_n (IR_LIST_CHUNK,
server_list
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
CORBA::ULong list_length = server_list->length ();
if (list_length > 0)
{
for (CORBA::ULong i = 0; i < list_length; i++)
this->display_server_information (server_list[i]);
}
else
{
flag = 0;
}
}
// We are done with the iterator, so it can go away now.
server_iter->destroy ();
}
}
else
{
ImplementationRepository::ServerInformation_var server_information;
this->imr_locator_->find (this->server_name_.c_str (), server_information ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
this->verbose_server_information_ = 1;
this->display_server_information (server_information.in ());
}
}
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_ENDTRY;
return TAO_IMR_Op::NORMAL;
}
int
TAO_IMR_Op_Remove::run (void)
{
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
{
if (this->activator_.length() == 0)
{
this->imr_locator_->remove_server (this->server_name_.c_str ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
}
else
{
this->imr_locator_->remove_server_in_activator (
this->server_name_.c_str (),
this->activator_.c_str ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
}
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_CATCH (CORBA::NO_PERMISSION, ex)
{
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_ENDTRY;
// Success
return TAO_IMR_Op::NORMAL;
}
int
TAO_IMR_Op_Shutdown::run (void)
{
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
{
if (this->activator_.length() == 0)
{
this->imr_locator_->shutdown_server (this->server_name_.c_str ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
}
else
{
this->imr_locator_->shutdown_server_in_activator (
this->server_name_.c_str (),
this->activator_.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_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, "Shutting Down Server");
return TAO_IMR_Op::UNKNOWN;
}
ACE_ENDTRY;
// Success
return TAO_IMR_Op::NORMAL;
}
int
TAO_IMR_Op_Update::run (void)
{
ImplementationRepository::ServerInformation_var server_information;
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
{
if (this->activator_.length() == 0) {
this->imr_locator_->find(this->server_name_.c_str (),
server_information.out() ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
} else {
this->imr_locator_->find_in_activator (this->server_name_.c_str (),
this->activator_.c_str(),
server_information.out() ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
}
// Conditionally update the startup options
if (this->set_command_line_ == 1)
server_information->startup.command_line =
CORBA::string_dup (this->command_line_.c_str ());
if (this->set_environment_vars_ == 1)
server_information->startup.environment = this->environment_vars_;
if (this->set_working_dir_ == 1)
server_information->startup.working_directory =
CORBA::string_dup (this->working_dir_.c_str ());
if (this->set_activation_ == 1)
server_information->startup.activation = this->activation_;
// @@ Add logical server support here also
this->imr_locator_->reregister_server (this->server_name_.c_str (),
server_information->startup
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
// Now that we've reregistered the server, update the server
// information before we display it.
this->imr_locator_->find(this->server_name_.c_str (),
server_information.out() ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
this->display_server_information (server_information.in ());
}
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_CATCH (CORBA::NO_PERMISSION, ex)
{
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_ENDTRY;
// Success
return TAO_IMR_Op::NORMAL;
}
// ============================================================================
// = Display Server Information methods
void
TAO_IMR_Op_List::display_server_information (const ImplementationRepository::ServerInformation &info)
{
if (this->verbose_server_information_)
TAO_IMR_Op::display_server_information (info);
else
ACE_DEBUG ((LM_DEBUG, "<%s>\n", info.server.in ()));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -