summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/ImplRepo_Service
diff options
context:
space:
mode:
authorbrunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-06-03 04:06:39 +0000
committerbrunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-06-03 04:06:39 +0000
commitc7b635c0d938909fa3a6bd32dca382b18afde171 (patch)
tree224130c0748c81ee667ae73d038c372c0796fd82 /TAO/orbsvcs/ImplRepo_Service
parent652dcfff8f12cf97beefb029cfe20e769587a0fe (diff)
downloadATCD-c7b635c0d938909fa3a6bd32dca382b18afde171.tar.gz
ChangeLogTag:Fri Jun 2 20:39:14 2000 Darrell Brunsch <brunsch@uci.edu>
Diffstat (limited to 'TAO/orbsvcs/ImplRepo_Service')
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/ImplRepo.cpp5
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.cpp104
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.h12
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Options.cpp43
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Repository.cpp42
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Repository.h5
6 files changed, 120 insertions, 91 deletions
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImplRepo.cpp b/TAO/orbsvcs/ImplRepo_Service/ImplRepo.cpp
index 033ad9be7ab..028bbe0cde6 100644
--- a/TAO/orbsvcs/ImplRepo_Service/ImplRepo.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/ImplRepo.cpp
@@ -21,6 +21,10 @@ main (int argc, char *argv[])
{
server.run (ACE_TRY_ENV);
ACE_TRY_CHECK;
+
+ if (server.fini (ACE_TRY_ENV) == -1)
+ return 1;
+ ACE_TRY_CHECK;
}
}
ACE_CATCH (CORBA::SystemException, sysex)
@@ -39,6 +43,5 @@ main (int argc, char *argv[])
return -1;
}
ACE_ENDTRY;
-
return 0;
}
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.cpp b/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.cpp
index 9ac93426b1c..f03ed7b451f 100644
--- a/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.cpp
@@ -734,7 +734,8 @@ ImplRepo_i::init (int argc, char **argv, CORBA::Environment &ACE_TRY_ENV)
ACE_TRY_ENV);
ACE_TRY_CHECK;
- this->poa_manager_ = this->root_poa_->the_POAManager (ACE_TRY_ENV);
+ PortableServer::POAManager_var poa_manager =
+ this->root_poa_->the_POAManager (ACE_TRY_ENV);
ACE_TRY_CHECK;
CORBA::PolicyList policies (2);
@@ -754,9 +755,10 @@ ImplRepo_i::init (int argc, char **argv, CORBA::Environment &ACE_TRY_ENV)
this->imr_poa_ =
this->root_poa_->create_POA ("ImplRepoService",
- PortableServer::POAManager::_duplicate (this->poa_manager_.in ()),
+ poa_manager.in (),
policies,
ACE_TRY_ENV);
+
// Warning! If create_POA fails, then the policies won't be
// destroyed and there will be hell to pay in memory leaks!
ACE_TRY_CHECK;
@@ -775,8 +777,8 @@ ImplRepo_i::init (int argc, char **argv, CORBA::Environment &ACE_TRY_ENV)
return retval;
ACE_NEW_RETURN (this->forwarder_impl_,
- IMR_Forwarder (CORBA::ORB::_duplicate (this->orb_.in ()),
- PortableServer::POA::_duplicate (this->root_poa_.in ()),
+ IMR_Forwarder (this->orb_.in (),
+ this->root_poa_.in (),
this),
-1);
@@ -822,8 +824,7 @@ ImplRepo_i::init (int argc, char **argv, CORBA::Environment &ACE_TRY_ENV)
}
ACE_NEW_RETURN (this->activator_,
- IMR_Adapter_Activator (this->forwarder_impl_,
- PortableServer::POAManager::_duplicate (this->poa_manager_.in ())),
+ IMR_Adapter_Activator (this->forwarder_impl_),
-1);
PortableServer::AdapterActivator_var activator =
@@ -845,9 +846,8 @@ ImplRepo_i::init (int argc, char **argv, CORBA::Environment &ACE_TRY_ENV)
this->process_mgr_.open (ACE_Process_Manager::DEFAULT_SIZE, reactor);
#if defined (ACE_HAS_IP_MULTICAST)
- //
+
// Install ior multicast handler.
- //
// See if the -ORBMulticastDiscoveryEndpoint option was specified.
ACE_CString mde (TAO_ORB_Core_instance ()->orb_params ()->mcast_discovery_endpoint ());
@@ -904,10 +904,11 @@ ImplRepo_i::init (int argc, char **argv, CORBA::Environment &ACE_TRY_ENV)
if (OPTIONS::instance ()->debug () > 0)
ACE_DEBUG ((LM_DEBUG,
"Implementation Repository: The multicast server setup is done.\n"));
+
#endif /* ACE_HAS_IP_MULTICAST */
// Initialize the persistent storage
- if (this->repository_.init (OPTIONS::instance()->config()))
+ if (this->repository_.init ())
ACE_ERROR_RETURN ((LM_ERROR, "Repository failed to initialize\n"), -1);
}
ACE_CATCHANY
@@ -921,9 +922,39 @@ ImplRepo_i::init (int argc, char **argv, CORBA::Environment &ACE_TRY_ENV)
}
int
+ImplRepo_i::fini (CORBA::Environment &ACE_TRY_ENV)
+{
+ // Unregister ourself with the orb by replacing with a regular
+ // callback
+ TAO_IOR_LookupTable_Callback *regular;
+
+ ACE_NEW_RETURN (regular, TAO_IOR_LookupTable_Callback, -1);
+
+ this->orb_->_tao_register_IOR_table_callback (regular, 1);
+
+ ACE_TRY_NEW_ENV
+ {
+ this->imr_poa_->destroy (1, 1, ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ this->root_poa_->destroy (1, 1, ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Server_i::init");
+ ACE_RETHROW;
+ }
+ ACE_ENDTRY;
+ ACE_CHECK_RETURN (-1);
+ return 0;
+}
+
+int
ImplRepo_i::run (CORBA::Environment &ACE_TRY_ENV)
{
- this->poa_manager_->activate (ACE_TRY_ENV);
+ PortableServer::POAManager_var poa_manager = this->imr_poa_->the_POAManager (ACE_TRY_ENV);
+ poa_manager->activate (ACE_TRY_ENV);
ACE_CHECK_RETURN (-1);
// Get a new iterator
@@ -987,33 +1018,19 @@ ImplRepo_i::run (CORBA::Environment &ACE_TRY_ENV)
ImplRepo_i::~ImplRepo_i (void)
{
- if (this->forwarder_impl_ != 0)
- delete this->forwarder_impl_;
-
- if (this->activator_ != 0)
- delete this->activator_;
-
- if (this->ior_multicast_ != 0)
- delete this->ior_multicast_;
-
- // Unregister ourself with the orb by replacing with a regular
- // callback
- TAO_IOR_LookupTable_Callback *regular;
-
- ACE_NEW (regular, TAO_IOR_LookupTable_Callback);
-
- this->orb_->_tao_register_IOR_table_callback (regular, 1);
-
- ACE_TRY_NEW_ENV
- {
- this->root_poa_->destroy (1, 1, ACE_TRY_ENV);
- ACE_TRY_CHECK;
- }
- ACE_CATCHANY
- {
- // Ignore
- }
- ACE_ENDTRY;
+ // Get reactor instance from TAO.
+ ACE_Reactor *reactor = this->orb_->orb_core ()->reactor ();
+
+ // Register event handler for the ior multicast.
+ if (reactor->remove_handler (this->ior_multicast_,
+ ACE_Event_Handler::READ_MASK) == -1)
+ if (OPTIONS::instance ()->debug () > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "Implementation Repository: cannot remove handler\n"));
+
+ delete this->forwarder_impl_;
+ delete this->activator_;
+ delete this->ior_multicast_;
}
@@ -1228,10 +1245,8 @@ ImplRepo_i::shutdown_server (const char *server,
}
-IMR_Adapter_Activator::IMR_Adapter_Activator (IMR_Forwarder *servant,
- PortableServer::POAManager_ptr poa_manager)
- : servant_ (servant),
- poa_manager_ (PortableServer::POAManager::_duplicate (poa_manager))
+IMR_Adapter_Activator::IMR_Adapter_Activator (IMR_Forwarder *servant)
+ : servant_ (servant)
{
// Nothing
}
@@ -1272,11 +1287,16 @@ IMR_Adapter_Activator::unknown_adapter (PortableServer::POA_ptr parent,
parent->create_id_uniqueness_policy (PortableServer::MULTIPLE_ID, ACE_TRY_ENV);
ACE_TRY_CHECK;
+ PortableServer::POAManager_var poa_manager =
+ parent->the_POAManager (ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
exception_message = "While create_POA";
PortableServer::POA_var child = parent->create_POA (name,
- this->poa_manager_.in (),
+ poa_manager.in (),
policies,
ACE_TRY_ENV);
+ ACE_TRY_CHECK;
exception_message = "While unknown_adapter::policy->destroy";
for (CORBA::ULong i = 0; i < policies.length (); ++i)
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.h b/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.h
index ff1343c5626..ec5c17a1680 100644
--- a/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.h
+++ b/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.h
@@ -44,8 +44,7 @@ class IMR_Adapter_Activator : public POA_PortableServer::AdapterActivator
// arbitrary requests. This allows for the setting up of child
// POAs with default servants.
public:
- IMR_Adapter_Activator (IMR_Forwarder *servant,
- PortableServer::POAManager_ptr poa_manager);
+ IMR_Adapter_Activator (IMR_Forwarder *servant);
// Constructor
virtual CORBA::Boolean unknown_adapter (PortableServer::POA_ptr parent,
@@ -58,9 +57,6 @@ public:
private:
IMR_Forwarder *servant_;
// The object to use as the default servant.
-
- PortableServer::POAManager_var poa_manager_;
- // POA Manager
};
class ImplRepo_i
@@ -152,6 +148,9 @@ public:
CORBA_Environment &ACE_TRY_ENV = TAO_default_environment ());
// Initialize the Server state - parsing arguments and waiting.
+ int fini (CORBA_Environment &ACE_TRY_ENV = TAO_default_environment ());
+ // Cleans up any state created by init ().
+
int run (CORBA_Environment &ACE_TRY_ENV = TAO_default_environment ());
// Runs the orb.
@@ -192,9 +191,6 @@ private:
PortableServer::POA_var imr_poa_;
// Implementation Repository's POA.
- PortableServer::POAManager_var poa_manager_;
- // The POA manager.
-
char *server_key_;
// Key of the obj ref of the server.
diff --git a/TAO/orbsvcs/ImplRepo_Service/Options.cpp b/TAO/orbsvcs/ImplRepo_Service/Options.cpp
index 13e7f8fda65..f9c76719c39 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Options.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/Options.cpp
@@ -40,26 +40,33 @@ Options::parse_args (int argc, ACE_TCHAR *argv[])
break;
case 'p': // persistent heap implementation
{
- ACE_Configuration_Heap* heap = new ACE_Configuration_Heap;
- if(heap->open(get_opts.optarg))
- {
- ACE_ERROR_RETURN((LM_ERROR,
- "Error:: Opening persistent heap file '%s'\n",
- get_opts.optarg), -2);
- }
- config_ = heap;
+ ACE_Configuration_Heap* heap;
+ ACE_NEW_RETURN (heap, ACE_Configuration_Heap, -1);
+
+ if (heap->open(get_opts.optarg))
+ {
+ ACE_ERROR_RETURN((LM_ERROR,
+ "Error:: Opening persistent heap file '%s'\n",
+ get_opts.optarg), -2);
+ }
+ this->config_ = heap;
}
break;
#if defined(ACE_WIN32)
case 'r': // win32 registry implementation
{
- HKEY root = ACE_Configuration_Win32Registry::resolve_key(HKEY_LOCAL_MACHINE, "Software\\TAO\\IR");
- config_ = new ACE_Configuration_Win32Registry(root);
+ HKEY root =
+ ACE_Configuration_Win32Registry::resolve_key(HKEY_LOCAL_MACHINE,
+ "Software\\TAO\\IR");
+ ACE_NEW_RETURN (this->config_,
+ ACE_Configuration_Win32Registry(root),
+ -1);
}
break;
#endif
case 't': // Set timeout value
- this->startup_timeout_ = ACE_Time_Value (ACE_OS::atoi (get_opts.optarg));
+ this->startup_timeout_ =
+ ACE_Time_Value (ACE_OS::atoi (get_opts.optarg));
break;
case '?': // display help for use of the server.
default:
@@ -76,12 +83,14 @@ Options::parse_args (int argc, ACE_TCHAR *argv[])
}
// if no persistent implementation specified, use a simple heap
- if(!config_)
- {
- ACE_Configuration_Heap* heap = new ACE_Configuration_Heap;
- heap->open();
- config_ = heap;
- }
+ if (!this->config_)
+ {
+ ACE_Configuration_Heap *heap;
+
+ ACE_NEW_RETURN (heap, ACE_Configuration_Heap, -1);
+ heap->open ();
+ this->config_ = heap;
+ }
// Indicates successful parsing of command line.
return 0;
diff --git a/TAO/orbsvcs/ImplRepo_Service/Repository.cpp b/TAO/orbsvcs/ImplRepo_Service/Repository.cpp
index 9628837d968..bf7ea1b5e12 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Repository.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/Repository.cpp
@@ -113,7 +113,6 @@ Server_Info::get_running_info (ACE_TString &location,
// Default Constructor
Server_Repository::Server_Repository ()
-: config_ (0)
{
// Nothing
}
@@ -123,24 +122,23 @@ Server_Repository::Server_Repository ()
Server_Repository::~Server_Repository ()
{
- delete this->config_;
+ // Nothing
}
// Initialize the the configuration class.
int
-Server_Repository::init (ACE_Configuration* config)
+Server_Repository::init ()
{
- delete this->config_;
- this->config_ = config;
-
+ ACE_Configuration *config = OPTIONS::instance ()->config ();
+
// iterate through the list of registered servers and register them
- this->config_->open_section(config_->root_section(), "Servers", 1, this->servers_);
+ config->open_section(config->root_section(), "Servers", 1, this->servers_);
int index = 0;
ACE_TString name;
- while (this->config_->enumerate_sections (servers_, index, name) == 0)
+ while (config->enumerate_sections (servers_, index, name) == 0)
{
ACE_TString logical, startup, working_dir, activation_str;
Server_Info::ActivationMode activation;
@@ -150,11 +148,11 @@ Server_Repository::init (ACE_Configuration* config)
ACE_Configuration_Section_Key server_key;
int error = 0;
- error += this->config_->open_section (this->servers_, name.c_str(), 0, server_key);
- error += this->config_->get_string_value (server_key, "LogicalServer", logical);
- error += this->config_->get_string_value (server_key, "StartupCommand", startup);
- error += this->config_->get_string_value (server_key, "WorkingDir", working_dir);
- error += this->config_->get_string_value (server_key, "Activation", activation_str);
+ error += config->open_section (this->servers_, name.c_str(), 0, server_key);
+ error += config->get_string_value (server_key, "LogicalServer", logical);
+ error += config->get_string_value (server_key, "StartupCommand", startup);
+ error += config->get_string_value (server_key, "WorkingDir", working_dir);
+ error += config->get_string_value (server_key, "Activation", activation_str);
activation = convert_str_to_mode (activation_str.c_str ());
// Maybe environments variables?? need a straight forward way to store env vars
@@ -181,13 +179,15 @@ Server_Repository::add (const ACE_TString POA_name,
const ACE_TString working_dir,
const Server_Info::ActivationMode activation)
{
- // Add this to the persistent configuration; environment_vars??
+ ACE_Configuration *config = OPTIONS::instance ()->config ();
+
+ // @@ Add this to the persistent configuration; environment_vars??
ACE_Configuration_Section_Key server;
- this->config_->open_section (this->servers_, POA_name.c_str(), 1, server);
- this->config_->set_string_value (server, "LogicalServer", logical_server_name);
- this->config_->set_string_value (server, "StartupCommand", startup_command);
- this->config_->set_string_value (server, "WorkingDir", working_dir);
- this->config_->set_string_value (server, "Activation", convert_mode_to_str (activation));
+ config->open_section (this->servers_, POA_name.c_str(), 1, server);
+ config->set_string_value (server, "LogicalServer", logical_server_name);
+ config->set_string_value (server, "StartupCommand", startup_command);
+ config->set_string_value (server, "WorkingDir", working_dir);
+ config->set_string_value (server, "Activation", convert_mode_to_str (activation));
Server_Info *new_server;
ACE_NEW_RETURN (new_server,
@@ -306,8 +306,10 @@ Server_Repository::starting_up (const ACE_TString POA_name)
int
Server_Repository::remove (const ACE_TString POA_name)
{
+ ACE_Configuration *config = OPTIONS::instance ()->config ();
+
// Remove the persistent configuration information
- this->config_->remove_section (this->servers_, POA_name.c_str(), 1);
+ config->remove_section (this->servers_, POA_name.c_str(), 1);
return this->repository_.unbind (POA_name);
}
diff --git a/TAO/orbsvcs/ImplRepo_Service/Repository.h b/TAO/orbsvcs/ImplRepo_Service/Repository.h
index b16a5056db7..ad847f5318c 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Repository.h
+++ b/TAO/orbsvcs/ImplRepo_Service/Repository.h
@@ -150,8 +150,8 @@ public:
ACE_Equal_To<ACE_TString>,
ACE_Null_Mutex> HASH_IMR_ITER;
- int init (ACE_Configuration *config);
- // Initializes the configuration persistent storage based on <config>
+ int init ();
+ // Initializes the Server Repository
int add (const ACE_TString POA_name,
const ACE_TString logical_server_name,
@@ -199,7 +199,6 @@ public:
private:
HASH_IMR_MAP repository_;
- ACE_Configuration* config_;
ACE_Configuration_Section_Key servers_;
};