summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-06-20 02:08:42 +0000
committerbrunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-06-20 02:08:42 +0000
commit04b78bbd4237493c6c6075747bab88edb9114596 (patch)
treeecbc46dacea71789bfcc793780580b27da207d3d
parent6d6fc9a7884f7624a081ff61fd28bcd338c4929b (diff)
downloadATCD-04b78bbd4237493c6c6075747bab88edb9114596.tar.gz
Got it mostly working with the new IR.
-rw-r--r--TAO/orbsvcs/tests/ImplRepo/IR_Helper.cpp124
-rw-r--r--TAO/orbsvcs/tests/ImplRepo/IR_Helper.h18
-rw-r--r--TAO/orbsvcs/tests/ImplRepo/airplane_server_i.cpp22
-rw-r--r--TAO/orbsvcs/tests/ImplRepo/airplane_server_i.h3
-rw-r--r--TAO/orbsvcs/tests/ImplRepo/nestea_server_i.cpp4
-rwxr-xr-xTAO/orbsvcs/tests/ImplRepo/run_test.pl17
6 files changed, 81 insertions, 107 deletions
diff --git a/TAO/orbsvcs/tests/ImplRepo/IR_Helper.cpp b/TAO/orbsvcs/tests/ImplRepo/IR_Helper.cpp
index 47c193db6ea..5438c83ad83 100644
--- a/TAO/orbsvcs/tests/ImplRepo/IR_Helper.cpp
+++ b/TAO/orbsvcs/tests/ImplRepo/IR_Helper.cpp
@@ -3,25 +3,30 @@
#include "IR_Helper.h"
#include "ace/Get_Opt.h"
#include "ace/Read_Buffer.h"
-#include "orbsvcs/PingS.h"
#include "tao/IIOP_Profile.h"
-class Ping_i: public POA_Ping_Object
+class ServerObject_i: public POA_ImplementationRepository::ServerObject
// = TITLE
- // Ping Object Implementation
+ // IR Server Object Implementation
//
// = DESCRIPTION
- // Implementation Repository uses this to check to see if the server
- // is still running.
+ // Implementation Repository uses this to communicate with the IR
+ // registered server.
{
public:
- Ping_i (int debug = 0) : debug_ (debug) {}
+ ServerObject_i (int debug = 0) : debug_ (debug) {}
- virtual void ping (CORBA::Environment &)
+ virtual void ping (CORBA::Environment &ACE_TRY_ENV = CORBA::Environment::default_environment ())
{
if (this->debug_)
ACE_DEBUG ((LM_DEBUG, "Pong!\n"));
}
+
+ virtual void shutdown (CORBA::Environment &ACE_TRY_ENV = CORBA::Environment::default_environment ())
+ {
+ if (this->debug_)
+ ACE_DEBUG ((LM_DEBUG, "ServerObject_i::Shutdown\n"));
+ }
private:
int debug_;
};
@@ -31,9 +36,8 @@ IR_Helper::IR_Helper (char *server_name,
CORBA::ORB_ptr orb,
int debug)
: name_ (ACE::strnew (server_name)),
- ir_key_ (0),
ir_addr_ (0),
- ping_ (new Ping_i (debug)),
+ server_object_ (new ServerObject_i (debug)),
implrepo_ (0),
poa_ (poa),
orb_ (orb),
@@ -44,41 +48,41 @@ IR_Helper::IR_Helper (char *server_name,
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
{
- exception_message = "While read_ir_ior";
- this->read_ir_ior (ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
- // Resolve the IR.
- exception_message = "While string_to_object of ImplRepo";
CORBA::Object_var implrepo_object =
- this->orb_->string_to_object (this->ir_key_, ACE_TRY_ENV);
- ACE_TRY_CHECK;;
+ orb_->resolve_initial_references ("ImplRepoService");
if (CORBA::is_nil (implrepo_object.in ()))
- ACE_ERROR ((LM_ERROR,
- "invalid implrepo key <%s>\n",
- this->ir_key_));
+ {
+ ACE_ERROR ((LM_ERROR,
+ "Unable to resolve the Implementation Repository.\n"));
+ ACE_OS::exit (-1);
+ }
exception_message = "While narrowing ImplRepo";
this->implrepo_ =
- Implementation_Repository::_narrow (implrepo_object.in(), ACE_TRY_ENV);
+ ImplementationRepository::Administration::_narrow (implrepo_object.in(), ACE_TRY_ENV);
ACE_TRY_CHECK;
// Now register the Ping Object
- PortableServer::ObjectId_var ping_id =
- PortableServer::string_to_ObjectId ("ping");
+ PortableServer::ObjectId_var server_object_id =
+ PortableServer::string_to_ObjectId ("server_object");
- exception_message = "While activating ping object";
- this->poa_->activate_object_with_id (ping_id.in (),
- this->ping_,
+ exception_message = "While activating server object";
+ this->poa_->activate_object_with_id (server_object_id.in (),
+ this->server_object_,
ACE_TRY_ENV);
ACE_TRY_CHECK;
exception_message = "While creating reference to ping object";
- this->ping_ptr_ =
- this->poa_->id_to_reference (ping_id.in (),
+ CORBA::Object_ptr svr_obj =
+ this->poa_->id_to_reference (server_object_id.in (),
ACE_TRY_ENV);
ACE_TRY_CHECK;
+
+ this->server_object_ptr_ =
+ ImplementationRepository::ServerObject::_narrow (svr_obj,
+ ACE_TRY_ENV);
+ ACE_TRY_CHECK;
}
ACE_CATCHANY
{
@@ -92,7 +96,6 @@ IR_Helper::IR_Helper (char *server_name,
IR_Helper::~IR_Helper ()
{
delete this->name_;
- delete this->ir_key_;
// @@ Delete the two objects
}
@@ -106,26 +109,31 @@ IR_Helper::register_server (const char *comm_line,
ACE_TRY
{
CORBA::Object_var implrepo_object =
- this->orb_->string_to_object (this->ir_key_, ACE_TRY_ENV);
- ACE_TRY_CHECK;
+ orb_->resolve_initial_references ("ImplRepoService");
+
+ if (CORBA::is_nil (implrepo_object.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Unable to resolve the Implementation Repository.\n"),
+ -1);
- Implementation_Repository *ImplRepo =
- Implementation_Repository::_narrow (implrepo_object.in(), ACE_TRY_ENV);
+ ImplementationRepository::Administration *ImplRepo =
+ ImplementationRepository::Administration::_narrow (implrepo_object.in(), ACE_TRY_ENV);
ACE_TRY_CHECK;
if (CORBA::is_nil (implrepo_object.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
- "invalid implrepo key <%s>\n",
- this->ir_key_),
+ "IR_Helper::register_server - Could not narrow IR::Admin\n"),
-1);
- Implementation_Repository::Process_Options proc_opts;
+ ImplementationRepository::StartupOptions startup_options;
- proc_opts.command_line_ = CORBA::string_dup (comm_line);
- proc_opts.environment_ = CORBA::string_dup (environment);
- proc_opts.working_directory_ = CORBA::string_dup (working_dir);
+ startup_options.command_line = CORBA::string_dup (comm_line);
+ // @@ Implement Environment
+ // startup_options.environment = CORBA::string_dup (environment);
+ startup_options.working_directory = CORBA::string_dup (working_dir);
- ImplRepo->reregister_server (this->name_, proc_opts, ACE_TRY_ENV);
+ ImplRepo->reregister_server (this->name_, startup_options, ACE_TRY_ENV);
+ ACE_TRY_CHECK;
}
ACE_CATCHANY
{
@@ -136,48 +144,22 @@ IR_Helper::register_server (const char *comm_line,
return 0;
}
-int
-IR_Helper::read_ir_ior (CORBA_Environment &ACE_TRY_ENV)
-{
- ACE_UNUSED_ARG (ACE_TRY_ENV);
-
- // Open the file for reading.
- // @@ Hard-coded name is bad. Need to fix.
- ACE_HANDLE f_handle_ = ACE_OS::open ("implrepo.ior", 0);
-
- if (f_handle_ == ACE_INVALID_HANDLE)
- ACE_ERROR_RETURN ((LM_ERROR,
- "Unable to open %s for writing: implrepo.ior\n"),
- -1);
-
- ACE_Read_Buffer ior_buffer (f_handle_);
- this->ir_key_ = ior_buffer.read ();
-
- if (this->ir_key_ == 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- "Unable to allocate memory to read ior: %p\n"),
- -1);
-
- ACE_OS::close (f_handle_);
- return 0;
-}
-
-
void
IR_Helper::notify_startup (CORBA_Environment &ACE_TRY_ENV)
{
// Get our host and port and convert it to something we can use.
ACE_INET_Addr my_addr = TAO_ORB_Core_instance ()->orb_params ()->addr ();
- Implementation_Repository::INET_Addr my_ir_addr;
- my_ir_addr.port_ = my_addr.get_port_number ();
- my_ir_addr.host_ = CORBA::string_dup (my_addr.get_host_name ());
+ ImplementationRepository::Address my_ir_addr;
+ my_ir_addr.port = my_addr.get_port_number ();
+ my_ir_addr.host = CORBA::string_dup (my_addr.get_host_name ());
ACE_TRY
{
delete this->ir_addr_;
+
this->ir_addr_ = this->implrepo_->server_is_running (this->name_,
my_ir_addr,
- this->ping_ptr_,
+ ACE_dynamic_cast (ImplementationRepository::ServerObject *, this->server_object_ptr_),
ACE_TRY_ENV);
ACE_TRY_CHECK;
}
diff --git a/TAO/orbsvcs/tests/ImplRepo/IR_Helper.h b/TAO/orbsvcs/tests/ImplRepo/IR_Helper.h
index bffd082b524..a853291ed09 100644
--- a/TAO/orbsvcs/tests/ImplRepo/IR_Helper.h
+++ b/TAO/orbsvcs/tests/ImplRepo/IR_Helper.h
@@ -22,8 +22,7 @@
#include "tao/TAO.h"
#include "orbsvcs/ImplRepoC.h"
-
-class POA_Ping_Object;
+#include "orbsvcs/ImplRepoS.h"
class IR_Helper
// = TITLE
@@ -55,18 +54,17 @@ public:
CORBA_Environment &_env = CORBA_Environment::default_environment ());
// Convert an object into a IR controlled object.
private:
- int read_ir_ior (CORBA_Environment &_env = CORBA_Environment::default_environment ());
-
char *name_;
- char *ir_key_;
-
- Implementation_Repository::INET_Addr *ir_addr_;
+ ImplementationRepository::Address *ir_addr_;
- POA_Ping_Object *ping_;
- CORBA::Object_ptr ping_ptr_;
+ POA_ImplementationRepository::ServerObject *server_object_;
+ // Pointer to our implementation of the server object
+
+ ImplementationRepository::ServerObject_ptr server_object_ptr_;
+ // Object pointer to <server_object>
- Implementation_Repository *implrepo_;
+ ImplementationRepository::Administration *implrepo_;
PortableServer::POA_var poa_;
CORBA::ORB_var orb_;
int debug_;
diff --git a/TAO/orbsvcs/tests/ImplRepo/airplane_server_i.cpp b/TAO/orbsvcs/tests/ImplRepo/airplane_server_i.cpp
index 36a01002ef3..5b42ab1b1c8 100644
--- a/TAO/orbsvcs/tests/ImplRepo/airplane_server_i.cpp
+++ b/TAO/orbsvcs/tests/ImplRepo/airplane_server_i.cpp
@@ -10,7 +10,6 @@ Airplane_Server_i::Airplane_Server_i (void)
: server_impl_ (0),
ior_output_file_ (0),
ir_helper_ (0),
- register_with_ir_ (0),
use_ir_ (0)
{
// Nothing
@@ -19,7 +18,7 @@ Airplane_Server_i::Airplane_Server_i (void)
int
Airplane_Server_i::parse_args (void)
{
- ACE_Get_Opt get_opts (this->argc_, this->argv_, "do:ir");
+ ACE_Get_Opt get_opts (this->argc_, this->argv_, "do:i");
int c;
while ((c = get_opts ()) != -1)
@@ -28,9 +27,6 @@ Airplane_Server_i::parse_args (void)
case 'd': // debug flag.
TAO_debug_level++;
break;
- case 'r': // Register restart information with the IR.
- this->register_with_ir_ = 1;
- break;
case 'i': // Use the IR
this->use_ir_ = 1;
break;
@@ -47,7 +43,6 @@ Airplane_Server_i::parse_args (void)
"usage: %s"
" [-d]"
" [-i]"
- " [-r]"
" [-o] <ior_output_file>"
"\n",
argv_ [0]),
@@ -89,16 +84,11 @@ Airplane_Server_i::init (int argc, char** argv, CORBA::Environment &ACE_TRY_ENV)
ACE_TRY_CHECK;
if (this->use_ir_ == 1)
- {
- ACE_NEW_RETURN (this->ir_helper_, IR_Helper (poa_name,
- this->orb_manager_.child_poa (),
- this->orb_manager_.orb (),
- TAO_debug_level),
- -1);
-
- if (this->register_with_ir_ == 1)
- this->ir_helper_->register_server ("airplane_server -i");
- }
+ ACE_NEW_RETURN (this->ir_helper_, IR_Helper (poa_name,
+ this->orb_manager_.child_poa (),
+ this->orb_manager_.orb (),
+ TAO_debug_level),
+ -1);
PortableServer::ObjectId_var id =
PortableServer::string_to_ObjectId ("server");
diff --git a/TAO/orbsvcs/tests/ImplRepo/airplane_server_i.h b/TAO/orbsvcs/tests/ImplRepo/airplane_server_i.h
index 28e36c7a7a4..5fc60113a4e 100644
--- a/TAO/orbsvcs/tests/ImplRepo/airplane_server_i.h
+++ b/TAO/orbsvcs/tests/ImplRepo/airplane_server_i.h
@@ -70,9 +70,6 @@ private:
IR_Helper *ir_helper_;
// Helper class for using the IR.
- int register_with_ir_;
- // Flag for whether or not to register startup with the IR.
-
int use_ir_;
// Flag for whether or not to use the IR.
};
diff --git a/TAO/orbsvcs/tests/ImplRepo/nestea_server_i.cpp b/TAO/orbsvcs/tests/ImplRepo/nestea_server_i.cpp
index 330ba2e4587..613fc0de0e1 100644
--- a/TAO/orbsvcs/tests/ImplRepo/nestea_server_i.cpp
+++ b/TAO/orbsvcs/tests/ImplRepo/nestea_server_i.cpp
@@ -105,7 +105,7 @@ Nestea_Server_i::init (int argc, char** argv, CORBA::Environment &ACE_TRY_ENV)
-1);
if (this->register_with_ir_ == 1)
- this->ir_helper_->register_server ("nestea_server -i");
+ this->ir_helper_->register_server ("nestea_server -i -ORBImplRepoIOR file://implrepo.ior");
}
PortableServer::ObjectId_var id =
@@ -115,7 +115,7 @@ Nestea_Server_i::init (int argc, char** argv, CORBA::Environment &ACE_TRY_ENV)
this->orb_manager_.child_poa ()->id_to_reference (id.in (),
ACE_TRY_ENV);
ACE_TRY_CHECK;
-
+
if (this->use_ir_ == 1)
{
this->ir_helper_->change_object (server_obj.inout (), ACE_TRY_ENV);
diff --git a/TAO/orbsvcs/tests/ImplRepo/run_test.pl b/TAO/orbsvcs/tests/ImplRepo/run_test.pl
index 725e3bec62e..c128c79c9a2 100755
--- a/TAO/orbsvcs/tests/ImplRepo/run_test.pl
+++ b/TAO/orbsvcs/tests/ImplRepo/run_test.pl
@@ -40,8 +40,10 @@ sub airplane_ir_test
ACE::waitforfile ($implrepo_ior);
+ system ("tao_ir -ORBImplRepoIOR file://$implrepo_ior add plane -c \"airplane_server -i -ORBImplRepoIOR file://$implrepo_ior\"");
+
$SV = Process::Create ($EXEPREFIX."airplane_server".$Process::EXE_EXT,
- "-o $airplane_ior -i -r -ORBobjrefstyle url");
+ "-o $airplane_ior -i -ORBobjrefstyle url -ORBImplRepoIOR file://$implrepo_ior");
ACE::waitforfile ($airplane_ior);
@@ -72,14 +74,16 @@ sub nestea_ir_test
ACE::waitforfile ($implrepo_ior);
+ system ("tao_ir -ORBImplRepoIOR file://$implrepo_ior add nestea_server -c \"nestea_server -i -ORBImplRepoIOR file://$implrepo_ior\"");
+
$SV = Process::Create ($EXEPREFIX."nestea_server".$Process::EXE_EXT,
- "-o $nestea_ior -i -r -ORBobjrefstyle url");
+ "-o $nestea_ior -i -ORBobjrefstyle url -ORBImplRepoIOR file://$implrepo_ior");
ACE::waitforfile ($nestea_ior);
system($EXEPREFIX."nestea_client -k file://$nestea_ior -ORBobjrefstyle url");
- $IR->Kill (); $IR->Wait ();
+# $IR->Kill (); $IR->Wait ();
}
sub both_ir_test
@@ -89,11 +93,14 @@ sub both_ir_test
ACE::waitforfile ($implrepo_ior);
+ system ("tao_ir -ORBImplRepoIOR file://$implrepo_ior add plane -c \"airplane_server -i -ORBImplRepoIOR file://$implrepo_ior\"");
+ system ("tao_ir -ORBImplRepoIOR file://$implrepo_ior add nestea -c \"nestea_server -i -ORBImplRepoIOR file://$implrepo_ior\"");
+
$ASV = Process::Create ($EXEPREFIX."nestea_server".$Process::EXE_EXT,
- "-o $nestea_ior -i -r -ORBobjrefstyle url");
+ "-o $nestea_ior -i -ORBobjrefstyle url -ORBImplRepoIOR file://$implrepo_ior");
$NSV = Process::Create ($EXEPREFIX."airplane_server".$Process::EXE_EXT,
- "-o $airplane_ior -i -r -ORBobjrefstyle url");
+ "-o $airplane_ior -i -ORBobjrefstyle url -ORBImplRepoIOR file://$implrepo_ior");
ACE::waitforfile ($nestea_ior);