diff options
author | brunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-10-21 07:23:32 +0000 |
---|---|---|
committer | brunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-10-21 07:23:32 +0000 |
commit | 21f198facd3e95dec89bf7b999699f80878ab8ae (patch) | |
tree | bd567cfab3555d2ef720652e9deef64d34c3af7d | |
parent | 9c51b10c88bcfa7dda8d9edfaf0b26593b51160b (diff) | |
download | ATCD-21f198facd3e95dec89bf7b999699f80878ab8ae.tar.gz |
New IR stuff brought over.
-rw-r--r-- | TAO/orbsvcs/tests/ImplRepo/Impl_Repo.idl | 14 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/ImplRepo/client.dsp | 9 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/ImplRepo/client_impl.cpp | 1 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/ImplRepo/implrepo.dsp | 17 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/ImplRepo/ir_implrepo_impl.cpp | 340 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/ImplRepo/ir_implrepo_impl.h | 76 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/ImplRepo/ir_server.cpp | 3 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/ImplRepo/ir_server_impl.h | 6 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/ImplRepo/ir_simple_object_impl.h | 10 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/ImplRepo/server.dsp | 9 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/ImplRepo/server_impl.cpp | 123 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/ImplRepo/server_impl.h | 17 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/ImplRepo/simple_object_impl.cpp | 4 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/ImplRepo/simple_object_impl.h | 14 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/ImplRepo/svc.conf | 2 |
15 files changed, 466 insertions, 179 deletions
diff --git a/TAO/orbsvcs/tests/ImplRepo/Impl_Repo.idl b/TAO/orbsvcs/tests/ImplRepo/Impl_Repo.idl index 88cb24d07e0..e68b98f40dc 100644 --- a/TAO/orbsvcs/tests/ImplRepo/Impl_Repo.idl +++ b/TAO/orbsvcs/tests/ImplRepo/Impl_Repo.idl @@ -52,11 +52,13 @@ interface Implementation_Repository struct Process_Options { - string executable_name_; + // @@string executable_name_; // Executable name - Command_Line_Options command_line_options_; + // @@Command_Line_Options command_line_options_; + string command_line_; // Command line options - Environment environment_; + // @@ Environment environment_; + string environment_; // Environment string working_directory_; // Working directory @@ -86,9 +88,9 @@ interface Implementation_Repository // activated. - //void register_server (in string server, - // in Process_Options options) - // raises (Already_Registered); + void register_server (in string server, + in Process_Options options) + raises (Already_Registered); // Restart server process when client is looking for <server>. // // The <Already_Registered> exception is raised when <server> has diff --git a/TAO/orbsvcs/tests/ImplRepo/client.dsp b/TAO/orbsvcs/tests/ImplRepo/client.dsp index f451152652e..f727171d743 100644 --- a/TAO/orbsvcs/tests/ImplRepo/client.dsp +++ b/TAO/orbsvcs/tests/ImplRepo/client.dsp @@ -42,7 +42,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0
# PROP Target_Dir ".\client"
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\..\\" /I "..\..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\\" /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
@@ -51,7 +51,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 ace.lib TAO.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\tao" /libpath:"..\..\..\..\ace"
+# ADD LINK32 ace.lib TAO.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\tao" /libpath:"..\..\..\ace"
!ELSEIF "$(CFG)" == "ImplRepoTest Client - Win32 Debug"
@@ -121,7 +121,7 @@ SOURCE=.\Simple_Object.idl !IF "$(CFG)" == "ImplRepoTest Client - Win32 Release"
-USERDEP__SIMPL="..\..\..\..\bin\Release\tao_idl.exe"
+USERDEP__SIMPL="..\..\..\bin\Release\tao_idl.exe"
# Begin Custom Build - Invoking TAO_IDL Compiler
InputPath=.\Simple_Object.idl
InputName=Simple_Object
@@ -159,7 +159,8 @@ BuildCmds= \ !ELSEIF "$(CFG)" == "ImplRepoTest Client - Win32 Debug"
-USERDEP__SIMPL="..\..\..\..\bin\tao_idl.exe"
+# PROP Ignore_Default_Tool 1
+USERDEP__SIMPL="..\..\..\bin\tao_idl.exe"
# Begin Custom Build - Invoking TAO_IDL Compiler
InputPath=.\Simple_Object.idl
InputName=Simple_Object
diff --git a/TAO/orbsvcs/tests/ImplRepo/client_impl.cpp b/TAO/orbsvcs/tests/ImplRepo/client_impl.cpp index 4822865a12f..6502eabac54 100644 --- a/TAO/orbsvcs/tests/ImplRepo/client_impl.cpp +++ b/TAO/orbsvcs/tests/ImplRepo/client_impl.cpp @@ -172,7 +172,6 @@ Client_i::init (int argc, char **argv) this->argv_[0]), -1); - CORBA::Object_var server_object = this->orb_->string_to_object (this->server_key_, TAO_TRY_ENV); TAO_CHECK_ENV; diff --git a/TAO/orbsvcs/tests/ImplRepo/implrepo.dsp b/TAO/orbsvcs/tests/ImplRepo/implrepo.dsp index e8b5f3fbc7d..5dfec42d24a 100644 --- a/TAO/orbsvcs/tests/ImplRepo/implrepo.dsp +++ b/TAO/orbsvcs/tests/ImplRepo/implrepo.dsp @@ -42,7 +42,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0
# PROP Target_Dir ".\server"
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\..\\" /I "..\..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\\" /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
@@ -51,7 +51,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 ace.lib TAO.lib /nologo /subsystem:console /machine:I386 /out:"Impl_Repo.exe" /libpath:"..\..\..\tao" /libpath:"..\..\..\..\ace"
+# ADD LINK32 ace.lib TAO.lib /nologo /subsystem:console /machine:I386 /out:"Impl_Repo.exe" /libpath:"..\..\tao" /libpath:"..\..\..\ace"
!ELSEIF "$(CFG)" == "ImplRepoTest ImplRepo - Win32 Debug"
@@ -106,6 +106,10 @@ SOURCE=.\ir_server.cpp # End Source File
# Begin Source File
+SOURCE=.\Repository.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\Simple_ObjectC.cpp
# End Source File
# Begin Source File
@@ -120,6 +124,10 @@ SOURCE=.\Simple_ObjectS.cpp SOURCE=.\ir_implrepo_impl.h
# End Source File
+# Begin Source File
+
+SOURCE=.\Repository.h
+# End Source File
# End Group
# Begin Group "IDL Files"
@@ -130,7 +138,7 @@ SOURCE=.\Impl_Repo.idl !IF "$(CFG)" == "ImplRepoTest ImplRepo - Win32 Release"
-USERDEP__IMPL_="..\..\..\..\bin\Release\tao_idl.exe"
+USERDEP__IMPL_="..\..\..\bin\Release\tao_idl.exe"
# Begin Custom Build - Invoking TAO_IDL Compiler
InputPath=.\Impl_Repo.idl
InputName=Impl_Repo
@@ -168,7 +176,8 @@ BuildCmds= \ !ELSEIF "$(CFG)" == "ImplRepoTest ImplRepo - Win32 Debug"
-USERDEP__IMPL_="..\..\..\..\bin\tao_idl.exe"
+# PROP Ignore_Default_Tool 1
+USERDEP__IMPL_="..\..\..\bin\tao_idl.exe"
# Begin Custom Build - Invoking TAO_IDL Compiler
InputPath=.\Impl_Repo.idl
InputName=Impl_Repo
diff --git a/TAO/orbsvcs/tests/ImplRepo/ir_implrepo_impl.cpp b/TAO/orbsvcs/tests/ImplRepo/ir_implrepo_impl.cpp index 193a3c97be3..8bf757457bb 100644 --- a/TAO/orbsvcs/tests/ImplRepo/ir_implrepo_impl.cpp +++ b/TAO/orbsvcs/tests/ImplRepo/ir_implrepo_impl.cpp @@ -10,44 +10,60 @@ ACE_RCSID(ImplRepo, ir_implrepo_impl, "$Id$") IR_iRepo_i::IR_iRepo_i (void) : ior_output_file_ (0), server_key_ (0), - server_impl_ (0) + server_impl_ (0), + activator_ (0) { } void IR_iRepo_i::start (const char *server) { - if (ACE_OS::strcmp (server, "Simple_Server") == 0) - { - ACE_DEBUG ((LM_DEBUG, "Starting Simple_Server!\n")); - ACE_Process_Options proc_opts; + char *cl; + + int status = this->repository_.get_comm_line (server, cl); + + if (status == 0) + { + ACE_DEBUG ((LM_DEBUG, "Starting %s\n", server)); + + ACE_Process_Options proc_opts; - proc_opts.command_line ("server -o server.ior"); + proc_opts.command_line (cl); - ACE_Process proc; + ACE_Process proc; - proc.spawn (proc_opts); + proc.spawn (proc_opts); - ACE_OS::sleep (2); + ACE_OS::sleep (2); + delete [] cl; } + else + { + ACE_DEBUG ((LM_DEBUG, "ERROR starting %s\n", server)); + } } void IR_iRepo_i::server_is_running (const char *server, CORBA::Object_ptr &obj, const Implementation_Repository::INET_Addr &addr, - CORBA::Environment &_tao_environment) + CORBA::Environment &_env) { - ACE_DEBUG ((LM_DEBUG, "Server is running!\n")); -// int result = this->read_ior (this->server_input_file_); -// if (result < 0) -// { -// ACE_ERROR ((LM_ERROR, -// "Unable to read ior from %s : %p\n", -// this->server_input_file_)); -// return; -// } -// CORBA::Object_var server_object = -// this->orb_manager_.orb ()->string_to_object (this->server_key_, _tao_environment); this->server_impl_->forward_to (obj); + + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Server is running!\n")); + + IIOP_Object *iiop_obj = ACE_dynamic_cast (IIOP_Object *, obj->_stubobj ()); + + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "The old IOR is: <%s>\n", this->orb_manager_.orb ()->object_to_string (obj, _env))); + + ACE_INET_Addr my_addr = TAO_ORB_Core_instance ()->addr (); + + iiop_obj->profile.port = my_addr.get_port_number (); + + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "The new IOR is: <%s>\n", this->orb_manager_.orb ()->object_to_string (obj, _env))); + } @@ -115,59 +131,176 @@ IR_iRepo_i::parse_args (void) } int -IR_iRepo_i::init (int argc, char** argv, CORBA::Environment& env) +IR_iRepo_i::init (int argc, char **argv, CORBA::Environment &_env) { - // Call the init of <TAO_ORB_Manager> to initialize the ORB and - // create a child POA under the root POA. - if (this->orb_manager_.init_child_poa (argc, argv, "child_poa", env) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "init_child_poa"), -1); - - TAO_CHECK_ENV_RETURN (env, -1); - - this->argc_ = argc; - this->argv_ = argv; - - int retval = this->parse_args (); + TAO_TRY + { + // Call the init of <TAO_ORB_Manager> to initialize the ORB and + // create a child POA under the root POA. + if (this->orb_manager_.init_child_poa (argc, argv, "ir_poa", TAO_TRY_ENV) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "init_child_poa"), -1); + TAO_CHECK_ENV; + + this->argc_ = argc; + this->argv_ = argv; + + int retval = this->parse_args (); + + if (retval != 0) + return retval; + + ACE_NEW_RETURN (this->server_impl_, + IR_Simple_i (this->orb_manager_.orb (), + this->orb_manager_.child_poa (), + this), + -1); + + CORBA::String_var str = + this->orb_manager_.activate (this->server_impl_); + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "The server IOR is: <%s>\n", str.in ())); + + if (this->ior_output_file_) + { + ACE_OS::fprintf (this->ior_output_file_, "%s", str.in ()); + ACE_OS::fclose (this->ior_output_file_); + } - if (retval != 0) - return retval; + CORBA::String_var ir_var = + this->orb_manager_.activate_under_child_poa ("implrepo", + this, + TAO_TRY_ENV); + TAO_CHECK_ENV; - this->server_impl_ = new IR_Simple_i (this->orb_manager_.orb (), - this->orb_manager_.child_poa (), - this); + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "The IR IOR is: <%s>\n", ir_var.in ())); + + FILE *ir_file = ACE_OS::fopen ("implrepo.ior", "w"); + ACE_OS::fprintf (ir_file, "%s", ir_var.in ()); + ACE_OS::fclose (ir_file); - CORBA::String_var str = - this->orb_manager_.activate_under_child_poa ("server", - this->server_impl_, - env); + ACE_NEW_RETURN (this->activator_, + IR_Adapter_Activator(this->server_impl_), + -1); - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, "The server IOR is: <%s>\n", str.in ())); + PortableServer::AdapterActivator_var activator = + this->activator_->_this (TAO_TRY_ENV); + TAO_CHECK_ENV; - if (this->ior_output_file_) - { - ACE_OS::fprintf (this->ior_output_file_, "%s", str.in ()); - ACE_OS::fclose (this->ior_output_file_); - } + // Register the TAO_Adapter_Activator reference to be the RootPOA's + // Adapter Activator. - CORBA::String_var ir_var = - this->orb_manager_.activate_under_child_poa ("implrepo", - this, - env); + this->orb_manager_.root_poa ()->the_activator (activator.in (), TAO_TRY_ENV); + TAO_CHECK_ENV; - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, "The IR IOR is: <%s>\n", ir_var.in ())); - FILE *ir_file = ACE_OS::fopen ("implrepo.ior", "w"); - ACE_OS::fprintf (ir_file, "%s", ir_var.in ()); - ACE_OS::fclose (ir_file); - + } + TAO_CATCHANY + { + TAO_TRY_ENV.print_exception ("Server_i::init"); + TAO_RETHROW_RETURN (-1); + } + TAO_ENDTRY; return 0; } int IR_iRepo_i::run (CORBA::Environment& env) { + /* + ACE_CString name = "firstPOA"; + PortableServer::POA_var first_poa = + this->orb_manager_.root_poa()->find_POA (name.c_str (), + 1, + env); + if (env.exception () != 0) + { + env.print_exception ("PortableServer::POA::find_POA"); + return -1; + } + + // Use the TAO_POA name_separator (which is '/') to find a childPOA + // of firstPOA named secondPOA. + + name += TAO_POA::name_separator (); + name += "secondPOA"; + PortableServer::POA_var second_poa = + this->orb_manager_.root_poa()->find_POA (name.c_str (), + 1, + env); + if (env.exception () != 0) + { + env.print_exception ("PortableServer::POA::find_POA"); + return -1; + } + + // Create a hierarchical string of POA names + // eg. thirdPOA/forthPOA/fifthPOA thirdPOA being the root of the + // hierarchy with forthPOA as its child and fifthPOA as its + // grandchild. + + name = "thirdPOA"; + name += TAO_POA::name_separator (); + name += "forthPOA"; + name += TAO_POA::name_separator (); + name += "fifthPOA"; + + // Try to find the fifth_poa by passing the hierarchy of POA names + // resulting in the creation of third and forth POAs as well as the + // fifth POA. + + PortableServer::POA_var fifth_poa = + this->orb_manager_.root_poa()->find_POA (name.c_str (), + 1, + env); + if (env.exception () != 0) + { + env.print_exception ("PortableServer::POA::find_POA"); + return -1; + } + + // Get the names of all the POAs + + CORBA::String_var root_poa_name = + this->orb_manager_.root_poa()->the_name (env); + if (env.exception () != 0) + { + env.print_exception ("PortableServer::POA::_narrow"); + return -1; + } + + CORBA::String_var first_poa_name = + first_poa->the_name (env); + if (env.exception () != 0) + { + env.print_exception ("PortableServer::POA::_narrow"); + return -1; + } + + CORBA::String_var second_poa_name = + second_poa->the_name (env); + if (env.exception () != 0) + { + env.print_exception ("PortableServer::POA::_narrow"); + return -1; + } + + CORBA::String_var fifth_poa_name = + fifth_poa->the_name (env); + if (env.exception () != 0) + { + env.print_exception ("PortableServer::POA::_narrow"); + return -1; + } + + + ACE_DEBUG((LM_DEBUG,"%s\n%s\n%s\n%s\n", + root_poa_name.in (), + first_poa_name.in (), + second_poa_name.in (), + fifth_poa_name.in ())); + +*/ if (this->orb_manager_.run (env) == -1) ACE_ERROR_RETURN ((LM_ERROR, "IR_Server_i::run"), -1); return 0; @@ -176,10 +309,32 @@ IR_iRepo_i::run (CORBA::Environment& env) IR_iRepo_i::~IR_iRepo_i (void) { if (this->server_impl_ != 0) - delete server_impl_; + delete this->server_impl_; + if (this->activator_ != 0) + delete this->activator_; } -IR_Adapter_Activator::IR_Adapter_Activator (PortableServer::Servant servant) +void +IR_iRepo_i::register_server (const char *server, + const Implementation_Repository::Process_Options &options, + CORBA::Environment &env) +{ + int status = this->repository_.add (server, + options.command_line_, + options.environment_, + options.working_directory_); + if (status == -1) + { + ACE_DEBUG ((LM_DEBUG, "Server %s Already Registered\n", server)); + TAO_THROW_ENV (Implementation_Repository::Already_Registered, env); + } + else + ACE_DEBUG ((LM_DEBUG, "Server %s Successfully Registered\n", server)); + this->repository_.dump (); +} + + +IR_Adapter_Activator::IR_Adapter_Activator (IR_Simple_i_ptr servant) : servant_ (servant) { // Nothing @@ -191,24 +346,44 @@ IR_Adapter_Activator::unknown_adapter (PortableServer::POA_ptr parent, const char *name, CORBA_Environment &env) { - CORBA::PolicyList policies (2); - policies.length (2); + ACE_DEBUG ((LM_DEBUG, "Unknown Adapter called\n")); + + CORBA::PolicyList policies (4); + policies.length (4); - // Request Processing Policy + // ID Assignment Policy policies[0] = + parent->create_id_assignment_policy (PortableServer::USER_ID, env); + if (env.exception () != 0) + { + env.print_exception ("PortableServer::POA::create_id_assignment_policy"); + return -1; + } + + // Lifespan Policy + policies[1] = + parent->create_lifespan_policy (PortableServer::PERSISTENT, env); + if (env.exception () != 0) + { + env.print_exception ("PortableServer::POA::create_lifespan_policy"); + return -1; + } + + // Request Processing Policy + policies[2] = parent->create_request_processing_policy (PortableServer::USE_DEFAULT_SERVANT, env); if (env.exception () != 0) { - env.print_exception ("unknown_adapter::create_request_processing_policy"); + env.print_exception ("PortableServer::POA::create_request_processing_policy"); return -1; } - // Servant Retention Policy - policies[1] = - parent->create_servant_retention_policy (PortableServer::RETAIN, env); + // Id Uniqueness Policy + policies[3] = + parent->create_id_uniqueness_policy (PortableServer::MULTIPLE_ID, env); if (env.exception () != 0) { - env.print_exception ("unknown_adapter::create_servant_retention_policy"); + env.print_exception ("PortableServer::POA::create_id_uniqueness_policy"); return -1; } @@ -244,12 +419,13 @@ IR_Adapter_Activator::unknown_adapter (PortableServer::POA_ptr parent, if (env.exception () != 0) { + env.print_exception ("unknown_adapter, the_activator"); child->destroy (0, 0, env); return 0; } - child->set_servant (this->servant_); - + child->set_servant (this->servant_, env); + if (env.exception () != 0) { env.print_exception ("unknown_adapter, set_servant"); @@ -271,7 +447,7 @@ IR_Simple_i::IR_Simple_i (CORBA::ORB_ptr orb_ptr, : ir_impl_ (ir_impl), orb_var_ (CORBA::ORB::_duplicate (orb_ptr)), poa_var_ (PortableServer::POA::_duplicate (poa_ptr)), - forward_to_var_ (CORBA::Object::_nil ()) + forward_to_ptr_ (CORBA::Object::_nil ()) { } @@ -299,10 +475,13 @@ void IR_Simple_i::shutdown (CORBA::Environment &env) int IR_Simple_i::forward (CORBA::Environment &env) { this->ir_impl_->start ("Simple_Server"); - ACE_DEBUG ((LM_DEBUG, "Forwarding...\n")); - if (!CORBA::is_nil (this->forward_to_var_.in ())) + + ACE_DEBUG ((LM_DEBUG, "Forwarding to %s\n", + this->orb_var_->object_to_string (this->forward_to_ptr_))); + + if (!CORBA::is_nil (this->forward_to_ptr_)) { - env.exception (new PortableServer::ForwardRequest (this->forward_to_var_)); + env.exception (new PortableServer::ForwardRequest (this->forward_to_ptr_)); /* ACE_DEBUG ((LM_DEBUG, "Forwarding...\n")); @@ -340,5 +519,14 @@ int IR_Simple_i::forward (CORBA::Environment &env) void IR_Simple_i::forward_to (CORBA::Object_ptr forward_to_ptr) { - this->forward_to_var_ = CORBA::Object::_duplicate (forward_to_ptr); + IIOP_Object *iiop_obj = ACE_dynamic_cast (IIOP_Object *, forward_to_ptr->_stubobj ()); + IIOP::Profile *new_profile = new IIOP::Profile; + *new_profile = iiop_obj->profile; + IIOP_Object *new_iiop_obj = new IIOP_Object (iiop_obj->type_id, *new_profile); + + this->forward_to_ptr_ = + new CORBA_Object (new_iiop_obj, forward_to_ptr->_servant ()); + } + + diff --git a/TAO/orbsvcs/tests/ImplRepo/ir_implrepo_impl.h b/TAO/orbsvcs/tests/ImplRepo/ir_implrepo_impl.h index d783604a6be..f421c209fd7 100644 --- a/TAO/orbsvcs/tests/ImplRepo/ir_implrepo_impl.h +++ b/TAO/orbsvcs/tests/ImplRepo/ir_implrepo_impl.h @@ -5,22 +5,23 @@ // // = LIBRARY // TAO/orbsvcs/tests/ImplRepo -// +// // = FILENAME // ir_implrepo_impl.h // // = DESCRIPTION -// This class implements the Simple Object object. +// This class implements the Implementation Repository. // // = AUTHOR // Darrell Brunsch <brunsch@cs.wustl.edu> -// +// // ============================================================================ -#ifndef IR_IMPLREPO_IMPL_H -#define IR_IMPLREPO_IMPL_H +#if !defined (IR_IMPLREPO_IMPL_H) +#define IR_IMPLREPO_IMPL_H #include "Impl_RepoS.h" +#include "Repository.h" #include "tao/TAO.h" // Forward declarations. @@ -33,10 +34,30 @@ typedef IR_iRepo_i_ptr IR_iRepo_i_ref; typedef IR_Simple_i *IR_Simple_i_ptr; typedef IR_Simple_i_ptr IR_Simple_i_ref; +class IR_Adapter_Activator : public POA_PortableServer::AdapterActivator +{ + // = TITLE + // Implementation Repository Adapter Activator + // + // = DESCRIPTION + // Part of the Default Servant/DSI combination that forwards + // arbitrary requests. This allows for the setting up of child POAs + // with default servants. +public: + // Constructor + IR_Adapter_Activator (IR_Simple_i_ptr servant); + + virtual CORBA::Boolean unknown_adapter (PortableServer::POA_ptr parent, + const char *name, + CORBA_Environment &_env = CORBA_Environment::default_environment ()); +private: + IR_Simple_i_ptr servant_; +}; + class IR_iRepo_i : public POA_Implementation_Repository { // = TITLE - // Implementation Repository + // Implementation Repository // // = DESCRIPTION // This provides the interface to communicate directly with the @@ -47,22 +68,22 @@ public: ~IR_iRepo_i (void); // = Interface methods -// virtual void register_server (const char *server, -// const Implementation_Repository::Process_Options &options, -// CORBA::Environment &_tao_environment); + virtual void register_server (const char *server, + const Implementation_Repository::Process_Options &options, + CORBA::Environment &env); virtual void server_is_running (const char *server, CORBA::Object_ptr &obj, const Implementation_Repository::INET_Addr &addr, CORBA::Environment &_tao_environment); - + // = Other methods int init (int argc, char **argv, CORBA::Environment& env); // Initialize the Server state - parsing arguments and waiting int run (CORBA::Environment& env); - // Run the orb + // Run the orb void start (const char *server); // Starts the program registered as <server> @@ -70,11 +91,17 @@ public: private: IR_Simple_i *server_impl_; + IR_Adapter_Activator *activator_; + // Used for the forwarding of any type of POA. + + Repository repository_; + // Repository containing information about each server. + int parse_args (void); // Parses the commandline arguments. int read_ior (char *filename); - // Reads the IOR of the real server from the file + // Reads the IOR of the real server from the file. TAO_ORB_Manager orb_manager_; // The ORB manager. @@ -95,34 +122,13 @@ private: // The command line arguments. }; -class IR_Adapter_Activator : public POA_PortableServer::AdapterActivator -{ - // = TITLE - // Implementation Repository Adapter Activator - // - // = DESCRIPTION - // Part of the Default Servant/DSI combination that forwards - // arbitrary requests. This allows for the setting up of child POAs - // with default servants. -public: - // Constructor - IR_Adapter_Activator (PortableServer::Servant servant); - - virtual CORBA::Boolean unknown_adapter (PortableServer::POA_ptr parent, - const char *name, - CORBA_Environment &_env = CORBA_Environment::default_environment ()); -private: - PortableServer::Servant &servant_; -}; - - class IR_Simple_i: public POA_simple_object { // = TITLE // Simple Object Implementation // // = DESCRIPTION - // Implementation of a simple object that has two methods, one that + // Implementation of a simple object that has two methods, one that // returns the cube of a long, another that shuts down the server. public: // = Constructor and Destructor @@ -151,7 +157,7 @@ private: CORBA::ORB_var orb_var_; PortableServer::POA_var poa_var_; - CORBA::Object_var forward_to_var_; + CORBA::Object_ptr forward_to_ptr_; }; diff --git a/TAO/orbsvcs/tests/ImplRepo/ir_server.cpp b/TAO/orbsvcs/tests/ImplRepo/ir_server.cpp index 48773fb1b36..ae5bf8ed119 100644 --- a/TAO/orbsvcs/tests/ImplRepo/ir_server.cpp +++ b/TAO/orbsvcs/tests/ImplRepo/ir_server.cpp @@ -2,6 +2,8 @@ #include "ir_implrepo_impl.h" +#include "ace/Naming_Context.h" + ACE_RCSID(ImplRepo, ir_server, "$Id$") int @@ -33,5 +35,6 @@ main (int argc, char *argv[]) return -1; } TAO_ENDTRY; + return 0; } diff --git a/TAO/orbsvcs/tests/ImplRepo/ir_server_impl.h b/TAO/orbsvcs/tests/ImplRepo/ir_server_impl.h index df38d3b39f0..6da5fd7fc5c 100644 --- a/TAO/orbsvcs/tests/ImplRepo/ir_server_impl.h +++ b/TAO/orbsvcs/tests/ImplRepo/ir_server_impl.h @@ -18,7 +18,7 @@ // // ============================================================================ -#ifndef IR_SERVER_IMPL_H +#if !defined (IR_SERVER_IMPL_H) #define IR_SERVER_IMPL_H #include "ir_simple_object_impl.h" @@ -30,7 +30,7 @@ class IR_Server_i // CORBA Server Implementation // // = DESCRIPTION - // + // public: // = Initialization and termination methods. IR_Server_i (void); @@ -43,7 +43,7 @@ public: // Initialize the Server state - parsing arguments and waiting int run (CORBA::Environment& env); - // Run the orb + // Run the orb private: IR_Simple_i *server_impl_; diff --git a/TAO/orbsvcs/tests/ImplRepo/ir_simple_object_impl.h b/TAO/orbsvcs/tests/ImplRepo/ir_simple_object_impl.h index eb0d7fc24c0..53d178751b7 100644 --- a/TAO/orbsvcs/tests/ImplRepo/ir_simple_object_impl.h +++ b/TAO/orbsvcs/tests/ImplRepo/ir_simple_object_impl.h @@ -5,7 +5,7 @@ // // = LIBRARY // TAO/tests/Simple -// +// // = FILENAME // simple_object_impl.h // @@ -14,11 +14,11 @@ // // = AUTHOR // Darrell Brunsch <brunsch@cs.wustl.edu> -// +// // ============================================================================ -#ifndef IR_SIMPLE_OBJECT_IMPL_H -#define IR_SIMPLE_OBJECT_IMPL_H +#if !defined (IR_SIMPLE_OBJECT_IMPL_H) +#define IR_SIMPLE_OBJECT_IMPL_H #include "Impl_RepoS.h" @@ -35,7 +35,7 @@ class IR_Simple_i: public POA_simple_object // Simple Object Implementation // // = DESCRIPTION - // Implementation of a simple object that has two methods, one that + // Implementation of a simple object that has two methods, one that // returns the cube of a long, another that shuts down the server. public: IR_Simple_i (CORBA::ORB_ptr orb_ptr, diff --git a/TAO/orbsvcs/tests/ImplRepo/server.dsp b/TAO/orbsvcs/tests/ImplRepo/server.dsp index 2a908c8ade0..79adb6c2f20 100644 --- a/TAO/orbsvcs/tests/ImplRepo/server.dsp +++ b/TAO/orbsvcs/tests/ImplRepo/server.dsp @@ -42,7 +42,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0
# PROP Target_Dir ".\server"
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\..\\" /I "..\..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\\" /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
@@ -51,7 +51,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 ace.lib TAO.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\tao" /libpath:"..\..\..\..\ace"
+# ADD LINK32 ace.lib TAO.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\tao" /libpath:"..\..\..\ace"
!ELSEIF "$(CFG)" == "ImplRepoTest Server - Win32 Debug"
@@ -141,7 +141,7 @@ SOURCE=.\Simple_Object.idl !IF "$(CFG)" == "ImplRepoTest Server - Win32 Release"
-USERDEP__SIMPL="..\..\..\..\bin\Release\tao_idl.exe"
+USERDEP__SIMPL="..\..\..\bin\Release\tao_idl.exe"
# Begin Custom Build - Invoking TAO_IDL Compiler
InputPath=.\Simple_Object.idl
InputName=Simple_Object
@@ -179,7 +179,8 @@ BuildCmds= \ !ELSEIF "$(CFG)" == "ImplRepoTest Server - Win32 Debug"
-USERDEP__SIMPL="..\..\..\..\bin\tao_idl.exe"
+# PROP Ignore_Default_Tool 1
+USERDEP__SIMPL="..\..\..\bin\tao_idl.exe"
# Begin Custom Build - Invoking TAO_IDL Compiler
InputPath=.\Simple_Object.idl
InputName=Simple_Object
diff --git a/TAO/orbsvcs/tests/ImplRepo/server_impl.cpp b/TAO/orbsvcs/tests/ImplRepo/server_impl.cpp index 282212ebc2b..40803b2c6fb 100644 --- a/TAO/orbsvcs/tests/ImplRepo/server_impl.cpp +++ b/TAO/orbsvcs/tests/ImplRepo/server_impl.cpp @@ -8,14 +8,16 @@ ACE_RCSID(ImplRepo, server_impl, "$Id$") Server_i::Server_i (void) - : ior_output_file_ (0) + : ior_output_file_ (0), + register_ (0), + use_ir_ (1) { } int Server_i::parse_args (void) { - ACE_Get_Opt get_opts (this->argc_, this->argv_, "do:f:"); + ACE_Get_Opt get_opts (this->argc_, this->argv_, "do:f:ri"); int c; while ((c = get_opts ()) != -1) @@ -24,6 +26,13 @@ Server_i::parse_args (void) case 'd': // debug flag. TAO_debug_level++; break; + case 'r': + this->register_ = 1; + break; + case 'i': + this->use_ir_ = 0; + this->server_impl.use_ir_ = 0; + break; case 'o': // output the IOR to a file. this->ior_output_file_ = ACE_OS::fopen (get_opts.optarg, "w"); if (this->ior_output_file_ == 0) @@ -33,6 +42,7 @@ Server_i::parse_args (void) break; case '?': // display help for use of the server. default: + // @@ Update me. ACE_ERROR_RETURN ((LM_ERROR, "usage: %s" " [-d]" @@ -53,7 +63,7 @@ Server_i::init (int argc, char** argv, CORBA::Environment& env) { // Call the init of <TAO_ORB_Manager> to initialize the ORB and // create a child POA under the root POA. - if (this->orb_manager_.init_child_poa (argc, argv, "child_poa", TAO_TRY_ENV) == -1) + if (this->orb_manager_.init_child_poa (argc, argv, "simpserv", TAO_TRY_ENV) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "init_child_poa"), -1); TAO_CHECK_ENV; @@ -72,39 +82,55 @@ Server_i::init (int argc, char** argv, CORBA::Environment& env) TAO_TRY_ENV); TAO_CHECK_ENV; - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, "The IOR is: <%s>\n", str.in ())); + if (this->use_ir_) + { + this->read_ir_ior (); - // Talk to the Implementation Repository - - this->read_ir_ior (); + if (this->register_ == 1) + this->register_with_ir (); - CORBA::Object_var implrepo_object = - this->orb_manager_.orb ()->string_to_object (this->ir_server_key_, TAO_TRY_ENV); - TAO_CHECK_ENV; + CORBA::Object_var server_object = + this->orb_manager_.orb ()->string_to_object (str, env); - Implementation_Repository *ImplRepo = - Implementation_Repository::_narrow (implrepo_object.in(), TAO_TRY_ENV); - TAO_CHECK_ENV; + // Talk to the Implementation Repository if we are already registered + CORBA::Object_var implrepo_object = + this->orb_manager_.orb ()->string_to_object (this->ir_server_key_, TAO_TRY_ENV); + TAO_CHECK_ENV; - if (CORBA::is_nil (implrepo_object.in ())) - ACE_ERROR_RETURN ((LM_ERROR, - "invalid implrepo key <%s>\n", - this->ir_server_key_), - -1); + Implementation_Repository *ImplRepo = + Implementation_Repository::_narrow (implrepo_object.in(), TAO_TRY_ENV); + TAO_CHECK_ENV; - Implementation_Repository::INET_Addr addr; + if (CORBA::is_nil (implrepo_object.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + "invalid implrepo key <%s>\n", + this->ir_server_key_), + -1); - CORBA::Object_var server_object = - this->orb_manager_.orb ()->string_to_object (str, env); - - ImplRepo->server_is_running ("Simple_Server", server_object, addr, TAO_TRY_ENV); + Implementation_Repository::INET_Addr addr; - if (this->ior_output_file_) - { - ACE_OS::fprintf (this->ior_output_file_, "%s", server_object.in ()); - ACE_OS::fclose (this->ior_output_file_); + ImplRepo->server_is_running ("Simple_Server", server_object, addr, TAO_TRY_ENV); + + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "The IOR is: <%s>\n", this->orb_manager_.orb ()->object_to_string (server_object, env))); + + if (this->ior_output_file_) + { + ACE_OS::fprintf (this->ior_output_file_, "%s", this->orb_manager_.orb ()->object_to_string (server_object, env)); + ACE_OS::fclose (this->ior_output_file_); + } } + else + { + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "The IOR is: <%s>\n", str.in())); + + if (this->ior_output_file_) + { + ACE_OS::fprintf (this->ior_output_file_, "%s", str.in()); + ACE_OS::fclose (this->ior_output_file_); + } + } } TAO_CATCHANY @@ -120,8 +146,45 @@ Server_i::init (int argc, char** argv, CORBA::Environment& env) int Server_i::run (CORBA::Environment& env) { - if (this->orb_manager_.run (env) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "Server_i::run"), -1); + if (this->register_ != 1) + if (this->orb_manager_.run (env) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "Server_i::run"), -1); + return 0; +} + +int +Server_i::register_with_ir (void) +{ + TAO_TRY + { + CORBA::Object_var implrepo_object = + this->orb_manager_.orb ()->string_to_object (this->ir_server_key_, TAO_TRY_ENV); + TAO_CHECK_ENV; + + Implementation_Repository *ImplRepo = + Implementation_Repository::_narrow (implrepo_object.in(), TAO_TRY_ENV); + TAO_CHECK_ENV; + + if (CORBA::is_nil (implrepo_object.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + "invalid implrepo key <%s>\n", + this->ir_server_key_), + -1); + + Implementation_Repository::Process_Options proc_opts; + + proc_opts.command_line_ = CORBA::string_dup ("server -o svr.ior -ORBobjrefstyle url"); + proc_opts.environment_ = CORBA::string_dup (""); + proc_opts.working_directory_ = CORBA::string_dup (""); + + ImplRepo->register_server ("Simple_Server", proc_opts, TAO_TRY_ENV); + } + TAO_CATCHANY + { + TAO_TRY_ENV.print_exception ("Server_i::register_with_ir"); + return -1; + } + TAO_ENDTRY; return 0; } diff --git a/TAO/orbsvcs/tests/ImplRepo/server_impl.h b/TAO/orbsvcs/tests/ImplRepo/server_impl.h index c33e6edf8cd..69de1218256 100644 --- a/TAO/orbsvcs/tests/ImplRepo/server_impl.h +++ b/TAO/orbsvcs/tests/ImplRepo/server_impl.h @@ -18,7 +18,7 @@ // // ============================================================================ -#ifndef SERVER_IMPL_H +#if !defined (SERVER_IMPL_H) #define SERVER_IMPL_H #include "simple_object_impl.h" @@ -30,7 +30,7 @@ class Server_i // CORBA Server Implementation // // = DESCRIPTION - // + // public: // = Initialization and termination methods. Server_i (void); @@ -43,13 +43,15 @@ public: // Initialize the Server state - parsing arguments and waiting int run (CORBA::Environment& env); - // Run the orb + // Run the orb private: Simple_i server_impl; int read_ir_ior (void); + int register_with_ir (void); + int parse_args (void); // Parses the commandline arguments. @@ -57,10 +59,17 @@ private: // The ORB manager. char *ir_server_key_; - + FILE *ior_output_file_; // File where the IOR of the server object is stored. + int register_; + // Flag to indicate whether ImplRepo registration should take + // place + + int use_ir_; + // Flag to indicate whether the IR should be used or not. + int argc_; // Number of command line arguments. diff --git a/TAO/orbsvcs/tests/ImplRepo/simple_object_impl.cpp b/TAO/orbsvcs/tests/ImplRepo/simple_object_impl.cpp index 4d92ba290fd..036ea7fbfae 100644 --- a/TAO/orbsvcs/tests/ImplRepo/simple_object_impl.cpp +++ b/TAO/orbsvcs/tests/ImplRepo/simple_object_impl.cpp @@ -8,6 +8,7 @@ ACE_RCSID(ImplRepo, simple_object_impl, "$Id$") // Constructor Simple_i::Simple_i (const char *) +: use_ir_ (1) { } @@ -37,6 +38,7 @@ void Simple_i::shutdown (CORBA::Environment &env) ACE_DEBUG ((LM_DEBUG, "%s\n", "Simple_i is shutting down")); - TAO_ORB_Core_instance ()->orb ()->shutdown (); +// if (this->use_ir_ == 1) + // TAO_ORB_Core_instance ()->orb ()->shutdown (); } diff --git a/TAO/orbsvcs/tests/ImplRepo/simple_object_impl.h b/TAO/orbsvcs/tests/ImplRepo/simple_object_impl.h index 1b0818a5444..f92a47dcce1 100644 --- a/TAO/orbsvcs/tests/ImplRepo/simple_object_impl.h +++ b/TAO/orbsvcs/tests/ImplRepo/simple_object_impl.h @@ -5,7 +5,7 @@ // // = LIBRARY // TAO/tests/Simple -// +// // = FILENAME // simple_object_impl.h // @@ -14,11 +14,11 @@ // // = AUTHOR // Darrell Brunsch <brunsch@cs.wustl.edu> -// +// // ============================================================================ -#ifndef SIMPLE_OBJECT_IMPL_H -#define SIMPLE_OBJECT_IMPL_H +#if !defined (SIMPLE_OBJECT_IMPL_H) +#define SIMPLE_OBJECT_IMPL_H #include "Simple_ObjectS.h" @@ -35,7 +35,7 @@ class Simple_i: public POA_simple_object // Simple Object Implementation // // = DESCRIPTION - // Implementation of a simple object that has two methods, one that + // Implementation of a simple object that has two methods, one that // returns the cube of a long, another that shuts down the server. public: Simple_i (const char *obj_name = 0); @@ -50,6 +50,10 @@ public: virtual void shutdown (CORBA::Environment &env); // Shutdown routine. + + int use_ir_; + // Should we shutdown after each call? If using the Impl Repo, then yes. + }; diff --git a/TAO/orbsvcs/tests/ImplRepo/svc.conf b/TAO/orbsvcs/tests/ImplRepo/svc.conf index e983d040980..0d5859f760d 100644 --- a/TAO/orbsvcs/tests/ImplRepo/svc.conf +++ b/TAO/orbsvcs/tests/ImplRepo/svc.conf @@ -46,4 +46,4 @@ # dynamic Resource_Factory Service_Object * TAO:_make_TAO_Resource_Factory() "-ORBresources tss" dynamic Client_Strategy_Factory Service_Object * TAO:_make_TAO_Default_Client_Strategy_Factory() -dynamic Server_Strategy_Factory Service_Object * TAO:_make_TAO_Default_Server_Strategy_Factory() "-ORBconcurrency thread-per-connection -ORBdemuxstrategy dynamic -ORBtablesize 128" +dynamic Server_Strategy_Factory Service_Object * TAO:_make_TAO_Default_Server_Strategy_Factory() "-ORBconcurrency thread-per-connection -ORBdemuxstrategy dynamic -ORBtablesize 128 -ORBpoalock null" |