summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-06-20 02:10:32 +0000
committerbrunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-06-20 02:10:32 +0000
commit3f928a2527f3dbce95cce8ae483e1f049e54de59 (patch)
tree4ec8317664aba76f38c5908506711d08e735f6ec
parent04b78bbd4237493c6c6075747bab88edb9114596 (diff)
downloadATCD-3f928a2527f3dbce95cce8ae483e1f049e54de59.tar.gz
tao_ir is working, listing is functions, let the fun begin!
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/ImplRepo.cpp25
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.cpp247
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.h7
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Repository.cpp18
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Repository.h15
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/tao_ir.dsp13
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/tao_ir_i.cpp606
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/tao_ir_i.h150
8 files changed, 836 insertions, 245 deletions
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImplRepo.cpp b/TAO/orbsvcs/ImplRepo_Service/ImplRepo.cpp
index 5a50e899fef..033ad9be7ab 100644
--- a/TAO/orbsvcs/ImplRepo_Service/ImplRepo.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/ImplRepo.cpp
@@ -12,34 +12,33 @@ main (int argc, char *argv[])
ACE_DEBUG ((LM_DEBUG, "TAO Implementation Repository\n"));
- TAO_TRY
+ ACE_DECLARE_NEW_CORBA_ENV;
+ ACE_TRY
{
- if (server.init (argc, argv, TAO_TRY_ENV) == -1)
+ if (server.init (argc, argv, ACE_TRY_ENV) == -1)
return 1;
else
{
- server.run (TAO_TRY_ENV);
- TAO_CHECK_ENV;
+ server.run (ACE_TRY_ENV);
+ ACE_TRY_CHECK;
}
}
- TAO_CATCH (CORBA::SystemException, sysex)
+ ACE_CATCH (CORBA::SystemException, sysex)
{
- ACE_UNUSED_ARG (sysex);
- TAO_TRY_ENV.print_exception ("System Exception");
+ ACE_PRINT_EXCEPTION (sysex, "System Exception");
return -1;
}
- TAO_CATCH (CORBA::UserException, userex)
+ ACE_CATCH (CORBA::UserException, userex)
{
- ACE_UNUSED_ARG (userex);
- TAO_TRY_ENV.print_exception ("User Exception");
+ ACE_PRINT_EXCEPTION (userex, "User Exception");
return -1;
}
- TAO_CATCHANY
+ ACE_CATCHANY
{
- TAO_TRY_ENV.print_exception ("Unknown Exception");
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Unknown Exception");
return -1;
}
- TAO_ENDTRY;
+ ACE_ENDTRY;
return 0;
}
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.cpp b/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.cpp
index 4c5fc4e5456..4c5473bf9bd 100644
--- a/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.cpp
@@ -6,6 +6,8 @@
#include "ace/Read_Buffer.h"
#include "ace/Process.h"
#include "tao/IIOP_Profile.h"
+//#include "ace/Hash_Map_Manager.h"
+#include "ace/Auto_Ptr.h"
// Constructor
@@ -24,50 +26,50 @@ ImplRepo_i::activate_server (const char *server,
CORBA::Environment &ACE_TRY_ENV)
{
int start = 0;
- ACE_TString ping_ior, host;
+ ACE_TString server_object_ior, host;
unsigned short port;
if (OPTIONS::instance()->debug () >= 1)
ACE_DEBUG ((LM_DEBUG, "Activating Server: %s\n", server));
// Find out if it is already running
- if (this->repository_.get_running_info (server, host, port, ping_ior) != 0)
+ if (this->repository_.get_running_info (server, host, port, server_object_ior) != 0)
{
- // If we had problems getting the ping_ior, probably meant that
+ // If we had problems getting the server_object_ior, probably meant that
// there is no <server> registered
ACE_ERROR ((LM_ERROR,
- "Error: Cannot find ping IOR for server <%s>\n",
+ "Error: Cannot find ServerObject IOR for server <%s>\n",
server));
ACE_THROW (ImplementationRepository::Administration::NotFound ());
}
- // Check to see if there is one running (if there is a ping_ior)
- if (ping_ior.length () != 0)
+ // Check to see if there is one running (if there is a server_object_ior)
+ if (server_object_ior.length () != 0)
{
// It is running
ACE_TRY
{
CORBA::Object_var object =
- this->orb_manager_.orb ()->string_to_object (ping_ior.c_str (),
+ this->orb_manager_.orb ()->string_to_object (server_object_ior.c_str (),
ACE_TRY_ENV);
ACE_TRY_CHECK;
- // We shouldn't have to narrow.
+ // @@ We shouldn't have to narrow.
- ImplementationRepository::ServerObject_var ping_object =
+ ImplementationRepository::ServerObject_var server_object =
ImplementationRepository::ServerObject::_narrow (object.in (), ACE_TRY_ENV);
ACE_TRY_CHECK;
- if (CORBA::is_nil (ping_object.in ()))
+ if (CORBA::is_nil (server_object.in ()))
{
ACE_ERROR ((LM_ERROR,
- "Error: Invalid Ping Object ior: <%s>\n",
- ping_ior));
+ "Error: Invalid ServerObject IOR: <%s>\n",
+ server_object_ior));
ACE_THROW (ImplementationRepository::Administration::NotFound ());
}
// Check to see if we can ping it
- ping_object->ping (ACE_TRY_ENV);
+ server_object->ping (ACE_TRY_ENV);
ACE_TRY_CHECK;
}
ACE_CATCHANY
@@ -163,7 +165,7 @@ ImplRepo_i::activate_server (const char *server,
// Now it should be started.
}
- if (this->repository_.get_running_info (server, host, port, ping_ior) != 0)
+ if (this->repository_.get_running_info (server, host, port, server_object_ior) != 0)
{
ACE_ERROR ((LM_ERROR,
"ImplRepo_i::activate_server: "
@@ -285,11 +287,11 @@ ImplRepo_i::server_is_running (const char * server,
// Update the record in the repository
- // Get the stringified ping_ior
- ASYS_TCHAR *ping_ior = this->orb_manager_.orb ()->object_to_string (server_object, ACE_TRY_ENV);
+ // Get the stringified server_object_ior
+ ASYS_TCHAR *server_object_ior = this->orb_manager_.orb ()->object_to_string (server_object, ACE_TRY_ENV);
ACE_CHECK_RETURN (0);
- if (this->repository_.update (server, addr.host.in (), addr.port, ping_ior) == 0)
+ if (this->repository_.update (server, addr.host.in (), addr.port, server_object_ior) == 0)
{
if (OPTIONS::instance()->debug () >= 1)
ACE_DEBUG ((LM_DEBUG,
@@ -342,6 +344,8 @@ ImplRepo_i::server_is_shutting_down (const char *server,
}
}
+
+
int
ImplRepo_i::init (int argc, char **argv, CORBA::Environment &ACE_TRY_ENV)
{
@@ -370,8 +374,10 @@ ImplRepo_i::init (int argc, char **argv, CORBA::Environment &ACE_TRY_ENV)
this),
-1);
- CORBA::String_var str =
- this->orb_manager_.activate (this->forwarder_impl_);
+ CORBA::String_var str =
+ this->orb_manager_.activate (this->forwarder_impl_, ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
if (OPTIONS::instance()->debug () >= 2)
ACE_DEBUG ((LM_DEBUG,
"The server IOR is: <%s>\n",
@@ -417,7 +423,7 @@ ImplRepo_i::init (int argc, char **argv, CORBA::Environment &ACE_TRY_ENV)
}
ACE_CATCHANY
{
- ACE_TRY_ENV.print_exception ("Server_i::init");
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Server_i::init");
ACE_RETHROW;
}
ACE_ENDTRY;
@@ -439,10 +445,10 @@ ImplRepo_i::run (CORBA::Environment& env)
CORBA::String
ImplRepo_i::get_forward_host (const char *server)
{
- ACE_TString host, ping_ior;
+ ACE_TString host, server_object_ior;
unsigned short port;
- if (this->repository_.get_running_info (server, host, port, ping_ior) != 0)
+ if (this->repository_.get_running_info (server, host, port, server_object_ior) != 0)
return 0;
return CORBA::string_dup (host.c_str ());
@@ -451,10 +457,10 @@ ImplRepo_i::get_forward_host (const char *server)
CORBA::UShort
ImplRepo_i::get_forward_port (const char *server)
{
- ACE_TString host, ping_ior;
+ ACE_TString host, server_object_ior;
unsigned short port;
- if (this->repository_.get_running_info (server, host, port, ping_ior) != 0)
+ if (this->repository_.get_running_info (server, host, port, server_object_ior) != 0)
return 0;
return port;
@@ -470,6 +476,42 @@ ImplRepo_i::~ImplRepo_i (void)
}
+// Returns the startup information for a server
+
+void
+ImplRepo_i::find (const char * server,
+ ImplementationRepository::ServerInformation_out info,
+ CORBA::Environment &ACE_TRY_ENV)
+{
+ ACE_TString logical, command_line, working_directory;
+ ACE_TString host, server_object_ior;
+ unsigned short port;
+
+ ACE_NEW_THROW_EX (info,
+ ImplementationRepository::ServerInformation,
+ CORBA::NO_MEMORY (CORBA::COMPLETED_NO));
+ ACE_CHECK;
+
+ // Get the information from the server repository.
+ if (this->repository_.get_startup_info (server,
+ logical,
+ command_line,
+ working_directory) != 0)
+ ACE_THROW (ImplementationRepository::Administration::NotFound ());
+
+ if (this->repository_.get_running_info (server, host, port, server_object_ior) != 0)
+ ACE_THROW (ImplementationRepository::Administration::NotFound ());
+
+ // Fill in <info>.
+ info->logical_server = CORBA::string_dup (logical.c_str ());
+ info->server = CORBA::string_dup (server);
+ info->startup.command_line = CORBA::string_dup (command_line.c_str ());
+ info->startup.working_directory = CORBA::string_dup (working_directory.c_str ());
+ info->location.host = CORBA::string_dup (host.c_str ());
+ info->location.port = port;
+}
+
+
// Used to access the list of servers registered. May also return an
// iterator which can be used to access more than <how_many> of them.
@@ -479,7 +521,7 @@ ImplRepo_i::list (CORBA::ULong how_many,
ImplementationRepository::ServerInformationIterator_out server_iterator,
CORBA::Environment &ACE_TRY_ENV)
{
- // Initialize the out varaibles, so if we return early, they will
+ // Initialize the out variables, so if we return early, they will
// not be dangling.
server_iterator =
ImplementationRepository::ServerInformationIterator::_nil ();
@@ -490,10 +532,10 @@ ImplRepo_i::list (CORBA::ULong how_many,
ACE_CHECK;
// Get a new iterator
- Server_Repository::HASH_IR_ITER *hash_iter = this->repository_.new_iterator ();
+ auto_ptr<Server_Repository::HASH_IR_ITER> server_iter = this->repository_.new_iterator ();
// Check for a memory error.
- if (hash_iter == 0)
+ if (server_iter.get () == 0)
{
ACE_THROW (CORBA::NO_MEMORY (CORBA::COMPLETED_NO));
ACE_CHECK;
@@ -506,49 +548,61 @@ ImplRepo_i::list (CORBA::ULong how_many,
n = how_many;
else
n = this->repository_.get_repository_size ();
+
+ // Now copy over to the server list.
+ server_list->length (n);
-/*
- // A pointer to BindingIterator servant.
- TAO_Hash_Binding_Iterator *bind_iter = 0;
-
- // Use hash iterator to populate a BindingList with bindings.
- bl->length (n);
+ Server_Repository::HASH_IR_ENTRY *server_entry;
- Server_Repository::HASH_IR_ENTRY *hash_entry;
+ if (OPTIONS::instance()->debug () >= 2)
+ ACE_DEBUG ((LM_DEBUG, "list: Filling ServerList with %d servers\n", n));
for (CORBA::ULong i = 0; i < n; i++)
{
- hash_iter->next (hash_entry);
- hash_iter->advance ();
+ server_iter->next (server_entry);
+ server_iter->advance ();
- if (populate_binding (hash_entry, bl[i]) == 0)
- {
- delete hash_iter;
- ACE_THROW (CORBA::NO_MEMORY(CORBA::COMPLETED_NO));
- }
+ ACE_TString logical, server, command_line, working_directory, host, server_ior;
+ unsigned short port;
+
+ server_entry->int_id_->get_running_info (host, port, server_ior);
+ server_entry->int_id_->get_startup_info (logical, command_line, working_directory);
+
+ server_list[i].logical_server = CORBA::string_dup (logical.c_str ());
+ server_list[i].server = CORBA::string_dup (server_entry->ext_id_.c_str ());
+ server_list[i].startup.command_line = CORBA::string_dup (command_line.c_str ());
+ server_list[i].startup.working_directory = CORBA::string_dup (working_directory.c_str ());
+ server_list[i].location.host = CORBA::string_dup (host.c_str ());
+ server_list[i].location.port = port;
}
- // Now we are done with the BindingsList, and we can follow up on
- // the iterator business.
- // If we do not need to pass back BindingIterator.
- if (this->context_.current_size () <= how_many)
- delete hash_iter;
- else
+ // Now work on the iterator
+
+ // Only set up an iterator if we need to
+ if (this->repository_.get_repository_size () > how_many)
{
- // Create a BindingIterator for return.
+ if (OPTIONS::instance()->debug () >= 2)
+ ACE_DEBUG ((LM_DEBUG, "list: Creating ServerInformationIterator\n"));
- bind_iter = new TAO_Hash_Binding_Iterator (hash_iter, this->poa_.in (), this->lock_);
- if (bind_iter == 0)
- {
- delete hash_iter;
- ACE_THROW (CORBA::NO_MEMORY (CORBA::COMPLETED_NO));
- }
+ // Create an ir_iter and give it the server_iter pointer
+ IR_Iterator *ir_iter;
+
+ // @@ The iterator object should be put in their own POA (a transient poa)
+ ACE_NEW_THROW_EX (ir_iter,
+ IR_Iterator (server_iter.release (), this->orb_manager_.root_poa ()),
+ CORBA::NO_MEMORY (CORBA::COMPLETED_NO));
+ ACE_CHECK;
ACE_TRY
{
- char poa_id[BUFSIZ];
+ CORBA::String_var str =
+ this->orb_manager_.activate (ir_iter, ACE_TRY_ENV)
+ ACE_TRY_CHECK;
+ /*
+
+ char poa_id[BUFSIZ];
ACE_OS::sprintf (poa_id,
"%s_%ld",
this->poa_id_.c_str (),
@@ -563,17 +617,17 @@ ImplRepo_i::list (CORBA::ULong how_many,
ACE_TRY_CHECK;
bi = bind_iter->_this (ACE_TRY_ENV);
+ ACE_TRY_CHECK;*/
+ server_iterator = ir_iter->_this (ACE_TRY_ENV);
ACE_TRY_CHECK;
-
}
ACE_CATCHANY
{
- delete bind_iter;
ACE_RETHROW;
}
ACE_ENDTRY;
ACE_CHECK;
- }*/
+ }
}
@@ -659,7 +713,7 @@ IR_Adapter_Activator::unknown_adapter (PortableServer::POA_ptr parent,
ACE_CATCHANY
{
ACE_ERROR ((LM_ERROR, "IR_Adapter_Activator::unknown_adapter - %s\n", exception_message));
- ACE_TRY_ENV.print_exception ("SYS_EX");
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "System Exception");
return 0;
}
ACE_ENDTRY;
@@ -696,6 +750,7 @@ IR_Forwarder::invoke (CORBA::ServerRequest_ptr /* request */,
TAO_ORB_Core *orb_core = TAO_ORB_Core_instance ();
TAO_POA_Current *poa_current = orb_core->poa_current ();
+ // @@ This is not the way this should be done.
if (ACE_TRY_ENV.exception () != 0)
{
ACE_TRY_ENV.print_exception ("PortableServer::Current::_narrow");
@@ -779,50 +834,48 @@ IR_Iterator::next_n (CORBA::ULong how_many,
ImplementationRepository::ServerInformationList_out server_list,
CORBA::Environment &ACE_TRY_ENV)
{
-/* // We perform an allocation before obtaining the lock so that an out
-// parameter is allocated in case we fail to obtain the lock.
-ACE_NEW_THROW_EX (bl,
-CosNaming::BindingList (0),
-CORBA::NO_MEMORY (CORBA::COMPLETED_NO));
-ACE_CHECK_RETURN (0);
-// Obtain a lock.
-ACE_GUARD_THROW_EX (ACE_Lock,
-ace_mon,
-*this->lock_,
-CORBA::INTERNAL (CORBA::COMPLETED_NO));
-ACE_CHECK_RETURN (0);
-
+ ACE_NEW_THROW_EX (server_list,
+ ImplementationRepository::ServerInformationList (0),
+ CORBA::NO_MEMORY (CORBA::COMPLETED_NO));
+
// If there are no more bindings...
- if (hash_iter_->done ())
- return 0;
- else
- {
+ if (this->iterator_->done ())
+ return 0; // Return false
+
// Initially assume that iterator has the requested number of
// bindings.
- bl->length (how_many);
+ server_list->length (how_many);
+
+ Server_Repository::HASH_IR_ENTRY *server_entry;
- TAO_Hash_Naming_Context::HASH_MAP::ENTRY *hash_entry;
+ // Iterate and populate the BindingList.
+
+ for (CORBA::ULong i = 0; i < how_many; i++)
+ {
+ this->iterator_->next (server_entry);
- // Iterate and populate the BindingList.
-
- for (CORBA::ULong i = 0; i < how_many; i++)
+ ACE_TString logical, server, command_line, working_directory, host, server_ior;
+ unsigned short port;
+
+ server_entry->int_id_->get_running_info (host, port, server_ior);
+ server_entry->int_id_->get_startup_info (logical, command_line, working_directory);
+
+ server_list[i].logical_server = CORBA::string_dup (logical.c_str ());
+ server_list[i].server = CORBA::string_dup (server_entry->ext_id_.c_str ());
+ server_list[i].startup.command_line = CORBA::string_dup (command_line.c_str ());
+ server_list[i].startup.working_directory = CORBA::string_dup (working_directory.c_str ());
+ server_list[i].location.host = CORBA::string_dup (host.c_str ());
+ server_list[i].location.port = port;
+
+ if (this->iterator_->advance () == 0)
{
- hash_iter_->next (hash_entry);
-
- if (TAO_Hash_Naming_Context::populate_binding (hash_entry, bl[i]) == 0)
- ACE_THROW_RETURN (CORBA::NO_MEMORY (CORBA::COMPLETED_NO), 0);
-
- if (hash_iter_->advance () == 0)
- {
- // If no more bindings left, reset length to the actual
- // number of bindings populated and get out of the loop.
- bl->length (i + 1);
- break;
- }
- }
- return 1;
-}*/
- return 0;
+ // If no more server left, reset length to the actual
+ // number servers and get out of the loop.
+ server_list->length (i + 1);
+ break;
+ }
+ }
+ return 1;
}
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.h b/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.h
index ebfb5e0ed26..ca43e7076e7 100644
--- a/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.h
+++ b/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.h
@@ -101,12 +101,17 @@ public:
ImplementationRepository::ServerObject_ptr server_object,
CORBA::Environment &ACE_TRY_ENV = CORBA::Environment::default_environment ());
// Called by the server to update transient information such as current location of
- // the <server> and its ping object.
+ // the <server> and its ServerObject.
virtual void server_is_shutting_down (const char * server,
CORBA_Environment &ACE_TRY_ENV = CORBA_Environment::default_environment ());
// What the server should call before it shuts down.
+ virtual void find (const char * server,
+ ImplementationRepository::ServerInformation_out info,
+ CORBA::Environment &ACE_TRY_ENV = CORBA::Environment::default_environment ());
+ // Returns the startup information for a server
+
virtual void list (CORBA::ULong how_many,
ImplementationRepository::ServerInformationList_out server_list,
ImplementationRepository::ServerInformationIterator_out server_iterator,
diff --git a/TAO/orbsvcs/ImplRepo_Service/Repository.cpp b/TAO/orbsvcs/ImplRepo_Service/Repository.cpp
index 1d7fa9b552d..dc8578ace17 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Repository.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/Repository.cpp
@@ -21,7 +21,7 @@ Server_Info::Server_Info (const ACE_TString POA_name,
working_dir_ (working_dir),
host_ (""),
port_ (0),
- ping_ior_ ("")
+ server_object_ior_ ("")
{
// Nothing
}
@@ -39,11 +39,11 @@ Server_Info::~Server_Info ()
void
Server_Info::update_running_info (const ACE_TString host,
const unsigned short port,
- const ACE_TString ping_ior)
+ const ACE_TString server_object_ior)
{
this->host_ = host;
this->port_ = port;
- this->ping_ior_ = ping_ior;
+ this->server_object_ior_ = server_object_ior;
}
@@ -65,11 +65,11 @@ Server_Info::get_startup_info (ACE_TString &logical_server_name,
void
Server_Info::get_running_info (ACE_TString &host,
unsigned short &port,
- ACE_TString &ping_ior)
+ ACE_TString &server_object_ior)
{
host = this->host_;
port = this->port_;
- ping_ior = this->ping_ior_;
+ server_object_ior = this->server_object_ior_;
}
// Default Constructor
@@ -103,14 +103,14 @@ int
Server_Repository::update (const ACE_TString POA_name,
const ACE_TString host,
const unsigned short port,
- const ACE_TString ping_ior)
+ const ACE_TString server_object_ior)
{
Server_Info *server;
int retval = this->repository_.find (POA_name, server);
// Only fill in data if it was found
if (retval == 0)
- server->update_running_info (host, port, ping_ior);
+ server->update_running_info (host, port, server_object_ior);
return retval;
}
@@ -141,14 +141,14 @@ int
Server_Repository::get_running_info (const ACE_TString POA_name,
ACE_TString &host,
unsigned short &port,
- ACE_TString &ping_ior)
+ ACE_TString &server_object_ior)
{
Server_Info *server;
int retval = this->repository_.find (POA_name, server);
// Only fill in data if it was found
if (retval == 0)
- server->get_running_info (host, port, ping_ior);
+ server->get_running_info (host, port, server_object_ior);
return retval;
}
diff --git a/TAO/orbsvcs/ImplRepo_Service/Repository.h b/TAO/orbsvcs/ImplRepo_Service/Repository.h
index be6b2a08abf..95936e9c5a0 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Repository.h
+++ b/TAO/orbsvcs/ImplRepo_Service/Repository.h
@@ -49,7 +49,7 @@ public:
void update_running_info (const ACE_TString host,
const unsigned short port,
- const ACE_TString ping_ior);
+ const ACE_TString server_object_ior);
// Updates information that is relevant only when an instance
// of the server is running.
@@ -60,7 +60,7 @@ public:
void get_running_info (ACE_TString &host,
unsigned short &port,
- ACE_TString &ping_ior);
+ ACE_TString &server_object_ior);
// Returns information about a running instance.
// @@ Does this belong here?
@@ -93,14 +93,17 @@ private:
unsigned short port_;
// Current port used by the server.
- ACE_TString ping_ior_;
- // IOR of the ping object in the server.
+ ACE_TString server_object_ior_;
+ // IOR of the server object in the server.
// No copying allowed.
void operator= (Server_Info &);
Server_Info (Server_Info &);
};
+
+
+
class Server_Repository
// = TITLE
// Repository of Server_Infos.
@@ -136,7 +139,7 @@ public:
int update (const ACE_TString POA_name,
const ACE_TString host,
const unsigned short port,
- const ACE_TString ping_ior);
+ const ACE_TString server_object_ior);
// Update the associated process information.
int get_startup_info (const ACE_TString POA_name,
@@ -148,7 +151,7 @@ public:
int get_running_info (const ACE_TString POA_name,
ACE_TString &host,
unsigned short &port,
- ACE_TString &ping_ior);
+ ACE_TString &server_object_ior);
// Returns information related to a running copy.
int starting_up (const ACE_TString POA_name, int new_value);
diff --git a/TAO/orbsvcs/ImplRepo_Service/tao_ir.dsp b/TAO/orbsvcs/ImplRepo_Service/tao_ir.dsp
index 516a8b2165c..5836bf0aec3 100644
--- a/TAO/orbsvcs/ImplRepo_Service/tao_ir.dsp
+++ b/TAO/orbsvcs/ImplRepo_Service/tao_ir.dsp
@@ -39,6 +39,7 @@ RSC=rc.exe
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\\" /I "..\..\\" /I "..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
@@ -49,8 +50,8 @@ BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 ace.lib TAO.lib orbsvcs.lib /nologo /subsystem:console /machine:I386 /libpath:"..\orbsvcs" /libpath:"..\..\tao" /libpath:"..\..\..\ace"
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 ace.lib TAO.lib orbsvcs.lib /nologo /subsystem:console /machine:I386 /out:"../../../bin/Release/tao_ir.exe" /libpath:"..\orbsvcs" /libpath:"..\..\tao" /libpath:"..\..\..\ace"
!ELSEIF "$(CFG)" == "tao_ir - Win32 Debug"
@@ -65,8 +66,8 @@ LINK32=link.exe
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\\" /I "..\..\\" /I "..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\\" /I "..\..\\" /I "..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
@@ -74,8 +75,8 @@ BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 aced.lib TAOd.lib orbsvcsd.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\orbsvcs" /libpath:"..\..\tao" /libpath:"..\..\..\ace"
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 aced.lib TAOd.lib orbsvcsd.lib /nologo /subsystem:console /debug /machine:I386 /out:"../../../bin/tao_ir.exe" /pdbtype:sept /libpath:"..\orbsvcs" /libpath:"..\..\tao" /libpath:"..\..\..\ace"
!ENDIF
diff --git a/TAO/orbsvcs/ImplRepo_Service/tao_ir_i.cpp b/TAO/orbsvcs/ImplRepo_Service/tao_ir_i.cpp
index 335d6f005d8..f05f0c1178a 100644
--- a/TAO/orbsvcs/ImplRepo_Service/tao_ir_i.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/tao_ir_i.cpp
@@ -4,11 +4,17 @@
#include "ace/Get_Opt.h"
#include "ace/Read_Buffer.h"
-ACE_RCSID(ImplRepo_Service, tao_ir_i, "$Id")
+ACE_RCSID(ImplRepo_Service, tao_ir_i, "$Id:")
+
+// How many servers should we get at once?
+const size_t IR_LIST_CHUNK = 4;
+
// Constructor
TAO_IR_i::TAO_IR_i (void)
+: implrepo_ (ImplementationRepository::Administration::_nil ()),
+ op_ (0)
{
// Nothing
}
@@ -18,13 +24,19 @@ TAO_IR_i::TAO_IR_i (void)
TAO_IR_i::~TAO_IR_i (void)
{
- // Nothing
+ delete this->op_;
}
int
TAO_IR_i::run ()
{
- return 0;
+ if (this->op_ == 0)
+ {
+ ACE_ERROR ((LM_ERROR, "Unknown operation"));
+ return -1;
+ }
+
+ return this->op_->run ();
}
int
@@ -33,6 +45,8 @@ TAO_IR_i::init (int argc, char **argv)
this->argc_ = argc;
this->argv_ = argv;
+ const char *exception_message = "Null Message";
+
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
{
@@ -43,14 +57,31 @@ TAO_IR_i::init (int argc, char **argv)
ACE_TRY_ENV);
ACE_TRY_CHECK;
+ // Get the ImplRepo object
+
+ CORBA::Object_var implrepo_object =
+ orb_->resolve_initial_references ("ImplRepoService");
+
+ if (CORBA::is_nil (implrepo_object.in ()))
+ {
+ ACE_ERROR ((LM_ERROR,
+ "Unable to resolve the Implementation Repository.\n"));
+ ACE_OS::exit (-1);
+ }
+
+ exception_message = "While narrowing ImplRepo";
+ this->implrepo_ =
+ ImplementationRepository::Administration::_narrow (implrepo_object.in(), ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
// Parse command line and verify parameters.
if (this->parse_args () == -1)
return -1;
-
}
ACE_CATCHANY
{
- ACE_TRY_ENV.print_exception ("TAO_IR_i::init");
+ ACE_ERROR ((LM_ERROR, "TAO_IR_i::init - %s\n", exception_message));
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Exception");
return -1;
}
ACE_ENDTRY;
@@ -64,78 +95,163 @@ TAO_IR_i::init (int argc, char **argv)
int
TAO_IR_i::parse_args (void)
{
+ // Make sure one command was given
if (this->argc_ < 2)
{
- this->print_usage (ALL);
+ this->print_usage ();
return -1;
}
- // Figure out which command we are doing
-
- if (ACE_OS::strcasecmp (this->argv_[1], ASYS_TEXT ("add")) == 0)
- {
- // Check for enough arguments (we need 3 for program name, "add",
- // and the server name to add)
- if (this->argc_ < 3)
- {
- this->print_usage (ADD);
- return -1;
- }
+ this->op_ = TAO_IR_Op::make_op (this->argv_[1], this->implrepo_);
+
+ // Check for unrecognized operation
- // Parse the rest of the arguments
- return this->parse_add_args ();
- }
- else if (ACE_OS::strcasecmp (this->argv_[1], ASYS_TEXT ("remove")) == 0)
- {
- if (this->argc_ < 3)
- {
- this->print_usage (REMOVE);
- return -1;
- }
- }
- else if (ACE_OS::strcasecmp (this->argv_[1], ASYS_TEXT ("update")) == 0)
+ if (this->op_ == 0)
{
- if (this->argc_ < 3)
- {
- this->print_usage (UPDATE);
- return -1;
- }
+ ACE_ERROR ((LM_ERROR, "ERROR: Unrecognized command: <%s>\n", this->argv_[1]));
+ this->print_usage ();
+ return -1;
}
- else if (ACE_OS::strcasecmp (this->argv_[1], ASYS_TEXT ("list")) == 0)
- {
- this->parse_list_args ();
- }
+ // Adjust argc and argv so only the command specific args are passed
+ return this->op_->parse (this->argc_ - 2, this->argv_ + 2);
+}
+
+
+// Print out information about all operations.
+
+void
+TAO_IR_i::print_usage (void)
+{
+ ACE_ERROR ((LM_ERROR, "Usage: tao_ir [options] command [command-arguments]\n"));
+ ACE_ERROR ((LM_ERROR, " where [options] are ORB options\n"));
+ ACE_ERROR ((LM_ERROR, " where command is one of the following:\n"));
+ ACE_ERROR ((LM_ERROR, " add Add an entry to the IR\n"));
+ ACE_ERROR ((LM_ERROR, " remove Remove an entry from the IR\n"));
+ ACE_ERROR ((LM_ERROR, " update Update an entry in the IR\n"));
+ ACE_ERROR ((LM_ERROR, " list List the entries in the IR\n"));
+ ACE_ERROR ((LM_ERROR, " where [command-arguments] depend on the command\n"));
+}
+
- // Indicates successful parsing of command line.
+// Factory for operations
+
+TAO_IR_Op *
+TAO_IR_Op::make_op (const ASYS_TCHAR *op_name, ImplementationRepository::Administration_ptr ir)
+{
+ if (ACE_OS::strcasecmp (op_name, ASYS_TEXT ("add")) == 0)
+ return new TAO_IR_Op_Add (ir);
+ else if (ACE_OS::strcasecmp (op_name, ASYS_TEXT ("list")) == 0)
+ return new TAO_IR_Op_List (ir);
+ else if (ACE_OS::strcasecmp (op_name, ASYS_TEXT ("remove")) == 0)
+ return new TAO_IR_Op_Remove (ir);
+ else if (ACE_OS::strcasecmp (op_name, ASYS_TEXT ("update")) == 0)
+ return new TAO_IR_Op_Update (ir);
+
return 0;
}
+
+
+// ============================================================================
+// = Constructors.
+
+
+TAO_IR_Op::TAO_IR_Op (ImplementationRepository::Administration_ptr implrepo)
+: implrepo_ (implrepo)
+{
+ // Nothing
+}
+
+TAO_IR_Op_Add::TAO_IR_Op_Add (ImplementationRepository::Administration_ptr implrepo)
+: TAO_IR_Op (implrepo)
+{
+ // Nothing
+}
+
+TAO_IR_Op_List::TAO_IR_Op_List (ImplementationRepository::Administration_ptr implrepo)
+: TAO_IR_Op (implrepo),
+ verbose_server_information_ (0)
+{
+ // Nothing
+}
+
+TAO_IR_Op_Remove::TAO_IR_Op_Remove (ImplementationRepository::Administration_ptr implrepo)
+: TAO_IR_Op (implrepo)
+{
+ // Nothing
+}
+TAO_IR_Op_Update::TAO_IR_Op_Update (ImplementationRepository::Administration_ptr implrepo)
+: TAO_IR_Op (implrepo),
+ set_command_line_ (0),
+ set_working_dir_ (0)
+{
+ // Nothing
+}
+
+
+// ============================================================================
+// = Virtual Destructors.
+
+
+TAO_IR_Op::~TAO_IR_Op ()
+{
+ // Nothing
+}
+
+TAO_IR_Op_Add::~TAO_IR_Op_Add (void)
+{
+ // Nothing
+}
+
+TAO_IR_Op_List::~TAO_IR_Op_List (void)
+{
+ // Nothing
+}
+
+TAO_IR_Op_Remove::~TAO_IR_Op_Remove (void)
+{
+ // Nothing
+}
+
+TAO_IR_Op_Update::~TAO_IR_Op_Update (void)
+{
+ // Nothing
+}
+
+
+// ============================================================================
+// = Parse methods
-// Look at the arguments assuming that it is an add command.
int
-TAO_IR_i::parse_add_args ()
+TAO_IR_Op_Add::parse (int argc, ASYS_TCHAR **argv)
{
- // Skip both the program name and the "add" command
- ACE_Get_Opt get_opts (this->argc_ - 2, this->argv_ + 2, "hc:w:");
+ // Check for enough arguments (we need at least one for the server name)
+ if (argc < 1)
+ {
+ this->print_usage ();
+ return -1;
+ }
- ACE_DEBUG ((LM_DEBUG, "Server name: %s\n", this->argv_[2]));
+ // Skip both the program name and the "add" command
+ ACE_Get_Opt get_opts (argc, argv, "hc:w:");
+ this->server_name_ = argv[0];
int c;
while ((c = get_opts ()) != -1)
switch (c)
{
case 'c': // Command line arguments
- ACE_DEBUG ((LM_DEBUG, "Command line argument: %s\n", get_opts.optarg));
+ this->command_line_ = get_opts.optarg;
break;
case 'w': // Working Directory
- ACE_DEBUG ((LM_DEBUG, "Working directory: %s\n", get_opts.optarg));
+ this->working_dir_ = get_opts.optarg;
break;
case 'h': // display help
default:
- this->print_usage (ADD);
+ this->print_usage ();
return -1;
}
@@ -143,24 +259,31 @@ TAO_IR_i::parse_add_args ()
return 0;
}
-// Look at the arguments assuming that it is an list command.
-
int
-TAO_IR_i::parse_list_args ()
+TAO_IR_Op_List::parse (int argc, ASYS_TCHAR **argv)
{
+ int server_flag = 0;
+
+ if (argc > 0 && argv[0][0] != '-')
+ {
+ this->server_name_ = argv[0];
+ server_flag = 1;
+ }
+
// Skip both the program name and the "list" command
- // We specify 0 as the 4th argument so it will look at the first
- // argv.
- ACE_Get_Opt get_opts (this->argc_ - 2, this->argv_ + 2, "h", 0);
+ ACE_Get_Opt get_opts (argc, argv, "vh", server_flag);
int c;
while ((c = get_opts ()) != -1)
switch (c)
{
+ case 'v': // verbose server display
+ this->verbose_server_information_ = 1;
+ break;
case 'h': // display help
default:
- this->print_usage (LIST);
+ this->print_usage ();
return -1;
}
@@ -168,54 +291,339 @@ TAO_IR_i::parse_list_args ()
return 0;
}
+int
+TAO_IR_Op_Remove::parse (int argc, ASYS_TCHAR **argv)
+{
+ // Check for enough arguments (we need at least one for the server name)
+ if (argc < 1)
+ {
+ this->print_usage ();
+ return -1;
+ }
+
+ // Skip both the program name and the "add" command
+ ACE_Get_Opt get_opts (argc, argv, "h");
-// Print out information about an operation.
+ this->server_name_ = argv[0];
+ int c;
-void
-TAO_IR_i::print_usage (Operation op)
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'h': // display help
+ default:
+ this->print_usage ();
+ return -1;
+ }
+
+ // Success
+ return 0;
+}
+
+int
+TAO_IR_Op_Update::parse (int argc, ASYS_TCHAR **argv)
{
- switch (op)
+ // Check for enough arguments (we need at least one for the server name)
+ if (argc < 1)
{
- case ADD:
- ACE_ERROR ((LM_ERROR, "Usage: tao_ir [options] add <name> [command-arguments]\n"));
- ACE_ERROR ((LM_ERROR, " where [options] are ORB options\n"));
- ACE_ERROR ((LM_ERROR, " where <name> is the POA name used by the server object\n"));
- ACE_ERROR ((LM_ERROR, " where [command-arguments] can be\n"));
- ACE_ERROR ((LM_ERROR, " -h Displays this\n"));
- ACE_ERROR ((LM_ERROR, " -c command Startup command\n"));
- ACE_ERROR ((LM_ERROR, " -w dir Working directory\n"));
- break;
- case REMOVE:
- ACE_ERROR ((LM_ERROR, "Usage: tao_ir [options] remove <name> [command-arguments]\n"));
- ACE_ERROR ((LM_ERROR, " where [options] are ORB options\n"));
- ACE_ERROR ((LM_ERROR, " where <name> is the POA name used by the server object\n"));
- ACE_ERROR ((LM_ERROR, " where [command-arguments] can be\n"));
- ACE_ERROR ((LM_ERROR, " -h Displays this\n"));
- break;
- case UPDATE:
- ACE_ERROR ((LM_ERROR, "Usage: tao_ir [options] update <name> [command-arguments]\n"));
- ACE_ERROR ((LM_ERROR, " where [options] are ORB options\n"));
- ACE_ERROR ((LM_ERROR, " where <name> is the POA name used by the server object\n"));
- ACE_ERROR ((LM_ERROR, " where [command-arguments] can be\n"));
- ACE_ERROR ((LM_ERROR, " -h Displays this\n"));
- ACE_ERROR ((LM_ERROR, " -c command Startup command\n"));
- ACE_ERROR ((LM_ERROR, " -w dir Working directory\n"));
- break;
- case LIST:
- ACE_ERROR ((LM_ERROR, "Usage: tao_ir [options] list [command-arguments]\n"));
- ACE_ERROR ((LM_ERROR, " where [options] are ORB options\n"));
- ACE_ERROR ((LM_ERROR, " where [command-arguments] can be\n"));
- ACE_ERROR ((LM_ERROR, " -h Displays this\n"));
- break;
- default:
- ACE_ERROR ((LM_ERROR, "Usage: tao_ir [options] command [command-arguments]\n"));
- ACE_ERROR ((LM_ERROR, " where [options] are ORB options\n"));
- ACE_ERROR ((LM_ERROR, " where command is one of the following:\n"));
- ACE_ERROR ((LM_ERROR, " add Add an entry to the IR\n"));
- ACE_ERROR ((LM_ERROR, " remove Remove an entry from the IR\n"));
- ACE_ERROR ((LM_ERROR, " update Update an entry in the IR\n"));
- ACE_ERROR ((LM_ERROR, " list List the entries in the IR\n"));
- ACE_ERROR ((LM_ERROR, " where [command-arguments] depend on the command\n"));
- break;
+ this->print_usage ();
+ return -1;
}
+
+ // Skip both the program name and the "add" command
+ ACE_Get_Opt get_opts (argc, argv, "hc:w:");
+
+ this->server_name_ = argv[0];
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'c': // Command line arguments
+ this->set_command_line_ = 1;
+ this->command_line_ = get_opts.optarg;
+ break;
+ case 'w': // Working Directory
+ this->set_working_dir_ = 1;
+ this->working_dir_ = get_opts.optarg;
+ break;
+ case 'h': // display help
+ default:
+ this->print_usage ();
+ return -1;
+ }
+
+ // Success
+ return 0;
+}
+
+
+// ============================================================================
+// = Run methods
+
+
+int
+TAO_IR_Op_Add::run (void)
+{
+ ImplementationRepository::StartupOptions startup_options;
+
+ startup_options.command_line = CORBA::string_dup (this->command_line_.c_str ());
+ // @@ add environment
+ startup_options.working_directory = CORBA::string_dup (this->working_dir_.c_str ());
+
+ ACE_DECLARE_NEW_CORBA_ENV;
+ ACE_TRY
+ {
+ this->implrepo_->register_server (this->server_name_.c_str (), startup_options, ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ ACE_DEBUG ((LM_DEBUG, "Successfully registered server <%s>\n", this->server_name_.c_str ()));
+ }
+ ACE_CATCH (ImplementationRepository::Administration::AlreadyRegistered, ex)
+ {
+ ACE_ERROR ((LM_ERROR, "Server <%s> already registered!\n", this->server_name_.c_str ()));
+ return -1;
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Adding server");
+ return -1;
+ }
+ ACE_ENDTRY;
+
+ // Success
+ return 0;
+}
+
+int
+TAO_IR_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->implrepo_->list (IR_LIST_CHUNK, server_list, server_iter, ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ for (size_t 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)
+ {
+ flag = server_iter->next_n (IR_LIST_CHUNK, server_list, ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ for (size_t i = 0; i < server_list->length (); i++)
+ this->display_server_information (server_list[i]);
+ }
+
+ // We are done with the iterator, so it can go away now.
+ server_iter->destroy ();
+ }
+ }
+ else
+ {
+ ImplementationRepository::ServerInformation_var server_information;
+
+ this->implrepo_->find (this->server_name_.c_str (), server_information, ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ // Display verbosely
+ this->verbose_server_information_ = 1;
+
+ this->display_server_information (server_information);
+ }
+ }
+ ACE_CATCH (ImplementationRepository::Administration::NotFound, ex)
+ {
+ ACE_ERROR ((LM_ERROR, "Could not find server <%s>!\n", this->server_name_.c_str ()));
+ return -1;
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "List");
+ return -1;
+ }
+ ACE_ENDTRY;
+ return 0;
+}
+
+int
+TAO_IR_Op_Remove::run (void)
+{
+ ACE_DECLARE_NEW_CORBA_ENV;
+ ACE_TRY
+ {
+ this->implrepo_->remove_server (this->server_name_.c_str (), ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ ACE_DEBUG ((LM_DEBUG, "Successfully removed server <%s>\n", this->server_name_.c_str ()));
+ }
+ ACE_CATCH (ImplementationRepository::Administration::NotFound, ex)
+ {
+ ACE_ERROR ((LM_ERROR, "Could not find server <%s>!\n", this->server_name_.c_str ()));
+ return -1;
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Removing Server");
+ return -1;
+ }
+ ACE_ENDTRY;
+
+ // Success
+ return 0;
+}
+
+int
+TAO_IR_Op_Update::run (void)
+{
+ ImplementationRepository::ServerInformation_var server_information;
+
+ ACE_DECLARE_NEW_CORBA_ENV;
+ ACE_TRY
+ {
+ this->implrepo_->find (this->server_name_.c_str (), server_information, ACE_TRY_ENV);
+ 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_working_dir_ == 1)
+ server_information->startup.working_directory =
+ CORBA::string_dup (this->working_dir_.c_str ());
+ // @@ add environment and logical server
+
+ this->implrepo_->reregister_server (this->server_name_.c_str (),
+ server_information->startup,
+ ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ this->display_server_information (server_information);
+ }
+ ACE_CATCH (ImplementationRepository::Administration::NotFound, ex)
+ {
+ ACE_ERROR ((LM_ERROR, "Could not find server <%s>\n", this->server_name_.c_str ()));
+ return -1;
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Updating server");
+ return -1;
+ }
+ ACE_ENDTRY;
+
+ // Success
+ return 0;
+}
+
+
+// ============================================================================
+// = Print Usage methods
+
+
+void
+TAO_IR_Op_Add::print_usage (void)
+{
+ ACE_ERROR ((LM_ERROR, "Usage: tao_ir [options] add <name> [command-arguments]\n"
+ " where [options] are ORB options\n"
+ " where <name> is the POA name used by the server object\n"
+ " where [command-arguments] can be\n"
+ " -h Displays this\n"
+ " -c command Startup command\n"
+ " -w dir Working directory\n"));
+}
+
+void
+TAO_IR_Op_List::print_usage (void)
+{
+ ACE_ERROR ((LM_ERROR, "Lists all or one of the servers in the Implementation Repository\n"
+ "\n"
+ "Usage: tao_ir [options] list [name] [command-arguments]\n"
+ " where [options] are ORB options\n"
+ " where [name] is the optional server name to search for\n"
+ " where [command-arguments] can be\n"
+ " -v Verbose: Displays more info for each server when\n"
+ " displaying more than one server\n"
+ " -h Displays this\n"));
+}
+
+void
+TAO_IR_Op_Remove::print_usage (void)
+{
+ ACE_ERROR ((LM_ERROR, "Removes a server entry\n"
+ "\n"
+ "Usage: tao_ir [options] remove <name> [command-arguments]\n"
+ " where [options] are ORB options\n"
+ " where <name> is the POA name used by the server object\n"
+ " where [command-arguments] can be\n"
+ " -h Displays this\n"));
+}
+
+void
+TAO_IR_Op_Update::print_usage (void)
+{
+ ACE_ERROR ((LM_ERROR, "Updates a server entry\n"
+ "\n"
+ "Usage: tao_ir [options] update <name> [command-arguments]\n"
+ " where [options] are ORB options\n"
+ " where <name> is the POA name used by the server object\n"
+ " where [command-arguments] can be\n"
+ " -h Displays this\n"
+ " -c command Startup command\n"
+ " -w dir Working directory\n"));
+}
+
+
+
+// Prints out information in a ServerInformation structure.
+
+void
+TAO_IR_Op::display_server_information (const ImplementationRepository::ServerInformation &info)
+{
+ // Print out information
+ ACE_DEBUG ((LM_DEBUG, "Server <%s>\n", info.server));
+ ACE_DEBUG ((LM_DEBUG,
+ " Command Line: %s\n"
+ " Working Directory: %s\n",
+ info.startup.command_line,
+ info.startup.working_directory));
+ // @@ add environment and logical server once implemented
+
+ // I am assuming that a blank host means currently not running.
+ if (ACE_OS::strlen (info.location.host) > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ " Running at \n"
+ " Host: %s\n"
+ " Port: %d\n",
+ info.location.host,
+ info.location.port));
+ else
+ ACE_DEBUG ((LM_DEBUG,
+ " Not currently running\n"));
+}
+
+
+// ============================================================================
+// = Display Server Information methods
+
+void
+TAO_IR_Op_List::display_server_information (const ImplementationRepository::ServerInformation &info)
+{
+ if (this->verbose_server_information_)
+ TAO_IR_Op::display_server_information (info);
+ else
+ ACE_DEBUG ((LM_DEBUG, "<%s>\n", info.server));
}
diff --git a/TAO/orbsvcs/ImplRepo_Service/tao_ir_i.h b/TAO/orbsvcs/ImplRepo_Service/tao_ir_i.h
index d45e47af58b..038a808c2a4 100644
--- a/TAO/orbsvcs/ImplRepo_Service/tao_ir_i.h
+++ b/TAO/orbsvcs/ImplRepo_Service/tao_ir_i.h
@@ -23,6 +23,9 @@
#include "tao/corba.h"
#include "orbsvcs/ImplRepoC.h"
+class TAO_IR_Op;
+// Forward Declaration
+
class TAO_IR_i
{
// = TITLE
@@ -35,30 +38,19 @@ public:
TAO_IR_i (void);
~TAO_IR_i (void);
- int run ();
+ int run (void);
// Execute client code.
int init (int argc, char **argv);
// Initialize the client communication endpoint with server.
private:
- enum Operation {ALL, ADD, REMOVE, UPDATE, LIST};
-
- void print_usage (Operation op);
- // Print out information about an operation.
-
- int read_ior (char *filename);
- // Function to read the server ior from a file.
+ void print_usage (void);
+ // Print out information about all operations.
int parse_args (void);
// Parses the arguments passed on the command line.
- int parse_add_args (void);
- // Parses arguments specific to the ADD command.
-
- int parse_list_args (void);
- // Parses arguments specific to the LIST command.
-
int argc_;
// # of arguments on the command line.
@@ -67,6 +59,136 @@ private:
CORBA::ORB_var orb_;
// Remember our orb.
+
+ ImplementationRepository::Administration_var implrepo_;
+ // Reference to our implementation repository.
+
+ TAO_IR_Op *op_;
+ // What we need to do.
+};
+
+class TAO_IR_Op
+{
+public:
+ static TAO_IR_Op *make_op (const ASYS_TCHAR *op_name, ImplementationRepository::Administration_ptr ir);
+ // Factory.
+
+ TAO_IR_Op (ImplementationRepository::Administration_ptr implrepo);
+ // Constructor.
+
+ virtual ~TAO_IR_Op (void);
+ // Virtual Destructor.
+
+ virtual int parse (int argc, ASYS_TCHAR **argv) = 0;
+ // Parse arguments.
+
+ virtual int run (void) = 0;
+ // Do the work.
+
+protected:
+ ImplementationRepository::Administration_ptr implrepo_;
+ // Reference to our implementation repository.
+
+ // = Helper methods
+
+ void display_server_information (const ImplementationRepository::ServerInformation &info);
+ // Prints out the information contained in a ServerInformation structure.
+};
+
+class TAO_IR_Op_Add : public TAO_IR_Op
+{
+public:
+ TAO_IR_Op_Add (ImplementationRepository::Administration_ptr implrepo);
+ ~TAO_IR_Op_Add (void);
+
+ virtual int parse (int argc, ASYS_TCHAR **argv);
+ virtual int run (void);
+
+protected:
+ void print_usage (void);
+ // Prints a message about the usage.
+
+ ACE_TString server_name_;
+ // POA server name.
+
+ ACE_TString command_line_;
+ // Command line.
+
+ ACE_TString working_dir_;
+ // Working directory.
+};
+
+
+// Used to list the entries in the IR
+
+class TAO_IR_Op_List : public TAO_IR_Op
+{
+public:
+ TAO_IR_Op_List (ImplementationRepository::Administration_ptr implrepo);
+ ~TAO_IR_Op_List (void);
+
+ virtual int parse (int argc, ASYS_TCHAR **argv);
+ virtual int run (void);
+
+protected:
+ void print_usage (void);
+ // Prints a message about the usage
+
+ ACE_TString server_name_;
+ // POA server name.
+
+ int verbose_server_information_;
+ // If true, more server information is displayed.
+
+ void display_server_information (const ImplementationRepository::ServerInformation &info);
+ // Prints out the information contained in a ServerInformation structure.
+ // Specialized to only print server information
+};
+
+class TAO_IR_Op_Remove : public TAO_IR_Op
+{
+public:
+ TAO_IR_Op_Remove (ImplementationRepository::Administration_ptr implrepo);
+ ~TAO_IR_Op_Remove (void);
+
+ virtual int parse (int argc, ASYS_TCHAR **argv);
+ virtual int run (void);
+
+protected:
+ void print_usage (void);
+ // Prints a message about the usage
+
+ ACE_TString server_name_;
+ // POA server name.
+};
+
+class TAO_IR_Op_Update : public TAO_IR_Op
+{
+public:
+ TAO_IR_Op_Update (ImplementationRepository::Administration_ptr implrepo);
+ ~TAO_IR_Op_Update (void);
+
+ virtual int parse (int argc, ASYS_TCHAR **argv);
+ virtual int run (void);
+
+protected:
+ void print_usage (void);
+ // Prints a message about the usage.
+
+ ACE_TString server_name_;
+ // POA server name.
+
+ int set_command_line_;
+ // True if the command_line_ needs to be updated.
+
+ ACE_TString command_line_;
+ // Startup command.
+
+ int set_working_dir_;
+ // True if the working_dir_ needs to be updated.
+
+ ACE_TString working_dir_;
+ // Working directory.
};
#endif /* TAO_IR_I_H */