summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs
diff options
context:
space:
mode:
authormichel_j <michel_j@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-11-10 17:45:18 +0000
committermichel_j <michel_j@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-11-10 17:45:18 +0000
commite5689040b93c74df3588981d7be8701ef8014b0e (patch)
treee001863527a50f3596af21b1c1ca761fb765fe7b /TAO/orbsvcs
parent2ce848ef1d33b9d8d97988a993b1d1b3be1c819f (diff)
downloadATCD-e5689040b93c74df3588981d7be8701ef8014b0e.tar.gz
Mon Nov 10 11:33:34 2003 Justin Michel <michel_j@ociweb.com>
Diffstat (limited to 'TAO/orbsvcs')
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Activator_NT_Service.cpp (renamed from TAO/orbsvcs/ImplRepo_Service/NT_Service.cpp)43
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Activator_NT_Service.h59
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Activator_Options.cpp (renamed from TAO/orbsvcs/ImplRepo_Service/Options.cpp)603
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Activator_Options.h (renamed from TAO/orbsvcs/ImplRepo_Service/Options.h)74
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Forwarder.cpp32
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Forwarder.h4
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/INS_Locator.cpp (renamed from TAO/orbsvcs/ImplRepo_Service/Locator.cpp)14
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/INS_Locator.h (renamed from TAO/orbsvcs/ImplRepo_Service/Locator.h)35
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/ImR_Activator.cpp14
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.cpp496
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.h50
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/ImR_Locator.cpp72
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp1180
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.h198
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/ImplRepo_Service.mpc10
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Iterator.cpp8
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Iterator.h5
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Locator_NT_Service.cpp95
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Locator_NT_Service.h (renamed from TAO/orbsvcs/ImplRepo_Service/NT_Service.h)36
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Locator_Options.cpp487
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Locator_Options.h102
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/README.txt46
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Repository_Configuration.cpp18
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Server_Info.cpp7
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Server_Info.h2
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Server_Repository.cpp336
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Server_Repository.h75
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/XML_ContentHandler.cpp60
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/XML_ContentHandler.h16
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/tao_imr_i.cpp598
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/tao_imr_i.h57
-rw-r--r--TAO/orbsvcs/tests/ImplRepo/ImplRepo.mpc16
-rw-r--r--TAO/orbsvcs/tests/ImplRepo/NameService/ImplRepo_NameService.mpc1
-rw-r--r--TAO/orbsvcs/tests/ImplRepo/README99
-rwxr-xr-xTAO/orbsvcs/tests/ImplRepo/run_test.pl404
35 files changed, 2779 insertions, 2573 deletions
diff --git a/TAO/orbsvcs/ImplRepo_Service/NT_Service.cpp b/TAO/orbsvcs/ImplRepo_Service/Activator_NT_Service.cpp
index f45f20de59d..5a5c784aedd 100644
--- a/TAO/orbsvcs/ImplRepo_Service/NT_Service.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/Activator_NT_Service.cpp
@@ -11,35 +11,20 @@
*/
//=============================================================================
-#include "NT_Service.h"
+#include "Activator_NT_Service.h"
-// Only on Windows for now
#if defined (ACE_WIN32)
#include "ImR_Activator_i.h"
#include "tao/ORB_Core.h"
/**
- * Default constructor, does nothing special.
- */
-ImR_NT_Service::ImR_NT_Service (void)
-{
-}
-
-/**
- * Destructor, does nothing special.
- */
-ImR_NT_Service::~ImR_NT_Service (void)
-{
-}
-
-/**
* Handles the SERVICE_CONTROL_SHUTDOWN and SERVICE_CONTROL_STOP commands
* by shutting down the ORB. Otherwise ACE_NT_Service::handle_control
* handles the command.
*/
void
-ImR_NT_Service::handle_control (DWORD control_code)
+Activator_NT_Service::handle_control (DWORD control_code)
{
if (control_code == SERVICE_CONTROL_SHUTDOWN
|| control_code == SERVICE_CONTROL_STOP)
@@ -47,7 +32,6 @@ ImR_NT_Service::handle_control (DWORD control_code)
report_status (SERVICE_STOP_PENDING);
TAO_ORB_Core_instance ()->reactor ()->end_reactor_event_loop ();
TAO_ORB_Core_instance ()->orb ()->shutdown (1);
- report_status (SERVICE_STOPPED);
}
else
{
@@ -59,7 +43,7 @@ ImR_NT_Service::handle_control (DWORD control_code)
/**
*/
int
-ImR_NT_Service::handle_exception (ACE_HANDLE)
+Activator_NT_Service::handle_exception (ACE_HANDLE)
{
return 0;
}
@@ -70,7 +54,7 @@ ImR_NT_Service::handle_exception (ACE_HANDLE)
* we update the report_status after init.
*/
int
-ImR_NT_Service::svc (void)
+Activator_NT_Service::svc (void)
{
ImR_Activator_i server;
@@ -84,6 +68,7 @@ ImR_NT_Service::svc (void)
if (status == -1)
{
+ report_status (SERVICE_STOPPED);
return -1;
}
else
@@ -95,28 +80,28 @@ ImR_NT_Service::svc (void)
status = server.fini (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
- if (status == -1)
- return -1;
+ report_status (SERVICE_STOPPED);
+
}
+ if (status != -1)
+ return 0;
}
ACE_CATCH (CORBA::SystemException, sysex)
{
- ACE_PRINT_EXCEPTION (sysex, "Implementation Repository");
- return -1;
+ ACE_PRINT_EXCEPTION (sysex, IMR_ACTIVATOR_DISPLAY_NAME);
}
ACE_CATCH (CORBA::UserException, userex)
{
- ACE_PRINT_EXCEPTION (userex, "Implementation Repository");
- return -1;
+ ACE_PRINT_EXCEPTION (userex, IMR_ACTIVATOR_DISPLAY_NAME);
}
ACE_CATCHANY
{
- ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Implementation Repository");
- return -1;
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, IMR_ACTIVATOR_DISPLAY_NAME);
}
ACE_ENDTRY;
- return 0;
+ report_status (SERVICE_STOPPED);
+ return -1;
}
#endif /* ACE_WIN32 */
diff --git a/TAO/orbsvcs/ImplRepo_Service/Activator_NT_Service.h b/TAO/orbsvcs/ImplRepo_Service/Activator_NT_Service.h
new file mode 100644
index 00000000000..f20f0a7db9a
--- /dev/null
+++ b/TAO/orbsvcs/ImplRepo_Service/Activator_NT_Service.h
@@ -0,0 +1,59 @@
+/* -*- C++ -*- */
+//=============================================================================
+/**
+ * @file NT_Service.h
+ *
+ * $Id$
+ *
+ * @author Darrell Brunsch <brunsch@cs.wustl.edu>
+ * @author Jeff Parsons <parsons@cs.wustl.edu>
+ * @author John Tucker <jtucker@infoglide.com>
+ * @author Mike Vitalo <mvitalo@infoglide.com>
+ */
+//=============================================================================
+
+#ifndef Activator_NT_Service_H
+#define Activator_NT_Service_H
+
+#include "ace/config.h"
+
+#if defined (ACE_WIN32)
+
+#include "ace/NT_Service.h"
+#include "ace/Singleton.h"
+#include "ace/Synch.h"
+#include "tao/orbconf.h"
+
+static const char * IMR_ACTIVATOR_SERVICE_NAME = "TAOIMRActivator";
+static const char * IMR_ACTIVATOR_DISPLAY_NAME = "TAO Implementation Repository Activator";
+static const char * IMR_ACTIVATOR_DESCRIPTION = "Implementation Repository Activator service for TAO";
+
+/**
+ * @class Activator_NT_Service
+ *
+ * @brief Allows the Implementation Repository to act as a Windows NT Service.
+ */
+class Activator_NT_Service : public ACE_NT_Service
+{
+public:
+ typedef TAO_SYNCH_RECURSIVE_MUTEX MUTEX;
+
+ /// We override <handle_control> because it handles stop requests
+ /// privately.
+ virtual void handle_control (DWORD control_code);
+
+ /// We override <handle_exception> so a 'stop' control code can wake
+ /// the reactor off of its wait.
+ virtual int handle_exception (ACE_HANDLE h);
+
+ /// This is a virtual method inherited from ACE_NT_Service.
+ virtual int svc (void);
+private:
+ friend class ACE_Singleton<Activator_NT_Service, MUTEX>;
+};
+
+typedef ACE_Singleton<Activator_NT_Service, ACE_Mutex> SERVICE;
+
+#endif /* ACE_WIN32 */
+
+#endif /* Activator_NT_Service_H */
diff --git a/TAO/orbsvcs/ImplRepo_Service/Options.cpp b/TAO/orbsvcs/ImplRepo_Service/Activator_Options.cpp
index b754fb55363..35d0e4144fe 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Options.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/Activator_Options.cpp
@@ -7,14 +7,14 @@
* @author Darrell Brunsch <brunsch@cs.wustl.edu>
*/
//=============================================================================
-
-#include "Options.h"
-#include "NT_Service.h"
+#include "Activator_Options.h"
+#include "Activator_NT_Service.h"
#include "tao/Strategies/advanced_resource.h"
#include "ace/Arg_Shifter.h"
#include "ace/ARGV.h"
#include "ace/OS_NS_strings.h"
+
ACE_RCSID (ImplRepo_Service,
Options,
"$Id$")
@@ -22,40 +22,30 @@ ACE_RCSID (ImplRepo_Service,
#if defined (ACE_WIN32)
static const HKEY SERVICE_REG_ROOT = HKEY_LOCAL_MACHINE;
+// This string must agree with the one used in Activator_NT_Service.h
static const ACE_TCHAR *SERVICE_REG_PATH =
- ACE_TEXT ("SYSTEM\\CurrentControlSet\\Services\\TAOImplRepo\\Parameters");
-static const ACE_TCHAR *SERVICE_REG_VALUE_NAME = ACE_TEXT ("ORBOptions");
+ ACE_TEXT ("SYSTEM\\CurrentControlSet\\Services\\TAOIMRActivator\\Parameters");
#endif /* ACE_WIN32 */
/**
* Default Constructor. Assigns default values to all the member variables.
*/
Options::Options ()
- : repo_config_ (0)
- , repo_mode_ ('p')
+ : repo_mode_ (REPO_NONE)
, debug_ (1)
- , ior_output_file_ (0)
- , multicast_ (0)
- , ping_interval_ (0, 200)
- , service_ (0)
+ , ping_interval_ (0, 200 * 1000) // 200 milliseconds
+ , service_ (false)
, startup_timeout_ (5)
- , readonly_ (0)
+ , readonly_ (false)
+ , service_command_(SC_NONE)
{
}
-
-/**
- * Destructor. Just deletes this->repo_config_.
- */
-Options::~Options ()
-{
- delete this->repo_config_;
-}
-
-
/**
* parse_args uses an ACE_Arg_Shifter to grab all the options that are
* specific to the ImR.
+ * If running as an nt service, most of these options will come from the
+ * registry instead.
*
* @retval 0 Success
* @retval -1 Error parsing args
@@ -65,36 +55,47 @@ int
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 (),
ACE_TEXT ("-c")) == 0)
{
- // Run the service command
shifter.consume_arg ();
if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
{
ACE_ERROR ((LM_ERROR, "Error: -c option needs a command\n"));
+ this->print_usage ();
return -1;
}
- if (this->run_service_command (shifter.get_current ()) != 0)
+ if (ACE_OS::strcasecmp (shifter.get_current (),
+ ACE_TEXT ("install")) == 0)
+ {
+ this->service_command_ = SC_INSTALL;
+ }
+ else if (ACE_OS::strcasecmp (shifter.get_current (),
+ ACE_TEXT ("remove")) == 0)
+ {
+ this->service_command_ = SC_REMOVE;
+ }
+ else
+ {
+ ACE_ERROR((LM_ERROR, "Error: Unknown service command : %s\n", shifter.get_current()));
+ this->print_usage ();
return -1;
-
- // Since we just ran a command, we will exit right away.
- return 1;
+ }
}
else if (ACE_OS::strcasecmp (shifter.get_current (),
ACE_TEXT ("-d")) == 0)
{
- // Set the debug level
shifter.consume_arg ();
if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
{
ACE_ERROR ((LM_ERROR, "Error: -d option needs a debuglevel\n"));
+ this->print_usage ();
return -1;
}
@@ -103,100 +104,92 @@ Options::parse_args (int &argc, char *argv[])
else if (ACE_OS::strcasecmp (shifter.get_current (),
ACE_TEXT ("-l")) == 0)
{
- // Lock the database
- this->readonly_ = 1;
- }
- else if (ACE_OS::strcasecmp (shifter.get_current (),
- ACE_TEXT ("-m")) == 0)
- {
- // multicast?
- shifter.consume_arg ();
-
- if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
- {
- ACE_ERROR ((LM_ERROR, "Error: -m option requires 1/0\n"));
- return -1;
- }
-
- this->multicast_ = ACE_OS::atoi (shifter.get_current ());
+ this->readonly_ = true;
}
else if (ACE_OS::strcasecmp (shifter.get_current (),
ACE_TEXT ("-o")) == 0)
{
- // Output the IOR to a file.
shifter.consume_arg ();
if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
{
ACE_ERROR ((LM_ERROR, "Error: -o option needs a filename\n"));
+ this->print_usage ();
return -1;
}
-
- this->ior_output_file_ = ACE_OS::fopen (shifter.get_current (), "w");
- if (this->ior_output_file_ == 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- "Error: Unable to open %s for writing: %p\n",
- shifter.get_current ()), -1);
+ this->ior_output_file_ = shifter.get_current();
}
else if (ACE_OS::strcasecmp (shifter.get_current (),
ACE_TEXT ("-p")) == 0)
{
- // Initialize file persistence
shifter.consume_arg ();
if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
{
ACE_ERROR ((LM_ERROR, "Error: -p option needs a filename\n"));
+ this->print_usage ();
return -1;
}
- if (this->initialize_file_persistence (shifter.get_current ()) != 0)
+ if (repo_mode_ != REPO_NONE)
+ {
+ ACE_ERROR ((LM_ERROR, "Error: Persistence already specified.\n"));
+ this->print_usage ();
return -1;
+ }
+
+ this->file_name_ = shifter.get_current ();
+ this->repo_mode_ = REPO_HEAP_FILE;
}
else if (ACE_OS::strcasecmp (shifter.get_current (),
ACE_TEXT ("-r")) == 0)
{
- // win32 registry implementation
- if (this->initialize_registry_persistence () != 0)
+ if (repo_mode_ != REPO_NONE)
+ {
+ ACE_ERROR ((LM_ERROR, "Error: Persistence already specified.\n"));
+ this->print_usage ();
return -1;
+ }
+ this->repo_mode_ = REPO_REGISTRY;
}
else if (ACE_OS::strcasecmp (shifter.get_current (),
ACE_TEXT ("-x")) == 0)
{
- // Initialize file persistence. The file is going to be of
- // XML format.
shifter.consume_arg ();
if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
{
ACE_ERROR ((LM_ERROR, "Error: -x option needs a filename\n"));
+ this->print_usage ();
return -1;
}
- /// Use XML for repository
- if (this->initialize_xml_persistence (shifter.get_current ()) != 0)
+ if (repo_mode_ != REPO_NONE)
+ {
+ ACE_ERROR ((LM_ERROR, "Error: Persistence already specified.\n"));
+ this->print_usage ();
return -1;
+ }
- this->repo_mode_ = 'x';
+ this->file_name_ = shifter.get_current ();
+ this->repo_mode_ = REPO_XML_FILE;
}
else if (ACE_OS::strcasecmp (shifter.get_current (),
ACE_TEXT ("-s")) == 0)
{
- // Run as a service
- this->service_ = 1;
+ this->service_ = true;
}
else if (ACE_OS::strcasecmp (shifter.get_current (),
ACE_TEXT ("-t")) == 0)
{
- // Set timeout value
shifter.consume_arg ();
if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
{
ACE_ERROR ((LM_ERROR, "Error: -t option needs a value\n"));
+ this->print_usage ();
return -1;
}
-
this->startup_timeout_ =
ACE_Time_Value (ACE_OS::atoi (shifter.get_current ()));
}
@@ -216,7 +209,6 @@ Options::parse_args (int &argc, char *argv[])
shifter.consume_arg ();
}
-
return 0;
}
@@ -228,20 +220,18 @@ Options::parse_args (int &argc, char *argv[])
int
Options::init (int argc, char *argv[])
{
- ACE_ARGV orb_args;
- int i = 0;
- int result = 0;
-
// Make an initial pass through and grab the arguments that we recognize.
-
- result = this->parse_args (argc, argv);
-
- if (result != 0)
+ // 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;
+ }
- // Save the leftovers to a ACE_ARGV class
- for (i = 1; i < argc; ++i)
+ ACE_ARGV orb_args; // Save the leftovers to a ACE_ARGV class
+ ACE_CString cmdline; // We'll save this in the registry when installing.
+ for (int i = 1; i < argc; ++i)
{
+ cmdline += ACE_CString(argv[i]) + ACE_CString(" ");
if (orb_args.add (argv[i]) == -1)
{
ACE_ERROR ((LM_ERROR, "Error: Could not save argument"));
@@ -249,22 +239,18 @@ Options::init (int argc, char *argv[])
}
}
-#if defined (ACE_WIN32)
- // Load any arguments from the registry
-
- if (this->load_registry_options (orb_args) != 0)
- return -1;
-#endif /* ACE_WIN32 */
-
- // Make another pass to catch any ImR arguments that may be in the
- // registry
+ result = run_service_command(cmdline);
+
+ if (result != 0)
+ return result;
- int orb_argc = orb_args.argc ();
+ char* argv_tmp = 0;
- result = this->parse_args (orb_argc, orb_args.argv ());
+ // Load from the registry. This may replace the args.
+ if (this->load_registry_options(argv_tmp, orb_args) != 0)
+ return -1;
- if (result != 0)
- return result;
+ ACE_Auto_Array_Ptr<char> argv_deleter(argv_tmp);
if (orb_args.add ("-ORBSvcConfDirective\"static Advanced_Resource_Factory '-ORBReactorType select_st'\"") == -1)
{
@@ -273,7 +259,8 @@ Options::init (int argc, char *argv[])
" SvcConfDirective \n"),
-1);
}
- orb_argc = orb_args.argc ();
+
+ int orb_argc = orb_args.argc ();
// Now initialize the orb and pass it the leftover arguments
ACE_TRY_NEW_ENV
@@ -296,7 +283,6 @@ Options::init (int argc, char *argv[])
// If there are any arguments left (besides the executable filename)
// then they were not picked up by us or the orb and must be
// unrecognized.
-
if (orb_argc > 1)
{
// Just print out the first option as an error
@@ -306,10 +292,8 @@ Options::init (int argc, char *argv[])
return -1;
}
- // If no persistent implementation specified, use a simple heap.
- if (this->repo_config_ == 0)
- if (this->initialize_non_persistence () != 0)
- return -1;
+ if (this->initialize_persistence () != 0)
+ return -1;
// Indicates successful parsing of command line.
return 0;
@@ -325,13 +309,12 @@ Options::print_usage (void) const
ACE_ERROR ((LM_ERROR,
"Usage:\n"
"\n"
- "ImR_Activator [-c cmd] [-d lvl] [-l] [-m 0/1] [-o file]"
- " [-r|-p file|-x file] [-r] [-s] [-t secs]\n"
+ "ImR_Activator [-c cmd] [-d 0|1|2] [-l] [-m] [-o file]"
+ " [-r|-p file|-x file] [-s] [-t secs]\n"
"\n"
" -c command Runs service commands ('install' or 'remove')\n"
" -d level Sets the debug level\n"
" -l Lock the database\n"
- " -m [0/1] Turn on(1)/off(0) multicast (default: 1)\n"
" -o file Outputs the ImR's IOR to a file\n"
" -p file Use file for storing/loading settings\n"
" -x file Use XML file for storing/loading setting\n"
@@ -341,7 +324,23 @@ Options::print_usage (void) const
);
}
-
+int
+Options::initialize_persistence(void)
+{
+ switch (this->repo_mode_)
+ {
+ case REPO_NONE:
+ return this->initialize_non_persistence();
+ case REPO_XML_FILE:
+ return this->initialize_xml_persistence();
+ case REPO_HEAP_FILE:
+ return this->initialize_heap_persistence();
+ case REPO_REGISTRY:
+ return this->initialize_registry_persistence();
+ }
+ ACE_ERROR((LM_ERROR, "Error: Unknown persistence type.\n"));
+ return -1;
+}
/**
* The most portable form of persistence is file persistence. Here
* we assign an ACE_Configuration_Heap object using @param filename
@@ -351,36 +350,21 @@ Options::print_usage (void) const
* @retval -1 Failure
*/
int
-Options::initialize_file_persistence (const char *filename)
+Options::initialize_heap_persistence (void)
{
- if (this->repo_config_ != 0)
- {
- ACE_ERROR ((LM_ERROR,
- "Error: initialize_file_persistence (): "
- "Configuration already defined. \n"
- "Did you pass multiple persistence options?\n"));
- return -1;
- }
-
- Repository_Configuration *repo_config = 0;
+ ACE_ASSERT(this->repo_config_.get() == 0);
- ACE_NEW_RETURN (repo_config,
- Repository_Configuration ("h"),
- -1);
+ auto_ptr<Repository_Configuration> rc(new Repository_Configuration ("h"));
- if (repo_config->open (filename) == 0)
+ if (rc->open (this->file_name_.c_str()) == 0)
{
- this->repo_config_ = repo_config;
+ this->repo_config_ = rc;
return 0;
}
-
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("Error: Opening persistent heap file '%s'\n"),
- filename));
-
+ this->file_name_.c_str()));
return -1;
-
- return 0;
}
@@ -397,19 +381,10 @@ Options::initialize_file_persistence (const char *filename)
int
Options::initialize_registry_persistence (void)
{
+ ACE_ASSERT(this->repo_config_.get() == 0);
#if defined (ACE_WIN32)
- if (this->repo_config_ != 0)
- {
- ACE_ERROR ((LM_ERROR,
- "Error: initialize_registry_persistence (): "
- "Configuration already defined. \n"
- "Did you pass multiple persistence options?\n"));
- return -1;
- }
-
- ACE_NEW_RETURN (this->repo_config_,
- Repository_Configuration ("w"),
- -1);
+ auto_ptr<Repository_Configuration> rc(new Repository_Configuration ("w"));
+ this->repo_config_ = rc;
return 0;
#else /* ACE_WIN32 */
ACE_ERROR_RETURN ((LM_ERROR, "Registry not supported on this platform"), -1);
@@ -428,20 +403,15 @@ Options::initialize_registry_persistence (void)
int
Options::initialize_non_persistence (void)
{
- Repository_Configuration *repo_config = 0;
- ACE_NEW_RETURN (repo_config,
- Repository_Configuration ("h"),
- -1);
+ ACE_ASSERT(this->repo_config_.get() == 0);
+
+ auto_ptr<Repository_Configuration> rc(new Repository_Configuration ("h"));
- if (repo_config->open () == 0)
+ if (rc->open () == 0)
{
- this->repo_config_ = repo_config;
+ this->repo_config_ = rc;
return 0;
}
-
- delete repo_config;
- repo_config = 0;
-
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("Error: Opening Configuration heap\n")));
return -1;
@@ -449,27 +419,21 @@ Options::initialize_non_persistence (void)
/// Initialize for the XML repository case.
int
-Options::initialize_xml_persistence (const char *file_name)
+Options::initialize_xml_persistence (void)
{
- this->file_name_ = ACE_const_cast (char *, file_name);
+ ACE_ASSERT(this->repo_config_.get() == 0);
- Repository_Configuration *repo_config = 0;
- ACE_NEW_RETURN (repo_config,
- Repository_Configuration ("x"),
- -1);
+ auto_ptr<Repository_Configuration> rc(new Repository_Configuration ("x"));
- if (repo_config->open (file_name) == 0)
+ if (rc->open (this->file_name_.c_str()) == 0)
{
- this->repo_config_ = repo_config;
+ this->repo_config_ = rc;
return 0;
}
-
- delete repo_config;
- repo_config = 0;
-
ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("Error: Opening Configuration XML file\n")));
-
+ ACE_TEXT ("Error: Opening Configuration XML file %s\n"),
+ this->file_name_.c_str()
+ ));
return -1;
}
@@ -483,12 +447,14 @@ Options::initialize_xml_persistence (const char *file_name)
* @todo Update to unicode
*/
int
-Options::run_service_command (const char *command)
+Options::run_service_command (const ACE_CString& cmdline)
{
+ if (this->service_command_ == SC_NONE)
+ return 0;
#if defined (ACE_WIN32)
- SERVICE::instance ()->name (IMR_SERVICE_NAME, IMR_DISPLAY_NAME);
+ SERVICE::instance ()->name (IMR_ACTIVATOR_SERVICE_NAME, IMR_ACTIVATOR_DISPLAY_NAME);
- if (ACE_OS::strcmp (command, ACE_TEXT ("install")) == 0)
+ if (this->service_command_ == SC_INSTALL)
{
char pathname[_MAX_PATH * 2 + 3]; // +3 for the ' -s' at the end
@@ -501,143 +467,232 @@ Options::run_service_command (const char *command)
// Append the command used for running the implrepo as
ACE_OS::strcat (pathname, ACE_TEXT (" -s"));
- return SERVICE::instance ()->insert (SERVICE_AUTO_START,
- SERVICE_ERROR_IGNORE,
- pathname);
+ const char* DEPENDS_ON = "TAOIMRLocator"; // Must match Locator_NT_Service.h
+
+ int ret = SERVICE::instance ()->insert (SERVICE_DEMAND_START,
+ SERVICE_ERROR_NORMAL,
+ pathname,
+ 0, // group
+ 0, // tag
+ DEPENDS_ON
+ );
+ if (ret != -1) {
+ if (debug() >= 1) {
+ ACE_DEBUG ((LM_DEBUG, "ImR Activator: Service installed.\n"));
+ }
+ this->save_registry_options(cmdline);
+ } else {
+ ACE_ERROR((LM_ERROR, "Error: Failed to install service.\n"));
+ }
+ if (ret == 0)
+ return 1;
}
- else if (ACE_OS::strcmp (command, ACE_TEXT ("remove")) == 0)
+ else if (this->service_command_ == SC_REMOVE)
{
- return SERVICE::instance ()->remove ();
+ int ret = SERVICE::instance ()->remove ();
+ if (debug() >= 1) {
+ ACE_DEBUG ((LM_DEBUG, "ImR Activator: Service removed.\n"));
+ }
+ if (ret == 0)
+ return 1; // If successfull, then we don't want to continue.
}
- ACE_ERROR ((LM_ERROR, "Error: Unrecognized command: %s\n", command));
return -1;
#else /* ACE_WIN32 */
- ACE_UNUSED_ARG (command);
+ ACE_UNUSED_ARG (cmdline);
ACE_ERROR ((LM_ERROR, "Service not supported on this platform"));
return -1;
#endif /* ACE_WIN32 */
}
+int
+Options::save_registry_options(const ACE_CString& cmdline)
+{
+#if defined (ACE_WIN32)
+ HKEY key = 0;
+ // Create or open the parameters key
+ LONG err = ACE_TEXT_RegCreateKeyEx (SERVICE_REG_ROOT,
+ SERVICE_REG_PATH,
+ 0,
+ "", // class
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &key,
+ NULL
+ );
+ if (err != ERROR_SUCCESS) {
+ return -1;
+ }
+ err = ACE_TEXT_RegSetValueEx(key, "ORBInitOptions", 0, REG_SZ,
+ (LPBYTE) cmdline.c_str(), cmdline.length() + 1);
+ ACE_ASSERT(err == ERROR_SUCCESS);
+
+ err = ACE_TEXT_RegSetValueEx(key, "PersistFile", 0, REG_SZ,
+ (LPBYTE) file_name_.c_str(), file_name_.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_));
+ ACE_ASSERT(err == ERROR_SUCCESS);
+
+ DWORD tmp = ping_interval_.msec();
+ err = ACE_TEXT_RegSetValueEx(key, "PingInterval", 0, REG_DWORD,
+ (LPBYTE) &tmp, sizeof(DWORD));
+ ACE_ASSERT(err == ERROR_SUCCESS);
+
+ tmp = readonly_ ? 1 : 0;
+ err = ACE_TEXT_RegSetValueEx(key, "Lock", 0, REG_DWORD,
+ (LPBYTE) &tmp, sizeof(DWORD));
+ ACE_ASSERT(err == ERROR_SUCCESS);
+
+ tmp = repo_mode_;
+ err = ACE_TEXT_RegSetValueEx(key, "PersistType", 0, REG_DWORD,
+ (LPBYTE) &tmp, sizeof(DWORD));
+ ACE_ASSERT(err == ERROR_SUCCESS);
+
+ tmp = startup_timeout_.sec();
+ err = ACE_TEXT_RegSetValueEx(key, "Timeout", 0, REG_DWORD,
+ (LPBYTE) &tmp, sizeof(DWORD));
+ ACE_ASSERT(err == ERROR_SUCCESS);
+
+ err = ::RegCloseKey(key);
+ ACE_ASSERT(err == ERROR_SUCCESS);
+#else
+ ACE_UNUSED_ARG (cmdline);
+#endif
+ return 0;
+}
+
+namespace {
+ // This both parses the cmdline by replacing spaces with \0's, and
+ // adds each command to the ACE_ARGV.
+ void parse_command_line(char* cmdline, ACE_ARGV& argv) {
+ // This tokenizer will replace all spaces with end-of-string
+ // characters and will preserve text between "" and '' pairs.
+ ACE_Tokenizer parser (cmdline);
+ parser.delimiter_replace (' ', '\0');
+ parser.preserve_designators ('\"', '\"');
+ parser.preserve_designators ('\'', '\'');
+
+ for (char *p = parser.next (); p; p = parser.next ()) {
+ argv.add(p);
+ }
+ }
+}
/**
* We will only load from the registry if we are a service.
- * The location we store options in is HKEY_LOCAL_MACHINE:
- * SYSTEM\CurrentControlSet\Services\TAOImplRepo\Parameters
- *
- * The only key currently supported is ORBOptions
- *
- * @todo Is there a better way to handle the hKey? (as in a auto_ptr)
+ * We load each parameter from individual string keys, and then
+ * we have to parse the cmdline property into the orb_options
+ * so that they can be passed to ORB_init()
*/
int
-Options::load_registry_options (ACE_ARGV &orb_options)
+Options::load_registry_options (char*& cmdline, ACE_ARGV& argv)
{
#if defined (ACE_WIN32)
- // Only if we are running as a service
- if (!this->service ())
+ if (! this->service())
{
- if (this->debug () > 1)
+ if (this->debug () >= 2)
ACE_DEBUG ((LM_DEBUG,
- "Not running as a service, will not load data from "
- "registry\n"));
+ "ActivatorOptions::load_registry_options: Not running as "
+ "a service, will not load data from registry\n"));
return 0;
}
- HKEY hKey = 0;
- BYTE buffer[ACE_DEFAULT_ARGV_BUFSIZ] = {0};
-
- if (ACE_TEXT_RegOpenKeyEx (SERVICE_REG_ROOT,
+ HKEY key = 0;
+ // Create or open the parameters key
+ LONG err = ACE_TEXT_RegOpenKeyEx (SERVICE_REG_ROOT,
SERVICE_REG_PATH,
0,
KEY_READ,
- &hKey) != ERROR_SUCCESS)
- {
- if (this->debug () > 1)
- {
- ACE_DEBUG ((LM_DEBUG, "Could not open Registry Key, skipping\n"));
- }
-
- return 0;
- }
-
- DWORD dwType = 0;
- DWORD dwSize = sizeof (buffer);
-
- if (ACE_TEXT_RegQueryValueEx (hKey,
- SERVICE_REG_VALUE_NAME,
- NULL,
- &dwType,
- buffer,
- &dwSize) != ERROR_SUCCESS)
- {
- if (this->debug () > 1)
- {
- ACE_DEBUG ((LM_DEBUG, "Could not read Registry Key, skipping\n"));
- ::RegCloseKey (hKey);
- return 0;
- }
- }
-
- if (dwType != REG_MULTI_SZ)
- {
- ACE_ERROR ((LM_ERROR, "Error: ORB Options registry key not MULTI_SZ\n"));
- ::RegCloseKey (hKey);
- return -1;
- }
-
- // Skip the case where there are no arguments
- if (dwSize > 1)
- {
- // Create an argv array
- char **orb_argv = 0;
-
- ACE_NEW_RETURN (orb_argv, char *[dwSize], -1);
-
- char *tchar_buffer = ACE_reinterpret_cast (char *, buffer);
- orb_argv[0] = tchar_buffer;
+ &key
+ );
+ if (err != ERROR_SUCCESS) {
+ // If there aren't any saved parameters, then that's ok.
+ return 0;
+ }
+ TCHAR tmpstr[4096];
+ DWORD sz = sizeof(tmpstr);
+ DWORD type = 0;
+ err = ACE_TEXT_RegQueryValueEx(key, "ORBInitOptions", 0, &type,
+ (LPBYTE) tmpstr, &sz);
+ if (err == ERROR_SUCCESS) {
+ ACE_ASSERT(type == REG_SZ);
+ tmpstr[sz] = ACE_LIB_TEXT('\0');
+ cmdline = new char[sz+1];
+ ACE_OS::strcpy(cmdline, tmpstr);
+ parse_command_line(cmdline, argv);
+ }
- if (this->debug () > 1)
- ACE_DEBUG ((LM_DEBUG,
- "Registry Argument Added: %s\n",
- orb_argv[0]));
+ sz = sizeof(tmpstr);
+ err = ACE_TEXT_RegQueryValueEx(key, "PersistFile", 0, &type,
+ (LPBYTE) tmpstr, &sz);
+ if (err == ERROR_SUCCESS) {
+ ACE_ASSERT(type == REG_SZ);
+ tmpstr[sz] = ACE_LIB_TEXT('\0');
+ this->file_name_ = ACE_CString(tmpstr);
+ }
- int orb_argv_pos = 1;
+ sz = sizeof(tmpstr);
+ err = ACE_TEXT_RegQueryValueEx(key, "IORFile", 0, &type,
+ (LPBYTE) tmpstr, &sz);
+ if (err == ERROR_SUCCESS) {
+ ACE_ASSERT(type == REG_SZ);
+ tmpstr[sz] = ACE_LIB_TEXT('\0');
+ this->ior_output_file_ = ACE_CString(tmpstr);
+ }
- for (unsigned int buffer_pos = 0;
- buffer_pos < dwSize / sizeof (char ) - 2;
- ++buffer_pos)
- {
- if (tchar_buffer[buffer_pos] == 0)
- {
- if (this->debug () > 1)
- ACE_DEBUG ((LM_DEBUG,
- "Registry Argument Added: %s\n",
- &tchar_buffer[buffer_pos] + 1));
+ sz = sizeof(debug_);
+ err = ACE_TEXT_RegQueryValueEx(key, "DebugLevel", 0, &type,
+ (LPBYTE) &debug_ , &sz);
+ if (err == ERROR_SUCCESS) {
+ ACE_ASSERT(type == REG_DWORD);
+ }
- orb_argv[orb_argv_pos++] = &tchar_buffer[buffer_pos] + 1;
- }
- }
+ DWORD tmp = 0;
+ err = ACE_TEXT_RegQueryValueEx(key, "PingInterval", 0, &type,
+ (LPBYTE) &tmp, &sz);
+ if (err == ERROR_SUCCESS) {
+ ACE_ASSERT(type == REG_DWORD);
+ ping_interval_.msec(tmp);
+ }
- orb_argv[orb_argv_pos] = 0;
+ tmp = 0;
+ err = ACE_TEXT_RegQueryValueEx(key, "Lock", 0, &type,
+ (LPBYTE) &tmp, &sz);
+ if (err == ERROR_SUCCESS) {
+ ACE_ASSERT(type == REG_DWORD);
+ readonly_ = tmp != 0;
+ }
- orb_options.add (orb_argv);
+ err = ACE_TEXT_RegQueryValueEx(key, "PersistType", 0, &type,
+ (LPBYTE) &repo_mode_, &sz);
+ if (err == ERROR_SUCCESS) {
+ ACE_ASSERT(type == REG_DWORD);
+ }
- delete [] orb_argv;
- }
+ tmp = 0;
+ err = ACE_TEXT_RegQueryValueEx(key, "Timeout", 0, &type,
+ (LPBYTE) &tmp, &sz);
+ if (err == ERROR_SUCCESS) {
+ ACE_ASSERT(type == REG_DWORD);
+ startup_timeout_.sec(tmp);
+ }
- if (::RegCloseKey (hKey) != ERROR_SUCCESS)
- {
- ACE_ERROR ((LM_ERROR, "Error: Could close Registry Key\n"));
- return -1;
- }
+ err = ::RegCloseKey(key);
+ ACE_ASSERT(err == ERROR_SUCCESS);
return 0;
#else /* ACE_WIN32 */
- ACE_UNUSED_ARG (orb_options);
- ACE_ERROR ((LM_ERROR, "Service not supported on this platform"));
-
- return -1;
+ ACE_UNUSED_ARG (cmdline);
+ ACE_UNUSED_ARG (argv);
+ return 0;
#endif /* ACE_WIN32 */
}
@@ -647,7 +702,7 @@ Options::load_registry_options (ACE_ARGV &orb_options)
* @retval 0 Run as standalone service
* @retval 1 Run as a service (only on NT right now)
*/
-int
+bool
Options::service (void) const
{
return this->service_;
@@ -671,8 +726,8 @@ Options::debug (void) const
/**
* @return The file where the IOR will be stored.
*/
-FILE *
-Options::output_file (void) const
+ACE_CString
+Options::output_filename (void) const
{
return this->ior_output_file_;
}
@@ -681,7 +736,7 @@ Options::output_file (void) const
/**
* @return The amount of time to wait for a server to start.
*/
-const ACE_Time_Value &
+ACE_Time_Value
Options::startup_timeout (void) const
{
return this->startup_timeout_;
@@ -691,7 +746,7 @@ Options::startup_timeout (void) const
/**
* @return The amount of time to wait between pings
*/
-const ACE_Time_Value &
+ACE_Time_Value
Options::ping_interval (void) const
{
return this->ping_interval_;
@@ -703,16 +758,16 @@ Options::ping_interval (void) const
Repository_Configuration *
Options::config (void) const
{
- return this->repo_config_;
+ return this->repo_config_.get();
}
-char *
+int
Options::repository_mode (void)
{
- return &this->repo_mode_;
+ return this->repo_mode_;
}
-char *
+ACE_CString
Options::file_name (void) const
{
return this->file_name_;
@@ -758,26 +813,16 @@ Options::orb (void) const
return CORBA::ORB::_duplicate (this->orb_.in ());
}
-
-/**
- * @retval 0 Do not listen for multicast location requests.
- * @retval 1 Do Listen.
- */
-int
-Options::multicast (void) const
-{
- return this->multicast_;
-}
-
/**
* @retval 0 Normal operation.
* @retval 1 Do not let server info be modified.
*/
-int
+bool
Options::readonly (void) const
{
return this->readonly_;
}
+
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
template class ACE_Singleton <Options, ACE_Null_Mutex>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
diff --git a/TAO/orbsvcs/ImplRepo_Service/Options.h b/TAO/orbsvcs/ImplRepo_Service/Activator_Options.h
index 7f9bf30a776..252e4311dbb 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Options.h
+++ b/TAO/orbsvcs/ImplRepo_Service/Activator_Options.h
@@ -12,8 +12,8 @@
*/
//=============================================================================
-#ifndef OPTIONS_H
-#define OPTIONS_H
+#ifndef ACTIVATOR_OPTIONS_H
+#define ACTIVATOR_OPTIONS_H
#include "Repository_Configuration.h"
@@ -21,7 +21,8 @@
#include "tao/PortableServer/ImplRepoC.h"
#include "ace/Singleton.h"
-
+#include "ace/SString.h"
+#include "ace/Auto_Ptr.h"
// Forward declarations
class ACE_ARGV;
@@ -37,31 +38,41 @@ class ACE_ARGV;
class Options
{
public:
+ enum REPO_MODE {
+ REPO_NONE,
+ REPO_XML_FILE,
+ REPO_HEAP_FILE,
+ REPO_REGISTRY
+ };
+
+ enum SERVICE_COMMAND {
+ SC_NONE,
+ SC_INSTALL,
+ SC_REMOVE
+ };
+
/// Default Constructor
Options ();
- /// Destructor
- ~Options();
-
/// Parse the command-line arguments and initialize the options.
int init (int argc, char *argv[]);
/// Service Mode
- int service (void) const;
+ bool service (void) const;
/// Debug level for the Implementation Repository.
unsigned int debug (void) const;
/// Returns the file where the IOR should be stored.
- FILE *output_file (void) const;
+ ACE_CString output_filename (void) const;
/// Returns the configuration object.
Repository_Configuration* config (void) const;
- char *repository_mode (void);
+ int repository_mode (void);
- /// Returns the file addr.
- char *file_name (void) const;
+ /// Returns the file name.
+ ACE_CString file_name (void) const;
/// Converts the activation mode to a const char *. Needed to put
/// the activation mode into the XML file or print it out.
@@ -70,19 +81,19 @@ public:
ImplementationRepository::ActivationMode convert_mode (const char *mode);
/// Returns the timeout value for program starting.
- const ACE_Time_Value &startup_timeout (void) const;
+ ACE_Time_Value startup_timeout (void) const;
/// Returns the timeout value for program starting.
- const ACE_Time_Value &ping_interval (void) const;
+ ACE_Time_Value ping_interval (void) const;
/// Returns a pointer to the ORB.
CORBA::ORB_ptr orb (void) const;
/// Will we listen for multicast location requests?
- int multicast (void) const;
+ bool multicast (void) const;
/// Do we allow modifications to the servers?
- int readonly (void) const;
+ bool readonly (void) const;
private:
/// Parses and pulls out arguments for the ImR
@@ -91,8 +102,11 @@ private:
/// Print the usage information.
void print_usage (void) const;
- /// Initialize file persistence.
- int initialize_file_persistence (const char *filename);
+ /// Wrapper for the other initialize_persistence() methods
+ int initialize_persistence(void);
+
+ /// Initialize heap file persistence.
+ int initialize_heap_persistence (void);
/// Initialize Registry persistence.
int initialize_registry_persistence (void);
@@ -101,31 +115,32 @@ private:
int initialize_non_persistence (void);
/// Initialize XML file persistence
- int initialize_xml_persistence (const char *file_name);
+ int initialize_xml_persistence (void);
/// Run a service command.
- int run_service_command (const char *command);
+ int run_service_command (const ACE_CString& cmdline);
/// Loads ORB options from the registry
- int load_registry_options (ACE_ARGV &orb_options);
+ int load_registry_options (char*& cmdline, ACE_ARGV& argv);
+ int save_registry_options (const ACE_CString& cmdline);
/// The persistent configuration object.
- Repository_Configuration* repo_config_;
+ auto_ptr<Repository_Configuration> repo_config_;
/// Mode of the Server Repository: if XML (x) or non-XML (n)
- char repo_mode_;
+ int repo_mode_;
/// The persistent file option.
- char *file_name_;
+ ACE_CString file_name_;
/// Debug level.
unsigned int debug_;
/// File where the IOR of the server object is stored.
- FILE *ior_output_file_;
+ ACE_CString ior_output_file_;
/// Will we listen for multicast location requests?
- int multicast_;
+ bool multicast_;
/// The ORB for the Implementation Repository.
CORBA::ORB_var orb_;
@@ -134,15 +149,18 @@ private:
ACE_Time_Value ping_interval_;
/// Are we running as a service?
- int service_;
+ bool service_;
/// The amount of time to wait for a server to response after starting it.
ACE_Time_Value startup_timeout_;
/// Can the server_repository be modified?
- int readonly_;
+ bool readonly_;
+
+ /// SC_NONE, SC_INSTALL, SC_REMOVE, ...
+ int service_command_;
};
typedef ACE_Singleton <Options, ACE_Null_Mutex> OPTIONS;
-#endif /* OPTIONS_H */
+#endif
diff --git a/TAO/orbsvcs/ImplRepo_Service/Forwarder.cpp b/TAO/orbsvcs/ImplRepo_Service/Forwarder.cpp
index b30fc16f690..709239a31ce 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Forwarder.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/Forwarder.cpp
@@ -25,8 +25,7 @@
* use. It also grabs a reference to the POACurrent object for use in
* preinvoke.
*/
-ImR_Forwarder::ImR_Forwarder (ImR_Locator_i *imr_impl,
- CORBA::ORB_ptr orb)
+ImR_Forwarder::ImR_Forwarder (ImR_Locator_i *imr_impl, CORBA::ORB_ptr orb)
: imr_impl_ (imr_impl),
orb_ (orb)
{
@@ -76,30 +75,30 @@ ImR_Forwarder::preinvoke (const PortableServer::ObjectId &,
ACE_TRY
{
- // Get the POA name.
CORBA::String_var poa_name = poa->the_name();
- // Activate the server.
- ior =
- this->imr_impl_->activate_server_with_startup (poa_name.in (),
- 1
- ACE_ENV_ARG_PARAMETER);
+ // 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.
+ ior = this->imr_impl_->activate_server_with_startup (poa_name.in (), 1 ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
- // Add the key
- char *key_str = 0;
+ // Check that the returned ior is the expected partial ior with
+ // missing ObjectKey.
+ ACE_ASSERT(ACE_OS::strncmp(ior.c_str(), "corbaloc:", 9) == 0);
+ ACE_ASSERT(ior[ior.length() - 1] == '/');
+
+ CORBA::String_var key_str;
// Unlike POA Current, this implementation cannot be cached.
TAO_POA_Current *tao_current =
ACE_dynamic_cast (TAO_POA_Current*, this->poa_current_var_.in ());
TAO_POA_Current_Impl *impl = tao_current->implementation ();
- TAO::ObjectKey::encode_sequence_to_string (key_str,
- impl->object_key ());
+ TAO::ObjectKey::encode_sequence_to_string (key_str.out(), impl->object_key ());
// Append the key_string to the IOR that is received from the
// activate_server_with_startup function call.
- ior += key_str;
- CORBA::string_free (key_str);
+ ior += key_str.in();
// Get the object corresponding to the string.
forward_obj =
@@ -123,10 +122,8 @@ ImR_Forwarder::preinvoke (const PortableServer::ObjectId &,
if (!CORBA::is_nil (forward_obj.in ()))
ACE_THROW_RETURN (PortableServer::ForwardRequest (forward_obj.in ()), 0);
- else
- ACE_ERROR ((LM_ERROR,
- "Error: Forward_to reference is nil.\n"));
+ ACE_ERROR ((LM_ERROR, "Error: Forward_to reference is nil.\n"));
ACE_THROW_RETURN (CORBA::OBJECT_NOT_EXIST (), 0);
}
@@ -143,5 +140,4 @@ ImR_Forwarder::postinvoke (const PortableServer::ObjectId &,
ACE_THROW_SPEC ((CORBA::SystemException))
{
delete servant;
- delete imr_impl_;
}
diff --git a/TAO/orbsvcs/ImplRepo_Service/Forwarder.h b/TAO/orbsvcs/ImplRepo_Service/Forwarder.h
index 5daf82c1cad..fe0828939ad 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Forwarder.h
+++ b/TAO/orbsvcs/ImplRepo_Service/Forwarder.h
@@ -31,9 +31,7 @@ class ImR_Locator_i;
class ImR_Forwarder: public PortableServer::ServantLocator
{
public:
- /// Constructor
- ImR_Forwarder (ImR_Locator_i *ir_impl,
- CORBA::ORB_ptr orb);
+ ImR_Forwarder (ImR_Locator_i *ir_impl, CORBA::ORB_ptr orb);
/// Called before the invocation begins.
virtual PortableServer::Servant preinvoke (
diff --git a/TAO/orbsvcs/ImplRepo_Service/Locator.cpp b/TAO/orbsvcs/ImplRepo_Service/INS_Locator.cpp
index f6a17925a79..1139095072c 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Locator.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/INS_Locator.cpp
@@ -10,19 +10,17 @@
*/
//=============================================================================
-#include "Locator.h"
-#include "ImR_Activator_i.h"
+#include "INS_Locator.h"
+#include "ImR_Locator_i.h"
-ImR_Locator::ImR_Locator (ImR_Activator_i *repo)
- : repo_ (repo)
+INS_Locator::INS_Locator (ImR_Locator_i* loc)
+ : imr_locator_ (loc)
{
}
char *
-ImR_Locator::locate (const char *object_key
- ACE_ENV_ARG_DECL)
+INS_Locator::locate (const char* object_key ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException, IORTable::NotFound))
{
- ACE_CString key (object_key);
- return this->repo_->find_ior (key ACE_ENV_ARG_PARAMETER);
+ return this->imr_locator_->find_ior (object_key ACE_ENV_ARG_PARAMETER);
}
diff --git a/TAO/orbsvcs/ImplRepo_Service/Locator.h b/TAO/orbsvcs/ImplRepo_Service/INS_Locator.h
index c5e18b06273..2b8a8a35c56 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Locator.h
+++ b/TAO/orbsvcs/ImplRepo_Service/INS_Locator.h
@@ -11,52 +11,39 @@
*/
//=============================================================================
-#ifndef IMR_LOCATOR_H
-#define IMR_LOCATOR_H
-
+#ifndef IMR_INS_LOCATOR_H
+#define IMR_INS_LOCATOR_H
#include /**/ "ace/pre.h"
#include "tao/IORTable/IORTable.h"
#include "tao/LocalObject.h"
-class ImR_Activator_i;
-
-#if defined (_MSC_VER)
-# if (_MSC_VER >= 1200)
-# pragma warning(push)
-# endif /* _MSC_VER >= 1200 */
-# pragma warning (disable:4250)
-#endif /* _MSC_VER */
+class ImR_Locator_i;
/**
- * @class ImR_Locator
+ * @class INS_Locator
*
* @brief Implementation Repository INS Locator class
*
* This class provides a callback for the IORTable to call when it needs
* to dynamically receive a IOR to forward in response to an INS request.
*/
-class ImR_Locator : public virtual IORTable::Locator,
+class INS_Locator : public virtual IORTable::Locator,
public virtual TAO_Local_RefCounted_Object
{
public:
/// Constructor
- ImR_Locator (ImR_Activator_i *repo);
+ INS_Locator (ImR_Locator_i* loc);
/// Locate the appropriate IOR.
- char * locate (const char *object_key
- ACE_ENV_ARG_DECL)
+ char * locate (const char *object_key ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException, IORTable::NotFound));
private:
- /// The Implementation Repository implementation
- ImR_Activator_i *repo_;
-};
-#if defined(_MSC_VER) && (_MSC_VER >= 1200)
-# pragma warning(pop)
-#endif /* _MSC_VER */
+ ImR_Locator_i* imr_locator_;
-#include /**/ "ace/post.h"
+};
-#endif /* IMR_LOCATOR_H */
+#include /**/ "ace/post.h"
+#endif
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImR_Activator.cpp b/TAO/orbsvcs/ImplRepo_Service/ImR_Activator.cpp
index 7a371e8a26e..a0d724942f5 100644
--- a/TAO/orbsvcs/ImplRepo_Service/ImR_Activator.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/ImR_Activator.cpp
@@ -1,9 +1,9 @@
/* -*- C++ -*- */
// $Id$
-#include "Options.h"
+#include "Activator_Options.h"
#include "ImR_Activator_i.h"
-#include "NT_Service.h"
+#include "Activator_NT_Service.h"
int
run_standalone (void)
@@ -34,29 +34,27 @@ run_standalone (void)
if (status == -1)
return 1;
}
+ return 0;
}
ACE_CATCH (CORBA::SystemException, sysex)
{
ACE_PRINT_EXCEPTION (sysex, "System Exception");
- return 1;
}
ACE_CATCH (CORBA::UserException, userex)
{
ACE_PRINT_EXCEPTION (userex, "User Exception");
- return 1;
}
ACE_CATCHANY
{
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Unknown Exception");
- return 1;
}
ACE_ENDTRY;
- return 0;
+ return 1;
}
#if defined (ACE_WIN32)
-ACE_NT_SERVICE_DEFINE (service, ImR_NT_Service, IMR_SERVICE_NAME);
+ACE_NT_SERVICE_DEFINE (service, Activator_NT_Service, IMR_ACTIVATOR_SERVICE_NAME);
#endif /* ACE_WIN32 */
int
@@ -89,7 +87,7 @@ main (int argc, char *argv[])
else if (result > 0)
return 0; // No error, but we should exit anyway.
- if (OPTIONS::instance ()->service () == 1)
+ if (OPTIONS::instance()->service())
return run_service ();
return run_standalone ();
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.cpp b/TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.cpp
index d35ccf90f8f..146b3685b8b 100644
--- a/TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.cpp
@@ -2,9 +2,9 @@
#include "ImR_Activator_i.h"
-#include "Locator.h"
+#include "INS_Locator.h"
#include "Iterator.h"
-#include "Options.h"
+#include "Activator_Options.h"
#include "tao/PortableServer/Default_Acceptor_Filter.h"
#include "tao/PortableServer/ImR_LocatorC.h"
@@ -25,38 +25,31 @@ ACE_RCSID (ImplRepo_Service,
"$Id$")
-// Constructor
ImR_Activator_i::ImR_Activator_i (void)
- : locator_ (0),
- ior_multicast_ (0)
+ : registration_token_(0)
{
- this->locator_ = new ImR_Locator (this);
+ char host_name[MAXHOSTNAMELEN + 1];
+ ACE_OS::hostname (host_name, MAXHOSTNAMELEN);
+ name_ = host_name;
}
char *
-ImR_Activator_i::find_ior (const ACE_CString &object_name
- ACE_ENV_ARG_DECL)
- ACE_THROW_SPEC ((CORBA::SystemException, IORTable::NotFound))
+ImR_Activator_i::find_ior (const char* oname ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound))
{
- ACE_CString endpoint;
- ACE_CString poa_name;
-
// We assume that the first part of the object name is the poa name.
// So we would think that a name of foo/bar means that the POA name
// is foo.
+ ACE_CString object_name(oname);
+ ssize_t pos = object_name.find ('/');
- int pos = object_name.find ('/');
-
- if (pos == object_name.npos)
- pos = ACE_static_cast (int, object_name.length ());
+ if (pos == ACE_CString::npos)
+ pos = ACE_static_cast (ssize_t, object_name.length ());
+ ACE_CString poa_name;
poa_name.set (object_name.fast_rep (), pos, 1);
- if (OPTIONS::instance()->debug () >= 2)
- ACE_DEBUG ((LM_DEBUG,
- "find_ior: poa name <%s>, %d\n",
- poa_name.c_str (), pos));
-
+ ACE_CString endpoint;
ACE_TRY
{
// Activate the server and return the object reference.
@@ -66,7 +59,7 @@ ImR_Activator_i::find_ior (const ACE_CString &object_name
}
ACE_CATCHANY
{
- ACE_THROW_RETURN (IORTable::NotFound (), 0);
+ ACE_THROW_RETURN (ImplementationRepository::NotFound (), 0);
}
ACE_ENDTRY;
ACE_CHECK_RETURN (0);
@@ -78,10 +71,9 @@ ImR_Activator_i::find_ior (const ACE_CString &object_name
ACE_CString ior = endpoint;
ior += object_name2;
- if (OPTIONS::instance()->debug () >= 2)
- ACE_DEBUG ((LM_DEBUG,
- "find_ior: new ior is <%s>\n",
- endpoint.c_str ()));
+ if (OPTIONS::instance()->debug () >= 1)
+ ACE_DEBUG ((LM_DEBUG, "ImR Activator: Found IOR"
+ " for %s is %s\n", oname, endpoint.c_str()));
return CORBA::string_dup (ior.c_str ());
}
@@ -90,21 +82,38 @@ ImR_Activator_i::find_ior (const ACE_CString &object_name
// Starts the server defined by the POA name <server> if it is
// not already started and if it can be started.
void
-ImR_Activator_i::activate_server (const char *server
- ACE_ENV_ARG_DECL)
+ImR_Activator_i::activate_server (const char *server ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
ImplementationRepository::NotFound,
ImplementationRepository::CannotActivate))
{
// Since this is called through the Admin interface, we should ignore some
// of the activation modes. Also ignore the return value.
- this->activate_server_with_startup (server, 0 ACE_ENV_ARG_PARAMETER);
+ this->activate_server_i (server, 0 ACE_ENV_ARG_PARAMETER);
+ if (OPTIONS::instance()->debug () >= 1)
+ ACE_DEBUG ((LM_DEBUG, "ImR Activator: Activate server %s.\n", server));
+}
+
+char *
+ImR_Activator_i::activate_server_with_startup (const char *server,
+ int check_startup
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ImplementationRepository::NotFound,
+ ImplementationRepository::CannotActivate))
+{
+ if (OPTIONS::instance()->debug () >= 1)
+ {
+ ACE_DEBUG ((LM_DEBUG, "ImR Activator: Activate server"
+ " %s. Check startup=%d.\n", server, check_startup));
+ }
+ return this->activate_server_i (server, check_startup ACE_ENV_ARG_PARAMETER);
}
// Activates the server and returns the IOR of the object that is
// activated.
char *
-ImR_Activator_i::activate_server_with_startup (const char *server,
+ImR_Activator_i::activate_server_i(const char *server,
int check_startup
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
@@ -114,10 +123,7 @@ ImR_Activator_i::activate_server_with_startup (const char *server,
CORBA::ORB_var orb = OPTIONS::instance ()->orb ();
int start = 0;
- ACE_CString server_object_ior, location;
-
- if (OPTIONS::instance()->debug () >= 1)
- ACE_DEBUG ((LM_DEBUG, "Activating Server: %s\n", server));
+ ACE_CString server_object_ior, partial_ior;
ACE_CString logical, startup, working;
ImplementationRepository::EnvironmentList environment;
@@ -132,20 +138,20 @@ ImR_Activator_i::activate_server_with_startup (const char *server,
activation) != 0)
{
ACE_ERROR ((LM_ERROR,
- "Error: Cannot find startup info for server <%s>\n",
+ "ImR Activator: Cannot find startup info for server <%s>\n",
server));
ACE_THROW_RETURN(ImplementationRepository::NotFound (), 0);
}
// Find out if it is already running
if (this->repository_.get_running_info (server,
- location,
+ partial_ior,
server_object_ior) != 0)
{
// If we had problems getting the server_object_ior, probably meant that
// there is no <server> registered
ACE_ERROR ((LM_ERROR,
- "Error: Cannot find ServerObject IOR for server <%s>\n",
+ "ImR Activator: Cannot find ServerObject IOR for server <%s>\n",
server));
ACE_THROW_RETURN (ImplementationRepository::NotFound (), 0);
}
@@ -169,7 +175,7 @@ ImR_Activator_i::activate_server_with_startup (const char *server,
if (CORBA::is_nil (server_object.in ()))
{
ACE_ERROR ((LM_ERROR,
- "Error: Invalid ServerObject IOR: <%s>\n",
+ "ImR Activator: Invalid ServerObject IOR: <%s>\n",
server_object_ior.c_str ()));
ACE_THROW_RETURN (ImplementationRepository::NotFound (), 0);
}
@@ -186,10 +192,10 @@ ImR_Activator_i::activate_server_with_startup (const char *server,
ACE_ENDTRY;
}
else
- // We need to restart
+ {
start = 1;
+ }
- // Start it up...
if (start == 1)
{
// Make sure the activation allows us to start it up.
@@ -200,7 +206,6 @@ ImR_Activator_i::activate_server_with_startup (const char *server,
CORBA::COMPLETED_NO),
0);
- // Start the server.
this->start_server_i (server);
ACE_CHECK_RETURN (0);
}
@@ -208,11 +213,11 @@ ImR_Activator_i::activate_server_with_startup (const char *server,
// Get the latest information about where the server is running and
// it's IOR
if (this->repository_.get_running_info (server,
- location,
+ partial_ior,
server_object_ior) != 0)
{
ACE_ERROR ((LM_ERROR,
- "ImR_Activator_i::activate_server: cannot resolve server <%s>\n",
+ "ImR Activator: Can not resolve server <%s>\n",
server));
}
@@ -221,20 +226,19 @@ ImR_Activator_i::activate_server_with_startup (const char *server,
if (this->repository_.update (server, "", "") != 0)
{
ACE_ERROR ((LM_ERROR,
- "Error: Could not update information for server <%s>\n",
+ "ImR Activator: Could not update information for server <%s>\n",
server));
ACE_THROW_RETURN (ImplementationRepository::NotFound (), 0);
}
}
- return CORBA::string_dup (location.c_str ());
+ return CORBA::string_dup (partial_ior.c_str ());
}
// Starts the server process
void
-ImR_Activator_i::start_server_i (const char *server
- ACE_ENV_ARG_DECL)
+ImR_Activator_i::start_server_i (const char *server ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
ImplementationRepository::NotFound,
ImplementationRepository::CannotActivate))
@@ -242,7 +246,7 @@ ImR_Activator_i::start_server_i (const char *server
CORBA::ORB_var orb = OPTIONS::instance ()->orb ();
int spawned_pid = 0;
- ACE_CString logical, startup, working, location;
+ ACE_CString logical, startup, working;
ImplementationRepository::EnvironmentList environment;
ImplementationRepository::ActivationMode activation;
@@ -256,7 +260,7 @@ ImR_Activator_i::start_server_i (const char *server
{
// In case of failure, print it out.
ACE_ERROR ((LM_ERROR,
- "Error: Cannot find startup info for server <%s>\n",
+ "ImR Activator: Cannot find startup info for server <%s>\n",
server));
// And, throw the exception.
@@ -270,7 +274,7 @@ ImR_Activator_i::start_server_i (const char *server
if (startup_val == -1)
{
ACE_ERROR ((LM_ERROR,
- "Error: Cannot find startup info for server <%s>\n",
+ "ImR Activator: Cannot find startup info for server <%s>\n",
server));
ACE_THROW (ImplementationRepository::NotFound ());
@@ -284,7 +288,7 @@ ImR_Activator_i::start_server_i (const char *server
{
// If there is no startup information, throw an exception
ACE_ERROR ((LM_ERROR,
- "Error: No startup information for server <%s>\n",
+ "ImR Activator: No startup information for server <%s>\n",
server));
ACE_THROW (ImplementationRepository::CannotActivate
(CORBA::string_dup ("No startup information")));
@@ -292,7 +296,7 @@ ImR_Activator_i::start_server_i (const char *server
}
if (OPTIONS::instance()->debug () >= 1)
- ACE_DEBUG ((LM_DEBUG, "Starting %s\n", server));
+ ACE_DEBUG ((LM_DEBUG, "ImR Activator: Starting server %s\n", server));
// Set the Process parameters.
ACE_Process_Options proc_opts;
@@ -316,7 +320,7 @@ ImR_Activator_i::start_server_i (const char *server
{
// If invalid PID..
ACE_ERROR ((LM_ERROR,
- "Error: Cannot activate server <%s> using <%s>\n",
+ "ImR Activator: Cannot activate server <%s> using <%s>\n",
server,
startup.c_str ()));
@@ -326,7 +330,7 @@ ImR_Activator_i::start_server_i (const char *server
ACE_CHECK;
}
else if (OPTIONS::instance ()->debug () >= 2)
- ACE_DEBUG ((LM_DEBUG, "Process ID is %d\n", spawned_pid));
+ ACE_DEBUG ((LM_DEBUG, "ImR_Activator_i::start_server_i: Process ID is %d\n", spawned_pid));
}
// Now that the server has been started up, we need to go back into the event
@@ -335,7 +339,6 @@ ImR_Activator_i::start_server_i (const char *server
int starting_up;
- // Get the timeout value.
ACE_Time_Value timeout = OPTIONS::instance ()->startup_timeout ();
// We will wait till the timeout period for the server to get
@@ -345,7 +348,7 @@ ImR_Activator_i::start_server_i (const char *server
while ((starting_up = this->repository_.starting_up (server)) == 1)
{
if (OPTIONS::instance()->debug () >= 2)
- ACE_DEBUG ((LM_DEBUG, "activate_server: Going into handle_events\n"));
+ ACE_DEBUG ((LM_DEBUG, "ImR_Activator_i::activate_server: Going into handle_events\n"));
// Will wait for the specified timeout.
int result = orb_core->reactor ()->handle_events (&timeout);
@@ -359,7 +362,7 @@ ImR_Activator_i::start_server_i (const char *server
// print the same.
ACE_ERROR ((LM_ERROR,
- "Error: Cannot activate server <%s> using <%s>, "
+ "ImR Activator: Cannot activate server <%s> using <%s>, "
"terminating it.\n",
server,
startup.c_str ()));
@@ -375,13 +378,13 @@ ImR_Activator_i::start_server_i (const char *server
// If the control comes here, it means that the server got activated.
if (OPTIONS::instance()->debug () >= 2)
- ACE_DEBUG ((LM_DEBUG, "activate_server: Got out of handle_events loop\n"));
+ ACE_DEBUG ((LM_DEBUG, "ImR_Activator_i::activate_server: Got out of handle_events loop\n"));
// Check to see if it disappeared on us
if (starting_up == -1)
{
ACE_ERROR ((LM_ERROR,
- "Error: Cannot find startup info for server <%s>\n",
+ "ImR Activator: Cannot find startup info for server <%s>\n",
server));
ACE_THROW (ImplementationRepository::NotFound ());
@@ -439,7 +442,7 @@ ImR_Activator_i::ready_check (const char *server)
// If get_running_info fails, something weird must have happened.
// Maybe it was removed after we started it up, but before we got here.
ACE_ERROR ((LM_ERROR,
- "Error: Cannot find ServerObject IOR for server <%s>\n",
+ "ImR Activator: Cannot find ServerObject IOR for server <%s>\n",
server));
ACE_THROW_RETURN (
@@ -466,7 +469,7 @@ ImR_Activator_i::ready_check (const char *server)
if (CORBA::is_nil (ping_object.in ()))
{
ACE_ERROR ((LM_ERROR,
- "Error: Invalid ServerObject IOR: <%s>\n",
+ "ImR Activator: Invalid ServerObject IOR: <%s>\n",
ping_object_ior.c_str ()));
ACE_THROW_RETURN (
@@ -479,7 +482,7 @@ ImR_Activator_i::ready_check (const char *server)
ACE_CATCHANY
{
ACE_ERROR ((LM_ERROR,
- "Error: Cannot activate server <%s>, "
+ "ImR Activator: Cannot activate server <%s>, "
"terminating it (Server Ping Object failed).\n",
server));
@@ -493,25 +496,24 @@ ImR_Activator_i::ready_check (const char *server)
{
ACE_TRY_EX (ping2);
{
- // Check to see if we can ping it
if (OPTIONS::instance()->debug () >= 2)
- ACE_DEBUG ((LM_DEBUG, "Pinging Server...\n"));
+ ACE_DEBUG ((LM_DEBUG, "ImR_Activator_i::ready_check: ping server.\n"));
ping_object->ping (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK_EX (ping2);
if (OPTIONS::instance()->debug () >= 2)
- ACE_DEBUG ((LM_DEBUG, "Pinged Server OK\n"));
+ ACE_DEBUG ((LM_DEBUG, "ImR_Activator_i::ready_check: Pinged Server OK\n"));
// If we got here, we successfully pinged, therefore we
// can exit the function.
return 0;
}
- ACE_CATCHANY
+ ACE_CATCHANY // todo : I doubt we really want to retry on all exceptions. Maybe just transient?
{
// Ignore the exception
if (OPTIONS::instance()->debug () >= 2)
- ACE_DEBUG ((LM_DEBUG, "Server not ready (Exception)\n"));
+ ACE_DEBUG ((LM_DEBUG, "ImR_Activator_i::ready_check: Server not ready (Exception)\n"));
}
ACE_ENDTRY;
ACE_CHECK_RETURN (-2);
@@ -534,17 +536,22 @@ ImR_Activator_i::register_server (
const ImplementationRepository::StartupOptions &options
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
- ImplementationRepository::AlreadyRegistered))
+ ImplementationRepository::AlreadyRegistered,
+ ImplementationRepository::NotFound
+ ))
{
if (OPTIONS::instance ()->readonly ())
{
ACE_THROW (CORBA::NO_PERMISSION ());
}
+ if (OPTIONS::instance ()->debug () >= 1)
+ ACE_DEBUG((LM_DEBUG, "Imr Activator: Register server %s.\n", server));
+
if (OPTIONS::instance ()->debug () >= 2)
{
ACE_DEBUG ((LM_DEBUG,
- "Server: %s\n"
+ "ImR_Activator_i::register_server:\nServer: %s\n"
"Command Line: %s\n"
"Working Directory: %s\n"
"Activation Mode: %s\n\n",
@@ -570,33 +577,10 @@ ImR_Activator_i::register_server (
if (status == 1)
{
ACE_ERROR ((LM_ERROR,
- "Error: Server %s Already Registered!\n",
+ "ImR Activator: Server %s Already Registered!\n",
server));
ACE_THROW (ImplementationRepository::AlreadyRegistered ());
}
- else
- {
- if (OPTIONS::instance()->debug () >= 1)
- ACE_DEBUG ((LM_DEBUG,
- "register_server: Server %s Successfully Registered\n",
- server));
-
- if (OPTIONS::instance()->debug () >= 2)
- {
- ACE_DEBUG ((LM_DEBUG, "Server: %s\n"
- "Command Line: %s\n"
- "Working Directory: %s\n"
- "Activation Mode: %s\n\n",
- server,
- options.command_line.in (),
- options.working_directory.in (),
- OPTIONS::instance ()->convert_str (options.activation)));
- for (CORBA::ULong i = 0; i < options.environment.length(); ++i)
- ACE_DEBUG ((LM_DEBUG, "Environment variable %s=%s\n",
- options.environment[i].name.in (),
- options.environment[i].value.in ()));
- }
- }
}
@@ -607,8 +591,14 @@ void
ImR_Activator_i::reregister_server (const char *server,
const ImplementationRepository::StartupOptions &options
ACE_ENV_ARG_DECL)
- ACE_THROW_SPEC ((CORBA::SystemException))
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ImplementationRepository::AlreadyRegistered,
+ ImplementationRepository::NotFound
+ ))
{
+ if (OPTIONS::instance ()->debug () >= 1)
+ ACE_DEBUG((LM_DEBUG, "ImR Activator: Reregister server %s.\n", server));
+
if (OPTIONS::instance ()->readonly ())
{
ACE_THROW (CORBA::NO_PERMISSION ());
@@ -684,14 +674,9 @@ ImR_Activator_i::reregister_server (const char *server,
if (starting_up != -1)
this->repository_.starting_up (server, starting_up);
- if (OPTIONS::instance()->debug () >= 1)
- ACE_DEBUG ((LM_DEBUG,
- "Server %s Successfully Registered\n",
- server));
-
if (OPTIONS::instance()->debug () >= 2)
{
- ACE_DEBUG ((LM_DEBUG, "Server: %s\n"
+ ACE_DEBUG ((LM_DEBUG, "ImR_Activator_i::reregister_server:\nServer: %s\n"
"Command Line: %s\n"
"Working Directory: %s\n"
"Activation: %s\n\n",
@@ -717,141 +702,79 @@ ImR_Activator_i::remove_server (const char *server
{
if (OPTIONS::instance ()->readonly ())
{
+ ACE_ERROR ((LM_ERROR,
+ "ImR Activator: Activator is readonly. Can't remove server %s.\n",
+ server));
ACE_THROW (CORBA::NO_PERMISSION ());
}
if (this->repository_.remove (server) == 0)
{
if (OPTIONS::instance()->debug () >= 1)
- ACE_DEBUG ((LM_DEBUG,
- "Successfully Removed Server\n"));
+ ACE_DEBUG ((LM_DEBUG, "ImR Activator: Removed Server %s.\n", server));
}
else
{
ACE_ERROR ((LM_ERROR,
- "Error: Trying to remove unknown server <%s>\n",
+ "ImR Activator: Can't remove unknown server %s.\n",
server));
ACE_THROW (ImplementationRepository::NotFound ());
}
}
// Register the current location of the server
-char *
+void
ImR_Activator_i::server_is_running (const char *server,
- const char *location,
+ const char *partial_ior,
ImplementationRepository::ServerObject_ptr server_object
ACE_ENV_ARG_DECL)
- ACE_THROW_SPEC ((CORBA::SystemException,
- ImplementationRepository::NotFound))
+ ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound))
{
- // Get the ORB pointer.
CORBA::ORB_var orb = OPTIONS::instance ()->orb ();
- char *new_location = 0;
-
if (OPTIONS::instance()->debug () >= 1)
- ACE_DEBUG ((LM_DEBUG, "Server <%s> is running \n", server));
+ ACE_DEBUG ((LM_DEBUG, "ImR Activator: Server %s is running.\n", server));
if (OPTIONS::instance()->debug () >= 2)
- ACE_DEBUG ((LM_DEBUG, " at %s\n", location));
+ ACE_DEBUG ((LM_DEBUG, "ImR_Activator_i::server_is_running: at %s\n", partial_ior));
- // Get the stringified server_object_ior
CORBA::String_var server_object_ior =
- orb->object_to_string (server_object
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (0);
+ orb->object_to_string (server_object ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
// Update the status of the server in the repository.
- if (this->repository_.update (server, location, server_object_ior.in ()) == 0)
+ if (this->repository_.update (server, partial_ior, server_object_ior.in ()) == 0)
{
if (OPTIONS::instance()->debug () >= 1)
ACE_DEBUG ((LM_DEBUG,
- "Successful server_is_running () of <%s>\n",
- server));
+ "ImR Activator: Status updated for server %s.\n", server));
}
else
{
ACE_ERROR ((LM_ERROR,
- "Error: Could not update running information for server <%s>\n",
+ "ImR Activator: Could not update running information for server <%s>\n",
server));
- ACE_THROW_RETURN (ImplementationRepository::NotFound (), new_location);
+ ACE_THROW(ImplementationRepository::NotFound());
}
- // Get a reference to Acceptor_Registry.
- TAO_Acceptor_Registry &registry =
- orb->orb_core ()->lane_resources ().acceptor_registry ();
-
- TAO_MProfile mp;
- TAO::ObjectKey objkey;
-
- // Use a default acceptor filter, all the profiles in the ImR are valid, no
- // matter what the server has.
- TAO_Default_Acceptor_Filter filter;
-
- // Allocate space for storing the profiles. There can never be more
- // profiles than there are endpoints. In some cases, there can be
- // fewer profiles than endpoints.
- size_t pfile_count =
- registry.endpoint_count ();
- mp.set (ACE_static_cast (CORBA::ULong, pfile_count));
-
- // Leave it to the filter to decide which acceptors/in which order
- // go into the mprofile.
- filter.fill_profile (objkey,
- mp,
- registry.begin (),
- registry.end ());
-
- // @@ (brunsch) Only look at current profile for now.
- TAO_Profile *profile = mp.get_current_profile ();
-
- if (profile)
- {
- new_location = profile->to_string (ACE_ENV_SINGLE_ARG_PARAMETER);
- ACE_CHECK_RETURN (0);
- }
- else
- return new_location;
-
-
- // Search for "corbaloc:" alone, without the protocol. This code
- // should be protocol neutral.
- const char corbaloc[] = "corbaloc:";
- char *pos = ACE_OS::strstr (new_location, corbaloc);
- pos = ACE_OS::strchr (pos + sizeof (corbaloc), ':');
-
- pos = ACE_OS::strchr (pos + 1, profile->object_key_delimiter ());
-
- if (pos)
- *(pos + 1) = 0; // Crop the string
- else
- ACE_ERROR_RETURN ((LM_ERROR,
- "Could not parse my own IOR, bailing out.\n"),
- 0);
-
this->repository_.starting_up (server, 0);
-
- return new_location;
}
// Remove the state information for the current server
void
-ImR_Activator_i::server_is_shutting_down (const char *server
- ACE_ENV_ARG_DECL)
+ImR_Activator_i::server_is_shutting_down (const char *server ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
ImplementationRepository::NotFound))
{
if (this->repository_.update (server, "", "") == 0)
{
if (OPTIONS::instance()->debug () >= 1)
- ACE_DEBUG ((LM_DEBUG,
- "Successful server_is_shutting_down () of <%s>\n",
- server));
+ ACE_DEBUG ((LM_DEBUG, "ImR Activator: Shut down server %s.\n", server));
}
else
{
ACE_ERROR ((LM_ERROR,
- "Error: Could not update information for unknown server <%s>\n",
+ "ImR Activator: Could not update information for unknown server <%s>\n",
server));
ACE_THROW (ImplementationRepository::NotFound ());
}
@@ -864,39 +787,27 @@ ImR_Activator_i::init (ACE_ENV_SINGLE_ARG_DECL)
ACE_TRY
{
- // Resolve reference to IORTable
- CORBA::Object_var table_object =
+ CORBA::Object_var obj =
orb->resolve_initial_references ("IORTable" ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
-
IORTable::Table_var adapter =
- IORTable::Table::_narrow (table_object.in () ACE_ENV_ARG_PARAMETER);
+ IORTable::Table::_narrow (obj.in () ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
-
if (CORBA::is_nil (adapter.in ()))
{
ACE_ERROR ((LM_ERROR, "Nil IORTable\n"));
- }
- else
- {
- // Set the locator
- adapter->set_locator (this->locator_.in () ACE_ENV_ARG_PARAMETER);
- ACE_TRY_CHECK;
+ return -1;
}
- // Get a reference to RootPOA
- CORBA::Object_var root_poa_object =
- orb->resolve_initial_references ("RootPOA" ACE_ENV_ARG_PARAMETER);
+ obj = orb->resolve_initial_references ("RootPOA" ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
-
- if (CORBA::is_nil (root_poa_object.in ()))
+ if (CORBA::is_nil (obj.in ()))
+ {
ACE_ERROR_RETURN ((LM_ERROR,
"Unable to initialize the ROOT POA.\n"),
-1);
-
- // Get the POA object.
- this->root_poa_ = PortableServer::POA::_narrow (root_poa_object.in ()
- ACE_ENV_ARG_PARAMETER);
+ }
+ this->root_poa_ = PortableServer::POA::_narrow (obj.in () ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
PortableServer::POAManager_var poa_manager =
@@ -906,13 +817,11 @@ ImR_Activator_i::init (ACE_ENV_SINGLE_ARG_DECL)
CORBA::PolicyList policies (2);
policies.length (2);
- // Id Assignment policy
policies[0] =
this->root_poa_->create_id_assignment_policy (PortableServer::USER_ID
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
- // Lifespan policy
policies[1] =
this->root_poa_->create_lifespan_policy (PortableServer::PERSISTENT
ACE_ENV_ARG_PARAMETER);
@@ -924,12 +833,8 @@ ImR_Activator_i::init (ACE_ENV_SINGLE_ARG_DECL)
poa_manager.in (),
policies
ACE_ENV_ARG_PARAMETER);
-
- // 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;
-
- // Creation of the new POAs over, so destroy the Policy_ptr's.
+ // If create_POA throws an exception then the process will end, and free all memory.
for (CORBA::ULong i = 0; i < policies.length (); ++i)
{
CORBA::Policy_ptr policy = policies[i];
@@ -947,82 +852,37 @@ ImR_Activator_i::init (ACE_ENV_SINGLE_ARG_DECL)
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
- // Get the IMR object
- CORBA::Object_var imr_obj =
- this->imr_poa_->id_to_reference (imr_id.in () ACE_ENV_ARG_PARAMETER);
+ obj = this->imr_poa_->id_to_reference (imr_id.in () ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
+ ImplementationRepository::Administration_var activator =
+ ImplementationRepository::Administration::_narrow(obj.in() ACE_ENV_ARG_PARAMETER);
- // And its string
- this->imr_ior_ =
- orb->object_to_string (imr_obj.in () ACE_ENV_ARG_PARAMETER);
+ CORBA::String_var ior = orb->object_to_string (activator.in () ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
- // Register with IORTable
- adapter->bind ("ImR_Activator",
- this->imr_ior_.in ()
- ACE_ENV_ARG_PARAMETER);
+ adapter->bind ("ImR_Activator", ior.in() ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
- if (OPTIONS::instance ()->debug () >= 2)
- ACE_DEBUG ((LM_DEBUG,
- "The IMR IOR is: <%s>\n",
- this->imr_ior_.in ()));
-
- if (OPTIONS::instance()->output_file ())
- {
- ACE_OS::fprintf (OPTIONS::instance()->output_file (),
- "%s",
- this->imr_ior_.in ());
- ACE_OS::fclose (OPTIONS::instance()->output_file ());
- }
-
- // Register with the locator.
- // First get a reference to the ImplRepoService.
- CORBA::Object_var locator_object =
- orb->resolve_initial_references ("ImplRepoService"
- ACE_ENV_ARG_PARAMETER);
+ obj = orb->resolve_initial_references ("ImplRepoService" ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
-
- if (CORBA::is_nil (locator_object.in ()))
+ if (CORBA::is_nil (obj.in ()))
+ {
ACE_ERROR_RETURN ((LM_ERROR,
"Unable to get a reference to a Locator.\n"),
-1);
+ }
- // Get the POA object.
ImplementationRepository::Locator_var locator =
- ImplementationRepository::Locator::_narrow (locator_object.in ()
- ACE_ENV_ARG_PARAMETER);
- ACE_TRY_CHECK;
-
- char hostname[BUFSIZ];
- ACE_OS::hostname (hostname, BUFSIZ);
-
- // register this activator (with the name of the hostname where
- // this instance is being run) with the locator.
- struct hostent *hinfo = ACE_OS::gethostbyname (hostname);
- char full_hostname[BUFSIZ];
- ACE_OS::strcpy (full_hostname, hinfo->h_name);
-
- CORBA::ULong reg_act =
- locator->register_activator (full_hostname,
- imr_obj.in ()
+ ImplementationRepository::Locator::_narrow (obj.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
- if (reg_act == 1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "Activator on %s didnt get registered\n"),
- -1);
- }
+ ACE_DEBUG((LM_DEBUG, "Starting activator : %s\n", this->name_.c_str()));
- // Get reactor instance from TAO.
ACE_Reactor *reactor = orb->orb_core ()->reactor ();
- // = Set up the process manager
if (reactor != 0)
{
- // Init the Process Manager.
if (this->process_mgr_.open (ACE_Process_Manager::DEFAULT_SIZE, reactor) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
@@ -1038,6 +898,52 @@ ImR_Activator_i::init (ACE_ENV_SINGLE_ARG_DECL)
"Repository failed to initialize\n"),
-1);
}
+
+
+ // We need to send the list of our persisted server names to the Locator
+ // so that it knows we are managing them.
+ auto_ptr<Server_Repository::HASH_IMR_MAP::ITERATOR> server_iter(this->repository_.new_iterator());
+ if (server_iter.get () == 0)
+ {
+ ACE_THROW (CORBA::NO_MEMORY ());
+ }
+ ImplementationRepository::Locator::ServerNameList server_names;
+ server_names.length(this->repository_.get_repository_size());
+ Server_Repository::HASH_IMR_MAP::ENTRY* next_entry = 0;
+ for (CORBA::ULong idx = 0;server_iter->next(next_entry) != 0; server_iter->advance())
+ {
+ ACE_CString server_name = next_entry->ext_id_;
+ server_names[idx++] = server_name.c_str();
+ }
+
+ this->registration_token_ =
+ locator->register_activator (this->name_.c_str(),
+ activator.in (),
+ server_names
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // 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 (OPTIONS::instance ()->debug () >= 2)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "ImR_Activator_i::init: The Activator IOR is: <%s>\n",
+ ior.in ()));
+ }
+
+ ACE_CString filename = OPTIONS::instance()->output_filename();
+ if (filename.length() > 0)
+ {
+ FILE* fp = ACE_OS::fopen(filename.c_str(), "w");
+ if (fp != 0) {
+ ACE_OS::fprintf(fp, "%s", ior.in());
+ ACE_OS::fclose(fp);
+ } else {
+ ACE_ERROR((LM_ERROR, "ImR Activator: Could not open file %s\n", filename.c_str()));
+ }
+ }
+
}
ACE_CATCHANY
{
@@ -1049,7 +955,6 @@ ImR_Activator_i::init (ACE_ENV_SINGLE_ARG_DECL)
return 0;
}
-// Finish the ImR_Activator_i
int
ImR_Activator_i::fini (ACE_ENV_SINGLE_ARG_DECL)
{
@@ -1097,26 +1002,22 @@ ImR_Activator_i::run (ACE_ENV_SINGLE_ARG_DECL)
{
CORBA::ORB_var orb = OPTIONS::instance ()->orb ();
- // Get the POAManager.
PortableServer::POAManager_var poa_manager =
this->imr_poa_->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER);
- // Activate it.
poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK_RETURN (-1);
- // Get a new iterator
- auto_ptr<Server_Repository::HASH_IMR_ITER>
+ auto_ptr<Server_Repository::HASH_IMR_MAP::ITERATOR>
server_iter (this->repository_.new_iterator ());
- // Check for a memory error.
if (server_iter.get () == 0)
ACE_THROW_RETURN (CORBA::NO_MEMORY (), -1);
- Server_Repository::HASH_IMR_ENTRY *server_entry;
+ Server_Repository::HASH_IMR_MAP::ENTRY *server_entry;
if (OPTIONS::instance()->debug () >= 2)
- ACE_DEBUG ((LM_DEBUG, "run: Activating AUTO_START servers\n"));
+ ACE_DEBUG ((LM_DEBUG, "ImR_Activator_i::run: Activating AUTO_START servers\n"));
// For each of the entries in the Server_Repository, get the startup
// information and activate the servers, if they are not already
@@ -1149,7 +1050,7 @@ ImR_Activator_i::run (ACE_ENV_SINGLE_ARG_DECL)
if (OPTIONS::instance()->debug () >= 2)
{
ACE_DEBUG ((LM_DEBUG,
- "AUTO_START: Could not activate <%s>\n",
+ "ImR_Activator_i::run: AUTO_START Could not activate <%s>\n",
server_entry->ext_id_.c_str ()));
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "AUTO_START");
}
@@ -1166,20 +1067,6 @@ ImR_Activator_i::run (ACE_ENV_SINGLE_ARG_DECL)
ImR_Activator_i::~ImR_Activator_i (void)
{
- CORBA::ORB_var orb = OPTIONS::instance ()->orb ();
-
- // Get reactor instance from TAO.
- ACE_Reactor *reactor = orb->orb_core ()->reactor ();
-
- // Register event handler for the ior multicast.
- if (this->ior_multicast_
- && 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->ior_multicast_;
}
@@ -1216,7 +1103,9 @@ ImR_Activator_i::find (const char *server,
if (this->repository_.get_running_info (server,
location,
server_object_ior) != 0)
+ {
ACE_THROW (ImplementationRepository::NotFound ());
+ }
// Fill in <info>.
info->logical_server = CORBA::string_dup (logical.c_str ());
@@ -1225,7 +1114,11 @@ ImR_Activator_i::find (const char *server,
info->startup.environment = environment_vars;
info->startup.working_directory = CORBA::string_dup (working_directory.c_str ());
info->startup.activation = activation;
+ info->startup.activator = this->name_.c_str();
info->location = CORBA::string_dup (location.c_str ());
+
+ if (OPTIONS::instance()->debug () >= 1)
+ ACE_DEBUG ((LM_DEBUG, "ImR Activator: Found server %s.\n", server));
}
@@ -1239,6 +1132,9 @@ ImR_Activator_i::list (CORBA::ULong how_many,
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException))
{
+ if (OPTIONS::instance()->debug () >= 1)
+ ACE_DEBUG ((LM_DEBUG, "ImR Activator: List servers.\n"));
+
// Initialize the out variables, so if we return early, they will
// not be dangling.
server_iterator =
@@ -1249,7 +1145,7 @@ ImR_Activator_i::list (CORBA::ULong how_many,
CORBA::NO_MEMORY ());
// Get a new iterator
- auto_ptr<Server_Repository::HASH_IMR_ITER> server_iter (this->repository_.new_iterator ());
+ auto_ptr<Server_Repository::HASH_IMR_MAP::ITERATOR> server_iter (this->repository_.new_iterator ());
// Check for a memory error.
if (server_iter.get () == 0)
@@ -1268,10 +1164,10 @@ ImR_Activator_i::list (CORBA::ULong how_many,
server_list->length (n);
- Server_Repository::HASH_IMR_ENTRY *server_entry;
+ Server_Repository::HASH_IMR_MAP::ENTRY *server_entry;
if (OPTIONS::instance()->debug () >= 2)
- ACE_DEBUG ((LM_DEBUG, "list: Filling ServerList with %d servers\n", n));
+ ACE_DEBUG ((LM_DEBUG, "ImR_Activator_i::list: Filling ServerList with %d servers\n", n));
for (CORBA::ULong i = 0; i < n; i++)
{
@@ -1298,6 +1194,7 @@ ImR_Activator_i::list (CORBA::ULong how_many,
server_list[i].startup.environment = environment_vars;
server_list[i].startup.working_directory = CORBA::string_dup (working_directory.c_str ());
server_list[i].startup.activation = activation;
+ server_list[i].startup.activator = CORBA::string_dup(this->name_.c_str());
server_list[i].location = CORBA::string_dup (location.c_str ());
}
@@ -1308,7 +1205,7 @@ ImR_Activator_i::list (CORBA::ULong how_many,
if (this->repository_.get_repository_size () > how_many)
{
if (OPTIONS::instance()->debug () >= 2)
- ACE_DEBUG ((LM_DEBUG, "list: Creating ServerInformationIterator\n"));
+ ACE_DEBUG ((LM_DEBUG, "ImR_Activator_i::list: Creating ServerInformationIterator\n"));
// Create an imr_iter and give it the server_iter pointer
ImR_Iterator *imr_iter;
@@ -1340,14 +1237,12 @@ ImR_Activator_i::list (CORBA::ULong how_many,
* to do it ungracefully.
*/
void
-ImR_Activator_i::shutdown_server (const char *server
- ACE_ENV_ARG_DECL)
+ImR_Activator_i::shutdown_server (const char *server ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
ImplementationRepository::NotFound))
{
- if (OPTIONS::instance()->debug () >= 2)
- ACE_DEBUG ((LM_DEBUG,
- "ImR_Activator_i::shutdown_server\n"));
+ if (OPTIONS::instance()->debug () >= 1)
+ ACE_DEBUG ((LM_DEBUG, "ImR Activator: Shutting down server.\n"));
CORBA::ORB_var orb = OPTIONS::instance ()->orb ();
@@ -1359,7 +1254,7 @@ ImR_Activator_i::shutdown_server (const char *server
// If we had problems getting the server_object_ior, probably meant that
// there is no <server> registered
ACE_ERROR ((LM_ERROR,
- "Error: Cannot find ServerObject IOR for server <%s>\n",
+ "ImR Activator: Cannot find ServerObject IOR for server <%s>\n",
server));
ACE_THROW (ImplementationRepository::NotFound ());
}
@@ -1382,20 +1277,19 @@ ImR_Activator_i::shutdown_server (const char *server
if (CORBA::is_nil (server_object.in ()))
{
ACE_ERROR ((LM_ERROR,
- "Error: Invalid ServerObject IOR: <%s>\n",
+ "ImR Activator: Invalid ServerObject IOR: <%s>\n",
server_object_ior.c_str ()));
ACE_THROW (ImplementationRepository::NotFound ());
}
- // Call shutdown
server_object->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
- // Remove running info from repository
+ // This removes running info from repository
if (this->repository_.update (server, "", "") != 0)
{
ACE_ERROR ((LM_ERROR,
- "Error: Could not update information for unknown server <%s>\n",
+ "ImR Activator: Could not update information for unknown server <%s>\n",
server));
ACE_THROW (ImplementationRepository::NotFound ());
}
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.h b/TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.h
index 2a5bae1a875..099d473b098 100644
--- a/TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.h
+++ b/TAO/orbsvcs/ImplRepo_Service/ImR_Activator_i.h
@@ -41,9 +41,8 @@ public:
~ImR_Activator_i (void);
/// IOR_LookupTable_Callback method. Will return an IOR
- char *find_ior (const ACE_CString &object_name
- ACE_ENV_ARG_DECL)
- ACE_THROW_SPEC ((CORBA::SystemException, IORTable::NotFound));
+ char *find_ior (const char* object_name ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound));
// = Interface methods
@@ -65,7 +64,8 @@ public:
ACE_ENV_ARG_DECL_WITH_DEFAULTS
) ACE_THROW_SPEC ((
CORBA::SystemException,
- ImplementationRepository::AlreadyRegistered
+ ImplementationRepository::AlreadyRegistered,
+ ImplementationRepository::NotFound
));
/// Updates the startup information about the server <server>.
@@ -73,7 +73,10 @@ public:
const char *server,
const ImplementationRepository::StartupOptions &options
ACE_ENV_ARG_DECL_WITH_DEFAULTS
- ) ACE_THROW_SPEC ((CORBA::SystemException));
+ ) ACE_THROW_SPEC ((CORBA::SystemException,
+ ImplementationRepository::AlreadyRegistered,
+ ImplementationRepository::NotFound
+ ));
/// Removes the server <server> from the repository.
virtual void remove_server (
@@ -91,9 +94,9 @@ public:
/// Called by the server to update transient information such as current
/// location of the <server> and its ServerObject.
- virtual char *server_is_running (
+ virtual void server_is_running (
const char *server,
- const char *location,
+ const char * partial_ior,
ImplementationRepository::ServerObject_ptr server_object
ACE_ENV_ARG_DECL_WITH_DEFAULTS
) ACE_THROW_SPEC ((CORBA::SystemException,
@@ -145,6 +148,13 @@ public:
private:
+ char* activate_server_i (const char *server,int check_startup
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((
+ CORBA::SystemException,
+ ImplementationRepository::NotFound,
+ ImplementationRepository::CannotActivate
+ ));
+
/// This method starts the server process.
void start_server_i (
const char *server
@@ -161,9 +171,6 @@ private:
ACE_THROW_SPEC ((CORBA::SystemException,
ImplementationRepository::NotFound));
- /// The locator interface for the IORTable
- IORTable::Locator_var locator_;
-
/// The Process Manager.
ACE_Process_Manager process_mgr_;
@@ -176,26 +183,11 @@ private:
/// Implementation Repository's POA.
PortableServer::POA_var imr_poa_;
- /// Key of the obj ref of the server.
- char *server_key_;
-
- /// Copy of the filename for the server output file.
- char *server_input_file_;
-
- /// The ior_multicast event handler.
- TAO_IOR_Multicast *ior_multicast_;
-
- /// Implementation Repository's IOR. Why do we store it here? Multicast
- /// doesn't work otherwise.
- CORBA::String_var imr_ior_;
-
- /// Number of command line arguments.
- int argc_;
-
- /// The command line arguments.
- char **argv_;
+ /// We're given a token when registering with the locator, which
+ /// we must use when unregistering.
+ CORBA::Long registration_token_;
- friend class ImR_Forwarder;
+ ACE_CString name_;
};
#endif /* IMR_ACTIVATOR_I_H */
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator.cpp b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator.cpp
index 07b4705849d..33b21fbc734 100644
--- a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator.cpp
@@ -1,31 +1,75 @@
// $Id$
#include "ImR_Locator_i.h"
+#include "Locator_NT_Service.h"
+#include "Locator_Options.h"
int
-main (int argc, char *argv[])
+run_standalone (void)
{
+ ImR_Locator_i server;
+
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
{
- // Instantiate an instance of ImR_Locator_i
- ImR_Locator_i *imr_locator;
-
- ACE_NEW_THROW_EX (imr_locator,
- ImR_Locator_i,
- CORBA::NO_MEMORY ());
- ACE_TRY_CHECK;
-
- // Invoke the init method and the ImR_Locator running.
- imr_locator->init (argc, argv ACE_ENV_ARG_PARAMETER);
+ int status = server.init (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
+ if (status != -1)
+ return 0;
+ }
+ ACE_CATCH (CORBA::SystemException, sysex)
+ {
+ ACE_PRINT_EXCEPTION (sysex, "System Exception");
+ }
+ ACE_CATCH (CORBA::UserException, userex)
+ {
+ ACE_PRINT_EXCEPTION (userex, "User Exception");
}
ACE_CATCHANY
{
- ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "ImR_Locator");
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Unknown Exception");
}
ACE_ENDTRY;
- ACE_CHECK_RETURN (-1);
- return 0;
+ return 1;
+}
+
+#if defined (ACE_WIN32)
+ACE_NT_SERVICE_DEFINE (service, Locator_NT_Service, IMR_LOCATOR_SERVICE_NAME);
+#endif /* ACE_WIN32 */
+
+int
+run_service (void)
+{
+#if defined (ACE_WIN32)
+
+ SERVICE::instance ()->name (IMR_LOCATOR_SERVICE_NAME, IMR_LOCATOR_DISPLAY_NAME);
+
+ ACE_NT_SERVICE_RUN (service, SERVICE::instance (), ret);
+
+ if (ret == 0)
+ ACE_ERROR ((LM_ERROR, "%p\n", "Couldn't start service"));
+
+ return ret;
+#else /* ACE_WIN32 */
+ return 1;
+#endif /* ACE_WIN32 */
+}
+
+#include <ace/streams.h>
+
+int
+main (int argc, char *argv[])
+{
+ int result = OPTIONS::instance()->init(argc, argv);
+
+ if (result < 0)
+ return 1; // Error parsing args
+ else if (result > 0)
+ return 0; // No error, but we should exit anyway.
+
+ if (OPTIONS::instance()->service())
+ return run_service();
+
+ return run_standalone();
}
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp
index 5bd3944b842..997c7200e81 100644
--- a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp
@@ -1,9 +1,10 @@
// $Id$
#include "ImR_Locator_i.h"
-#include "ImR_Activator_i.h"
+#include "Locator_Options.h"
#include "Forwarder.h"
+#include "INS_Locator.h"
#include "Adapter_Activator.h"
#include "orbsvcs/orbsvcs/IOR_Multicast.h"
@@ -16,117 +17,54 @@
#include "ace/Get_Opt.h"
#include "ace/Process_Manager.h"
+#include "ace/OS_NS_sys_time.h"
ImR_Locator_i::ImR_Locator_i ()
- : first_timer_ (0),
- debug_ (0),
- multicast_ (0),
- ior_output_file_ (0),
+ :
forwarder_impl_ (0),
- activator_ (0)
+ activator_ (0),
+ ins_locator_ (0)
{
-}
-
-ImR_Locator_i::~ImR_Locator_i (void)
-{
- // Destructor
+ this->ins_locator_ = new INS_Locator(this);
}
int
-ImR_Locator_i::parse_args (int argc, char *argv [])
+ImR_Locator_i::init (ACE_ENV_SINGLE_ARG_DECL)
{
- ACE_Get_Opt get_opts (argc, argv, "o:md");
- int c;
-
- while ((c = get_opts ()) != -1)
- switch (c)
- {
- case 'o':
- this->ior_output_file_ = get_opts.optarg;
- break;
-
- case 'm':
- this->multicast_ = 1;
- break;
-
- case 'd':
- this->debug_ = 1;
- break;
-
- case '?':
- default:
- ACE_ERROR_RETURN ((LM_ERROR,
- "usage: %s "
- "-o <iorfile> "
- "-m "
- "-d "
- "\n",
- argv [0]),
- -1);
- }
- // Indicates sucessful parsing of the command line
- return 0;
-}
+ CORBA::ORB_var orb = OPTIONS::instance()->orb();
-int
-ImR_Locator_i::init (int argc, char *argv [] ACE_ENV_ARG_DECL)
-{
- // As always, initialize the ORB.
- CORBA::ORB_var orb = CORBA::ORB_init (argc,
- argv,
- ""
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (-1);
-
- // Parse the commandline parameters.
- if (this->parse_args (argc, argv) != 0)
- return -1;
-
- // Get a reference to the RootPOA.
CORBA::Object_var obj =
- orb->resolve_initial_references ("RootPOA"
- ACE_ENV_ARG_PARAMETER);
+ orb->resolve_initial_references ("RootPOA" ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (-1);
- // Narrow
PortableServer::POA_var root_poa =
- PortableServer::POA::_narrow (obj.in ()
- ACE_ENV_ARG_PARAMETER);
+ PortableServer::POA::_narrow (obj.in () ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (-1);
- // Check for nil references
if (CORBA::is_nil (root_poa.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
"Unable to obtain RootPOA reference.\n"),
-1);
- // Get poa_manager reference
PortableServer::POAManager_var poa_manager =
root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK_RETURN (-1);
- // Activate it.
- poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER);
- ACE_CHECK_RETURN (-1);
-
// We are going to set the policies to be used with the child
// POA.
CORBA::PolicyList policies (2);
policies.length (2);
- // Id Assignment policy
policies[0] =
root_poa->create_id_assignment_policy (PortableServer::USER_ID
ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (-1);
- // Lifespan policy
policies[1] =
root_poa->create_lifespan_policy (PortableServer::PERSISTENT
ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (-1);
- // Create a child POA with name ImR_Locator.
PortableServer::POA_var locator_poa =
root_poa->create_POA ("ImplRepoService",
poa_manager.in (),
@@ -134,7 +72,7 @@ ImR_Locator_i::init (int argc, char *argv [] ACE_ENV_ARG_DECL)
ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (-1);
- // Creation of the new POAs over, so destroy the Policy_ptr's as
+ // Creation of the new POAs is over, so destroy the Policy_ptr's as
// we dont need them anymore.
for (CORBA::ULong i = 0; i < policies.length (); ++i)
{
@@ -159,19 +97,17 @@ ImR_Locator_i::init (int argc, char *argv [] ACE_ENV_ARG_DECL)
ACE_CHECK_RETURN (-1);
// Get the locator object reference
- CORBA::Object_var locator_obj =
- locator_poa->id_to_reference (locator_id.in ()
- ACE_ENV_ARG_PARAMETER);
+ CORBA::Object_var locator_obj =
+ locator_poa->id_to_reference (locator_id.in () ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (-1);
// Get the reference to IORTable.
- CORBA::Object_var table_object =
- orb->resolve_initial_references ("IORTable" ACE_ENV_ARG_PARAMETER);
+ obj = orb->resolve_initial_references ("IORTable" ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (-1);
// Narrow it down to the correct type
IORTable::Table_var adapter =
- IORTable::Table::_narrow (table_object.in () ACE_ENV_ARG_PARAMETER);
+ IORTable::Table::_narrow (obj.in () ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (-1);
CORBA::String_var ior;
@@ -182,75 +118,61 @@ ImR_Locator_i::init (int argc, char *argv [] ACE_ENV_ARG_DECL)
}
else
{
+ // Set the locator
+ adapter->set_locator (this->ins_locator_.in () ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (-1);
+
// Get the stringified format of the locator's object
// reference.
- ior = orb->object_to_string (locator_obj.in ()
- ACE_ENV_ARG_PARAMETER);
+ ior = orb->object_to_string (locator_obj.in () ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (-1);
// Finally, bind this ior to the child POA's name in the
// IORTable.
- adapter->bind ("ImplRepoService",
- ior.in ()
- ACE_ENV_ARG_PARAMETER);
+ adapter->bind ("ImplRepoService", ior.in () ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (-1);
}
- // If the ior_output_file exists, output the ior to it
- if (this->ior_output_file_ != 0)
+ ACE_CString output_filename = OPTIONS::instance()->output_filename();
+
+ if (output_filename.length() > 0)
{
- FILE *output_file= ACE_OS::fopen (this->ior_output_file_, "w");
- if (output_file == 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- "Cannot open output file for writing IOR: %s",
- this->ior_output_file_),
- 1);
- ACE_OS::fprintf (output_file, "%s", ior.in ());
- ACE_OS::fclose (output_file);
+ FILE* fp = ACE_OS::fopen(output_filename.c_str(), "w");
+ ACE_ASSERT(fp != 0);
+ ACE_OS::fprintf(fp, "%s", ior.in());
+ ACE_OS::fclose(fp);
}
- // ImR_Adapter_Activator
ACE_NEW_RETURN (this->activator_,
ImR_Adapter_Activator (this->forwarder_impl_),
-1);
// Register the Adapter_Activator reference to be the RootPOA's
// Adapter Activator.
- root_poa->the_activator (this->activator_
- ACE_ENV_ARG_PARAMETER);
+ root_poa->the_activator (this->activator_ ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (-1);
- // Get reactor instance from TAO.
- ACE_Reactor *reactor = orb->orb_core ()->reactor ();
-
- // = Set up the process manager
+ if (OPTIONS::instance()->multicast())
+ {
+ ACE_Reactor *reactor = orb->orb_core ()->reactor ();
- // Init the Process Manager.
- ACE_Process_Manager process_manager;
- process_manager.open (ACE_Process_Manager::DEFAULT_SIZE, reactor);
+ ACE_Process_Manager process_manager;
+ process_manager.open (ACE_Process_Manager::DEFAULT_SIZE, reactor);
- // Set up multicast.
- if (this->multicast_)
- {
- // Do the multicast setup
if (this->setup_multicast (reactor, ior.in ()) != 0)
return -1;
}
else
{
- if (this->debug_)
+ if (OPTIONS::instance()->debug() >= 1)
{
- ACE_DEBUG ((LM_DEBUG,
- "ImR_Activator: "
- "Multicast Handler disabled.\n"));
+ ACE_DEBUG ((LM_DEBUG, "ImR Locator: Multicast Handler disabled.\n"));
}
}
- // Activate the POA Manager.
poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK_RETURN (-1);
- // Run the ORB.
orb->run (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK_RETURN (-1);
@@ -270,7 +192,7 @@ int
ImR_Locator_i::setup_multicast (ACE_Reactor *reactor,
const char *ior)
{
- ACE_ASSERT (reactor);
+ ACE_ASSERT (reactor != 0);
#if defined (ACE_HAS_IP_MULTICAST)
// See if the -ORBMulticastDiscoveryEndpoint option was specified.
@@ -324,16 +246,16 @@ ImR_Locator_i::setup_multicast (ACE_Reactor *reactor,
if (reactor->register_handler (ior_multicast,
ACE_Event_Handler::READ_MASK) == -1)
{
- if (this->debug_)
+ if (OPTIONS::instance()->debug() >= 1)
ACE_DEBUG ((LM_DEBUG,
- "Implementation Repository: "
+ "ImR Locator: "
"cannot register Event handler\n"));
return -1;
}
- if (this->debug_)
+ if (OPTIONS::instance()->debug() >= 1)
ACE_DEBUG ((LM_DEBUG,
- "Implementation Repository: Multicast Handler enabled.\n"));
+ "ImR Locator: Multicast Handler enabled.\n"));
return 0;
#else /* ACE_HAS_IP_MULTICAST */
@@ -341,7 +263,7 @@ ImR_Locator_i::setup_multicast (ACE_Reactor *reactor,
ACE_UNUSED_ARG (reactor);
ACE_UNUSED_ARG (ior);
ACE_DEBUG ((LM_WARNING,
- "Implementation Repository: "
+ "ImR Locator: "
"ACE_HAS_IP_MULTICAST is not defined. "
"Multicast support disabled.\n"));
@@ -349,124 +271,111 @@ ImR_Locator_i::setup_multicast (ACE_Reactor *reactor,
#endif /* ACE_HAS_IP_MULTICAST */
}
-CORBA::ULong
-ImR_Locator_i::register_activator (const char *location,
- CORBA::Object_ptr object_ref
- ACE_ENV_ARG_DECL)
- ACE_THROW_SPEC ((ImplementationRepository::AlreadyRegistered,
- CORBA::SystemException))
+CORBA::Long
+ImR_Locator_i::register_activator (const char* activator,
+ ImplementationRepository::Administration_ptr admin,
+ const ImplementationRepository::Locator::ServerNameList & servers
+ ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
{
- // Insert the activator into the table_
- CORBA::ULong bind_return =
- this->table_.bind (location,
- CORBA::Object::_duplicate (object_ref));
-
- if (bind_return == 1)
- {
- ACE_THROW_RETURN (ImplementationRepository::AlreadyRegistered (),
- 1);
- }
- else
- {
- // Saving these values will help avoid choosing activators
- // using server name in cases if there is only one activator.
- if (this->first_timer_ == 0)
- {
- this->first_timer_ = 1;
-
- this->default_admin_ref_ =
- ImplementationRepository::Administration::_narrow (
- CORBA::Object::_duplicate (object_ref)
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (1);
- }
- return 0;
- }
+ for (CORBA::ULong idx = 0; idx < servers.length(); ++idx) {
+ const char* server = servers[idx];
+ int err = this->server_map_.bind(server, activator);
+ ACE_ASSERT(err == 0 || err == 1);
+ ACE_UNUSED_ARG (err);
+ }
+
+ ActivatorInfo info;
+ // We save the unique hash value of the passed in admin object, so that
+ // we can prevent accidental unregister by a different activator.
+ info.token = ACE_OS::gettimeofday().msec();
+ info.admin = ImplementationRepository::Administration::_duplicate(admin);
+
+ int bind_return = this->activator_map_.bind (activator, info);
+
+ if (bind_return == 1) // Success, but was already bound.
+ {
+ if (OPTIONS::instance()->debug() >= 1)
+ {
+ ACE_DEBUG ((LM_DEBUG, "ImR Locator: New activator registered for %s.\n", activator));
+ }
+ return info.token;
+ }
+ else if (bind_return != 0)
+ {
+ ACE_ASSERT(bind_return != 0);
+ }
+
+ if (OPTIONS::instance()->debug() >= 1)
+ {
+ ACE_DEBUG ((LM_DEBUG, "ImR Locator: Activator registered for %s.\n", activator));
+ }
+ return info.token;
}
// Remove a activator when it no longer wants to receive requests.
-CORBA::ULong
-ImR_Locator_i::unregister_activator (const char *location,
- CORBA::Object_ptr object_ref
+// object_ref is set to the removed activator.
+void
+ImR_Locator_i::unregister_activator (const char * activator,
+ CORBA::Long token
ACE_ENV_ARG_DECL)
- ACE_THROW_SPEC ((ImplementationRepository::NotFound,
- CORBA::SystemException))
+ ACE_THROW_SPEC ((CORBA::SystemException))
{
- CORBA::ULong bind_return =
- this->table_.unbind (location,
- object_ref);
+ ActivatorInfo info;
+ if (this->activator_map_.find (activator, info) == 0)
+ {
+ if (info.token != token && OPTIONS::instance()->debug() >= 1)
+ {
+ ACE_DEBUG((LM_DEBUG, "ImR Locator: Ignoring unregister activator:%s. Wrong token.\n", activator));
+ return;
+ }
+
+ int bind_return = this->activator_map_.unbind (activator, info);
+ ACE_UNUSED_ARG (bind_return);
+ ACE_ASSERT(bind_return == 0);
- if (bind_return == 1)
+ if (OPTIONS::instance()->debug() >= 1)
{
- ACE_THROW_RETURN (ImplementationRepository::NotFound (),
- 1);
+ ACE_DEBUG ((LM_DEBUG, "ImR Locator: Activator %s unregistered.\n", activator));
}
- else
+ }
+ else
+ {
+ if (OPTIONS::instance()->debug() >= 1)
{
- // We duplicated the object ref while binding it. Decrement the
- // counter.
- object_ref->_remove_ref ();
+ ACE_DEBUG((LM_DEBUG, "ImR Locator: Ignoring unregister activator:%s. Unknown activator.\n", activator));
}
- return 0;
+ }
}
-// Starts up the server <server> at all the locations that it is
+// Starts up the server <server> at all the activators where it is
// registered, if not already running.
void
-ImR_Locator_i::activate_server (const char *server
- ACE_ENV_ARG_DECL)
+ImR_Locator_i::activate_server (const char *server ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((
CORBA::SystemException,
ImplementationRepository::NotFound,
ImplementationRepository::CannotActivate))
{
- ImplementationRepository::Administration_var admin_ref = 0;
-
- if (this->table_.current_size () != 1)
+ if (OPTIONS::instance()->debug() >= 1)
{
- Table_Entry *next_entry = 0;
-
- for (Table_Iterator iterator (this->table_);
- iterator.next (next_entry) != 0;
- iterator.advance ())
- {
- // the ImR_Activator that will do this activation.
- admin_ref =
- this->helper_for_choosing_activators (server,
- next_entry->ext_id_.c_str ()
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
-
- if (admin_ref.in () != 0)
- {
- // Invoke the required operation on that
- admin_ref->activate_server (server
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
-
- return;
- }
- }
-
- // All the activator entries are tried but didnt find the server
- // related activator.
- ACE_ERROR ((LM_ERROR,
- "Couldnt get the startup activator for the server\n"));
-
- ACE_THROW (ImplementationRepository::NotFound ());
- }
- else
- {
- // There is only one activator known to this locator.
- this->default_admin_ref_->activate_server (server
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
+ ACE_DEBUG ((LM_DEBUG, "ImR Locator: Activating server %s.\n", server));
}
+
+ ACE_CString activator;
+ if (this->server_map_.find(server, activator) == 0)
+ {
+ this->activate_server_in_activator(server, activator.c_str());
+ }
+ else
+ {
+ ACE_ERROR ((LM_ERROR, "ImR Locator: Couldn't find an activator for server:%s\n", server));
+ ACE_THROW(ImplementationRepository::NotFound());
+ }
}
-// Starts up the server <server> at the locations that it is
-// registered, if not already running and returns the IOR of the
-// activated server.
+// Starts up the server <server> at one or more activators
+// and returns the IOR of the activated server.
char *
ImR_Locator_i::activate_server_with_startup (const char *server,
int check_startup
@@ -475,89 +384,51 @@ ImR_Locator_i::activate_server_with_startup (const char *server,
ImplementationRepository::NotFound,
ImplementationRepository::CannotActivate))
{
- ImplementationRepository::Administration_var admin_ref = 0;
-
- ACE_CString ior;
- if (this->table_.current_size () != 1)
- {
- Table_Entry *next_entry = 0;
-
- for (Table_Iterator iterator (this->table_);
- iterator.next (next_entry) != 0;
- iterator.advance ())
- {
- // name of the activator that will do this activation.
- admin_ref =
- this->helper_for_choosing_activators (server,
- next_entry->ext_id_.c_str ()
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (0);
-
- if (admin_ref.in () != 0)
- {
- // Invoke the required operation on that
- ior =
- admin_ref->activate_server_with_startup (server,
- check_startup
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (0);
-
- return CORBA::string_dup (ior.c_str ());
- }
- }
-
- // The control came out of the for loop and came here .. implies
- // didnt find the correct activator. Something wrong ..
- ACE_ERROR ((LM_ERROR,
- "Couldnt get a reference to an activator at %s\n",
- next_entry->ext_id_.c_str ()));
- ACE_THROW_RETURN (ImplementationRepository::NotFound (),
- 0);
- }
- else
- {
- // There is only one activator known to this locator.
- ior =
- this->default_admin_ref_->activate_server_with_startup (server,
- check_startup
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (0);
- }
-
- return CORBA::string_dup (ior.c_str ());
+ if (OPTIONS::instance()->debug() >= 1)
+ {
+ ACE_DEBUG ((LM_DEBUG, "ImR Locator: Activating server %s."
+ " Check startup=%d.\n", server, check_startup));
+ }
+
+ ACE_CString activator;
+ if (this->server_map_.find(server, activator) == 0)
+ {
+ ImplementationRepository::Administration_var admin =
+ this->choose_activator (activator.c_str() ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+ char* partial_ior = admin->activate_server_with_startup (server,
+ check_startup ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+ if (partial_ior != 0) {
+ return partial_ior;
+ }
+ }
+ ACE_ERROR ((LM_ERROR, "ImR Locator: Couldn't find an activator for server:%s\n", server));
+ ACE_THROW_RETURN (ImplementationRepository::NotFound(), 0);
+ return 0;
}
// Starts up the server <server> if not already running in the
-// specified location.
+// specified activator.
void
-ImR_Locator_i::activate_server_in_location (const char *server,
- const char *location
+ImR_Locator_i::activate_server_in_activator (const char *server,
+ const char * activator
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
ImplementationRepository::NotFound,
ImplementationRepository::CannotActivate))
{
-
- // name of the activator that will do this activation.
- ImplementationRepository::Administration_var admin_ref =
- this->choose_activator_using_location (location
- ACE_ENV_ARG_PARAMETER);
+ if (OPTIONS::instance()->debug() >= 1)
+ {
+ ACE_DEBUG ((LM_DEBUG, "ImR Locator: Activating server"
+ " %s in activator %s.\n", server, activator));
+ }
+ ImplementationRepository::Administration_var admin =
+ this->choose_activator (activator ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+ admin->activate_server (server ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
-
- if (admin_ref.in () != 0)
- {
- // Invoke the required operation on that reference.
- admin_ref->activate_server (server
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
- }
- else
- {
- ACE_ERROR ((LM_ERROR,
- "Couldnt get a reference to the activator on %s\n:",
- location));
- }
}
// Adds the server to the repository and registers the startup information
@@ -566,413 +437,266 @@ void
ImR_Locator_i::register_server (const char *server,
const ImplementationRepository::StartupOptions &options
ACE_ENV_ARG_DECL)
- ACE_THROW_SPEC ((CORBA::SystemException,
- ImplementationRepository::AlreadyRegistered))
+ ACE_THROW_SPEC ((CORBA::SystemException,
+
+ImplementationRepository::AlreadyRegistered,
+ ImplementationRepository::NotFound))
{
- // name of the activator that will do this activation.
- ImplementationRepository::Administration_var admin_ref =
- this->choose_activator_using_location (options.location
- ACE_ENV_ARG_PARAMETER);
+ ACE_CString activator;
+ if (this->server_map_.find(server, activator) == 0)
+ {
+ ACE_THROW(ImplementationRepository::AlreadyRegistered());
+ return;
+ }
+
+ ImplementationRepository::Administration_var admin =
+ this->choose_activator (options.activator.in() ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
- if (admin_ref.in () != 0)
- {
- // Invoke the required operation on that reference.
- admin_ref->register_server (server,
- options
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
- }
- else
+ admin->register_server (server, options ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+ if (OPTIONS::instance()->debug() >= 1)
{
- ACE_ERROR ((LM_ERROR,
- "Couldnt get a reference to an activator\n"));
+ ACE_DEBUG ((LM_DEBUG, "ImR Locator: Registered server %s "
+ "in activator %s.\n", server, options.activator.in()));
}
+ int bind_return = this->server_map_.bind (server, options.activator.in());
+ ACE_UNUSED_ARG (bind_return);
+ ACE_ASSERT(bind_return == 0);
}
// Updates the startup information about the server <server>.
+// Can not currently be used to move a server from one activator to another,
+// this simply updates the registered info.
void
ImR_Locator_i::reregister_server (
const char *server,
const ImplementationRepository::StartupOptions &options
ACE_ENV_ARG_DECL )
- ACE_THROW_SPEC ((CORBA::SystemException))
+ ACE_THROW_SPEC ((CORBA::SystemException,ImplementationRepository::NotFound))
{
- ImplementationRepository::Administration_var admin_ref = 0;
-
- if (this->table_.current_size () != 1)
- {
- Table_Entry *next_entry = 0;
+ ACE_CString activator;
+ if (this->server_map_.find(server, activator) != 0)
+ {
+ ACE_THROW(ImplementationRepository::NotFound());
+ }
+ if (activator.compare(options.activator.in()) != 0)
+ {
+ ACE_THROW(ImplementationRepository::NotFound());
+ }
+
+ ImplementationRepository::Administration_var admin =
+ this->choose_activator (activator.c_str() ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
- for (Table_Iterator iterator (this->table_);
- iterator.next (next_entry) != 0;
- iterator.advance ())
- {
- // name of the activator that will do this activation.
- admin_ref =
- this->helper_for_choosing_activators (server,
- next_entry->ext_id_.c_str ()
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
-
- if (admin_ref.in () != 0)
- {
- // Invoke the required operation on that
- admin_ref->reregister_server (server,
- options
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
- }
- }
- ACE_ERROR ((LM_ERROR,
- "Couldnt get a reference to an activator at %s\n",
- next_entry->ext_id_.c_str ()));
- }
- else
- {
- // There is only one activator known to this locator.
- this->default_admin_ref_->reregister_server (server,
- options
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
- }
+ if (OPTIONS::instance()->debug() >= 1)
+ {
+ ACE_DEBUG ((LM_DEBUG, "ImR Locator: Reregister server %s "
+ "in activator %s.\n", server, activator.c_str()));
+ }
+ admin->reregister_server (server, options ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
}
// Removes the server <server> from the repository.
void
-ImR_Locator_i::remove_server (const char *server
- ACE_ENV_ARG_DECL)
- ACE_THROW_SPEC ((CORBA::SystemException,
- ImplementationRepository::NotFound))
+ImR_Locator_i::remove_server (const char *server ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound))
{
- ImplementationRepository::Administration_var admin_ref = 0;
-
- if (this->table_.current_size () != 1)
- {
- Table_Entry *next_entry = 0;
-
- for (Table_Iterator iterator (this->table_);
- iterator.next (next_entry) != 0;
- iterator.advance ())
- {
- // name of the activator that will do this activation.
- admin_ref =
- this->helper_for_choosing_activators (server,
- next_entry->ext_id_.c_str ()
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
-
- if (admin_ref.in () != 0)
- {
- // Invoke the required operation on that
- admin_ref->remove_server (server
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
- }
- }
- ACE_ERROR ((LM_ERROR,
- "Couldnt get a reference to an activator at %s\n",
- next_entry->ext_id_.c_str ()));
-
- ACE_THROW (ImplementationRepository::NotFound ());
- }
- else
- {
- // There is only one activator known to this locator.
- this->default_admin_ref_->remove_server (server
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
- }
+ if (OPTIONS::instance()->debug() >= 1)
+ {
+ ACE_DEBUG ((LM_DEBUG, "ImR Locator: Remove server %s.\n", server));
+ }
+ ACE_CString activator;
+ if (this->server_map_.find(server, activator) == 0)
+ {
+ this->remove_server_in_activator(server, activator.c_str());
+ }
+ else
+ {
+ ACE_ERROR ((LM_ERROR, "ImR Locator: Couldn't find an activator for server:%s\n", server));
+ ACE_THROW(ImplementationRepository::NotFound());
+ }
}
// Removes the server <server> from the repository.
void
-ImR_Locator_i::remove_server_in_location (const char *server,
- const char *location
+ImR_Locator_i::remove_server_in_activator (const char *server,
+ const char *activator
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
- ImplementationRepository::NotFound))
+ ImplementationRepository::NotFound
+ ))
{
- // name of the activator that will do this activation.
- ImplementationRepository::Administration_var admin_ref =
- this->choose_activator_using_location (location
- ACE_ENV_ARG_PARAMETER);
+ if (OPTIONS::instance()->debug() >= 1)
+ {
+ ACE_DEBUG ((LM_DEBUG, "ImR Locator: Remove server %s "
+ "from activator %s.\n", server, activator));
+ }
+ ACE_CString registered_activator;
+ if (this->server_map_.find(server, registered_activator) != 0)
+ {
+ ACE_THROW(ImplementationRepository::NotFound()); // todo : Add to signature in pidl and others
+ }
+ if (registered_activator.compare(activator) != 0)
+ {
+ ACE_ASSERT(false);
+ }
+
+ ImplementationRepository::Administration_var admin =
+ this->choose_activator (activator ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
-
- if (admin_ref.in () != 0)
- {
- // Invoke the required operation on that reference.
- admin_ref->remove_server (server
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
- }
- else
- {
- ACE_ERROR ((LM_ERROR,
- "Couldnt get a reference to the activator on %s\n:",
- location));
- }
+ admin->remove_server (server ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+ int err = this->server_map_.unbind(server);
+ ACE_UNUSED_ARG (err);
+ ACE_ASSERT(err == 0);
}
-// Attempts to gracefully shut down the server, at all locations that
+// Attempts to gracefully shut down the server, at all activators that
// it is running.
void
-ImR_Locator_i::shutdown_server (
- const char *server
- ACE_ENV_ARG_DECL)
- ACE_THROW_SPEC ((CORBA::SystemException,
- ImplementationRepository::NotFound))
+ImR_Locator_i::shutdown_server (const char *server ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound))
{
- ImplementationRepository::Administration_var admin_ref = 0;
-
- if (this->table_.current_size () != 1)
- {
- // If there are more activators registered than 1
-
- Table_Entry *next_entry = 0;
-
- for (Table_Iterator iterator (this->table_);
- iterator.next (next_entry) != 0;
- iterator.advance ())
- {
- // name of the activator that will do this activation.
- admin_ref =
- this->helper_for_choosing_activators (server,
- next_entry->ext_id_.c_str ()
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
-
- if (admin_ref.in () != 0)
- {
- // Invoke the required operation on that
- admin_ref->shutdown_server (server
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
- }
- else
- {
- ACE_ERROR ((LM_ERROR,
- "Couldnt get a reference to an activator at %s\n",
- next_entry->ext_id_.c_str ()));
-
- //ACE_THROW (ImplementationRepository::NotFound ());
- }
- }
- }
- else
- {
- // There is only one activator known to this locator.
- this->default_admin_ref_->shutdown_server (server
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
- }
+ if (OPTIONS::instance()->debug() >= 1)
+ {
+ ACE_DEBUG ((LM_DEBUG, "ImR Locator: Shutdown server %s.\n", server));
+ }
+ ACE_CString activator;
+ if (this->server_map_.find(server, activator) == 0)
+ {
+ this->shutdown_server_in_activator(server, activator.c_str());
+ }
+ else
+ {
+ ACE_ERROR ((LM_ERROR, "ImR Locator: Couldn't find an activator for server:%s\n", server));
+ ACE_THROW(ImplementationRepository::NotFound());
+ }
}
// Attempts to gracefully shut down the server,
void
-ImR_Locator_i::shutdown_server_in_location (
+ImR_Locator_i::shutdown_server_in_activator (
const char *server,
- const char *location
+ const char *activator
ACE_ENV_ARG_DECL)
- ACE_THROW_SPEC ((CORBA::SystemException,
- ImplementationRepository::NotFound))
+ ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound))
{
- // name of the activator that will do this activation.
- ImplementationRepository::Administration_var admin_ref =
- this->choose_activator_using_location (location
- ACE_ENV_ARG_PARAMETER);
+ ImplementationRepository::Administration_var admin =
+ this->choose_activator (activator ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
-
- if (admin_ref.in () != 0)
- {
- // Invoke the required operation on that reference.
- admin_ref->shutdown_server (server
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
- }
- else
+ if (OPTIONS::instance()->debug() >= 1)
{
- ACE_ERROR ((LM_ERROR,
- "Couldnt get a reference to the activator on %s\n:",
- location));
+ ACE_DEBUG ((LM_DEBUG, "ImR Locator: Shutdown server %s "
+ "in activator %s.\n", server, activator));
}
+ admin->shutdown_server (server ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
}
-// Called by the server to update transient information such as current
-// location of the <server> and its ServerObject.
-char *
-ImR_Locator_i::server_is_running (const char *server,
- const char *location,
- ImplementationRepository::ServerObject_ptr server_object
- ACE_ENV_ARG_DECL)
+void
+ImR_Locator_i::server_is_running (const char *,
+ const char *,
+ ImplementationRepository::ServerObject_ptr
+ ACE_ENV_ARG_DECL_NOT_USED)
ACE_THROW_SPEC ((CORBA::SystemException,
ImplementationRepository::NotFound))
{
- // Get the hostname from the location passed.
- ACE_CString hostname = ACE_OS::strstr (location,
- "@");
-
- hostname = ACE_OS::strtok (ACE_const_cast (char *,
- hostname.c_str ()),
- "@");
-
- hostname = ACE_OS::strtok (ACE_const_cast (char *,
- hostname.c_str ()),
- ":");
-
- hostname = ACE_OS::strtok (ACE_const_cast (char *,
- hostname.c_str ()),
- "/");
-
- // name of the activator that will do this activation.
- ImplementationRepository::Administration_var admin_ref =
- this->choose_activator_using_location (hostname.c_str ()
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (0);
-
- // Invoke the required operation on that reference.
- char *return_value =
- admin_ref->server_is_running (server,
- location,
- server_object
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (0);
-
- return return_value;
+ ACE_ERROR((LM_ERROR, "ImR_Locator_i::server_is_running() "
+ "This operation is only for the ImR_Activator.\n"));
+ ACE_ASSERT(false);
}
-// What the server should call before it shuts down.
void
-ImR_Locator_i::server_is_shutting_down (const char *server
- ACE_ENV_ARG_DECL)
- ACE_THROW_SPEC ((CORBA::SystemException,
- ImplementationRepository::NotFound))
+ImR_Locator_i::server_is_running_in_activator (const char* server,
+ const char* activator,
+ const char* partial_ior,
+ ImplementationRepository::ServerObject_ptr server_object
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound))
{
- ImplementationRepository::Administration_var admin_ref = 0;
-
- if (this->table_.current_size () != 1)
- {
- Table_Entry *next_entry = 0;
-
- for (Table_Iterator iterator (this->table_);
- iterator.next (next_entry) != 0;
- iterator.advance ())
- {
- // name of the activator that will do this activation.
- admin_ref =
- this->helper_for_choosing_activators (server,
- next_entry->ext_id_.c_str ()
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
-
- if (admin_ref.in () != 0)
- {
- // Invoke the required operation on that
- admin_ref->server_is_shutting_down (server
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
- }
- else
- {
- ACE_ERROR ((LM_ERROR,
- "Couldnt get a reference to an activator at %s\n",
- next_entry->ext_id_.c_str ()));
-
- //ACE_THROW (ImplementationRepository::NotFound ());
- }
- }
- }
- else
+ // todo : At this point we could automatically register the server, so that
+ // manually started servers don't require tao_imr add first.
+ ImplementationRepository::Administration_var admin =
+ this->choose_activator (activator ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+ if (OPTIONS::instance()->debug() >= 1)
{
- // There is only one activator known to this locator.
- this->default_admin_ref_->server_is_shutting_down (server
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
+ ACE_DEBUG ((LM_DEBUG, "ImR Locator: Server %s "
+ "running in activator %s.\n", server, activator));
}
+ admin->server_is_running (server, partial_ior, server_object ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+}
+
+void
+ImR_Locator_i::server_is_shutting_down (const char* ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound))
+{
+ ACE_ERROR((LM_ERROR, "ImR_Locator_i::server_is_shutting_down()"
+ " This operation is only for the ImR_Activator.\n"));
+ ACE_ASSERT(false);
}
// What the server should call before it shuts down.
void
-ImR_Locator_i::server_is_shutting_down_in_location (
+ImR_Locator_i::server_is_shutting_down_in_activator (
const char *server,
- const char *location
+ const char *activator
ACE_ENV_ARG_DECL
- ) ACE_THROW_SPEC ((CORBA::SystemException,
- ImplementationRepository::NotFound))
+ ) ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound))
{
- // name of the activator that will do this activation.
- ImplementationRepository::Administration_var admin_ref =
- this->choose_activator_using_location (location
- ACE_ENV_ARG_PARAMETER);
+ ImplementationRepository::Administration_var admin =
+ this->choose_activator (activator ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
-
- if (admin_ref.in () != 0)
+ if (OPTIONS::instance()->debug() >= 1)
{
- // Invoke the required operation on that reference.
- admin_ref->server_is_shutting_down (server
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
- }
- else
- {
- ACE_ERROR ((LM_ERROR,
- "Couldnt get a reference to the activator on %s\n:",
- location));
+ ACE_DEBUG ((LM_DEBUG, "ImR Locator: Server %s "
+ "shutting down in activator %s.\n", server, activator));
}
+ admin->server_is_shutting_down (server ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
}
-// Returns the startup information for a server
+// Find
void
ImR_Locator_i::find (
- const char *server,
+ const char * server,
ImplementationRepository::ServerInformation_out info
ACE_ENV_ARG_DECL)
- ACE_THROW_SPEC ((CORBA::SystemException,
- ImplementationRepository::NotFound))
+ ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound))
{
- ImplementationRepository::Administration_var admin_ref = 0;
-
- if (this->table_.current_size () != 1)
- {
- Table_Entry *next_entry = 0;
+ ACE_CString activator;
+ if (this->server_map_.find(server, activator) == 0)
+ {
+ this->find_in_activator(server, activator.c_str(), info);
+ }
+ else
+ {
+ ACE_ERROR ((LM_ERROR, "ImR Locator: Couldn't find an activator for server:%s\n", server));
+ ACE_THROW(ImplementationRepository::NotFound());
+ }
+}
- for (Table_Iterator iterator (this->table_);
- iterator.next (next_entry) != 0;
- iterator.advance ())
- {
- // name of the activator that will do this activation.
- admin_ref =
- this->helper_for_choosing_activators (server,
- next_entry->ext_id_.c_str ()
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
-
- if (admin_ref.in () != 0)
- {
- // Invoke the required operation on that
- admin_ref->find (server,
- info
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
- }
- else
- {
- ACE_ERROR ((LM_ERROR,
- "Couldnt get a reference to an activator at %s\n",
- next_entry->ext_id_.c_str ()));
-
- //ACE_THROW (ImplementationRepository::NotFound ());
- }
- }
- }
- else
+void
+ImR_Locator_i::find_in_activator (
+ const char* server,
+ const char* activator,
+ ImplementationRepository::ServerInformation_out info
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound))
+{
+ ImplementationRepository::Administration_var admin =
+ this->choose_activator (activator ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+ if (OPTIONS::instance()->debug() >= 1)
{
- // There is only one activator known to this locator.
- this->default_admin_ref_->find (server,
- info
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
+ ACE_DEBUG ((LM_DEBUG, "ImR Locator: Find server %s "
+ "in activator %s.\n", server, activator));
}
+ admin->find(server, info ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
}
// Used to access the list of servers registered. May also return an
@@ -984,153 +708,127 @@ ImR_Locator_i::list (CORBA::ULong how_many,
ACE_ENV_ARG_DECL
) ACE_THROW_SPEC ((CORBA::SystemException))
{
- ImplementationRepository::Administration_var admin_ref = 0;
-
- if (this->table_.current_size () != 1)
- {
- Table_Entry *next_entry = 0;
-
- // Temporary fix for the seg fault that occurs when the skel tries to
- // handle the unitialised sequence when this method is called and
- // no activator has been registered yet.
- // @todo A full rework of this method is needed - see bug #1543.
- server_iterator =
+ if (OPTIONS::instance()->debug() >= 1)
+ {
+ ACE_DEBUG ((LM_DEBUG, "ImR Locator: List servers.\n"));
+ }
+ ActivatorMap::ENTRY *next_entry = 0;
+ int cnt = 0;
+
+ for (ActivatorMap::ITERATOR iterator (this->activator_map_);
+ iterator.next (next_entry) != 0;
+ iterator.advance ())
+ {
+ ImplementationRepository::Administration_ptr admin = next_entry->int_id_.admin.in();
+ ++cnt;
+ // todo : Check to make sure activator implementation supports repeat calls correctly.
+ admin->list (how_many,
+ server_list,
+ server_iterator
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+ }
+
+ if (cnt <= 0)
+ {
+ // Temporary fix for the seg fault that occurs when the skel tries to
+ // handle the unitialised sequence when this method is called and
+ // no activator has been registered yet.
+ // @todo A full rework of this method is needed - see bug #1543.
+ server_iterator =
ImplementationRepository::ServerInformationIterator::_nil ();
- ACE_NEW_THROW_EX (server_list,
- ImplementationRepository::ServerInformationList (0),
- CORBA::NO_MEMORY ());
+ ACE_NEW_THROW_EX (server_list,
+ ImplementationRepository::ServerInformationList (0),
+ CORBA::NO_MEMORY ());
+ }
+}
- for (Table_Iterator iterator (this->table_);
- iterator.next (next_entry) != 0;
- iterator.advance ())
- {
- // name of the activator that will do this activation.
- admin_ref =
- this->choose_activator_using_location (next_entry->ext_id_.c_str ()
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
-
- if (admin_ref.in () != 0)
- {
- // Invoke the required operation on that reference.
- admin_ref->list (how_many,
- server_list,
- server_iterator
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
- }
- else
- {
- ACE_ERROR ((LM_ERROR,
- "Couldnt get a reference to an activator at %s\n",
- next_entry->ext_id_.c_str ()));
-
- //ACE_THROW (ImplementationRepository::NotFound ());
- }
- }
- }
- else
+ImplementationRepository::Administration_ptr
+ImR_Locator_i::choose_activator (const char *activator ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ImplementationRepository::NotFound, CORBA::SystemException))
+{
+ ActivatorInfo info;
+ if (this->activator_map_.find (activator, info) != 0)
{
- // There is only one activator known to this locator.
- this->default_admin_ref_->list (how_many,
- server_list,
- server_iterator
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
+ ACE_THROW_RETURN (ImplementationRepository::NotFound (), 0);
}
+ return info.admin._retn();
}
-ImplementationRepository::Administration_ptr
-ImR_Locator_i::helper_for_choosing_activators (const char *server,
- const char *location
- ACE_ENV_ARG_DECL)
- ACE_THROW_SPEC ((ImplementationRepository::NotFound,
- CORBA::SystemException))
+char *
+ImR_Locator_i::find_ior (const char *object_name ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound))
{
- ImplementationRepository::ServerInformation_var server_info;
-
- ImplementationRepository::Administration_var admin_var =
- this->choose_activator_using_location (location
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (0);
+ if (OPTIONS::instance()->debug() >= 1)
+ {
+ ACE_DEBUG ((LM_DEBUG, "ImR Locator: Find ior %s.\n", object_name));
+ }
- if (admin_var.in () != 0)
+ ActivatorMap::ENTRY *next_entry = 0;
+
+ for (ActivatorMap::ITERATOR iterator (this->activator_map_);
+ iterator.next (next_entry) != 0;
+ iterator.advance ())
{
- ACE_DECLARE_NEW_CORBA_ENV;
+ ImplementationRepository::Administration_ptr admin = next_entry->int_id_.admin.in();
ACE_TRY
{
- admin_var->find (server,
- server_info
- ACE_ENV_ARG_PARAMETER);
+ char* ior = admin->find_ior (object_name ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
+
+ return ior;
}
ACE_CATCH (ImplementationRepository::NotFound, ex)
{
- // An exception is thrown. Implies the server is not
- // registered with this activator. Return back.
- return 0;
+ ACE_UNUSED_ARG(ex);
}
ACE_ENDTRY;
-
- if (ACE_OS::strcmp (server_info->server, server) == 0)
- {
- // Double check: Found a match
- return ImplementationRepository::Administration::_duplicate (admin_var.in ());
- }
}
-
- // If it comes here, means it couldnt find one.
+
+ ACE_ERROR ((LM_ERROR, "ImR Locator: Couldn't find an activator for object:%s\n", object_name));
+ ACE_THROW_RETURN (ImplementationRepository::NotFound (), 0);
return 0;
}
-ImplementationRepository::Administration_ptr
-ImR_Locator_i::choose_activator_using_location (const char *location
- ACE_ENV_ARG_DECL)
- ACE_THROW_SPEC ((ImplementationRepository::NotFound,
- CORBA::SystemException))
-{
- CORBA::Object_var object_ref = 0;
-
- if (this->table_.find (location,
- object_ref) == -1)
- {
- ACE_THROW_RETURN (ImplementationRepository::NotFound (),
- 0);
- }
-
- ImplementationRepository::Administration_var admin_var =
- ImplementationRepository::Administration::_narrow (CORBA::Object::_duplicate (object_ref.in ())
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (0);
-
- if (admin_var.in () == 0)
- {
- ACE_DEBUG ((LM_DEBUG,
- "admin var is nil\n"));
- }
- return ImplementationRepository::Administration::_duplicate (admin_var.in ());
-}
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
-template class ACE_Hash_Map_Manager<ACE_CString, CORBA::Object_ptr, ACE_Null_Mutex>;
-template class ACE_Hash_Map_Manager_Ex<ACE_CString, CORBA::Object_ptr, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>;
-template class ACE_Hash_Map_Iterator<ACE_CString, CORBA::Object_ptr, ACE_Null_Mutex>;
-template class ACE_Hash_Map_Iterator_Ex<ACE_CString, CORBA::Object_ptr, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>;
-template class ACE_Hash_Map_Entry<ACE_CString, CORBA::Object_ptr>;
-template class ACE_Hash_Map_Reverse_Iterator<ACE_CString, CORBA::Object_ptr, ACE_Null_Mutex>;
-template class ACE_Hash_Map_Reverse_Iterator_Ex<ACE_CString, CORBA::Object_ptr, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>;
-template class ACE_Hash_Map_Iterator_Base_Ex<ACE_CString, CORBA::Object_ptr, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Manager<ACE_CString, ActivatorInfo, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Manager_Ex<ACE_CString, ActivatorInfo, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Iterator<ACE_CString, ActivatorInfo, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Iterator_Ex<ACE_CString, ActivatorInfo, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Entry<ACE_CString, ActivatorInfo>;
+template class ACE_Hash_Map_Reverse_Iterator<ACE_CString, ActivatorInfo, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Reverse_Iterator_Ex<ACE_CString, ActivatorInfo, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Iterator_Base_Ex<ACE_CString, ActivatorInfo, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>;
+
+template class ACE_Hash_Map_Manager<ACE_CString, ACE_CString, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Manager_Ex<ACE_CString, ACE_CString, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Iterator<ACE_CString, ACE_CString, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Iterator_Ex<ACE_CString, ACE_CString, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Entry<ACE_CString, ACE_CString>;
+template class ACE_Hash_Map_Reverse_Iterator<ACE_CString, ACE_CString, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Reverse_Iterator_Ex<ACE_CString, ACE_CString, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Iterator_Base_Ex<ACE_CString, ACE_CString, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
-#pragma instantiate ACE_Hash_Map_Manager<ACE_CString,CORBA::Object_ptr,ACE_Null_Mutex>
-#pragma instantiate ACE_Hash_Map_Manager_Ex<ACE_CString, CORBA::Object_ptr, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>
-#pragma instantiate ACE_Hash_Map_Iterator<ACE_CString,CORBA::Object_ptr,ACE_Null_Mutex>
-#pragma instantiate ACE_Hash_Map_Iterator_Ex<ACE_CString, CORBA::Object_ptr, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>
-#pragma instantiate ACE_Hash_Map_Entry<ACE_CString, CORBA::Object_ptr>
-#pragma instantiate ACE_Hash_Map_Reverse_Iterator<ACE_CString, CORBA::Object_ptr, ACE_Null_Mutex>
-#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<ACE_CString, CORBA::Object_ptr, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>
-#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<ACE_CString, CORBA::Object_ptr, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Manager<ACE_CString,ActivatorInfo,ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Manager_Ex<ACE_CString, ActivatorInfo, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Iterator<ACE_CString,ActivatorInfo,ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Iterator_Ex<ACE_CString, ActivatorInfo, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Entry<ACE_CString, ActivatorInfo>
+#pragma instantiate ACE_Hash_Map_Reverse_Iterator<ACE_CString, ActivatorInfo, ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<ACE_CString, ActivatorInfo, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<ACE_CString, ActivatorInfo, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>
+
+#pragma instantiate ACE_Hash_Map_Manager<ACE_CString,ACE_CString,ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Manager_Ex<ACE_CString, ACE_CString, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Iterator<ACE_CString,ACE_CString,ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Iterator_Ex<ACE_CString, ACE_CString, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Entry<ACE_CString, ACE_CString>
+#pragma instantiate ACE_Hash_Map_Reverse_Iterator<ACE_CString, ACE_CString, ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<ACE_CString, ACE_CString, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<ACE_CString, ACE_CString, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, ACE_Null_Mutex>
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.h b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.h
index 1d89a9003a6..b86c8c1f68a 100644
--- a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.h
+++ b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.h
@@ -5,6 +5,7 @@
#include /**/ "ace/pre.h"
#include "tao/PortableServer/ImR_LocatorS.h"
+#include "tao/IORTable/IORTable.h"
#include "ace/Hash_Map_Manager.h"
#include "ace/Null_Mutex.h"
@@ -12,21 +13,26 @@
class ACE_Reactor;
+struct ActivatorInfo {
+ CORBA::Long token; // A unique token is assigned at registration
+ ImplementationRepository::Administration_var admin;
+};
+
+// Look up activator information by activator name.
typedef ACE_Hash_Map_Manager_Ex <ACE_CString,
- CORBA::Object_ptr,
+ ActivatorInfo,
ACE_Hash<ACE_CString>,
ACE_Equal_To<ACE_CString>,
- ACE_Null_Mutex> HASH_MAP_MANAGER;
-
-typedef ACE_Hash_Map_Entry <ACE_CString, CORBA::Object_ptr> Table_Entry;
+ ACE_Null_Mutex> ActivatorMap;
-typedef ACE_Hash_Map_Iterator_Ex <ACE_CString,
- CORBA::Object_ptr,
- ACE_Hash<ACE_CString>,
- ACE_Equal_To<ACE_CString>,
- ACE_Null_Mutex> Table_Iterator;
+// Look up activator name by server name. (where the server name is the name of a poa
+// registered in the call to server_is_running().)
+typedef ACE_Hash_Map_Manager_Ex <ACE_CString,
+ ACE_CString,
+ ACE_Hash<ACE_CString>,
+ ACE_Equal_To<ACE_CString>,
+ ACE_Null_Mutex> ServerMap;
-// Forward declarations.
class ImR_Adapter_Activator;
class ImR_Forwarder;
@@ -42,29 +48,22 @@ class ImR_Locator_i : public virtual POA_ImplementationRepository::Locator
ImR_Locator_i ();
- ~ImR_Locator_i ();
-
// Initialize and gets the ImR_Locator running and ready to accept
// requests.
- int init (int argc, char *argv[] ACE_ENV_ARG_DECL_WITH_DEFAULTS);
-
- // Register an activator with the locator. Raises an
- // AlreadyRegistered Exception if it is already in the
- // list.
- virtual CORBA::ULong register_activator (const char *activator,
- CORBA::Object_ptr obj_ref
- ACE_ENV_ARG_DECL_WITH_DEFAULTS)
- ACE_THROW_SPEC ((ImplementationRepository::AlreadyRegistered,
- CORBA::SystemException));
+ int init (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);
+
+ // Register an activator with the locator.
+ // Returns a token that must be used when unregistering.
+ virtual CORBA::Long register_activator (const char *activator,
+ ImplementationRepository::Administration_ptr admin,
+ const ImplementationRepository::Locator::ServerNameList & servers
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
// UnRegister an activator with the locator.
- // Raises a NotFound Exception if there is no activator at the
- // specified location.
- virtual CORBA::ULong unregister_activator (const char *activator,
- CORBA::Object_ptr obj_ref
- ACE_ENV_ARG_DECL_WITH_DEFAULTS)
- ACE_THROW_SPEC ((ImplementationRepository::NotFound,
- CORBA::SystemException));
+ virtual void unregister_activator (const char *activator,
+ CORBA::Long token ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
// Starts up the server <server> if not already running.
virtual void activate_server (const char *server
@@ -74,8 +73,8 @@ class ImR_Locator_i : public virtual POA_ImplementationRepository::Locator
ImplementationRepository::CannotActivate));
// Starts up the server <server> if not already running.
- virtual void activate_server_in_location (const char *server,
- const char *location
+ virtual void activate_server_in_activator (const char *server,
+ const char *activator
ACE_ENV_ARG_DECL_WITH_DEFAULTS)
ACE_THROW_SPEC ((CORBA::SystemException,
ImplementationRepository::NotFound,
@@ -86,71 +85,81 @@ class ImR_Locator_i : public virtual POA_ImplementationRepository::Locator
virtual void register_server (const char *server,
const ImplementationRepository::StartupOptions &options
ACE_ENV_ARG_DECL_WITH_DEFAULTS)
- ACE_THROW_SPEC ((CORBA::SystemException,
- ImplementationRepository::AlreadyRegistered));
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ ImplementationRepository::AlreadyRegistered,
+ ImplementationRepository::NotFound));
// Updates the startup information about the server <server>.
virtual void reregister_server (const char *server,
const ImplementationRepository::StartupOptions &options
ACE_ENV_ARG_DECL_WITH_DEFAULTS)
- ACE_THROW_SPEC ((CORBA::SystemException));
+ ACE_THROW_SPEC ((CORBA::SystemException,ImplementationRepository::NotFound ));
// Removes the server <server> from the repository.
virtual void remove_server (const char *server
ACE_ENV_ARG_DECL_WITH_DEFAULTS)
- ACE_THROW_SPEC ((CORBA::SystemException,
- ImplementationRepository::NotFound));
+ ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound));
// Removes the server <server> from the repository.
- virtual void remove_server_in_location (const char *server,
- const char *location
+ virtual void remove_server_in_activator (const char *server,
+ const char *activator
ACE_ENV_ARG_DECL_WITH_DEFAULTS)
- ACE_THROW_SPEC ((CORBA::SystemException,
- ImplementationRepository::NotFound));
+ ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound));
// Attempts to gracefully shut down the server,
virtual void shutdown_server (const char *server
ACE_ENV_ARG_DECL_WITH_DEFAULTS)
- ACE_THROW_SPEC ((CORBA::SystemException,
- ImplementationRepository::NotFound));
+ ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound));
- // Attempts to gracefully shut down the server <server> in location
- // <location>
- virtual void shutdown_server_in_location (const char *server,
- const char *location
+ // Attempts to gracefully shut down the server <server> in activator
+ // <activator>
+ virtual void shutdown_server_in_activator (const char *server,
+ const char *activator
ACE_ENV_ARG_DECL_WITH_DEFAULTS)
- ACE_THROW_SPEC ((CORBA::SystemException,
- ImplementationRepository::NotFound));
+ ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound));
// Invoked by the server to update transient information such as current
- // location of the <server> and its ServerObject.
- virtual char *server_is_running (const char *server,
- const char *location,
+ // activator of the <server> and its ServerObject.
+ virtual void server_is_running_in_activator (const char *server,
+ const char* activator,
+ const char* partial_ior,
ImplementationRepository::ServerObject_ptr server_object
ACE_ENV_ARG_DECL_WITH_DEFAULTS)
- ACE_THROW_SPEC ((CORBA::SystemException,
- ImplementationRepository::NotFound));
+ ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound));
- // What the server should call before it shuts down.
- virtual void server_is_shutting_down (const char *server
- ACE_ENV_ARG_DECL_WITH_DEFAULTS)
- ACE_THROW_SPEC ((CORBA::SystemException,
- ImplementationRepository::NotFound));
+ // This version should only be used by the activator.
+ virtual void server_is_running (const char* server,
+ const char* partial_ior,
+ ImplementationRepository::ServerObject_ptr server_object
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound));
+
+ // Only used by activator.
+ virtual void server_is_shutting_down (const char *server ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound));
// What the server <server> should call before it shuts down from
- // location <location>
- virtual void server_is_shutting_down_in_location (const char *server,
- const char *location
+ // activator <activator>
+ virtual void server_is_shutting_down_in_activator (const char *server,
+ const char *activator
ACE_ENV_ARG_DECL_WITH_DEFAULTS)
- ACE_THROW_SPEC ((CORBA::SystemException,
- ImplementationRepository::NotFound));
+ ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound));
+
+ /// IOR_LookupTable_Callback method helper. Will return an IOR
+ char *find_ior (const char* object_name ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound));
- // Returns the startup information for a server
virtual void find (const char *server,
ImplementationRepository::ServerInformation_out info
ACE_ENV_ARG_DECL_WITH_DEFAULTS)
- ACE_THROW_SPEC ((CORBA::SystemException,
- ImplementationRepository::NotFound));
+ ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound));
+
+ // Returns the startup information for a server
+ virtual void find_in_activator (const char *server,
+ const char* activator,
+ ImplementationRepository::ServerInformation_out info
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::NotFound));
// 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.
@@ -161,68 +170,39 @@ class ImR_Locator_i : public virtual POA_ImplementationRepository::Locator
ACE_ENV_ARG_DECL_WITH_DEFAULTS)
ACE_THROW_SPEC ((CORBA::SystemException));
- // Starts up the server <server> if not already running.
+ // Starts up the server <server> on one or more activators.
+ // Returns a partial ior for the server that is missing only the ObjectKey.
char *activate_server_with_startup (const char *server,
int check_startup
ACE_ENV_ARG_DECL_WITH_DEFAULTS)
ACE_THROW_SPEC ((CORBA::SystemException,
ImplementationRepository::NotFound,
ImplementationRepository::CannotActivate));
+ private:
// Set up the multicast related if 'm' is passed on the command
// line.
- int setup_multicast (ACE_Reactor *reactor,
- const char *ior);
-
- private:
-
- // Parse the commandline paramters.
- int parse_args (int argc, char *argv[]);
+ int setup_multicast (ACE_Reactor *reactor, const char *ior);
// As the name suggests, this methods helps choose the activator
- // based on the location passed.
+ // based on the activator passed.
ImplementationRepository::Administration_ptr
- choose_activator_using_location (const char *location
- ACE_ENV_ARG_DECL_WITH_DEFAULTS)
- ACE_THROW_SPEC ((ImplementationRepository::NotFound,
- CORBA::SystemException));
-
- // Helper method for choosing the activators.
- ImplementationRepository::Administration_ptr
- helper_for_choosing_activators (const char *server,
- const char *location
- ACE_ENV_ARG_DECL_WITH_DEFAULTS)
- ACE_THROW_SPEC ((ImplementationRepository::NotFound,
- CORBA::SystemException));
-
- // Pointer to the default administration interface. Helps
- // unnecessary search when only one ImR_Activator is registered with
- // the ImR_Locator.
- ImplementationRepository::Administration_var default_admin_ref_;
+ choose_activator(const char *activator ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((ImplementationRepository::NotFound, CORBA::SystemException));
- // check if this is the first time an activator is getting
- // registered with the ImR_Locator. To be used while setting
- // default_admin_ref_ value.
- CORBA::Boolean first_timer_;
-
- // Table that maintains the Location to Object Reference of the
- // Activator running in that location.
- HASH_MAP_MANAGER table_;
-
- // variable to check if debug information is requested.
- int debug_;
-
- // Variable to check if multicast is enabled.
- int multicast_;
-
- // IOR file
- const char *ior_output_file_;
+ // Table that maintains the activator to Object Reference of the
+ // Activator running in that activator.
+ ActivatorMap activator_map_;
+ ServerMap server_map_;
// The class that handles the forwarding.
ImR_Forwarder *forwarder_impl_;
// Used for the forwarding of any type of POA.
ImR_Adapter_Activator *activator_;
+
+ /// The locator interface for the IORTable
+ IORTable::Locator_var ins_locator_;
};
#include /**/ "ace/post.h"
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImplRepo_Service.mpc b/TAO/orbsvcs/ImplRepo_Service/ImplRepo_Service.mpc
index dacfae37557..04015b883d1 100644
--- a/TAO/orbsvcs/ImplRepo_Service/ImplRepo_Service.mpc
+++ b/TAO/orbsvcs/ImplRepo_Service/ImplRepo_Service.mpc
@@ -1,10 +1,13 @@
-project : orbsvcsexe, core, acexml, minimum_corba, svc_utils, iortable {
+project(ImR_Locator) : orbsvcsexe, core, acexml, minimum_corba, svc_utils, iortable, strategies {
exename = ImplRepo_Service
Source_Files {
Adapter_Activator.cpp
Forwarder.cpp
ImR_Locator.cpp
ImR_Locator_i.cpp
+ Locator_NT_Service.cpp
+ Locator_Options.cpp
+ INS_Locator.cpp
}
}
@@ -15,13 +18,12 @@ project(ImR_Activator) : orbsvcsexe, core, acexml, minimum_corba, svc_utils, ior
ImR_Activator.cpp
ImR_Activator_i.cpp
Iterator.cpp
- Locator.cpp
- Options.cpp
+ Activator_Options.cpp
Server_Info.cpp
Server_Repository.cpp
Repository_Configuration.cpp
XML_ContentHandler.cpp
- NT_Service.cpp
+ Activator_NT_Service.cpp
}
}
diff --git a/TAO/orbsvcs/ImplRepo_Service/Iterator.cpp b/TAO/orbsvcs/ImplRepo_Service/Iterator.cpp
index 137ca36aed9..59fcb5b6a10 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Iterator.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/Iterator.cpp
@@ -12,9 +12,7 @@
#include "Iterator.h"
-// Plain old constructor
-
-ImR_Iterator::ImR_Iterator (Server_Repository::HASH_IMR_ITER *iterator,
+ImR_Iterator::ImR_Iterator (Server_Repository::HASH_IMR_MAP::ITERATOR *iterator,
PortableServer::POA_ptr poa)
: iterator_ (iterator),
poa_ (poa)
@@ -23,8 +21,6 @@ ImR_Iterator::ImR_Iterator (Server_Repository::HASH_IMR_ITER *iterator,
}
-// Destructor
-
ImR_Iterator::~ImR_Iterator ()
{
delete iterator_;
@@ -52,7 +48,7 @@ ImR_Iterator::next_n (CORBA::ULong how_many,
// bindings.
server_list->length (how_many);
- Server_Repository::HASH_IMR_ENTRY *server_entry;
+ Server_Repository::HASH_IMR_MAP::ENTRY *server_entry;
// Iterate and populate the BindingList.
diff --git a/TAO/orbsvcs/ImplRepo_Service/Iterator.h b/TAO/orbsvcs/ImplRepo_Service/Iterator.h
index ca755bc66c9..2acb593021e 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Iterator.h
+++ b/TAO/orbsvcs/ImplRepo_Service/Iterator.h
@@ -30,7 +30,7 @@ class ImR_Iterator
public:
/// Constructor
/// Ownership of iterator is transfered to this class (we'll delete it)
- ImR_Iterator (Server_Repository::HASH_IMR_ITER *iterator,
+ ImR_Iterator (Server_Repository::HASH_IMR_MAP::ITERATOR *iterator,
PortableServer::POA_ptr poa);
/// Destructor
@@ -51,9 +51,8 @@ public:
private:
/// Our very own iterator for transversing the server repository.
- Server_Repository::HASH_IMR_ITER *iterator_;
+ Server_Repository::HASH_IMR_MAP::ITERATOR *iterator_;
- /// Our lovely POA.
PortableServer::POA_var poa_;
};
diff --git a/TAO/orbsvcs/ImplRepo_Service/Locator_NT_Service.cpp b/TAO/orbsvcs/ImplRepo_Service/Locator_NT_Service.cpp
new file mode 100644
index 00000000000..4fb3d110445
--- /dev/null
+++ b/TAO/orbsvcs/ImplRepo_Service/Locator_NT_Service.cpp
@@ -0,0 +1,95 @@
+//=============================================================================
+/**
+ * @file Locator_NT_Service.cpp
+ *
+ * $Id$
+ *
+ * @author Darrell Brunsch <brunsch@cs.wustl.edu>
+ * @author Jeff Parsons <parsons@cs.wustl.edu>
+ * @author John Tucker <jtucker@infoglide.com>
+ * @author Mike Vitalo <mvitalo@infoglide.com>
+ */
+//=============================================================================
+
+#include "Locator_NT_Service.h"
+
+#if defined (ACE_WIN32)
+
+#include "ImR_Locator_i.h"
+
+#include "tao/ORB_Core.h"
+//#include "tao/corba.h"
+#include "ace/Reactor.h"
+
+/**
+ * Handles the SERVICE_CONTROL_SHUTDOWN and SERVICE_CONTROL_STOP commands
+ * by shutting down the ORB. Otherwise ACE_NT_Service::handle_control
+ * handles the command.
+ */
+void
+Locator_NT_Service::handle_control (DWORD control_code)
+{
+ if (control_code == SERVICE_CONTROL_SHUTDOWN
+ || control_code == SERVICE_CONTROL_STOP)
+ {
+ report_status (SERVICE_STOP_PENDING);
+ TAO_ORB_Core_instance ()->reactor ()->end_reactor_event_loop ();
+ TAO_ORB_Core_instance ()->orb ()->shutdown (1);
+ }
+ else
+ {
+ ACE_NT_Service::handle_control (control_code);
+ }
+}
+
+
+/**
+ */
+int
+Locator_NT_Service::handle_exception (ACE_HANDLE)
+{
+ return 0;
+}
+
+
+/**
+ * We do almost the same thing as we do in run_standalone ()
+ */
+int
+Locator_NT_Service::svc (void)
+{
+ ImR_Locator_i server;
+
+ ACE_DECLARE_NEW_CORBA_ENV;
+ ACE_TRY
+ {
+ report_status (SERVICE_RUNNING);
+ int status = server.init (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ report_status (SERVICE_STOPPED);
+
+ if (status != -1)
+ {
+ return 0;
+ }
+ }
+ ACE_CATCH (CORBA::SystemException, sysex)
+ {
+ ACE_PRINT_EXCEPTION (sysex, IMR_LOCATOR_DISPLAY_NAME);
+ }
+ ACE_CATCH (CORBA::UserException, userex)
+ {
+ ACE_PRINT_EXCEPTION (userex, IMR_LOCATOR_DISPLAY_NAME);
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, IMR_LOCATOR_DISPLAY_NAME);
+ }
+ ACE_ENDTRY;
+
+ report_status (SERVICE_STOPPED);
+
+ return -1;
+}
+
+#endif /* ACE_WIN32 */
diff --git a/TAO/orbsvcs/ImplRepo_Service/NT_Service.h b/TAO/orbsvcs/ImplRepo_Service/Locator_NT_Service.h
index d454650205b..577dc1e557b 100644
--- a/TAO/orbsvcs/ImplRepo_Service/NT_Service.h
+++ b/TAO/orbsvcs/ImplRepo_Service/Locator_NT_Service.h
@@ -12,41 +12,33 @@
*/
//=============================================================================
-#ifndef IMR_NT_SERVICE_H
-#define IMR_NT_SERVICE_H
+#ifndef Locator_NT_Service_H
+#define Locator_NT_Service_H
#include "ace/config.h"
-// Only on windows
#if defined (ACE_WIN32)
+#include "tao/orbconf.h"
+
#include "ace/NT_Service.h"
#include "ace/Singleton.h"
#include "ace/Synch.h"
-#include "tao/orbconf.h"
-static const char *IMR_SERVICE_NAME = "TAOImplRepo";
-static const char *IMR_DISPLAY_NAME = "TAO Implementation Repository";
-
-// @todo Not used yet, maybe ACE_NT_Service needs to be changed to accept it.
-static const char *IMR_DESCRIPTION = "Activation service for TAO";
+static const char * IMR_LOCATOR_SERVICE_NAME = "TAOIMRLocator";
+static const char * IMR_LOCATOR_DISPLAY_NAME = "TAO Implementation Repository Locator";
+static const char * IMR_LOCATOR_DESCRIPTION = "Implementation Repository Locator service for TAO";
/**
- * @class ImR_NT_Service
+ * @class Locator_NT_Service
*
* @brief Allows the Implementation Repository to act as a Windows NT Service.
*/
-class ImR_NT_Service : public ACE_NT_Service
+class Locator_NT_Service : public ACE_NT_Service
{
public:
typedef TAO_SYNCH_RECURSIVE_MUTEX MUTEX;
- /// Constructor (not protected since it is used by ACE_NT_SERVICE_DEFINE).
- ImR_NT_Service (void);
-
- /// Destructor
- virtual ~ImR_NT_Service (void);
-
/// We override <handle_control> because it handles stop requests
/// privately.
virtual void handle_control (DWORD control_code);
@@ -57,15 +49,13 @@ public:
/// This is a virtual method inherited from ACE_NT_Service.
virtual int svc (void);
-
+
private:
- friend class ACE_Singleton<ImR_NT_Service, MUTEX>;
+ friend class ACE_Singleton<Locator_NT_Service, MUTEX>;
};
-typedef ACE_Singleton<ImR_NT_Service, ACE_Mutex> SERVICE;
+typedef ACE_Singleton<Locator_NT_Service, ACE_Mutex> SERVICE;
#endif /* ACE_WIN32 */
-#endif /* IMR_NT_SERVICE_H */
-
-
+#endif /* Locator_NT_Service_H */
diff --git a/TAO/orbsvcs/ImplRepo_Service/Locator_Options.cpp b/TAO/orbsvcs/ImplRepo_Service/Locator_Options.cpp
new file mode 100644
index 00000000000..de4fff3a6e2
--- /dev/null
+++ b/TAO/orbsvcs/ImplRepo_Service/Locator_Options.cpp
@@ -0,0 +1,487 @@
+//=============================================================================
+/**
+ * @file Options.cpp
+ *
+ * $Id$
+ *
+ * @author Darrell Brunsch <brunsch@cs.wustl.edu>
+ */
+//=============================================================================
+
+#include "Locator_Options.h"
+#include "Locator_NT_Service.h"
+#include "tao/Strategies/advanced_resource.h"
+#include "ace/Arg_Shifter.h"
+#include "ace/ARGV.h"
+#include "ace/OS_NS_strings.h"
+
+ACE_RCSID (ImplRepo_Service,
+ Options,
+ "$Id$")
+
+
+#if defined (ACE_WIN32)
+static const HKEY SERVICE_REG_ROOT = HKEY_LOCAL_MACHINE;
+// This string must agree with the one used in Locator_NT_Service.h
+static const ACE_TCHAR *SERVICE_REG_PATH =
+ ACE_TEXT ("SYSTEM\\CurrentControlSet\\Services\\TAOIMRLocator\\Parameters");
+#endif /* ACE_WIN32 */
+
+/**
+ * Default Constructor. Assigns default values to all the member variables.
+ */
+Options::Options ()
+ : debug_ (1)
+ , multicast_ (false)
+ , service_ (false)
+ , service_command_(SC_NONE)
+{
+}
+
+/**
+ * parse_args uses an ACE_Arg_Shifter to grab all the options that are
+ * specific to the ImR.
+ *
+ * @retval 0 Success
+ * @retval -1 Error parsing args
+ * @retval 1 Success but we should exit.
+ */
+int
+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 (),
+ ACE_TEXT ("-c")) == 0)
+ {
+ shifter.consume_arg ();
+
+ if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
+ {
+ ACE_ERROR ((LM_ERROR, "Error: -c option needs a command\n"));
+ this->print_usage ();
+ return -1;
+ }
+
+ if (ACE_OS::strcasecmp (shifter.get_current (),
+ ACE_TEXT ("install")) == 0)
+ {
+ this->service_command_ = SC_INSTALL;
+ }
+ else if (ACE_OS::strcasecmp (shifter.get_current (),
+ ACE_TEXT ("remove")) == 0)
+ {
+ this->service_command_ = SC_REMOVE;
+ }
+ else
+ {
+ 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)
+ {
+ shifter.consume_arg ();
+
+ if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
+ {
+ ACE_ERROR ((LM_ERROR, "Error: -d option needs a debuglevel\n"));
+ this->print_usage ();
+ return -1;
+ }
+
+ this->debug_ = ACE_OS::atoi (shifter.get_current ());
+ }
+ else if (ACE_OS::strcasecmp (shifter.get_current (),
+ ACE_TEXT ("-m")) == 0)
+ {
+ this->multicast_ = true;
+ }
+ else if (ACE_OS::strcasecmp (shifter.get_current (),
+ ACE_TEXT ("-o")) == 0)
+ {
+ shifter.consume_arg ();
+
+ if (!shifter.is_anything_left () || shifter.get_current ()[0] == '-')
+ {
+ ACE_ERROR ((LM_ERROR, "Error: -o option needs a filename\n"));
+ this->print_usage ();
+ return -1;
+ }
+ this->ior_output_file_ = shifter.get_current();
+ }
+ else if (ACE_OS::strcasecmp (shifter.get_current (),
+ ACE_TEXT ("-s")) == 0)
+ {
+ // Run as a service
+ this->service_ = true;
+ }
+ else if ((ACE_OS::strcasecmp (shifter.get_current (),
+ ACE_TEXT ("-?")) == 0)
+ || (ACE_OS::strcasecmp (shifter.get_current (),
+ ACE_TEXT ("-h")) == 0))
+ {
+ this->print_usage ();
+ return 1;
+ }
+ else
+ {
+ shifter.ignore_arg ();
+ continue;
+ }
+
+ shifter.consume_arg ();
+ }
+
+ return 0;
+}
+
+/**
+ * @retval 0 Success
+ * @retval -1 Error parsing args
+ * @retval 1 Success but we should exit.
+ */
+int
+Options::init (int argc, char *argv[])
+{
+ int result = this->parse_args (argc, argv);
+ if (result != 0) {
+ return result;
+ }
+
+ ACE_ARGV orb_args; // Save the leftovers to a ACE_ARGV class
+ ACE_CString cmdline; // We'll save this in the registry when installing.
+ for (int i = 1; i < argc; ++i)
+ {
+ cmdline += ACE_CString(argv[i]) + ACE_CString(" ");
+ if (orb_args.add (argv[i]) == -1)
+ {
+ ACE_ERROR ((LM_ERROR, "Error: Could not save argument"));
+ return -1;
+ }
+ }
+
+ result = run_service_command(cmdline);
+
+ if (result != 0)
+ return result;
+
+ char* argv_tmp = 0;
+
+ // Load from the registry. This may replace the args.
+ if (this->load_registry_options(argv_tmp, orb_args) != 0)
+ return -1;
+
+ ACE_Auto_Array_Ptr<char> argv_deleter(argv_tmp);
+
+ int orb_argc = orb_args.argc ();
+ // Now initialize the orb and pass it the leftover arguments
+ ACE_TRY_NEW_ENV
+ {
+ this->orb_ = CORBA::ORB_init (orb_argc,
+ orb_args.argv (),
+ 0
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "Caught exception \n");
+ ACE_ERROR ((LM_ERROR, "Error: Cannot initialize ORB\n"));
+ return -1;
+ }
+ ACE_ENDTRY;
+
+ // Indicates successful parsing of command line.
+ return 0;
+}
+
+
+/**
+ * Just print out the usage message to STDERR
+ */
+void
+Options::print_usage (void) const
+{
+ ACE_ERROR ((LM_ERROR,
+ "Usage:\n"
+ "\n"
+ "ImR_Locator [-c cmd] [-d 0|1|2] [-m] [-o file] [-s]\n"
+ "\n"
+ " -c command Runs nt service commands ('install' or 'remove')\n"
+ " -d level Sets the debug level (default 1)\n"
+ " -m Turn on multicast\n"
+ " -o file Outputs the ImR's IOR to a file\n"
+ " -s Runs as a service (NT Only)\n")
+ );
+}
+
+
+/**
+ * Executes the various commands that are useful for a NT service. Right
+ * now these include 'install' and 'remove'. Others, such as 'start' and
+ * 'stop' can be added, but the 'net' program in Windows already handles
+ * these commands.
+ *
+ * @todo Finish implementing Options::run_service_command
+ * @todo Update to unicode
+ */
+int
+Options::run_service_command (const ACE_CString& cmdline)
+{
+ if (this->service_command_ == SC_NONE)
+ return 0;
+#if defined (ACE_WIN32)
+ SERVICE::instance ()->name (IMR_LOCATOR_SERVICE_NAME, IMR_LOCATOR_DISPLAY_NAME);
+
+ if (this->service_command_ == SC_INSTALL)
+ {
+ char pathname[_MAX_PATH * 2 + 3]; // +3 for the ' -s' at the end
+
+ if (ACE_TEXT_GetModuleFileName(NULL, pathname, _MAX_PATH * 2) == 0)
+ {
+ ACE_ERROR ((LM_ERROR, "Error: Could not get module file name.\n"));
+ return -1;
+ }
+
+ // Append the command used for running the implrepo as
+ ACE_OS::strcat (pathname, ACE_TEXT (" -s"));
+
+ int ret = SERVICE::instance ()->insert (SERVICE_DEMAND_START,
+ SERVICE_ERROR_NORMAL,
+ pathname
+ );
+ if (ret != -1) {
+ if (debug() > 0) {
+ ACE_DEBUG ((LM_DEBUG, "ImR Locator: Service installed.\n"));
+ }
+ this->save_registry_options(cmdline);
+ } else {
+ ACE_ERROR((LM_ERROR, "Error: Failed to install service.\n"));
+ }
+ if (ret == 0)
+ return 1;
+ }
+ else if (this->service_command_ == SC_REMOVE)
+ {
+ int ret = SERVICE::instance ()->remove ();
+ if (debug() > 0) {
+ ACE_DEBUG ((LM_DEBUG, "ImR Locator: Service removed.\n"));
+ }
+ if (ret == 0)
+ return 1; // If successfull, then we don't want to continue.
+ }
+
+ return -1;
+
+#else /* ACE_WIN32 */
+ ACE_UNUSED_ARG (cmdline);
+ ACE_ERROR ((LM_ERROR, "Service not supported on this platform"));
+
+ return -1;
+#endif /* ACE_WIN32 */
+}
+
+int
+Options::save_registry_options(const ACE_CString& cmdline)
+{
+#if defined (ACE_WIN32)
+ HKEY key = 0;
+ // Create or open the parameters key
+ LONG err = ACE_TEXT_RegCreateKeyEx (SERVICE_REG_ROOT,
+ SERVICE_REG_PATH,
+ 0,
+ "", // class
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &key,
+ NULL
+ );
+ if (err != ERROR_SUCCESS) {
+ return -1;
+ }
+ err = ACE_TEXT_RegSetValueEx(key, "ORBInitOptions", 0, REG_SZ,
+ (LPBYTE) cmdline.c_str(), 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, "DebugLevel", 0, REG_DWORD,
+ (LPBYTE) &debug_ , sizeof(debug_));
+ ACE_ASSERT(err == ERROR_SUCCESS);
+
+ DWORD tmp = multicast_ ? 1 : 0;
+ 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);
+#else
+ ACE_UNUSED_ARG (cmdline);
+#endif
+ return 0;
+}
+
+namespace {
+ // This both parses the cmdline by replacing spaces with \0's, and
+ // adds each command to the ACE_ARGV.
+ void parse_command_line(char* cmdline, ACE_ARGV& argv) {
+ // This tokenizer will replace all spaces with end-of-string
+ // characters and will preserve text between "" and '' pairs.
+ ACE_Tokenizer parser (cmdline);
+ parser.delimiter_replace (' ', '\0');
+ parser.preserve_designators ('\"', '\"');
+ parser.preserve_designators ('\'', '\'');
+
+ for (char *p = parser.next (); p; p = parser.next ()) {
+ argv.add(p);
+ }
+ }
+}
+/**
+ * We will only load from the registry if we are a service.
+ * We load each parameter from individual string keys, and then
+ * we have to parse the cmdline property into the orb_options
+ * so that they can be passed to ORB_init()
+ */
+int
+Options::load_registry_options (char*& cmdline, ACE_ARGV& argv)
+{
+#if defined (ACE_WIN32)
+ if (! this->service())
+ {
+ if (this->debug () > 1)
+ ACE_DEBUG ((LM_DEBUG,
+ "Locator_Options::load_registry_options: Not running "
+ "as a service, will not load data from registry\n"));
+ return 0;
+ }
+
+ HKEY key = 0;
+ // Create or open the parameters key
+ LONG err = ACE_TEXT_RegOpenKeyEx (SERVICE_REG_ROOT,
+ SERVICE_REG_PATH,
+ 0,
+ KEY_READ,
+ &key
+ );
+ if (err != ERROR_SUCCESS) {
+ // If there aren't any saved parameters, then that's ok.
+ return 0;
+ }
+ TCHAR tmpstr[4096];
+ DWORD sz = sizeof(tmpstr);
+ DWORD type = 0;
+ err = ACE_TEXT_RegQueryValueEx(key, "ORBInitOptions", 0, &type,
+ (LPBYTE) tmpstr, &sz);
+ if (err == ERROR_SUCCESS) {
+ ACE_ASSERT(type == REG_SZ);
+ cmdline = new char[sz+1];
+ ACE_OS::strncpy(cmdline, tmpstr, sz);
+ parse_command_line(cmdline, argv);
+ }
+
+ sz = sizeof(tmpstr);
+ err = ACE_TEXT_RegQueryValueEx(key, "IORFile", 0, &type,
+ (LPBYTE) tmpstr, &sz);
+ if (err == ERROR_SUCCESS) {
+ ACE_ASSERT(type == REG_SZ);
+ tmpstr[sz] = TCHAR('\0');
+ this->ior_output_file_ = ACE_CString(tmpstr);
+ }
+
+ sz = sizeof(debug_);
+ err = ACE_TEXT_RegQueryValueEx(key, "DebugLevel", 0, &type,
+ (LPBYTE) &debug_ , &sz);
+ if (err == ERROR_SUCCESS) {
+ ACE_ASSERT(type == REG_DWORD);
+ }
+
+ DWORD tmp = 0;
+ err = ACE_TEXT_RegQueryValueEx(key, "Multicast", 0, &type,
+ (LPBYTE) &tmp, &sz);
+ if (err == ERROR_SUCCESS) {
+ ACE_ASSERT(type == REG_DWORD);
+ this->multicast_ = tmp != 0;
+ }
+
+ err = ::RegCloseKey(key);
+ ACE_ASSERT(err == ERROR_SUCCESS);
+
+ return 0;
+#else /* ACE_WIN32 */
+ ACE_UNUSED_ARG (cmdline);
+ ACE_UNUSED_ARG (argv);
+ return 0;
+#endif /* ACE_WIN32 */
+}
+
+/**
+ * Standalone Mode
+ *
+ * @retval false Run as standalone service
+ * @retval true Run as a service (only on NT right now)
+ */
+bool
+Options::service (void) const
+{
+ return this->service_;
+}
+
+
+/**
+ * Debug level for the IR.
+ *
+ * @retval 0 Quiet
+ * @retval 1 Trace messages
+ * @retval 2 Detailed messages
+ */
+unsigned int
+Options::debug (void) const
+{
+ return this->debug_;
+}
+
+
+/**
+ * @return The file where the IOR will be stored.
+ */
+ACE_CString
+Options::output_filename (void) const
+{
+ return this->ior_output_file_;
+}
+
+/**
+ * @return A pointer to the ORB.
+ */
+CORBA::ORB_ptr
+Options::orb (void) const
+{
+ return CORBA::ORB::_duplicate (this->orb_.in ());
+}
+
+/**
+ * @retval false Do not listen for multicast location requests.
+ * @retval true Do Listen.
+ */
+bool
+Options::multicast (void) const
+{
+ return this->multicast_;
+}
+
+#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
+template class ACE_Singleton <Options, ACE_Null_Mutex>;
+#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
+#pragma instantiate ACE_Singleton <Options, ACE_Null_Mutex>
+#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
diff --git a/TAO/orbsvcs/ImplRepo_Service/Locator_Options.h b/TAO/orbsvcs/ImplRepo_Service/Locator_Options.h
new file mode 100644
index 00000000000..fb48823f101
--- /dev/null
+++ b/TAO/orbsvcs/ImplRepo_Service/Locator_Options.h
@@ -0,0 +1,102 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Options.h
+ *
+ * $Id$
+ *
+ * @brief Definition of the Options class for the Implementation Repository.
+ *
+ * @author Darrell Brunsch <brunsch@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef LOCATOR_OPTIONS_H
+#define LOCATOR_OPTIONS_H
+
+#include "Repository_Configuration.h"
+
+#include "tao/ORB.h"
+
+#include "ace/Singleton.h"
+#include "ace/SString.h"
+#include "ace/Auto_Ptr.h"
+
+
+// Forward declarations
+class ACE_ARGV;
+
+/**
+ * @class Options
+ *
+ * @brief Maintains the global options.
+ *
+ * This is where the settings for TAO's Implementation Repository are stored.
+ */
+class Options
+{
+public:
+ enum SERVICE_COMMAND {
+ SC_NONE,
+ SC_INSTALL,
+ SC_REMOVE
+ };
+
+ /// Default Constructor
+ Options ();
+
+ /// Parse the command-line arguments and initialize the options.
+ int init (int argc, char *argv[]);
+
+ /// Service Mode
+ bool service (void) const;
+
+ /// Debug level for the Implementation Repository.
+ unsigned int debug (void) const;
+
+ /// Returns the file where the IOR should be stored.
+ ACE_CString output_filename (void) const;
+
+ /// Returns a pointer to the ORB.
+ CORBA::ORB_ptr orb (void) const;
+
+ /// Will we listen for multicast location requests?
+ bool multicast (void) const;
+
+private:
+ /// Parses and pulls out arguments for the ImR
+ int parse_args (int &argc, char *argv[]);
+
+ /// Print the usage information.
+ void print_usage (void) const;
+
+ /// Run a service command.
+ int run_service_command (const ACE_CString& cmdline);
+
+ /// Loads ORB options from the registry
+ int load_registry_options (char*& cmdline, ACE_ARGV& argv);
+ int save_registry_options (const ACE_CString& cmdline);
+
+ /// Debug level.
+ unsigned int debug_;
+
+ /// File where the IOR of the server object is stored.
+ ACE_CString ior_output_file_;
+
+ /// Will we listen for multicast location requests?
+ bool multicast_;
+
+ /// The ORB for the Implementation Repository.
+ CORBA::ORB_var orb_;
+
+ /// Are we running as a service?
+ bool service_;
+
+ /// SC_NONE, SC_INSTALL, SC_REMOVE, ...
+ int service_command_;
+};
+
+typedef ACE_Singleton <Options, ACE_Null_Mutex> OPTIONS;
+
+#endif
diff --git a/TAO/orbsvcs/ImplRepo_Service/README.txt b/TAO/orbsvcs/ImplRepo_Service/README.txt
index c530aeabc5b..34fe77ace81 100644
--- a/TAO/orbsvcs/ImplRepo_Service/README.txt
+++ b/TAO/orbsvcs/ImplRepo_Service/README.txt
@@ -52,6 +52,7 @@ a question since responses are usually just replied back to the group.
The NT Service part of the ImR was developed by Jeff Parsons @<<a
href="mailto:parsons@cs.wustl.edu">parsons@cs.wustl.edu</a>@>. He can
also be reached via the same channels.
+It was later extended and enhanced by Justin Michel <michel_j@ociweb.com>
*/
@@ -137,7 +138,7 @@ Nothing yet.
@subsection XML Database Support
As of now, the support is only to be able to have the information
-about a registered server written to an XML file. Have to support
+ about a registered server written to an XML file. Have to support
retrieving information from the XML file to be able to do any actions
on the registered servers.
@@ -489,43 +490,30 @@ Service. The -c option can be used to install and remove the service
of its required ACE/TAO DLL's in the path or in the same directory.
For example, the run_test.pl copies ImplRepo_Service.exe to the
ACE_wrappers@\bin directory before using "-c install".
+Alternatively, You can set the usual ACE_ROOT, TAO_ROOT, and PATH environment
+variables on a system wide basis.
The service can be then started either from the Windows NT "Services"
Admin Tool or via the "net" program on the command line:
-<CODE>net start "TAO Implementation Repository"</CODE>
+<CODE>net start "TAO Implementation Repository Locator"</CODE>
+<CODE>net start "TAO Implementation Repository Activator"</CODE>
The Implementation Repository supports start and stop but not pause.
@subsection serviceopts Service Options
-When installing the Implementation Repository as a service, there isn't an
-opportunity to specify any command line options. So if you want to specify
-that the ImplRepo_Service should output to a file or set the debug level to 2,
-for example, you will have to manually edit the registry to do this.
-
-The magic key for extra options to pass to the Implementation Repository is
-<B>SYSTEM\CurrentControlSet\Services\TAOImplRepo\Parameters\ORBOptions</B>
-under <B>HKEY_LOCAL_MACHINE</B>. This value should be a MULTI_SZ value with
-each parameter in separate strings. Since it is a MULTI_SZ, you will need to
-use regedt32.exe to add this, since regedit.exe doesn't support MULTI_SZ types
-yet.
-
-So let's say you want to up the debug level to 2 and record the output to the
-C:@\ImplRepo.log file. First you will have to install the ImplRepo_Service
-as a service to create the TAOImplRepo subkey under Services. Now fire up
-regedt32 and browse to the TAOImplRepo key. The Parameters key under
-TAOImplRepo will now need to be created. And now you can create the
-"ORBOptions" value in Parameters. Now when the multi-string editor pops up,
-add the following on separate lines:
-
-- -ORBLogFile
-- C:@\ImplRepo.log
-- -ORBDebugLevel
-- 2
-
-And when the ImplRepo_Service is run as a service (and only when it runs as
-a service) it will use these options.
+Any options that are specified along with -c install, will be saved in
+the registry under
+HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TAOIMRActivator\Parameters and
+HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TAOIMRLocator\Parameters.
+For example:
+ImR_Activator -c install -d 3 -l -m -o activator.ior -x persist.xml -t 30 -orbendpoint iiop://:9988 -orbdebuglevel 1
+
+The order of arguments makes no difference, but you must run
+-c remove and then -c install if you want to change the parameters.
+
+You can also manually change these using the typical regedit utility.
*/
diff --git a/TAO/orbsvcs/ImplRepo_Service/Repository_Configuration.cpp b/TAO/orbsvcs/ImplRepo_Service/Repository_Configuration.cpp
index cbdaddf7b42..27a90b77f9b 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Repository_Configuration.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/Repository_Configuration.cpp
@@ -1,5 +1,5 @@
#include "Repository_Configuration.h"
-#include "NT_Service.h"
+#include "Activator_NT_Service.h"
#include "ace/Configuration.h"
#include "ace/OS_NS_stdio.h"
@@ -13,7 +13,6 @@ ACE_RCSID (ImplRepo_Service,
Repository_Configuration::Repository_Configuration (const char *repository_mode)
: config_ (0)
{
- /// Default Constructor
if (ACE_OS::strcmp (repository_mode, "x") == 0)
{
/// XML Mode : Dont do anything special
@@ -25,15 +24,13 @@ Repository_Configuration::Repository_Configuration (const char *repository_mode)
HKEY root =
ACE_Configuration_Win32Registry::resolve_key(HKEY_LOCAL_MACHINE,
"Software\\TAO\\IR");
- ACE_NEW (this->config_,
- ACE_Configuration_Win32Registry(root));
+ ACE_NEW (this->config_, ACE_Configuration_Win32Registry(root));
#endif /* ACE_WIN32 */
}
else if (ACE_OS::strcmp (repository_mode, "h") == 0)
{
- ACE_NEW (this->config_,
- ACE_Configuration_Heap);
+ ACE_NEW (this->config_, ACE_Configuration_Heap);
if (this->config_ == 0)
{
@@ -45,14 +42,13 @@ Repository_Configuration::Repository_Configuration (const char *repository_mode)
Repository_Configuration::~Repository_Configuration (void)
{
- /// Destructor
- if (this->config_ != 0)
- delete this->config_;
+ delete this->config_;
}
const ACE_Configuration_Section_Key &
Repository_Configuration::root_section ()
{
+ ACE_ASSERT(this->config_ != 0);
return this->config_->root_section ();
}
@@ -74,7 +70,7 @@ Repository_Configuration::open (void)
ACE_Configuration_Heap *heap =
ACE_dynamic_cast (ACE_Configuration_Heap *,
this->config_);
-
+ ACE_ASSERT(heap != 0);
return heap->open ();
}
return 0;
@@ -107,7 +103,7 @@ Repository_Configuration::open (const char *file_name)
ACE_Configuration_Heap *heap =
ACE_dynamic_cast (ACE_Configuration_Heap *,
this->config_);
-
+ ACE_ASSERT(heap != 0);
return heap->open (file_name);
}
return 0;
diff --git a/TAO/orbsvcs/ImplRepo_Service/Server_Info.cpp b/TAO/orbsvcs/ImplRepo_Service/Server_Info.cpp
index 87b684f3327..d2d503911ec 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Server_Info.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/Server_Info.cpp
@@ -13,7 +13,7 @@ Server_Info::Server_Info (
const ImplementationRepository::EnvironmentList environment_vars,
const ACE_CString working_dir,
const ImplementationRepository::ActivationMode activation)
- : starting_up_ (0),
+ : starting_up_ (false),
logical_server_name_ (logical_server_name),
POA_name_ (POA_name),
startup_command_ (startup_command),
@@ -23,7 +23,6 @@ Server_Info::Server_Info (
server_object_ior_ (""),
activation_ (activation)
{
- // Initialize the command_line and working_dir.
}
@@ -40,7 +39,7 @@ Server_Info::update_running_info (const ACE_CString location,
{
this->location_ = location;
this->server_object_ior_ = server_object_ior;
- this->starting_up_ = 0;
+ this->starting_up_ = false;
}
@@ -52,7 +51,6 @@ Server_Info::get_startup_info (
ACE_CString &working_dir,
ImplementationRepository::ActivationMode &activation)
{
- // Returns startup information.
logical_server_name = this->logical_server_name_;
startup_command = this->startup_command_;
environment_vars = this->environment_vars_;
@@ -64,7 +62,6 @@ void
Server_Info::get_running_info (ACE_CString &location,
ACE_CString &server_object_ior)
{
- // Returns information about a running instance.
location = this->location_;
server_object_ior = this->server_object_ior_;
}
diff --git a/TAO/orbsvcs/ImplRepo_Service/Server_Info.h b/TAO/orbsvcs/ImplRepo_Service/Server_Info.h
index dd0720b4ed1..090eb2bb603 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Server_Info.h
+++ b/TAO/orbsvcs/ImplRepo_Service/Server_Info.h
@@ -78,7 +78,7 @@ public:
/// This is a flag to determine if the process has already been spawned
/// and we are just waiting for it to start up.
- int starting_up_;
+ bool starting_up_;
private:
/// Which server process this poa is grouped in.
diff --git a/TAO/orbsvcs/ImplRepo_Service/Server_Repository.cpp b/TAO/orbsvcs/ImplRepo_Service/Server_Repository.cpp
index 7407cdef1d1..ae1b09da7b4 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Server_Repository.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/Server_Repository.cpp
@@ -1,6 +1,6 @@
#include "Server_Repository.h"
#include "XML_ContentHandler.h"
-#include "Options.h"
+#include "Activator_Options.h"
#include "ACEXML/parser/parser/Parser.h"
#include "ACEXML/common/FileCharStream.h"
@@ -10,30 +10,17 @@ ACE_RCSID (ImplRepo_Service,
"$Id$")
-Server_Repository::Server_Repository (void)
-{
-}
-
-
-Server_Repository::~Server_Repository (void)
-{
-}
-
-
-// Initialize the the configuration class.
-
int
Server_Repository::init (void)
{
- ACE_TCHAR *mode = OPTIONS::instance ()->repository_mode ();
-
- if (ACE_OS::strcmp (mode, "x") != 0)
+ int rmode = OPTIONS::instance ()->repository_mode ();
+ if (rmode != Options::REPO_XML_FILE)
{
Repository_Configuration *config = OPTIONS::instance ()->config ();
-
- // NON-XML mode
+ ACE_ASSERT(config != 0);
// iterate through the list of registered servers and register them
+
config->open_section (config->root_section (),
ACE_LIB_TEXT ("Servers"),
1,
@@ -81,10 +68,11 @@ Server_Repository::init (void)
// way to store env vars.
if (error != 0)
- { ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("Error reading configuration data for ")
- ACE_TEXT ("service '%s',skipping\n"),
- name.c_str ()));
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Error reading configuration data for ")
+ ACE_TEXT ("service '%s',skipping\n"),
+ name.c_str ()));
}
else
{
@@ -114,20 +102,19 @@ Server_Repository::init (void)
int
Server_Repository::add (
- const ACE_CString POA_name,
- const ACE_CString logical_server_name,
- const ACE_CString startup_command,
- const ImplementationRepository::EnvironmentList environment_vars,
- const ACE_CString working_dir,
- const ImplementationRepository::ActivationMode activation
+ const ACE_CString& POA_name,
+ const ACE_CString& logical_server_name,
+ const ACE_CString& startup_command,
+ const ImplementationRepository::EnvironmentList& environment_vars,
+ const ACE_CString& working_dir,
+ const ImplementationRepository::ActivationMode& activation
)
{
- ACE_TCHAR *mode = OPTIONS::instance ()->repository_mode ();
-
- if (ACE_OS::strcmp (mode, "x") != 0)
+ int rmode = OPTIONS::instance ()->repository_mode ();
+ if (rmode != Options::REPO_XML_FILE)
{
-
Repository_Configuration *config = OPTIONS::instance ()->config ();
+ ACE_ASSERT(config != 0);
// @@ Add this to the persistent configuration; environment_vars??
ACE_Configuration_Section_Key server;
@@ -162,40 +149,39 @@ Server_Repository::add (
activation),
-1);
- return this->repository_.bind (POA_name,
- new_server);
+ return this->repository_.bind (POA_name, new_server);
}
else
{
- /// XML mode: So, write into file.
- ACE_TCHAR *filename = OPTIONS::instance ()->file_name ();
-
- FILE *fp = ACE_OS::fopen (filename, "r");
-
- ACE_TCHAR buffer[4096];
- ACE_TCHAR *found;
+ ACE_CString filename = OPTIONS::instance ()->file_name ();
- while (ACE_OS::fgets (buffer, sizeof (buffer), fp))
+ FILE *fp = ACE_OS::fopen (filename.c_str(), "r");
+
+ if (fp != 0)
{
- /// Obviously, we need to/can update only if we find an
- /// entry for it in the xml file.
- found = ACE_OS::strstr (buffer, POA_name.c_str ());
-
- if (found)
+ ACE_TCHAR buffer[4096];
+ while (ACE_OS::fgets (buffer, sizeof (buffer), fp))
{
- /// An entry found for the POA_name. So, dont
- /// add it again.
- ACE_DEBUG ((LM_DEBUG,
- "The %s is already added.\n", POA_name.c_str ()));
+ /// Obviously, we need to/can update only if we find an
+ /// entry for it in the xml file.
+ ACE_TCHAR* found = ACE_OS::strstr (buffer, POA_name.c_str ());
+
+ if (found != 0)
+ {
+ /// An entry found for the POA_name. So, dont
+ /// add it again.
+ ACE_DEBUG ((LM_DEBUG,
+ "ImR Activator: The %s is already added.\n", POA_name.c_str ()));
- ACE_OS::fclose (fp);
+ ACE_OS::fclose (fp);
- return 0;
+ return 0;
+ }
}
}
/// If control comes here, it means this server isnt added already.
- fp = ACE_OS::fopen (filename, "a");
+ fp = ACE_OS::fopen (filename.c_str(), "a");
if (fp == 0)
{
@@ -215,9 +201,8 @@ Server_Repository::add (
server_info += OPTIONS::instance ()->convert_str (activation);
server_info += "</Activation>\n</StartupOptions>\n</SERVER_INFORMATION>\n";
- ACE_OS::fprintf (fp,
- server_info.c_str ());
- ACE_OS::fclose (fp);
+ ACE_OS::fprintf(fp, server_info.c_str());
+ ACE_OS::fclose(fp);
return 0;
}
@@ -226,45 +211,41 @@ Server_Repository::add (
// Update the associated process information.
int
-Server_Repository::update (const ACE_CString POA_name,
- const ACE_CString location,
- const ACE_CString server_object_ior)
+Server_Repository::update (const ACE_CString& POA_name,
+ const ACE_CString& location,
+ const ACE_CString& server_object_ior)
{
- ACE_TCHAR *mode = OPTIONS::instance ()->repository_mode ();
-
- if (ACE_OS::strcmp (mode, "x") != 0)
+ int rmode = OPTIONS::instance ()->repository_mode ();
+ if (rmode != Options::REPO_XML_FILE)
{
- Server_Info *server;
- int retval = this->repository_.find (POA_name,
- server);
+ Server_Info *server = 0;
+ int retval = this->repository_.find (POA_name, server);
// Only fill in data if it was found
if (retval == 0)
{
- server->update_running_info (location,
- server_object_ior);
+ ACE_ASSERT(server != 0);
+ server->update_running_info (location, server_object_ior);
}
return retval;
}
else
{
- /// XML mode
- ACE_TCHAR *filename = OPTIONS::instance ()->file_name ();
+ ACE_CString filename = OPTIONS::instance ()->file_name ();
- FILE *fp = ACE_OS::fopen (filename, "r+");
+ FILE *fp = ACE_OS::fopen (filename.c_str(), "r+");
+ ACE_ASSERT(fp != 0);
ACE_TCHAR buffer[4096];
- ACE_TCHAR *found;
-
while (ACE_OS::fgets (buffer, sizeof (buffer), fp))
{
/// Obviously, we need to/can update only if we find an
/// entry for it in the xml file.
- found = ACE_OS::strstr (buffer, POA_name.c_str ());
+ ACE_TCHAR* found = ACE_OS::strstr (buffer, POA_name.c_str ());
- if (found)
+ if (found != 0)
{
/// found an entry. So, need to update the entry
/// information.
@@ -282,32 +263,30 @@ Server_Repository::update (const ACE_CString POA_name,
int
Server_Repository::get_startup_info (
- const ACE_CString POA_name,
- ACE_CString &logical_server_name,
- ACE_CString &startup_command,
- ImplementationRepository::EnvironmentList &environment_vars,
- ACE_CString &working_dir,
- ImplementationRepository::ActivationMode &activation
+ const ACE_CString& POA_name,
+ ACE_CString& logical_server_name,
+ ACE_CString& startup_command,
+ ImplementationRepository::EnvironmentList& environment_vars,
+ ACE_CString& working_dir,
+ ImplementationRepository::ActivationMode& activation
)
{
- ACE_TCHAR *mode = OPTIONS::instance ()->repository_mode ();
-
- if (ACE_OS::strcmp (mode, "x") != 0)
+ int rmode = OPTIONS::instance ()->repository_mode ();
+ if (rmode != Options::REPO_XML_FILE)
{
-
- Server_Info *server;
+ Server_Info* server = 0;
int retval = this->repository_.find (POA_name, server);
// Only fill in data if it was found
if (retval == 0)
{
+ ACE_ASSERT(server != 0);
server->get_startup_info (logical_server_name,
startup_command,
environment_vars,
working_dir,
activation);
}
-
return retval;
}
else
@@ -317,17 +296,14 @@ Server_Repository::get_startup_info (
ACEXML_FileCharStream (),
1);
-
- if (fstm->open (OPTIONS::instance ()->file_name ()) != 0)
+ const char* fname = OPTIONS::instance()->file_name().c_str();
+ if (fstm->open (fname) != 0)
{
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_LIB_TEXT ("Fail to open XML file: trial.xml\n ")),
- -1);
+ ACE_ERROR((LM_ERROR, ACE_LIB_TEXT("Fail to open XML file: %s\n"), fname));
+ return 1;
}
- /// XML case
- this->handler_ =
- new XML_ContentHandler (POA_name.c_str ());
+ this->handler_ = new XML_ContentHandler (POA_name.c_str ());
ACEXML_Parser parser;
@@ -367,43 +343,39 @@ Server_Repository::get_startup_info (
// Returns information related to a running copy.
int
-Server_Repository::get_running_info (const ACE_CString POA_name,
- ACE_CString &location,
- ACE_CString &server_object_ior)
+Server_Repository::get_running_info (const ACE_CString& POA_name,
+ ACE_CString& location,
+ ACE_CString& server_object_ior)
{
- ACE_TCHAR *mode = OPTIONS::instance ()->repository_mode ();
+ int rmode = OPTIONS::instance ()->repository_mode ();
- if (ACE_OS::strcmp (mode, "x") != 0)
+ if (rmode != Options::REPO_XML_FILE)
{
-
Server_Info *server;
- int retval = this->repository_.find (POA_name,
- server);
+ int retval = this->repository_.find (POA_name, server);
// Only fill in data if it was found
if (retval == 0)
{
- server->get_running_info (location,
- server_object_ior);
+ ACE_ASSERT(server != 0);
+ server->get_running_info (location, server_object_ior);
}
-
return retval;
}
else
{
- /// XML mode
- ACE_TCHAR *filename = OPTIONS::instance ()->file_name ();
+ ACE_CString filename = OPTIONS::instance ()->file_name ();
- FILE *fp = ACE_OS::fopen (filename, "r");
+ FILE *fp = ACE_OS::fopen (filename.c_str(), "r");
+ ACE_ASSERT(fp != 0);
ACE_TCHAR buffer[4096];
- ACE_TCHAR *found;
while (ACE_OS::fgets (buffer, sizeof (buffer), fp))
{
- found = ACE_OS::strstr (buffer, POA_name.c_str ());
+ ACE_TCHAR* found = ACE_OS::strstr (buffer, POA_name.c_str ());
- if (found)
+ if (found != 0)
{
/// Found an entry for the POA_name. So, we can proceed.
this->handler_->get_running_information (POA_name,
@@ -423,51 +395,44 @@ Server_Repository::get_running_info (const ACE_CString POA_name,
// returns the previous value or -1 if the POA_name wasn't found
int
-Server_Repository::starting_up (const ACE_CString POA_name,
+Server_Repository::starting_up (const ACE_CString& POA_name,
int new_value)
{
- ACE_TCHAR *mode = OPTIONS::instance ()->repository_mode ();
+ int rmode = OPTIONS::instance ()->repository_mode ();
- if (ACE_OS::strcmp (mode, "x") != 0)
+ if (rmode != Options::REPO_XML_FILE)
{
Server_Info *server;
- int retval = this->repository_.find (POA_name,
- server);
+ int retval = this->repository_.find (POA_name, server);
// Only fill in data if it was found
if (retval == 0)
{
- retval = server->starting_up_;
- server->starting_up_ = new_value;
+ ACE_ASSERT(server != 0);
+ retval = server->starting_up_ ? 1 : 0;
+ server->starting_up_ = new_value != 0;
}
-
return retval;
}
else
{
- /// XML mode
- ACE_TCHAR *filename = OPTIONS::instance ()->file_name ();
+ ACE_CString filename = OPTIONS::instance ()->file_name ();
- FILE *fp = ACE_OS::fopen (filename, "r");
+ FILE *fp = ACE_OS::fopen (filename.c_str(), "r");
+ ACE_ASSERT(fp != 0);
ACE_TCHAR buffer[4096];
- ACE_TCHAR *found;
while (ACE_OS::fgets (buffer, sizeof (buffer), fp))
{
- found = ACE_OS::strstr (buffer, POA_name.c_str ());
+ ACE_TCHAR* found = ACE_OS::strstr (buffer, POA_name.c_str ());
- if (found)
+ if (found != 0)
{
int retval;
-
/// Found an entry for the POA_name. So, we can proceed.
- this->handler_->get_startup_value (POA_name,
- retval);
-
- this->handler_->set_startup_value (POA_name,
- new_value);
-
+ this->handler_->get_startup_value (POA_name, retval);
+ this->handler_->set_startup_value (POA_name, new_value);
return retval;
}
}
@@ -480,51 +445,46 @@ Server_Repository::starting_up (const ACE_CString POA_name,
// Same as above but does not alter the value
int
-Server_Repository::starting_up (const ACE_CString POA_name)
+Server_Repository::starting_up (const ACE_CString& POA_name)
{
- ACE_TCHAR *mode = OPTIONS::instance ()->repository_mode ();
+ int rmode = OPTIONS::instance ()->repository_mode ();
- if (ACE_OS::strcmp (mode, "x") != 0)
+ if (rmode != Options::REPO_XML_FILE)
{
Server_Info *server;
- int retval = this->repository_.find (POA_name,
- server);
+ int retval = this->repository_.find (POA_name, server);
// Only fill in data if it was found
if (retval == 0)
{
- retval = server->starting_up_;
+ ACE_ASSERT(server != 0);
+ retval = server->starting_up_ != 0;
}
return retval;
}
else
{
- /// XML mode
- ACE_TCHAR *filename = OPTIONS::instance ()->file_name ();
+ ACE_CString filename = OPTIONS::instance ()->file_name ();
- FILE *fp = ACE_OS::fopen (filename, "r");
+ FILE *fp = ACE_OS::fopen (filename.c_str(), "r");
+ ACE_ASSERT(fp != 0);
ACE_TCHAR buffer[4096];
- ACE_TCHAR *found;
-
+
while (ACE_OS::fgets (buffer, sizeof (buffer), fp))
{
- found = ACE_OS::strstr (buffer, POA_name.c_str ());
+ ACE_TCHAR* found = ACE_OS::strstr (buffer, POA_name.c_str ());
- if (found)
+ if (found != 0)
{
int retval;
-
/// Found an entry for the POA_name. So, we can proceed.
- this->handler_->get_startup_value (POA_name,
- retval);
-
+ this->handler_->get_startup_value (POA_name, retval);
return retval;
}
}
-
/// If control comes here.. implies, there is no entry for the
/// POA_name.
return -1;
@@ -535,61 +495,59 @@ Server_Repository::starting_up (const ACE_CString POA_name)
// Removes the server from the Repository.
int
-Server_Repository::remove (const ACE_CString POA_name)
+Server_Repository::remove (const ACE_CString& POA_name)
{
- ACE_TCHAR *mode = OPTIONS::instance ()->repository_mode ();
+ int rmode = OPTIONS::instance ()->repository_mode ();
- if (ACE_OS::strcmp (mode, "x") != 0)
+ if (rmode != Options::REPO_XML_FILE)
{
Repository_Configuration *config = OPTIONS::instance ()->config ();
-
+ ACE_ASSERT(config != 0);
// Remove the persistent configuration information
config->remove_section (this->servers_,
POA_name.c_str(),
1);
-
return this->repository_.unbind (POA_name);
}
else
{
- /// XML mode
- ACE_TCHAR *filename = OPTIONS::instance ()->file_name ();
+ ACE_CString filename = OPTIONS::instance ()->file_name ();
- FILE *fp = ACE_OS::fopen (filename, "r");
+ FILE *fp = ACE_OS::fopen (filename.c_str(), "r");
+ ACE_ASSERT(fp != 0);
/// Have a temporary file
CORBA::String_var temp_file = "temporary_file";
FILE *fp_temp = ACE_OS::fopen (temp_file.in (), "w");
+ ACE_ASSERT(fp_temp != 0);
ACE_TCHAR buffer[4096];
- int remove_section = 0;
- ACE_TCHAR *found;
+ bool remove_section = false;
// int dtd_section = 0;
while (ACE_OS::fgets (buffer, sizeof (buffer), fp))
{
- if (remove_section == 0)
+ if (! remove_section)
{
- found = ACE_OS::strstr (buffer, POA_name.c_str ());
+ ACE_TCHAR* found = ACE_OS::strstr (buffer, POA_name.c_str ());
- if (!found)
+ if (found == 0)
{
- ACE_OS::fprintf (fp_temp,
- buffer);
+ ACE_OS::fprintf (fp_temp, buffer);
}
else
{
- remove_section = 1;
+ remove_section = true;
}
}
else
{
- found = ACE_OS::strstr (buffer, "</SERVER_INFORMATION>");
+ ACE_TCHAR* found = ACE_OS::strstr (buffer, "</SERVER_INFORMATION>");
- if (found)
- remove_section = 0;
+ if (found != 0)
+ remove_section = false;
}
}
@@ -598,13 +556,14 @@ Server_Repository::remove (const ACE_CString POA_name)
// Now copy the temporary file to the original file.
fp_temp = ACE_OS::fopen (temp_file.in (), "r");
+ ACE_ASSERT(fp_temp != 0);
- fp = ACE_OS::fopen (filename, "w");
+ fp = ACE_OS::fopen (filename.c_str(), "w");
+ ACE_ASSERT(fp != 0);
while (ACE_OS::fgets (buffer, sizeof (buffer), fp_temp))
{
- ACE_OS::fprintf (fp,
- buffer);
+ ACE_OS::fprintf (fp, buffer);
}
ACE_OS::fclose (fp);
@@ -621,7 +580,7 @@ Server_Repository::remove (const ACE_CString POA_name)
{
found = ACE_OS::strstr (buffer, "]>");
- if (found)
+ if (found != 0)
{
dtd_section = 1;
remove_section = 0;
@@ -636,21 +595,21 @@ Server_Repository::remove (const ACE_CString POA_name)
{
found = ACE_OS::strstr (buffer, POA_name.c_str ());
- if (!found)
+ if (found == 0)
{
- ACE_OS::fprintf (fp_temp,
+ ACE_OS::fprintf (fp_temp,
buffer);
}
else
{
- remove_section = 1;
+ remove_section = 1;
}
}
else
{
- found = ACE_OS::strstr (buffer, "</SERVER_INFORMATION>");
+ found = ACE_OS::strstr (buffer, "</SERVER_INFORMATION>");
- if (found)
+ if (found != 0)
remove_section = 0;
}
}
@@ -677,15 +636,14 @@ Server_Repository::remove (const ACE_CString POA_name)
*/
}
-// Writes to XML file.
int
Server_Repository::write_to_xml (
- const ACE_CString,
- const ACE_CString,
- const ACE_CString,
- const ImplementationRepository::EnvironmentList,
- const ACE_CString,
- const ImplementationRepository::ActivationMode)
+ const ACE_CString&,
+ const ACE_CString&,
+ const ACE_CString&,
+ const ImplementationRepository::EnvironmentList&,
+ const ACE_CString&,
+ const ImplementationRepository::ActivationMode&)
{
/*
ACE_TCHAR *filename = "trial.xml";
@@ -711,12 +669,12 @@ Server_Repository::write_to_xml (
// Returns a new iterator that travels over the repository.
-Server_Repository::HASH_IMR_ITER *
+Server_Repository::HASH_IMR_MAP::ITERATOR *
Server_Repository::new_iterator (void)
{
- HASH_IMR_ITER *hash_iter = 0;
+ HASH_IMR_MAP::ITERATOR *hash_iter = 0;
ACE_NEW_RETURN (hash_iter,
- Server_Repository::HASH_IMR_ITER (this->repository_),
+ Server_Repository::HASH_IMR_MAP::ITERATOR (this->repository_),
0);
return hash_iter;
diff --git a/TAO/orbsvcs/ImplRepo_Service/Server_Repository.h b/TAO/orbsvcs/ImplRepo_Service/Server_Repository.h
index 8e13f6b1bae..75e0b484d38 100644
--- a/TAO/orbsvcs/ImplRepo_Service/Server_Repository.h
+++ b/TAO/orbsvcs/ImplRepo_Service/Server_Repository.h
@@ -35,79 +35,60 @@ class XML_ContentHandler;
class Server_Repository
{
public:
- /// Default Constructor
- Server_Repository (void);
-
- /// Destructor
- ~Server_Repository (void);
-
- typedef ACE_Hash_Map_Entry<ACE_CString,
- Server_Info *> HASH_IMR_ENTRY;
-
typedef ACE_Hash_Map_Manager_Ex<ACE_CString,
Server_Info *,
ACE_Hash<ACE_CString>,
ACE_Equal_To<ACE_CString>,
ACE_Null_Mutex> HASH_IMR_MAP;
- typedef ACE_Hash_Map_Iterator_Ex<ACE_CString,
- Server_Info *,
- ACE_Hash<ACE_CString>,
- ACE_Equal_To<ACE_CString>,
- ACE_Null_Mutex> HASH_IMR_ITER;
-
/// Initializes the Server Repository
int init (void);
/// Add a new server to the Repository
- int add (const ACE_CString POA_name,
- const ACE_CString logical_server_name,
- const ACE_CString startup_command,
- const ImplementationRepository::EnvironmentList
- environment_vars,
- const ACE_CString working_dir,
- const ImplementationRepository::ActivationMode activation);
+ int add (const ACE_CString& POA_name,
+ const ACE_CString& logical_server_name,
+ const ACE_CString& startup_command,
+ const ImplementationRepository::EnvironmentList& environment_vars,
+ const ACE_CString& working_dir,
+ const ImplementationRepository::ActivationMode& activation);
/// Update the associated process information.
- int update (const ACE_CString POA_name,
- const ACE_CString location,
- const ACE_CString server_object_ior);
+ int update (const ACE_CString& POA_name,
+ const ACE_CString& location,
+ const ACE_CString& server_object_ior);
/// Returns information related to startup.
- int get_startup_info (const ACE_CString POA_name,
- ACE_CString &logical_server_name,
- ACE_CString &startup_command,
- ImplementationRepository::EnvironmentList
- &environment_vars,
- ACE_CString &working_dir,
- ImplementationRepository::ActivationMode
- &activation);
+ int get_startup_info (const ACE_CString& POA_name,
+ ACE_CString& logical_server_name,
+ ACE_CString& startup_command,
+ ImplementationRepository::EnvironmentList& environment_vars,
+ ACE_CString& working_dir,
+ ImplementationRepository::ActivationMode& activation);
/// Returns information related to a running copy.
- int get_running_info (const ACE_CString POA_name,
- ACE_CString &location,
- ACE_CString &server_object_ior);
+ int get_running_info (const ACE_CString& POA_name,
+ ACE_CString& location,
+ ACE_CString& server_object_ior);
/// Checks the starting_up_ variable in the Server_Info and
/// returns the previous value or -1 if the POA_name wasn't found
- int starting_up (const ACE_CString POA_name, int new_value);
+ int starting_up (const ACE_CString& POA_name, int new_value);
/// Same as above but does not alter the value.
- int starting_up (const ACE_CString POA_name);
+ int starting_up (const ACE_CString& POA_name);
/// Removes the server from the Repository.
- int remove (const ACE_CString POA_name);
+ int remove (const ACE_CString& POA_name);
/// Write into the xml file.
- int write_to_xml (const ACE_CString POA_name,
- const ACE_CString logical_server_name,
- const ACE_CString startup_command,
- const ImplementationRepository::EnvironmentList
- environment_vars,
- const ACE_CString working_dir,
- const ImplementationRepository::ActivationMode activation);
+ int write_to_xml (const ACE_CString& POA_name,
+ const ACE_CString& logical_server_name,
+ const ACE_CString& startup_command,
+ const ImplementationRepository::EnvironmentList& environment_vars,
+ const ACE_CString& working_dir,
+ const ImplementationRepository::ActivationMode& activation);
/// Returns a new iterator that travels over the repository.
- HASH_IMR_ITER *new_iterator (void);
+ HASH_IMR_MAP::ITERATOR *new_iterator (void);
/// Returns the number of entries in the repository.
size_t get_repository_size (void);
diff --git a/TAO/orbsvcs/ImplRepo_Service/XML_ContentHandler.cpp b/TAO/orbsvcs/ImplRepo_Service/XML_ContentHandler.cpp
index 31a6939c23f..b3a42b2c304 100644
--- a/TAO/orbsvcs/ImplRepo_Service/XML_ContentHandler.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/XML_ContentHandler.cpp
@@ -8,14 +8,14 @@ ACE_RCSID (ImplRepo_Service,
XML_ContentHandler::XML_ContentHandler (const char *server_name)
: server_name_ (server_name),
- found_server_entry_ (0),
- command_line_entry_ (0),
- working_dir_entry_ (0),
- environment_vars_entry_ (0),
- activation_entry_ (0),
- server_object_ior_entry_ (0),
- location_entry_ (0),
- startup_value_ (0)
+ found_server_entry_ (false),
+ command_line_entry_ (false),
+ working_dir_entry_ (false),
+ environment_vars_entry_ (false),
+ activation_entry_ (false),
+ server_object_ior_entry_ (false),
+ location_entry_ (false),
+ startup_value_ (false)
{
// no-op
}
@@ -34,38 +34,38 @@ XML_ContentHandler::characters (const ACEXML_Char *cdata,
{
if (ACE_OS::strcmp (cdata, this->server_name_.c_str ()) == 0)
{
- this->found_server_entry_ = 1;
+ this->found_server_entry_ = true;
}
- if (this->command_line_entry_ == 1)
+ if (this->command_line_entry_ )
{
this->command_line_ = cdata;
- this->command_line_entry_ = 0;
+ this->command_line_entry_ = false;
}
- else if (this->working_dir_entry_ == 1)
+ else if (this->working_dir_entry_ )
{
this->working_dir_ = cdata;
- this->working_dir_entry_ = 0;
+ this->working_dir_entry_ = false;
}
- else if (this->activation_entry_ == 1)
+ else if (this->activation_entry_ )
{
this->activation_ = cdata;
- this->activation_entry_ = 0;
+ this->activation_entry_ = false;
}
- else if (this->environment_vars_entry_ == 1)
+ else if (this->environment_vars_entry_ )
{
this->environment_vars_ = cdata;
- this->environment_vars_entry_ = 0;
+ this->environment_vars_entry_ = false;
}
- else if (this->location_entry_ == 1)
+ else if (this->location_entry_ )
{
this->location_ = cdata;
- this->location_entry_ = 0;
+ this->location_entry_ = false;
}
- else if (this->server_object_ior_entry_ == 1)
+ else if (this->server_object_ior_entry_ )
{
this->server_object_ior_ = cdata;
- this->server_object_ior_entry_ = 0;
+ this->server_object_ior_entry_ = false;
}
}
@@ -136,31 +136,31 @@ XML_ContentHandler::startElement (const ACEXML_Char *,
ACEXML_Attributes * ACEXML_ENV_ARG_DECL_NOT_USED)
ACE_THROW_SPEC ((ACEXML_SAXException))
{
- if (this->found_server_entry_ == 1)
+ if (this->found_server_entry_ )
{
if (ACE_OS::strcmp (qName, "Command_Line") == 0)
{
- this->command_line_entry_ = 1;
+ this->command_line_entry_ = true;
}
else if (ACE_OS::strcmp (qName, "WorkingDir") == 0)
{
- this->working_dir_entry_ = 1;
+ this->working_dir_entry_ = true;
}
else if (ACE_OS::strcmp (qName, "Activation") == 0)
{
- this->activation_entry_ = 1;
+ this->activation_entry_ = true;
}
else if (ACE_OS::strcmp (qName, "Command_Line") == 0)
{
- this->environment_vars_entry_ = 1;
+ this->environment_vars_entry_ = true;
}
else if (ACE_OS::strcmp (qName, "Location") == 0)
{
- this->location_entry_ = 1;
+ this->location_entry_ = true;
}
else if (ACE_OS::strcmp (qName, "Server_Object_IOR") == 0)
{
- this->server_object_ior_entry_ = 1;
+ this->server_object_ior_entry_ = true;
}
}
}
@@ -269,14 +269,14 @@ XML_ContentHandler::set_startup_value (ACE_CString POA_name,
int new_value)
{
this->server_name_ = POA_name;
- this->startup_value_ = new_value;
+ this->startup_value_ = new_value != 0;
}
void
XML_ContentHandler::get_startup_value (ACE_CString /* POA_name */,
int &new_value)
{
- new_value = this->startup_value_;
+ new_value = this->startup_value_ ? 1 : 0;
}
void
diff --git a/TAO/orbsvcs/ImplRepo_Service/XML_ContentHandler.h b/TAO/orbsvcs/ImplRepo_Service/XML_ContentHandler.h
index 6f6185c2526..ee3e69beab7 100644
--- a/TAO/orbsvcs/ImplRepo_Service/XML_ContentHandler.h
+++ b/TAO/orbsvcs/ImplRepo_Service/XML_ContentHandler.h
@@ -208,14 +208,14 @@ public:
ACE_CString location_;
// Checks to see if that particular entry exists.
- int found_server_entry_;
- int command_line_entry_;
- int working_dir_entry_;
- int environment_vars_entry_;
- int activation_entry_;
- int server_object_ior_entry_;
- int location_entry_;
- int startup_value_;
+ bool found_server_entry_;
+ bool command_line_entry_;
+ bool working_dir_entry_;
+ bool environment_vars_entry_;
+ bool activation_entry_;
+ bool server_object_ior_entry_;
+ bool location_entry_;
+ bool startup_value_;
};
#endif /* XML_CONTENTHANDLER_H */
diff --git a/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.cpp b/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.cpp
index 1d4c3aebee8..f0ad7170c2e 100644
--- a/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.cpp
@@ -14,16 +14,6 @@
// How many servers should we get at once?
const size_t IR_LIST_CHUNK = 10;
-// exception return codes
-const int NORMAL = 0;
-const int UNKNOWN = 1;
-const int NO_PERMISSION = 2;
-const int ALREADY_REGISTERED = 3;
-const int CANNOT_ACTIVATE = 4;
-const int NOT_FOUND = 5;
-
-// Constructor
-
TAO_IMR_i::TAO_IMR_i (void)
: imr_locator_ (ImplementationRepository::Locator::_nil ()),
op_ (0)
@@ -31,9 +21,6 @@ TAO_IMR_i::TAO_IMR_i (void)
// Nothing
}
-
-// Destructor
-
TAO_IMR_i::~TAO_IMR_i (void)
{
delete this->op_;
@@ -45,7 +32,7 @@ TAO_IMR_i::run ()
if (this->op_ == 0)
{
ACE_ERROR ((LM_ERROR, "Unknown operation"));
- return UNKNOWN;
+ return TAO_IMR_Op::UNKNOWN;
}
return this->op_->run ();
@@ -95,9 +82,6 @@ TAO_IMR_i::init (int argc, char **argv)
ACE_TRY_CHECK;
this->op_->set_imr_locator (this->imr_locator_.in ());
-
- ACE_DEBUG ((LM_DEBUG,
- "imr locator narrowed\n"));
}
ACE_CATCHANY
{
@@ -185,7 +169,10 @@ TAO_IMR_Op::make_op (const ACE_TCHAR *op_name)
}
-// Sets the implrepo pointer.
+TAO_IMR_Op::~TAO_IMR_Op ()
+{
+ // Nothing
+}
void
TAO_IMR_Op::set_imr_locator (ImplementationRepository::Locator_ptr imr_locator)
@@ -193,33 +180,53 @@ TAO_IMR_Op::set_imr_locator (ImplementationRepository::Locator_ptr imr_locator)
this->imr_locator_ = imr_locator;
}
-// ============================================================================
-// = Constructors.
+void
+TAO_IMR_Op::display_server_information (const ImplementationRepository::ServerInformation &info)
+{
+ // Figure out what the activation string is.
+ const char *act = "UNKNOWN STARTUP";
+ if (info.startup.activation == ImplementationRepository::NORMAL)
+ act = "NORMAL";
+ else if (info.startup.activation == ImplementationRepository::MANUAL)
+ act = "MANUAL";
+ else if (info.startup.activation == ImplementationRepository::PER_CLIENT)
+ act = "PER_CLIENT";
+ else if (info.startup.activation == ImplementationRepository::AUTO_START)
+ act = "AUTO_START";
+ // Print out information
+ ACE_DEBUG ((LM_DEBUG, "Server <%s>\n", info.server.in ()));
+ ACE_DEBUG ((LM_DEBUG,
+ " Activator: %s\n"
+ " Command Line: %s\n"
+ " Working Directory: %s\n"
+ " Activation Mode: %s\n",
+ info.startup.activator.in (),
+ info.startup.command_line.in (),
+ info.startup.working_directory.in (),
+ act));
+ for (CORBA::ULong i = 0; i < info.startup.environment.length (); ++i)
+ ACE_DEBUG ((LM_DEBUG, "Environment Variable: %s=%s \n",
+ info.startup.environment[i].name.in (),
+ info.startup.environment[i].value.in ()));
-TAO_IMR_Op::TAO_IMR_Op (void)
-{
- // Nothing
-}
+ // @@ add logical server once implemented
-TAO_IMR_Op_Activate::TAO_IMR_Op_Activate (void)
- : location_ ("")
-{
- // Nothing
-}
-TAO_IMR_Op_Add::TAO_IMR_Op_Add (void)
- : activation_ (ImplementationRepository::NORMAL)
-{
- // Nothing
+ 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.location.in()) > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ " Running at endpoint: %s\n",
+ info.location.in ()));
+ else // I am assuming that a blank location means currently not running.
+ ACE_DEBUG ((LM_DEBUG,
+ " Not currently running\n"));
}
-TAO_IMR_Op_Autostart::TAO_IMR_Op_Autostart (void)
-{
- // Nothing
-}
-TAO_IMR_Op_IOR::TAO_IMR_Op_IOR (void)
+TAO_IMR_Op_Add::TAO_IMR_Op_Add (void)
+ : activation_ (ImplementationRepository::NORMAL)
{
// Nothing
}
@@ -230,18 +237,6 @@ TAO_IMR_Op_List::TAO_IMR_Op_List (void)
// Nothing
}
-TAO_IMR_Op_Remove::TAO_IMR_Op_Remove (void)
- : location_ ("")
-{
- // Nothing
-}
-
-TAO_IMR_Op_Shutdown::TAO_IMR_Op_Shutdown (void)
- : location_ ("")
-{
- // Nothing
-}
-
TAO_IMR_Op_Update::TAO_IMR_Op_Update (void)
: set_command_line_ (0),
set_working_dir_ (0),
@@ -250,61 +245,19 @@ TAO_IMR_Op_Update::TAO_IMR_Op_Update (void)
// Nothing
}
-
-// ============================================================================
-// = Virtual Destructors.
-
-
-TAO_IMR_Op::~TAO_IMR_Op ()
-{
- // Nothing
-}
-
-TAO_IMR_Op_Activate::~TAO_IMR_Op_Activate (void)
-{
- // Nothing
-}
-
-TAO_IMR_Op_Add::~TAO_IMR_Op_Add (void)
-{
- // Nothing
-}
-
-TAO_IMR_Op_Autostart::~TAO_IMR_Op_Autostart (void)
-{
- // Nothing
-}
-
-TAO_IMR_Op_IOR::~TAO_IMR_Op_IOR (void)
-{
- // Nothing
-}
-
-TAO_IMR_Op_List::~TAO_IMR_Op_List (void)
-{
- // Nothing
-}
-
-TAO_IMR_Op_Remove::~TAO_IMR_Op_Remove (void)
-{
- // Nothing
-}
-
-TAO_IMR_Op_Shutdown::~TAO_IMR_Op_Shutdown (void)
-{
- // Nothing
-}
-
-TAO_IMR_Op_Update::~TAO_IMR_Op_Update (void)
+void
+TAO_IMR_Op_Activate::print_usage (void)
{
- // Nothing
+ ACE_ERROR ((LM_ERROR, "Activates a server\n"
+ "\n"
+ "Usage: tao_imr [options] activate <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"
+ " -l Activator name.\n"
+ " -h Displays this\n"));
}
-
-// ============================================================================
-// = Parse methods
-
-
int
TAO_IMR_Op_Activate::parse (int argc, ACE_TCHAR **argv)
{
@@ -325,7 +278,7 @@ TAO_IMR_Op_Activate::parse (int argc, ACE_TCHAR **argv)
switch (c)
{
case 'l':
- this->location_ = get_opts.optarg;
+ this->activator_ = get_opts.optarg;
break;
case 'h': // display help
default:
@@ -353,6 +306,21 @@ TAO_IMR_Op_Add::setenv (ACE_TCHAR *opt)
CORBA::string_dup (tokens.substr (index + 1).c_str ());
}
+void
+TAO_IMR_Op_Add::print_usage (void)
+{
+ ACE_ERROR ((LM_ERROR, "Usage: tao_imr [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"
+ " -l Activator name. Defaults to local hostname.\n"
+ " -h Displays this\n"
+ " -c command Startup command\n"
+ " -w dir Working directory\n"
+ " -e vars Set environment variables\n"
+ " -a mode Set activate mode (NORMAL|MANUAL|PER_CLIENT|AUTO_START)\n"));
+}
+
int
TAO_IMR_Op_Add::parse (int argc, ACE_TCHAR **argv)
{
@@ -367,11 +335,10 @@ TAO_IMR_Op_Add::parse (int argc, ACE_TCHAR **argv)
ACE_Get_Opt get_opts (argc, argv, "hc:w:a:e:l:");
this->server_name_ = argv[1];
- if (ACE_OS::strlen(this->server_name_.c_str()) < 1)
+ if (this->server_name_.length() == 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
- "Server name <%s> must be at least one character long!\n",
- this->server_name_.c_str()),-1);
+ "Server name > must be at least one character long!\n"),-1);
}
int c;
@@ -403,8 +370,8 @@ TAO_IMR_Op_Add::parse (int argc, ACE_TCHAR **argv)
get_opts.opt_arg ()),
-1);
break;
- case 'l': /// Location (hostname) of the activator
- this->location_ = get_opts.optarg;
+ case 'l': /// hostname of the activator
+ this->activator_ = get_opts.optarg;
break;
case 'h': // display help
default:
@@ -416,6 +383,15 @@ TAO_IMR_Op_Add::parse (int argc, ACE_TCHAR **argv)
return 0;
}
+void
+TAO_IMR_Op_Autostart::print_usage (void)
+{
+ ACE_ERROR ((LM_ERROR, "Usage: tao_imr [options] autostart [command-arguments]\n"
+ " where [options] are ORB options\n"
+ " where [command-arguments] can be\n"
+ " -h Displays this\n"));
+}
+
int
TAO_IMR_Op_Autostart::parse (int argc, ACE_TCHAR **argv)
{
@@ -437,6 +413,21 @@ TAO_IMR_Op_Autostart::parse (int argc, ACE_TCHAR **argv)
return 0;
}
+void
+TAO_IMR_Op_IOR::print_usage (void)
+{
+ ACE_ERROR ((LM_ERROR, "Creates an IOR for a server that is registered with the IMR and uses\n"
+ "the InterOperable Naming Service. Please see the documentation for\n"
+ "more information on which server configurations work with this command.\n"
+ "\n"
+ "Usage: tao_imr [options] ior <name> [command-arguments]\n"
+ " where [options] are ORB options\n"
+ " where <name> is the POA name of the server\n"
+ " where [command-arguments] can be\n"
+ " -f filename filename to output the IOR to\n"
+ " -h Displays this\n"));
+}
+
int
TAO_IMR_Op_IOR::parse (int argc, ACE_TCHAR **argv)
{
@@ -450,7 +441,6 @@ TAO_IMR_Op_IOR::parse (int argc, ACE_TCHAR **argv)
// Skip both the program name and the "ior" command
ACE_Get_Opt get_opts (argc, argv, "hf:");
- this->server_name_ = argv[1];
int c;
while ((c = get_opts ()) != -1)
@@ -461,14 +451,45 @@ TAO_IMR_Op_IOR::parse (int argc, ACE_TCHAR **argv)
break;
case 'h': // display help
default:
- this->print_usage ();
+ this->print_usage();
return -1;
}
- // Success
+ int remaining_index = get_opts.opt_ind();
+ if (get_opts.argc() - remaining_index > 1) {
+ ACE_DEBUG((LM_DEBUG, "Error : Too many arguments.\n\n"));
+ this->print_usage();
+ return -1;
+ }
+
+ if (remaining_index < get_opts.argc()) {
+ this->server_name_ = get_opts.argv()[remaining_index];
+ }
+
+ if (this->server_name_.length() == 0)
+ {
+ ACE_DEBUG((LM_DEBUG, "Error : Missing server name.\n\n"));
+ this->print_usage();
+ return -1;
+ }
+
return 0;
}
+void
+TAO_IMR_Op_List::print_usage (void)
+{
+ ACE_ERROR ((LM_ERROR, "Lists all or one of the servers in the Implementation Repository\n"
+ "\n"
+ "Usage: tao_imr [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"));
+}
+
int
TAO_IMR_Op_List::parse (int argc, ACE_TCHAR **argv)
{
@@ -477,7 +498,7 @@ TAO_IMR_Op_List::parse (int argc, ACE_TCHAR **argv)
if (argc > 1 && argv[1][0] != '-')
{
this->server_name_ = argv[1];
- server_flag = 2;
+ server_flag = 2;
}
// Skip both the program name and the "list" command
@@ -501,6 +522,19 @@ TAO_IMR_Op_List::parse (int argc, ACE_TCHAR **argv)
return 0;
}
+void
+TAO_IMR_Op_Remove::print_usage (void)
+{
+ ACE_ERROR ((LM_ERROR, "Removes a server entry\n"
+ "\n"
+ "Usage: tao_imr [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"
+ " -l Activator name.\n"
+ " -h Displays this\n"));
+}
+
int
TAO_IMR_Op_Remove::parse (int argc, ACE_TCHAR **argv)
{
@@ -520,10 +554,10 @@ TAO_IMR_Op_Remove::parse (int argc, ACE_TCHAR **argv)
while ((c = get_opts ()) != -1)
switch (c)
{
- case 'l': /// Location (hostname) of the activator/server
- this->location_ = get_opts.optarg;
+ case 'l':
+ this->activator_ = get_opts.optarg;
break;
- case 'h': // display help
+ case 'h':
default:
this->print_usage ();
return -1;
@@ -533,6 +567,19 @@ TAO_IMR_Op_Remove::parse (int argc, ACE_TCHAR **argv)
return 0;
}
+void
+TAO_IMR_Op_Shutdown::print_usage (void)
+{
+ ACE_ERROR ((LM_ERROR, "Shuts down a server\n"
+ "\n"
+ "Usage: tao_imr [options] shutdown <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"
+ " -l Activator name.\n"
+ " -h Displays this\n"));
+}
+
int
TAO_IMR_Op_Shutdown::parse (int argc, ACE_TCHAR **argv)
{
@@ -553,9 +600,9 @@ TAO_IMR_Op_Shutdown::parse (int argc, ACE_TCHAR **argv)
switch (c)
{
case 'l':
- this->location_ = get_opts.optarg;
+ this->activator_ = get_opts.optarg;
break;
- case 'h': // display help
+ case 'h':
default:
this->print_usage ();
return -1;
@@ -581,6 +628,23 @@ TAO_IMR_Op_Update::setenv (ACE_TCHAR *opt)
CORBA::string_dup (tokens.substr (index + 1).c_str ());
}
+void
+TAO_IMR_Op_Update::print_usage (void)
+{
+ ACE_ERROR ((LM_ERROR, "Updates a server entry\n"
+ "\n"
+ "Usage: tao_imr [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"
+ " -l Activator name.\n"
+ " -h Displays this\n"
+ " -c command Startup command\n"
+ " -w dir Working directory\n"
+ " -e vars Set environment variables\n"
+ " -a mode Set activate mode (NORMAL|MANUAL|PER_CLIENT|AUTO_START)\n"));
+}
+
int
TAO_IMR_Op_Update::parse (int argc, ACE_TCHAR **argv)
{
@@ -628,7 +692,7 @@ TAO_IMR_Op_Update::parse (int argc, ACE_TCHAR **argv)
-1);
break;
case 'l':
- this->location_ = get_opts.optarg;
+ this->activator_ = get_opts.optarg;
break;
case 'h': // display help
default:
@@ -636,7 +700,6 @@ TAO_IMR_Op_Update::parse (int argc, ACE_TCHAR **argv)
return -1;
}
- // Success
return 0;
}
@@ -651,7 +714,7 @@ TAO_IMR_Op_Activate::run (void)
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
{
- if (ACE_OS::strcmp (this->location_.c_str (), "") == 0)
+ if (this->activator_.length() == 0)
{
this->imr_locator_->activate_server (this->server_name_.c_str ()
ACE_ENV_ARG_PARAMETER);
@@ -659,9 +722,9 @@ TAO_IMR_Op_Activate::run (void)
}
else
{
- this->imr_locator_->activate_server_in_location (
+ this->imr_locator_->activate_server_in_activator (
this->server_name_.c_str (),
- this->location_.c_str ()
+ this->activator_.c_str ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
}
@@ -674,22 +737,22 @@ TAO_IMR_Op_Activate::run (void)
ACE_ERROR ((LM_ERROR, "Cannot activate server <%s>, reason: <%s>\n",
this->server_name_.c_str (),
ex.reason.in ()));
- return CANNOT_ACTIVATE;
+ 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 NOT_FOUND;
+ return TAO_IMR_Op::NOT_FOUND;
}
ACE_CATCHANY
{
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Activating Server");
- return UNKNOWN;
+ return TAO_IMR_Op::UNKNOWN;
}
ACE_ENDTRY;
// Success
- return NORMAL;
+ return TAO_IMR_Op::NORMAL;
}
int
@@ -705,54 +768,59 @@ TAO_IMR_Op_Add::run (void)
CORBA::string_dup (this->working_dir_.c_str ());
startup_options.activation = this->activation_;
- if (ACE_OS::strcmp (this->location_.c_str (), "") != 0)
+ if (this->activator_.length() != 0)
{
- // If the location is specified, use it
- startup_options.location = CORBA::string_dup (this->location_.c_str ());
+ startup_options.activator = CORBA::string_dup (this->activator_.c_str ());
}
else
{
// else use the hostname on which tao_imr is run
- char hostname[BUFSIZ];
- ACE_OS::hostname (hostname, BUFSIZ);
-
- struct hostent *hinfo = ACE_OS::gethostbyname (hostname);
-
- startup_options.location = CORBA::string_dup (hinfo->h_name);
+ char host_name[MAXHOSTNAMELEN + 1];
+ ACE_OS::hostname (host_name, MAXHOSTNAMELEN);
+ startup_options.activator = CORBA::string_dup (host_name);
}
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
{
- this->imr_locator_->register_server (
- this->server_name_.c_str (), startup_options ACE_ENV_ARG_PARAMETER);
+ this->imr_locator_->register_server (this->server_name_.c_str (),
+ startup_options ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
ACE_DEBUG ((LM_DEBUG,
"Successfully registered server <%s>\n",
this->server_name_.c_str ()));
}
+ ACE_CATCH (ImplementationRepository::NotFound, ex)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "Could not register server <%s>. Activator <%s> not found!\n",
+ this->server_name_.c_str (),
+ this->activator_.c_str()
+ ));
+ return TAO_IMR_Op::ALREADY_REGISTERED;
+ }
ACE_CATCH (ImplementationRepository::AlreadyRegistered, ex)
{
ACE_ERROR ((LM_ERROR,
"Server <%s> already registered!\n",
this->server_name_.c_str ()));
- return ALREADY_REGISTERED;
+ return TAO_IMR_Op::ALREADY_REGISTERED;
}
ACE_CATCH (CORBA::NO_PERMISSION, ex)
{
ACE_ERROR ((LM_ERROR, "No Permission: ImplRepo is in Locked mode\n"));
- return NO_PERMISSION;
+ return TAO_IMR_Op::NO_PERMISSION;
}
ACE_CATCHANY
{
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Adding server");
- return UNKNOWN;
+ return TAO_IMR_Op::UNKNOWN;
}
ACE_ENDTRY;
// Success
- return NORMAL;
+ return TAO_IMR_Op::NORMAL;
}
int
@@ -789,8 +857,9 @@ TAO_IMR_Op_Autostart::run (void)
{
ACE_TRY_EX (inside)
{
- this->imr_locator_->activate_server (
- server_list[i].server.in ()
+ 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);
}
@@ -811,21 +880,24 @@ TAO_IMR_Op_Autostart::run (void)
// 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 UNKNOWN;
+ return TAO_IMR_Op::UNKNOWN;
}
ACE_ENDTRY;
- return NORMAL;
+ 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_)
@@ -872,14 +944,11 @@ TAO_IMR_Op_IOR::run (void)
// Add the key
ior += this->server_name_;
- ACE_DEBUG ((LM_DEBUG,
- "%s\n",
- ior.c_str ()));
+ ACE_DEBUG ((LM_DEBUG, "%s\n", ior.c_str ()));
if (this->filename_.length () > 0)
{
- FILE *file = ACE_OS::fopen (this->filename_.c_str (),
- "w");
+ FILE *file = ACE_OS::fopen (this->filename_.c_str (), "w");
if (file == 0)
{
@@ -898,11 +967,11 @@ TAO_IMR_Op_IOR::run (void)
ACE_CATCHANY
{
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Ior");
- return UNKNOWN;
+ return TAO_IMR_Op::UNKNOWN;
}
ACE_ENDTRY;
- return NORMAL;
+ return TAO_IMR_Op::NORMAL;
}
int
@@ -919,11 +988,17 @@ TAO_IMR_Op_List::run (void)
if (this->server_name_.length () == 0)
{
this->imr_locator_->list (IR_LIST_CHUNK,
- server_list,
- server_iter
+ 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]);
@@ -962,7 +1037,6 @@ TAO_IMR_Op_List::run (void)
this->imr_locator_->find (this->server_name_.c_str (), server_information ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
- // Display verbosely
this->verbose_server_information_ = 1;
this->display_server_information (server_information.in ());
@@ -971,16 +1045,16 @@ TAO_IMR_Op_List::run (void)
ACE_CATCH (ImplementationRepository::NotFound, ex)
{
ACE_ERROR ((LM_ERROR, "Could not find server <%s>!\n", this->server_name_.c_str ()));
- return NOT_FOUND;
+ return TAO_IMR_Op::NOT_FOUND;
}
ACE_CATCHANY
{
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "List");
- return UNKNOWN;
+ return TAO_IMR_Op::UNKNOWN;
}
ACE_ENDTRY;
- return NORMAL;
+ return TAO_IMR_Op::NORMAL;
}
int
@@ -989,7 +1063,7 @@ TAO_IMR_Op_Remove::run (void)
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
{
- if (ACE_OS::strcmp (this->location_.c_str (), "") == 0)
+ if (this->activator_.length() == 0)
{
this->imr_locator_->remove_server (this->server_name_.c_str ()
ACE_ENV_ARG_PARAMETER);
@@ -997,9 +1071,9 @@ TAO_IMR_Op_Remove::run (void)
}
else
{
- this->imr_locator_->remove_server_in_location (
+ this->imr_locator_->remove_server_in_activator (
this->server_name_.c_str (),
- this->location_.c_str ()
+ this->activator_.c_str ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
}
@@ -1012,22 +1086,22 @@ TAO_IMR_Op_Remove::run (void)
{
ACE_ERROR ((LM_ERROR, "Could not find server <%s>!\n",
this->server_name_.c_str ()));
- return NOT_FOUND;
+ 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 NO_PERMISSION;
+ return TAO_IMR_Op::NO_PERMISSION;
}
ACE_CATCHANY
{
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Removing Server");
- return UNKNOWN;
+ return TAO_IMR_Op::UNKNOWN;
}
ACE_ENDTRY;
// Success
- return NORMAL;
+ return TAO_IMR_Op::NORMAL;
}
int
@@ -1036,7 +1110,7 @@ TAO_IMR_Op_Shutdown::run (void)
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
{
- if (ACE_OS::strcmp (this->location_.c_str (), "") == 0)
+ if (this->activator_.length() == 0)
{
this->imr_locator_->shutdown_server (this->server_name_.c_str ()
ACE_ENV_ARG_PARAMETER);
@@ -1044,9 +1118,9 @@ TAO_IMR_Op_Shutdown::run (void)
}
else
{
- this->imr_locator_->shutdown_server_in_location (
+ this->imr_locator_->shutdown_server_in_activator (
this->server_name_.c_str (),
- this->location_.c_str ()
+ this->activator_.c_str ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
}
@@ -1058,17 +1132,17 @@ TAO_IMR_Op_Shutdown::run (void)
ACE_CATCH (ImplementationRepository::NotFound, ex)
{
ACE_ERROR ((LM_ERROR, "Could not find server <%s>!\n", this->server_name_.c_str ()));
- return NOT_FOUND;
+ return TAO_IMR_Op::NOT_FOUND;
}
ACE_CATCHANY
{
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Shutting Down Server");
- return UNKNOWN;
+ return TAO_IMR_Op::UNKNOWN;
}
ACE_ENDTRY;
// Success
- return NORMAL;
+ return TAO_IMR_Op::NORMAL;
}
int
@@ -1079,19 +1153,29 @@ TAO_IMR_Op_Update::run (void)
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
{
- this->imr_locator_->find (this->server_name_.c_str (),
- server_information ACE_ENV_ARG_PARAMETER);
- ACE_TRY_CHECK;
+ 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_;
@@ -1103,8 +1187,8 @@ TAO_IMR_Op_Update::run (void)
// 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 ACE_ENV_ARG_PARAMETER);
+ 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 ());
@@ -1112,178 +1196,24 @@ TAO_IMR_Op_Update::run (void)
ACE_CATCH (ImplementationRepository::NotFound, ex)
{
ACE_ERROR ((LM_ERROR, "Could not find server <%s>\n", this->server_name_.c_str ()));
- return NOT_FOUND;
+ 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 NO_PERMISSION;
+ return TAO_IMR_Op::NO_PERMISSION;
}
ACE_CATCHANY
{
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Updating server");
- return UNKNOWN;
+ return TAO_IMR_Op::UNKNOWN;
}
ACE_ENDTRY;
// Success
- return NORMAL;
-}
-
-
-// ============================================================================
-// = Print Usage methods
-
-
-void
-TAO_IMR_Op_Activate::print_usage (void)
-{
- ACE_ERROR ((LM_ERROR, "Activates a server\n"
- "\n"
- "Usage: tao_imr [options] activate <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_IMR_Op_Add::print_usage (void)
-{
- ACE_ERROR ((LM_ERROR, "Usage: tao_imr [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"
- " -a mode Set activate mode (NORMAL|MANUAL|PER_CLIENT|AUTO_START)\n"));
-}
-
-void
-TAO_IMR_Op_Autostart::print_usage (void)
-{
- ACE_ERROR ((LM_ERROR, "Usage: tao_imr [options] autostart [command-arguments]\n"
- " where [options] are ORB options\n"
- " where [command-arguments] can be\n"
- " -h Displays this\n"));
-}
-
-void
-TAO_IMR_Op_IOR::print_usage (void)
-{
- ACE_ERROR ((LM_ERROR, "Creates an IOR for a server that is registered with the IMR and uses\n"
- "the InterOperable Naming Service. Please see the documentation for\n"
- "more information on which server configurations work with this command.\n"
- "\n"
- "Usage: tao_imr [options] ior <name> [command-arguments]\n"
- " where [options] are ORB options\n"
- " where <name> is the POA name of the server\n"
- " where [command-arguments] can be\n"
- " -f filename filename to output the IOR to\n"
- " -h Displays this\n"));
-}
-
-void
-TAO_IMR_Op_List::print_usage (void)
-{
- ACE_ERROR ((LM_ERROR, "Lists all or one of the servers in the Implementation Repository\n"
- "\n"
- "Usage: tao_imr [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_IMR_Op_Remove::print_usage (void)
-{
- ACE_ERROR ((LM_ERROR, "Removes a server entry\n"
- "\n"
- "Usage: tao_imr [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"));
+ return TAO_IMR_Op::NORMAL;
}
-void
-TAO_IMR_Op_Shutdown::print_usage (void)
-{
- ACE_ERROR ((LM_ERROR, "Shuts down a server\n"
- "\n"
- "Usage: tao_imr [options] shutdown <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_IMR_Op_Update::print_usage (void)
-{
- ACE_ERROR ((LM_ERROR, "Updates a server entry\n"
- "\n"
- "Usage: tao_imr [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"
- " -a mode Set activate mode (NORMAL|MANUAL|PER_CLIENT|AUTO_START)\n"));
-}
-
-
-
-// Prints out information in a ServerInformation structure.
-
-void
-TAO_IMR_Op::display_server_information (const ImplementationRepository::ServerInformation &info)
-{
- // Figure out what the activation string is.
- const char *act = "UNKNOWN STARTUP";
- if (info.startup.activation == ImplementationRepository::NORMAL)
- act = "NORMAL";
- else if (info.startup.activation == ImplementationRepository::MANUAL)
- act = "MANUAL";
- else if (info.startup.activation == ImplementationRepository::PER_CLIENT)
- act = "PER_CLIENT";
- else if (info.startup.activation == ImplementationRepository::AUTO_START)
- act = "AUTO_START";
-
- // Print out information
- ACE_DEBUG ((LM_DEBUG, "Server <%s>\n", info.server.in ()));
- ACE_DEBUG ((LM_DEBUG,
- " Command Line: %s\n"
- " Working Directory: %s\n"
- " Activation Mode: %s\n",
- info.startup.command_line.in (),
- info.startup.working_directory.in (),
- act));
- for (CORBA::ULong i = 0; i < info.startup.environment.length (); ++i)
- ACE_DEBUG ((LM_DEBUG, "Environment Variable: %s=%s \n",
- info.startup.environment[i].name.in (),
- info.startup.environment[i].value.in ()));
-
- // @@ add logical server once implemented
-
-
- 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.location) > 0)
- ACE_DEBUG ((LM_DEBUG,
- " Running at endpoint: %s\n",
- info.location.in ()));
- else // I am assuming that a blank location means currently not running.
- ACE_DEBUG ((LM_DEBUG,
- " Not currently running\n"));
-}
-
-
// ============================================================================
// = Display Server Information methods
diff --git a/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.h b/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.h
index d7e468cda47..ea245907fc6 100644
--- a/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.h
+++ b/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.h
@@ -16,9 +16,7 @@
#define TAO_IMR_I_H
#include "tao/PortableServer/ImR_LocatorC.h"
-
-#include "tao/ORB.h"
-
+#include "tao/corba.h"
#include "ace/SString.h"
// Forward Declaration
@@ -34,6 +32,7 @@ class TAO_IMR_Op;
class TAO_IMR_i
{
public:
+
// = Constructor and destructor.
TAO_IMR_i (void);
~TAO_IMR_i (void);
@@ -79,16 +78,19 @@ private:
class TAO_IMR_Op
{
public:
+ enum RETURN_CODES {
+ NORMAL = 0,
+ UNKNOWN,
+ NO_PERMISSION,
+ ALREADY_REGISTERED,
+ CANNOT_ACTIVATE,
+ NOT_FOUND
+ };
+
/// Factory.
static TAO_IMR_Op *make_op (const ACE_TCHAR *op_name);
- /// Constructor.
- TAO_IMR_Op (void);
-
- /// Sets the implrepo locator pointer
- virtual void set_imr_locator (ImplementationRepository::Locator_ptr imr);
-
- /// Virtual Destructor.
+ /// Destructor.
virtual ~TAO_IMR_Op (void);
/// Parse arguments.
@@ -97,6 +99,9 @@ public:
/// Do the work.
virtual int run (void) = 0;
+ /// Sets the implrepo locator pointer
+ void set_imr_locator (ImplementationRepository::Locator_ptr imr);
+
protected:
/// Reference to our implementation repository.
ImplementationRepository::Locator_ptr imr_locator_;
@@ -118,9 +123,6 @@ protected:
class TAO_IMR_Op_Activate : public TAO_IMR_Op
{
public:
- TAO_IMR_Op_Activate (void);
- ~TAO_IMR_Op_Activate (void);
-
virtual int parse (int argc, ACE_TCHAR **argv);
virtual int run (void);
@@ -131,7 +133,8 @@ protected:
/// POA server name.
ACE_CString server_name_;
- ACE_CString location_;
+ /// The name of the activator
+ ACE_CString activator_;
};
@@ -146,7 +149,6 @@ class TAO_IMR_Op_Add : public TAO_IMR_Op
{
public:
TAO_IMR_Op_Add (void);
- ~TAO_IMR_Op_Add (void);
virtual int parse (int argc, ACE_TCHAR **argv);
virtual int run (void);
@@ -174,7 +176,7 @@ protected:
ImplementationRepository::ActivationMode activation_;
/// Hostname where the activator is running.
- ACE_CString location_;
+ ACE_CString activator_;
};
@@ -189,9 +191,6 @@ protected:
class TAO_IMR_Op_Autostart : public TAO_IMR_Op
{
public:
- TAO_IMR_Op_Autostart (void);
- ~TAO_IMR_Op_Autostart (void);
-
virtual int parse (int argc, ACE_TCHAR **argv);
virtual int run (void);
@@ -212,9 +211,6 @@ protected:
class TAO_IMR_Op_IOR : public TAO_IMR_Op
{
public:
- TAO_IMR_Op_IOR (void);
- ~TAO_IMR_Op_IOR (void);
-
virtual int parse (int argc, ACE_TCHAR **argv);
virtual int run (void);
@@ -242,7 +238,6 @@ class TAO_IMR_Op_List : public TAO_IMR_Op
{
public:
TAO_IMR_Op_List (void);
- ~TAO_IMR_Op_List (void);
virtual int parse (int argc, ACE_TCHAR **argv);
virtual int run (void);
@@ -273,9 +268,6 @@ protected:
class TAO_IMR_Op_Remove : public TAO_IMR_Op
{
public:
- TAO_IMR_Op_Remove (void);
- ~TAO_IMR_Op_Remove (void);
-
virtual int parse (int argc, ACE_TCHAR **argv);
virtual int run (void);
@@ -287,7 +279,7 @@ protected:
ACE_CString server_name_;
/// Hostname where the activator is running.
- ACE_CString location_;
+ ACE_CString activator_;
};
@@ -301,9 +293,6 @@ protected:
class TAO_IMR_Op_Shutdown : public TAO_IMR_Op
{
public:
- TAO_IMR_Op_Shutdown (void);
- ~TAO_IMR_Op_Shutdown (void);
-
virtual int parse (int argc, ACE_TCHAR **argv);
virtual int run (void);
@@ -314,7 +303,7 @@ protected:
/// POA server name.
ACE_CString server_name_;
- ACE_CString location_;
+ ACE_CString activator_;
};
@@ -329,8 +318,7 @@ protected:
class TAO_IMR_Op_Update : public TAO_IMR_Op
{
public:
- TAO_IMR_Op_Update (void);
- ~TAO_IMR_Op_Update (void);
+ TAO_IMR_Op_Update(void);
virtual int parse (int argc, ACE_TCHAR **argv);
virtual int run (void);
@@ -373,8 +361,7 @@ protected:
int set_location_;
/// Hostname where the activator is running.
- ACE_CString location_;
-
+ ACE_CString activator_;
};
#endif /* TAO_IMR_I_H */
diff --git a/TAO/orbsvcs/tests/ImplRepo/ImplRepo.mpc b/TAO/orbsvcs/tests/ImplRepo/ImplRepo.mpc
index f5e19cebff8..63e5d89f97d 100644
--- a/TAO/orbsvcs/tests/ImplRepo/ImplRepo.mpc
+++ b/TAO/orbsvcs/tests/ImplRepo/ImplRepo.mpc
@@ -1,6 +1,4 @@
-project(airplane server) : taoserver, orbsvcsexe, minimum_corba, iortable {
- exename = airplane_server
-
+project(airplane server) : portableserver, orbsvcsexe, minimum_corba, iortable {
IDL_Files {
Airplane.idl
}
@@ -14,9 +12,7 @@ project(airplane server) : taoserver, orbsvcsexe, minimum_corba, iortable {
}
}
-project(airplane client) : taoserver, orbsvcsexe, minimum_corba, iortable {
- exename = airplane_client
-
+project(airplane client) : portableserver, orbsvcsexe, minimum_corba, iortable {
IDL_Files {
Airplane.idl
}
@@ -29,9 +25,7 @@ project(airplane client) : taoserver, orbsvcsexe, minimum_corba, iortable {
}
}
-project(nestea server) : taoserver, orbsvcsexe, minimum_corba, iortable {
- exename = nestea_server
-
+project(nestea server) : portableserver, orbsvcsexe, minimum_corba, iortable {
IDL_Files {
Nestea.idl
}
@@ -45,9 +39,7 @@ project(nestea server) : taoserver, orbsvcsexe, minimum_corba, iortable {
}
}
-project(nestea client) : taoserver, orbsvcsexe, minimum_corba, iortable {
- exename = nestea_client
-
+project(nestea client) : portableserver, orbsvcsexe, minimum_corba, iortable {
IDL_Files {
Nestea.idl
}
diff --git a/TAO/orbsvcs/tests/ImplRepo/NameService/ImplRepo_NameService.mpc b/TAO/orbsvcs/tests/ImplRepo/NameService/ImplRepo_NameService.mpc
index b13db5bd77f..52f3d8140de 100644
--- a/TAO/orbsvcs/tests/ImplRepo/NameService/ImplRepo_NameService.mpc
+++ b/TAO/orbsvcs/tests/ImplRepo/NameService/ImplRepo_NameService.mpc
@@ -1,4 +1,3 @@
project: namingexe, minimum_corba {
- exename = test
}
diff --git a/TAO/orbsvcs/tests/ImplRepo/README b/TAO/orbsvcs/tests/ImplRepo/README
index 32da31f94b4..f104bcfabf3 100644
--- a/TAO/orbsvcs/tests/ImplRepo/README
+++ b/TAO/orbsvcs/tests/ImplRepo/README
@@ -23,85 +23,52 @@ run successfully, these conditions must be met:
-- ACE_ROOT/bin must be in the system path.
-How to use NT_ImplRepo_Service
+How to use NT ImR Services
==================================
-To set the options for the TAO NT ImplRepo Sevice, go to the Services icon
-in the Settings group under the start menu (start menu -> settings ->
-services). There, highlight "TAO NT ImplRepo Service", which is the name
-used by the ImplRepo Service when it is registered. After it's
-highlighted, you should see at the bottom of the dialog box an area to
-specify options for ImplRepo_Service.exe. Just enter the options you wish in
-that edit box and everything should just work. However, some options, such as
--ORBDebugLevel, won't work since an NT service can't write output to
-standard out.
+The first step is to install one or both ImplRepo applications as NT
+services. To do this run:
-1. Syntax
+ImplRepo_Service -c install
+ImR_Activator -c install
- % NT_ImplRepo_Service [-i value]
- [-r]
- [-s]
- [-k]
- [-t n]
- [-d]
+If you want to reinstall or change the installed settings then you
+must first use:
-2. Optional Command-line Arguments
+ImplRepo_Service -c remove
+ImR_Activator -c remove
- -i value
- Install this program as an NT service, with specified startup
+Any extra command line options, will be saved in the Windows registry,
+and used when the service is actually started.
- -r
- Remove this program from the Service Manager
- -s
- Start the service
+In the following example I start the activator service, and then the
+ImplRepo itself on port 8888 using iiop. I also tell the activator to use
+xml as its persistence format, and to timeout unresponsive servers in 60 seconds.
+I disable debug output for both, as there seems to be no way to access it anyway.
- -k
- Kill the service
+* copy the exe's to the same location as their dll's
+cd %ace_root%\lib
+copy %tao_root%\orbsvcs\ImplRepo_Service\*.exe .\
- -t value
- Set startup for an existing service
+* Register the services. (You may have to remove them first)
+ImR_Activator -c install -x activator.xml -t 60 -d 0 -orbinitref ImplRepoService=corbaloc::localhost:8888/ImplRepoService
+ImplRepo_Service -c install -d 0 -orbendpoint iiop://:8888
- -d
- Debug; run as a regular application
+* Start both services.
+net start taoimrlocator
+net start taoimractivator
-3. Usage
+* Register a server
+cd %tao_root%\orbsvcs\tests\ImplRepo
+%tao_root%\orbsvcs\ImplRepo_service\tao_imr add airplane_server -orbuseimr 1 -orbinitref ImplRepoService=corbaloc::localhost:8888/ImplRepoService
- To see different stages of an NT service application, you have
- to run the program several times, with different options.
- Please note: run with only one option at a time.
-
- a. First, you must initialize the service in the NT Service Control
- Manager database. Run NT_ImplRepo_Service with -in, where n is
- one of the following startup options:
-
- // Start Type (from WinNT.h)
- //
- #define SERVICE_SYSTEM_START 0x00000001
- #define SERVICE_AUTO_START 0x00000002
- #define SERVICE_DEMAND_START 0x00000003
- #define SERVICE_DISABLED 0x00000004
-
- If only -i is specified, SERVICE_DEMAND_START is default option.
-
- b. Now you are ready to run the actual service. Run
- NT_ImplRepo_Service again, this time with -s option. If the
- service starts successfully, it will ring the system
- bell every second or so until the service is stopped.
-
- c. To stop service execution, run NT_ImplRepo_Service with the
- -k option.
-
- d. To remove the service from the Service Control Manager
- database, run NT_ImplRepo_Service with -r.
-
- In addition, once you have initialized this service (by using
- the -i option) you can change its startup type to one of the
- other values above. To do this, run NT_ImplRepo_Service with
- -tn option. n is as explained above for -i.
-
- In order to debug the service's execution itself, use the -d
- option.
+* Run the server
+airplane_server -o airplane.ior -orbuseimr 1 -orbinitref ImplRepoService=corbaloc::localhost:8888/ImplRepoService
+* Run the client
+airplane_client -k file://airplane.ior
+--or--
+airplane_client -k corbaloc::localhost:8888/airplane_server
More information about the Implementation Repository can be found in
diff --git a/TAO/orbsvcs/tests/ImplRepo/run_test.pl b/TAO/orbsvcs/tests/ImplRepo/run_test.pl
index a212cf17365..d3cf4ddd45f 100755
--- a/TAO/orbsvcs/tests/ImplRepo/run_test.pl
+++ b/TAO/orbsvcs/tests/ImplRepo/run_test.pl
@@ -41,14 +41,7 @@ $endpoint = "-ORBEndpoint " . "$protocol" . "://" . "$host" . ":" . $port;
$IMR_LOCATOR = new PerlACE::Process ("../../ImplRepo_Service/ImplRepo_Service");
$IMR_ACTIVATOR = new PerlACE::Process ("../../ImplRepo_Service/ImR_Activator");
-
-if ($^O eq "MSWin32") {
- $TAO_IMR = new PerlACE::Process ("$ACE_ROOT/bin/tao_imr");
-}
-else {
- $TAO_IMR = new PerlACE::Process
- ("../../ImplRepo_Service/tao_imr");
-}
+$TAO_IMR = new PerlACE::Process("../../ImplRepo_Service/tao_imr");
$A_SVR = new PerlACE::Process (PerlACE::LocalFile ("airplane_server"));
$A_CLI = new PerlACE::Process (PerlACE::LocalFile ("airplane_client"),
@@ -62,6 +55,9 @@ unlink $airplane_ior;
unlink $nestea_ior;
unlink $imr_locator_ior;
unlink $imr_activator_ior;
+unlink $backing_store;
+unlink $nestea.dat;
+
# The Tests
@@ -80,7 +76,7 @@ sub airplane_test
return 1;
}
- my $client = $A_CLI->SpawnWaitKill (300);
+ my $client = $A_CLI->SpawnWaitKill (10);
if ($client != 0) {
print STDERR "ERROR: client returned $client\n";
@@ -102,7 +98,6 @@ sub airplane_test
sub nestea_test
{
my $status = 0;
- unlink $nestea_dat;
$N_SVR->Arguments ("-o $nestea_ior $refstyle");
$N_SVR->Spawn ();
@@ -113,7 +108,7 @@ sub nestea_test
return 1;
}
- my $client = $N_CLI->SpawnWaitKill (300);
+ my $client = $N_CLI->SpawnWaitKill (10);
if ($client != 0) {
print STDERR "ERROR: client returned $client\n";
@@ -127,7 +122,6 @@ sub nestea_test
$status = 1;
}
- unlink $nestea_dat;
return $status;
}
@@ -138,59 +132,60 @@ sub nt_service_test
{
my $result = 0;
- my $BIN_IMR_LOCATOR = new PerlACE::Process ("$ACE_ROOT/bin/ImplRepo_Service",
- "-c install");
+ # Just to show that it's possible, this test uses corbaloc instead of ior file.
+ my $imr_initref = "-orbinitref ImplRepoService=corbaloc::localhost:8888/ImplRepoService";
- my $BIN_IMR_ACTIVATOR = new PerlACE::Process ("$ACE_ROOT/bin/ImR_Activator",
- "-c install");
+ # To avoid having to ensure that they LocalSystem account has the correct path
+ # we simply copy the imr executables to the same directory as the DLL's.
+ my $BIN_IMR_LOCATOR = new PerlACE::Process ("$ACE_ROOT/lib/ImplRepo_Service","");
+ my $BIN_IMR_ACTIVATOR = new PerlACE::Process ("$ACE_ROOT/lib/ImR_Activator","");
- print "Copying ImplRepo_Service to bin\n";
+ print "Copying ImplRepo services to the same location as the dlls.\n";
copy ($IMR_LOCATOR->Executable (), $BIN_IMR_LOCATOR->Executable ());
-
- print "Installing TAO Implementation Locator Service\n";
-
- $result = $BIN_IMR_LOCATOR->SpawnWaitKill (300);
-
- if ($result != 0) {
- print STDERR "ERROR: IMR installation returned $result\n";
- return 1;
- }
-
- print "Copying ImR_Activator to bin\n";
copy ($IMR_ACTIVATOR->Executable (), $BIN_IMR_ACTIVATOR->Executable ());
- print "Installing TAO Implementation Activator Service\n";
+ print "Stopping any existing TAO ImR Services\n";
+ system("net stop taoimractivator > nul 2>&1");
+ system("net stop taoimrlocator > nul 2>&1");
- $result = $BIN_IMR_ACTIVATOR->SpawnWaitKill (300);
+ print "Removing any existing TAO ImR Services\n";
+ $BIN_IMR_ACTIVATOR->Arguments ("-c remove");
+ $BIN_IMR_LOCATOR->Arguments ("-c remove");
+ $BIN_IMR_ACTIVATOR->SpawnWaitKill (5);
+ $BIN_IMR_LOCATOR->SpawnWaitKill (5);
+ print "Installing TAO ImR Services\n";
+ $BIN_IMR_ACTIVATOR->Arguments ("-c install $imr_initref");
+ $BIN_IMR_LOCATOR->Arguments ("-c install -orbendpoint iiop://:8888");
+
+ $result = $BIN_IMR_LOCATOR->SpawnWaitKill (5);
if ($result != 0) {
- print STDERR "ERROR: IMR installation returned $result\n";
+ print STDERR "ERROR: IMR Locator installation returned $result\n";
return 1;
}
- print "Starting TAO Implementation Repository Service\n";
- my $NET = new PerlACE::Process ("net",
- "start \"TAO Implementation Repository\"");
- $NET->IgnoreExeSubDir (1);
-
- $result = $NET->SpawnWaitKill (300);
+ $result = $BIN_IMR_ACTIVATOR->SpawnWaitKill (5);
if ($result != 0) {
- print STDERR "ERROR: net returned $result\n";
+ print STDERR "ERROR: IMR Activator installation returned $result\n";
return 1;
}
+ # Starting the activator will also start the locator
+ print "Starting TAO Implementation Repository Services\n";
+ system("net start taoimrlocator > nul 2>&1");
+ system("net start taoimractivator > nul 2>&1");
+
$TAO_IMR->Arguments ("add airplane_server -c \""
. $A_SVR->Executable () .
- " -ORBUseIMR 1\" -w \"$ACE_ROOT/bin\"");
-
- $result = $TAO_IMR->SpawnWaitKill (30);
+ " -ORBUseIMR 1\" -w \"$ACE_ROOT/lib\" $imr_initref");
+ $result = $TAO_IMR->SpawnWaitKill (10);
if ($result != 0) {
- print STDERR "ERROR: tao_imr returned $result\n";
+ print STDERR "ERROR: tao_imr add airplane_server returned $result\n";
return 1;
}
- $A_SVR->Arguments ("-o $airplane_ior -ORBUseIMR 1");
+ $A_SVR->Arguments ("-o $airplane_ior -ORBUseIMR 1 $imr_initref");
$A_SVR->Spawn ();
if (PerlACE::waitforfile_timed ($airplane_ior, 10) == -1) {
@@ -199,46 +194,38 @@ sub nt_service_test
return 1;
}
- $result = $A_CLI->SpawnWaitKill (100);
-
+ $result = $A_CLI->SpawnWaitKill (10);
if ($result != 0) {
print STDERR "ERROR: airplane client returned $result\n";
return 1;
}
- $TAO_IMR->Arguments ("shutdown airplane_server");
-
- $result = $TAO_IMR->SpawnWaitKill (30);
+ $TAO_IMR->Arguments ("shutdown airplane_server $imr_initref");
+ $result = $TAO_IMR->SpawnWaitKill (10);
if ($result != 0) {
- print STDERR "ERROR: tao_imr returned $result\n";
+ print STDERR "ERROR: tao_imr shutdown airplane_server returned $result\n";
return 1;
}
- $result = $A_CLI->SpawnWaitKill (100);
-
+ $result = $A_SVR->WaitKill(5);
if ($result != 0) {
- print STDERR "ERROR: airplane client returned $result\n";
- return 1;
- }
-
- $result = $TAO_IMR->SpawnWaitKill (30);
-
- if ($result != 0) {
- print STDERR "ERROR: tao_imr returned $result\n";
- return 1;
+ print STDERR "ERROR: airplane_server returned $result\n";
}
print "Stopping TAO Implementation Repository Service\n";
- $NET->Arguments ("stop \"TAO Implementation Repository\"");
- $NET->SpawnWaitKill (300);
+ system("net stop taoimractivator > nul 2>&1");
+ system("net stop taoimrlocator > nul 2>&1");
- print "Removing TAO Implementation Repository Service\n";
- $BIN_IMR->Arguments ("-c remove");
- $BIN_IMR->SpawnWaitKill (300);
+ print "Removing TAO ImR Services\n";
+ $BIN_IMR_ACTIVATOR->Arguments ("-c remove");
+ $BIN_IMR_ACTIVATOR->SpawnWaitKill (5);
+ $BIN_IMR_LOCATOR->Arguments ("-c remove");
+ $BIN_IMR_LOCATOR->SpawnWaitKill (5);
- print "Removing ImplRepo_Service from bin\n";
- unlink $BIN_IMR->Executable ();
+ print "Removing ImplRepo_Service copy.\n";
+ unlink $BIN_IMR_ACTIVATOR->Executable ();
+ unlink $BIN_IMR_LOCATOR->Executable ();
return 0;
}
@@ -250,94 +237,89 @@ sub airplane_ir_test
my $status = 0;
my $result = 0;
- $IMR_LOCATOR->Arguments ("-o $imr_locator_ior");
+ my $imr_initref = "-ORBInitRef ImplRepoService=file://$imr_locator_ior";
+
+ $IMR_LOCATOR->Arguments ("-d 1 -o $imr_locator_ior");
$IMR_LOCATOR->Spawn ();
- if (PerlACE::waitforfile_timed ($imr_locator_ior, 10) == -1) {
+ if (PerlACE::waitforfile_timed ($imr_locator_ior, 5) == -1) {
print STDERR "ERROR: cannot find $imr_locator_ior\n";
$IMR_LOCATOR->Kill ();
return 1;
}
- $IMR_ACTIVATOR->Arguments ("-o $imr_activator_ior -ORBInitRef ImplRepoService=file://$imr_locator_ior");
+ $IMR_ACTIVATOR->Arguments ("-d 1 -o $imr_activator_ior $imr_initref");
$IMR_ACTIVATOR->Spawn ();
- if (PerlACE::waitforfile_timed ($imr_activator_ior, 10) == -1) {
+ if (PerlACE::waitforfile_timed ($imr_activator_ior, 5) == -1) {
print STDERR "ERROR: cannot find $imr_activator_ior\n";
$IMR_ACTIVATOR->Kill ();
return 1;
}
- $TAO_IMR->Arguments ("add airplane_server -ORBInitRef ImplRepoService=file://$imr_locator_ior -c \""
- . $A_SVR->Executable ()
- . " -ORBUseIMR 1 -o $airplane_ior -ORBInitRef ImplRepoService=file://$imr_locator_ior\"");
-
- $result = $TAO_IMR->SpawnWaitKill (30);
+ $TAO_IMR->Arguments ("$imr_initref add airplane_server -c \""
+ . $A_SVR->Executable ()
+ . " -ORBUseIMR 1 -o $airplane_ior $imr_initref\"");
+ $result = $TAO_IMR->SpawnWaitKill (5);
if ($result != 0) {
print STDERR "ERROR: tao_imr returned $result\n";
- $IMR_ACTIVATOR->Kill ();
+ $IMR_ACTIVATOR->Kill ();
$IMR_LOCATOR->Kill ();
return 1;
}
- $A_SVR->Arguments ("-ORBUseIMR 1 -o $airplane_ior -ORBInitRef ImplRepoService=file://$imr_locator_ior");
+ $A_SVR->Arguments ("-ORBUseIMR 1 -o $airplane_ior $imr_initref");
$A_SVR->Spawn ();
if (PerlACE::waitforfile_timed ($airplane_ior, 10) == -1) {
print STDERR "ERROR: cannot find $airplane_ior\n";
$IMR_ACTIVATOR->Kill ();
- $IMR_LOCATOR->Kill ();
+ $IMR_LOCATOR->Kill ();
$A_SVR->Kill ();
return 1;
}
- $result = $A_CLI->SpawnWaitKill (100);
-
+ $result = $A_CLI->SpawnWaitKill (10);
if ($result != 0) {
print STDERR "ERROR: airplane_client 1 returned $result\n";
$status = 1;
}
- $TAO_IMR->Arguments ("shutdown airplane_server -ORBInitRef ImplRepoService=file://$imr_locator_ior");
-
- $result = $TAO_IMR->SpawnWaitKill (30);
+ $TAO_IMR->Arguments ("$imr_initref shutdown airplane_server");
+ $result = $TAO_IMR->SpawnWaitKill (10);
if ($result != 0) {
print STDERR "ERROR: tao_imr 1 returned $result\n";
$status = 1;
}
- $result = $A_CLI->SpawnWaitKill (100);
-
+ # This client should force a new airplane_server to be started
+ $result = $A_CLI->SpawnWaitKill (10);
if ($result != 0) {
print STDERR "ERROR: airplane_client 2 returned $result\n";
$status = 1;
}
- $result = $TAO_IMR->SpawnWaitKill (30);
-
+ $result = $TAO_IMR->SpawnWaitKill (10);
if ($result != 0) {
print STDERR "ERROR: tao_imr 2 returned $result\n";
$status = 1;
}
my $server = $A_SVR->WaitKill (5);
-
if ($server != 0) {
print STDERR "ERROR: airplane server returned $server\n";
$status = 1;
}
my $imr_activator = $IMR_ACTIVATOR->TerminateWaitKill (5);
-
if ($imr_activator != 0) {
print STDERR "ERROR: IMR returned $implrepo\n";
$status = 1;
}
my $imr_locator = $IMR_LOCATOR->TerminateWaitKill (5);
-
if ($imr_locator != 0) {
print STDERR "ERROR: IMR returned $implrepo\n";
$status = 1;
@@ -350,11 +332,12 @@ sub airplane_ir_test
sub nestea_ir_test
{
- unlink $nestea_dat;
my $status = 0;
my $result = 0;
- $IMR_LOCATOR->Arguments ("-o $imr_locator_ior");
+ my $imr_initref = "-ORBInitRef ImplRepoService=file://$imr_locator_ior";
+
+ $IMR_LOCATOR->Arguments ("-d 1 -o $imr_locator_ior");
$IMR_LOCATOR->Spawn ();
if (PerlACE::waitforfile_timed ($imr_locator_ior, 10) == -1) {
@@ -363,22 +346,21 @@ sub nestea_ir_test
return 1;
}
- $IMR_ACTIVATOR->Arguments ("-o $imr_activator_ior -ORBInitRef ImplRepoService=file://$imr_locator_ior");
+ $IMR_ACTIVATOR->Arguments ("-d 1 -o $imr_activator_ior $imr_initref");
$IMR_ACTIVATOR->Spawn ();
if (PerlACE::waitforfile_timed ($imr_activator_ior, 30) == -1) {
print STDERR "ERROR: cannot find $imr_activator_ior\n";
$IMR_ACTIVATOR->Kill ();
- $IMR_LOCATOR->Kill ();
+ $IMR_LOCATOR->Kill ();
return 1;
}
- $TAO_IMR->Arguments ("add nestea_server -ORBInitRef ImplRepoService=file://$imr_locator_ior -c \""
+ $TAO_IMR->Arguments ("$imr_initref add nestea_server -c \""
. $N_SVR->Executable ()
- . " -ORBUseIMR 1 -ORBInitRef ImplRepoService=file://$imr_locator_ior -o $nestea_ior\"");
-
- $result = $TAO_IMR->SpawnWaitKill (30);
+ . " -ORBUseIMR 1 $imr_initref -o $nestea_ior\"");
+ $result = $TAO_IMR->SpawnWaitKill (10);
if ($result != 0) {
print STDERR "ERROR: tao_imr returned $result\n";
$IMR_ACTIVATOR->Kill ();
@@ -386,7 +368,7 @@ sub nestea_ir_test
return 1;
}
- $N_SVR->Arguments ("-ORBUseIMR 1 -o $nestea_ior -ORBInitRef ImplRepoService=file://$imr_locator_ior");
+ $N_SVR->Arguments ("-ORBUseIMR 1 -o $nestea_ior $imr_initref");
$N_SVR->Spawn ();
if (PerlACE::waitforfile_timed ($nestea_ior, 10) == -1) {
@@ -397,51 +379,55 @@ sub nestea_ir_test
return 1;
}
- $result = $N_CLI->SpawnWaitKill (100);
-
+ $result = $N_CLI->SpawnWaitKill (10);
if ($result != 0) {
print STDERR "ERROR: nestea client 1 returned $result\n";
$status = 1;
}
- $TAO_IMR->Arguments ("shutdown nestea_server -ORBInitRef ImplRepoService=file://$imr_locator_ior");
-
- $result = $TAO_IMR->SpawnWaitKill (30);
+ $TAO_IMR->Arguments ("$imr_initref shutdown nestea_server");
+ $result = $TAO_IMR->SpawnWaitKill (10);
if ($result != 0) {
print STDERR "ERROR: tao_imr 1 returned $result\n";
$status = 1;
}
- $result = $N_CLI->SpawnWaitKill (100);
+ my $server = $N_SVR->WaitKill (5);
+ if ($server != 0) {
+ print STDERR "ERROR: nestea server returned $server\n";
+ $status = 1;
+ }
+ # This should cause the activator to spawn another server.
+ $result = $N_CLI->SpawnWaitKill (20);
if ($result != 0) {
print STDERR "ERROR: nestea client 2 returned $result\n";
$status = 1;
}
- my $server = $N_SVR->TerminateWaitKill (5);
-
- if ($server != 0) {
- print STDERR "ERROR: nestea server returned $server\n";
+ $result = $TAO_IMR->SpawnWaitKill (10);
+ if ($result != 0) {
+ print STDERR "ERROR: tao_imr 1 returned $result\n";
$status = 1;
}
- my $implrepo = $IMR_ACTIVATOR->TerminateWaitKill (5);
+ # Since the second server was started by the activator, it is not
+ # managed by perl, and we can't wait for it to die. So sleep a few secs.
+ sleep(5);
+ my $implrepo = $IMR_ACTIVATOR->TerminateWaitKill (5);
if ($implrepo != 0) {
print STDERR "ERROR: IMR_Activator returned $implrepo\n";
$status = 1;
}
$implrepo = $IMR_LOCATOR->TerminateWaitKill (5);
-
if ($implrepo != 0) {
print STDERR "ERROR: IMR_Locator returned $implrepo\n";
$status = 1;
}
- unlink $nestea_dat;
return $status;
}
@@ -451,27 +437,36 @@ sub persistent_ir_test
{
my $status = 0;
my $result = 0;
- unlink $backing_store;
- $IMR->Arguments ("$endpoint -o $implrepo_ior -p $backing_store -d 0");
- $IMR->Spawn ();
+ my $imr_initref = "-ORBInitRef ImplRepoService=file://$imr_locator_ior";
- if (PerlACE::waitforfile_timed ($implrepo_ior, 10) == -1) {
+ $IMR_LOCATOR->Arguments ("-d 1 -o $imr_locator_ior");
+ $IMR_LOCATOR->Spawn ();
+ if (PerlACE::waitforfile_timed ($imr_locator_ior, 10) == -1) {
print STDERR "ERROR: cannot find $implrepo_ior\n";
- $IMR->Kill ();
+ $IMR_LOCATOR->Kill ();
+ return 1;
+ }
+
+ $IMR_ACTIVATOR->Arguments ("-d 1 -o $imr_activator_ior -p $backing_store $imr_initref");
+ $IMR_ACTIVATOR->Spawn ();
+
+ if (PerlACE::waitforfile_timed ($imr_activator_ior, 30) == -1) {
+ print STDERR "ERROR: cannot find $imr_activator_ior\n";
+ $IMR_ACTIVATOR->Kill ();
+ $IMR_LOCATOR->Kill ();
return 1;
}
- $TAO_IMR->Arguments ("-ORBInitRef ImplRepoService=file://$implrepo_ior add airplane_server -c \"".$A_SVR->Executable ()." -ORBUseIMR 1 $refstyle -ORBInitRef ImplRepoService=file://$implrepo_ior\"");
- $result = $TAO_IMR->SpawnWaitKill (30);
+ $TAO_IMR->Arguments ("$imr_initref add airplane_server -c \"" . $A_SVR->Executable () . " -ORBUseIMR 1 $refstyle $imr_initref\"");
+ $result = $TAO_IMR->SpawnWaitKill (10);
if ($result != 0) {
print STDERR "ERROR: tao_imr returned $result\n";
- $IMR->Kill ();
return 1;
}
- $A_SVR->Arguments ("-o $airplane_ior -ORBUseIMR 1 $refstyle -ORBInitRef ImplRepoService=file://$implrepo_ior");
+ $A_SVR->Arguments ("-o $airplane_ior -ORBUseIMR 1 $refstyle $imr_initref");
$A_SVR->Spawn ();
if (PerlACE::waitforfile_timed ($airplane_ior, 10) == -1) {
@@ -481,58 +476,106 @@ sub persistent_ir_test
return 1;
}
- $TAO_IMR->Arguments ("-ORBInitRef ImplRepoService=file://$implrepo_ior shutdown airplane_server");
-
- $result = $A_CLI->SpawnWaitKill (100);
+ $TAO_IMR->Arguments ("$imr_initref shutdown airplane_server");
+ $result = $A_CLI->SpawnWaitKill (10);
if ($result != 0) {
print STDERR "ERROR: airplane client returned $result\n";
$status = 1;
}
- $result = $TAO_IMR->SpawnWaitKill (30);
-
+ $result = $TAO_IMR->SpawnWaitKill (10);
if ($result != 0) {
- print STDERR "ERROR: tao_imr returned $result\n";
+ print STDERR "ERROR: tao_imr shutdown returned $result\n";
$status = 1;
}
- $result = $A_CLI->SpawnWaitKill (100);
-
+ $result = $A_SVR->WaitKill (10);
if ($result != 0) {
- print STDERR "ERROR: airplane client returned $result\n";
+ print STDERR "ERROR: airplane server returned $result\n";
$status = 1;
}
- $result = $TAO_IMR->SpawnWaitKill (30);
+ # Should cause the activator to spawn another server.
+ $result = $A_CLI->SpawnWaitKill (20);
+ if ($result != 0) {
+ print STDERR "ERROR: airplane client 2 returned $result\n";
+ $status = 1;
+ }
+ $result = $TAO_IMR->SpawnWaitKill (10);
if ($result != 0) {
- print STDERR "ERROR: tao_imr returned $result\n";
+ print STDERR "ERROR: tao_imr shutdown 2 returned $result\n";
$status = 1;
}
- $result = $A_SVR->WaitKill (10);
+ # Since the second server was started by the activator, it is not
+ # managed by perl, and we can't wait for it to die. So sleep a few secs.
+ sleep(5);
- if ($result != 0) {
- print STDERR "ERROR: airplane server returned $result\n";
+ my $implrepo = $IMR_ACTIVATOR->TerminateWaitKill (5);
+ if ($implrepo != 0) {
+ print STDERR "ERROR: IMR_Activator returned $implrepo\n";
$status = 1;
}
- print "\nShutting down Implementation Repository\n\n";
- $IMR->Kill ();
+ $implrepo = $IMR_LOCATOR->TerminateWaitKill (5);
+ if ($implrepo != 0) {
+ print STDERR "ERROR: IMR_Locator returned $implrepo\n";
+ $status = 1;
+ }
+
+ # Unlink so that we can wait on them again to know the servers started.
+ unlink $imr_locator_ior;
+ unlink $imr_activator_ior;
print "Restarting Implementation Repository.\n";
- $IMR->Arguments ("$endpoint -p $backing_store -d 0");
- $IMR->Spawn ();
+ $IMR_LOCATOR->Spawn ();
+ if (PerlACE::waitforfile_timed ($imr_locator_ior, 10) == -1) {
+ print STDERR "ERROR: cannot find $implrepo_ior\n";
+ $IMR_LOCATOR->Kill ();
+ return 1;
+ }
+
+ # Should reload the server list without having to run tao_imr again.
+ $IMR_ACTIVATOR->Spawn ();
+ if (PerlACE::waitforfile_timed ($imr_activator_ior, 30) == -1) {
+ print STDERR "ERROR: cannot find $imr_activator_ior\n";
+ $IMR_ACTIVATOR->Kill ();
+ $IMR_LOCATOR->Kill ();
+ return 1;
+ }
- PerlACE::waitforfile ($implrepo_ior);
+ # Should cause the activator to spawn another server.
+ $result = $A_CLI->SpawnWaitKill (20);
+ if ($result != 0) {
+ print STDERR "ERROR: airplane client 3 returned $result\n";
+ $status = 1;
+ }
+
+ $result = $TAO_IMR->SpawnWaitKill (10);
+ if ($result != 0) {
+ print STDERR "ERROR: tao_imr shutdown 3 returned $result\n";
+ $status = 1;
+ }
+
+ # Since the second server was started by the activator, it is not
+ # managed by perl, and we can't wait for it to die. So sleep a few secs.
+ sleep(5);
- $A_CLI->SpawnWaitKill (100);
- $TAO_IMR->SpawnWaitKill (30);
+ my $implrepo = $IMR_ACTIVATOR->TerminateWaitKill (5);
+ if ($implrepo != 0) {
+ print STDERR "ERROR: IMR_Activator returned $implrepo\n";
+ $status = 1;
+ }
- $IMR->Kill ();
+ $implrepo = $IMR_LOCATOR->TerminateWaitKill (5);
+ if ($implrepo != 0) {
+ print STDERR "ERROR: IMR_Locator returned $implrepo\n";
+ $status = 1;
+ }
- unlink $backing_store;
+ return $status;
}
###############################################################################
@@ -540,7 +583,10 @@ sub persistent_ir_test
sub both_ir_test
{
my $status = 0;
- $IMR_LOCATOR->Arguments ("-o $imr_locator_ior $refstyle");
+
+ my $imr_initref = "-ORBInitRef ImplRepoService=file://$imr_locator_ior";
+
+ $IMR_LOCATOR->Arguments ("-d 1 -o $imr_locator_ior $refstyle");
$IMR_LOCATOR->Spawn ();
if (PerlACE::waitforfile_timed ($imr_locator_ior, 10) == -1) {
@@ -549,35 +595,35 @@ sub both_ir_test
return 1;
}
- $IMR_ACTIVATOR->Arguments ("-o $imr_activator_ior -ORBInitRef ImplRepoService=file://$imr_locator_ior $refstyle -d 2");
+ $IMR_ACTIVATOR->Arguments ("-o $imr_activator_ior $imr_initref $refstyle -d 1");
$IMR_ACTIVATOR->Spawn ();
- if (PerlACE::waitforfile_timed ($imr_activator_ior, 1000) == -1) {
+ if (PerlACE::waitforfile_timed ($imr_activator_ior, 10) == -1) {
print STDERR "ERROR: cannot find $imr_activator_ior\n";
- $IMR_ACTIVATOR->Kill ();
+ $IMR_ACTIVATOR->Kill ();
$IMR_LOCATOR->Kill ();
return 1;
}
- $TAO_IMR->Arguments (" add nestea_server -ORBInitRef ImplRepoService=file://$imr_locator_ior -c \""
- . $N_SVR->Executable ()
- . " -ORBUseIMR 1 $refstyle -o $nestea_ior -ORBInitRef ImplRepoService=file://$imr_locator_ior\"");
- $TAO_IMR->SpawnWaitKill (30);
+ $TAO_IMR->Arguments ("$imr_initref add nestea_server -c \""
+ . $N_SVR->Executable ()
+ . " -ORBUseIMR 1 $refstyle -o $nestea_ior $imr_initref\"");
+ $TAO_IMR->SpawnWaitKill (10);
- $TAO_IMR->Arguments (" -ORBInitRef ImplRepoService=file://$imr_locator_ior add airplane_server -c \""
- . $A_SVR->Executable ()
- . " -ORBUseIMR 1 $refstyle -o $airplane_ior -ORBInitRef ImplRepoService=file://$imr_locator_ior\"");
- $TAO_IMR->SpawnWaitKill (30);
+ $TAO_IMR->Arguments ("$imr_initref add airplane_server -c \""
+ . $A_SVR->Executable ()
+ . " -ORBUseIMR 1 $refstyle -o $airplane_ior $imr_initref\"");
+ $TAO_IMR->SpawnWaitKill (10);
- $N_SVR->Arguments (" -o $nestea_ior -ORBUseIMR 1 $refstyle -ORBInitRef ImplRepoService=file://$imr_locator_ior");
+ $N_SVR->Arguments (" -o $nestea_ior -ORBUseIMR 1 $refstyle $imr_initref");
$N_SVR->Spawn ();
- $A_SVR->Arguments (" -o $airplane_ior -ORBUseIMR 1 $refstyle -ORBInitRef ImplRepoService=file://$imr_locator_ior");
+ $A_SVR->Arguments (" -o $airplane_ior -ORBUseIMR 1 $refstyle $imr_initref");
$A_SVR->Spawn ();
if (PerlACE::waitforfile_timed ($nestea_ior, 10) == -1) {
print STDERR "ERROR: cannot find $nestea_ior\n";
- $IMR_ACTIVATOR->Kill ();
+ $IMR_ACTIVATOR->Kill ();
$IMR_LOCATOR->Kill ();
$A_SVR->Kill ();
$N_SVR->Kill ();
@@ -587,39 +633,41 @@ sub both_ir_test
if (PerlACE::waitforfile_timed ($airplane_ior, 10) == -1) {
print STDERR "ERROR: cannot find $airplane_ior\n";
$IMR_ACTIVATOR->Kill ();
- $IMR_LOCATOR->Kill ();
+ $IMR_LOCATOR->Kill ();
$A_SVR->Kill ();
$N_SVR->Kill ();
return 1;
}
- $N_CLI->Spawn ();
+ # todo : Add error checking.
+ $N_CLI->Spawn ();
$A_CLI->Spawn ();
- $N_CLI->WaitKill (100);
- $A_CLI->WaitKill (100);
+ $N_CLI->WaitKill (10);
+ $A_CLI->WaitKill (10);
- $TAO_IMR->Arguments (" -ORBInitRef ImplRepoService=file://$imr_locator_ior shutdown nestea_server");
- $TAO_IMR->SpawnWaitKill (300);
+ $TAO_IMR->Arguments ("$imr_initref shutdown nestea_server");
+ $TAO_IMR->SpawnWaitKill (10);
+ $N_SVR->WaitKill(10);
- $N_CLI->Spawn (100);
+ $N_CLI->Spawn (20);
- $TAO_IMR->Arguments (" -ORBInitRef ImplRepoService=file://$imr_locator_ior shutdown airplane_server");
- $TAO_IMR->SpawnWaitKill (300);
+ $TAO_IMR->Arguments ("$imr_initref shutdown airplane_server");
+ $TAO_IMR->SpawnWaitKill (10);
+ $A_SVR->WaitKill(10);
- $A_CLI->SpawnWaitKill (100);
+ $A_CLI->SpawnWaitKill (20);
+ $N_CLI->WaitKill (10);
- $N_CLI->WaitKill (100);
+ $TAO_IMR->Arguments ("$imr_initref shutdown nestea_server");
+ $TAO_IMR->SpawnWaitKill (10);
- $TAO_IMR->Arguments (" -ORBInitRef ImplRepoService=file://$imr_locator_ior shutdown nestea_server");
- $TAO_IMR->SpawnWaitKill (30);
+ $TAO_IMR->Arguments ("$imr_initref shutdown airplane_server");
+ $TAO_IMR->SpawnWaitKill (10);
- $TAO_IMR->Arguments (" -ORBInitRef ImplRepoService=file://$imr_locator_ior shutdown airplane_server");
- $TAO_IMR->SpawnWaitKill (30);
+ sleep(5);
- $A_SVR->Kill ();
- $N_SVR->Kill ();
$IMR_ACTIVATOR->Kill ();
$IMR_LOCATOR->Kill ();
}
@@ -645,7 +693,7 @@ for ($i = 0; $i <= $#ARGV; $i++) {
elsif ($ARGV[$i] eq "airplane_ir") {
exit airplane_ir_test ();
}
- elsif ($ARGV[$i] eq "nt_service") {
+ elsif ($ARGV[$i] eq "nt_service_ir") {
exit nt_service_test ();
}
elsif ($ARGV[$i] eq "nestea") {