diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-07-18 14:43:03 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-07-18 14:43:03 +0000 |
commit | 53179d40d4419e6d8cfd6c20f8e09fc72c3e33bf (patch) | |
tree | 13ed654237c82ebd6df7e307f94f628f6b670496 /TAO | |
parent | 1a05dd9d58f6ed1bbef9bcc6a0b7b3c0767b266d (diff) | |
download | ATCD-53179d40d4419e6d8cfd6c20f8e09fc72c3e33bf.tar.gz |
*** empty log message ***
Diffstat (limited to 'TAO')
-rw-r--r-- | TAO/ChangeLog-98c | 17 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Naming/Naming_Utils.cpp | 39 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Naming/Naming_Utils.h | 12 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/Naming/ns_tree.cpp | 66 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/Simple_Naming/Makefile | 26 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/Simple_Naming/README | 13 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/Simple_Naming/client.cpp | 86 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/Simple_Naming/test_object.idl | 7 |
8 files changed, 201 insertions, 65 deletions
diff --git a/TAO/ChangeLog-98c b/TAO/ChangeLog-98c index 0b69adc48da..2a52dac1bd0 100644 --- a/TAO/ChangeLog-98c +++ b/TAO/ChangeLog-98c @@ -1,4 +1,19 @@ -Sat Jul 18 05:24:37 1998 Douglas C. Schmidt <schmidt@mambo.cs.wustl.edu> +Sat Jul 18 08:19:24 1998 Douglas C. Schmidt <schmidt@lambada.cs.wustl.edu> + + * orbsvcs/tests/Simple_Naming/client.cpp: Beefed up this test so + that it illustrates how to bind(), resolve(), and unbind() an + object reference to a remote Naming Context. This is an + important test to make sure that things are working properly. + + * orbsvcs/orbsvcs/Naming/Naming_Utils: Added an init() method to + this class to begin to factor out common code for being a client + of a Naming Service. + + * TAO/orbsvcs/tests/Naming/ns_tree.cpp (main): Cleaned up the + formatting for this test. + + * orbsvcs/tests/Simple_Naming: Renamed clnt.* to client.* to + be more consistent. * tests/Cubit/TAO/IDL_Cubit/svc.conf: Changed the default ORB concurrency model from reactive to thread-per-connection since diff --git a/TAO/orbsvcs/orbsvcs/Naming/Naming_Utils.cpp b/TAO/orbsvcs/orbsvcs/Naming/Naming_Utils.cpp index 761aab8d637..e48ec06b55f 100644 --- a/TAO/orbsvcs/orbsvcs/Naming/Naming_Utils.cpp +++ b/TAO/orbsvcs/orbsvcs/Naming/Naming_Utils.cpp @@ -37,7 +37,10 @@ TAO_Naming_Server::TAO_Naming_Server (CORBA::ORB_ptr orb, int argc, char **argv) { - this->init (orb, child_poa, argc, argv); + if (this->init (orb, child_poa, argc, argv) == -1) + ACE_ERROR ((LM_ERROR, + "(%P|%t) %p\n", + "TAO_Naming_Server::init")); } // Function to initialize the name server object under the passed ORB @@ -87,7 +90,7 @@ TAO_Naming_Server::init (CORBA::ORB_ptr orb, "NameService") == 0) { // Get the naming context ptr to NameService. - this->naming_context_var_ = + this->naming_context_ = this->naming_context_impl_._this (TAO_TRY_ENV); TAO_CHECK_ENV; @@ -250,7 +253,7 @@ TAO_Naming_Server::naming_service_ior (void) CosNaming::NamingContext_ptr TAO_Naming_Server::operator -> (void) const { - return this->naming_context_var_.ptr (); + return this->naming_context_.ptr (); } // Destructor. @@ -270,7 +273,35 @@ TAO_Naming_Server::~TAO_Naming_Server (void) CosNaming::NamingContext_ptr TAO_Naming_Client::operator -> (void) const { - return this->naming_context_var_.ptr (); + return this->naming_context_.ptr (); +} + +int +TAO_Naming_Client::init (CORBA::ORB_ptr orb, + int argc, + char **argv) +{ + TAO_TRY + { + CORBA::Object_var naming_obj = + orb->resolve_initial_references ("NameService"); + if (CORBA::is_nil (naming_obj.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Unable to initialize the NameService.\n"), + -1); + this->naming_context_ = + CosNaming::NamingContext::_narrow (naming_obj.in (), + TAO_TRY_ENV); + TAO_CHECK_ENV; + } + TAO_CATCHANY + { + TAO_TRY_ENV.print_exception ("init"); + return -1; + } + TAO_ENDTRY; + + return 0; } TAO_Naming_Client::TAO_Naming_Client (void) diff --git a/TAO/orbsvcs/orbsvcs/Naming/Naming_Utils.h b/TAO/orbsvcs/orbsvcs/Naming/Naming_Utils.h index 7d07f60fb69..a8f9008ee35 100644 --- a/TAO/orbsvcs/orbsvcs/Naming/Naming_Utils.h +++ b/TAO/orbsvcs/orbsvcs/Naming/Naming_Utils.h @@ -83,7 +83,7 @@ private: NS_NamingContext naming_context_impl_; // Naming context implemetation for "NameService". - CosNaming::NamingContext_var naming_context_var_; + CosNaming::NamingContext_var naming_context_; // NamingContext ptr. TAO_IOR_Multicast *ior_multicast_; @@ -111,6 +111,14 @@ public: TAO_Naming_Client (void); //Default constructor. + int init (CORBA::ORB_ptr orb, + int argc = 0, + char **argv = 0); + // Initialize the name server under the given ORB and POA. The + // <argc> and <argv> commmand-line arguments are parsed to determine + // if this name server instance is part of a naming tree that + // resides under the default name server. + ~TAO_Naming_Client (void); // Destructor. @@ -120,7 +128,7 @@ public: // Returns a <NamingContext_ptr>. private: - CosNaming::NamingContext_var naming_context_var_; + CosNaming::NamingContext_var naming_context_; // NamingContext ptr. }; diff --git a/TAO/orbsvcs/tests/Naming/ns_tree.cpp b/TAO/orbsvcs/tests/Naming/ns_tree.cpp index 303bebb9df6..8fcb52bf33d 100644 --- a/TAO/orbsvcs/tests/Naming/ns_tree.cpp +++ b/TAO/orbsvcs/tests/Naming/ns_tree.cpp @@ -6,6 +6,8 @@ // ns_tree.cpp // // = DESCRIPTION +// Tests various features of TAO's Naming Service. Note that this +// uses a co-located Naming Service, rather than a remote one. // // = AUTHOR // Ross Lillie <lillie@rsch.comm.mot.com> @@ -15,28 +17,30 @@ #include "tao/TAO.h" #include "orbsvcs/CosNamingC.h" -#include "test_objectS.h" #include "orbsvcs/Naming/Naming_Utils.h" +#include "test_objectS.h" -class Test_Object_impl : public POA_Test_Object +class My_Test_Object : public POA_Test_Object { public: - Test_Object_impl (void) {}; - ~Test_Object_impl (void) {}; + My_Test_Object (void) {}; + ~My_Test_Object (void) {}; }; int main (int argc, char **argv) { TAO_ORB_Manager orbmgr; - Test_Object_impl myObject; + My_Test_Object myObject; TAO_Naming_Server my_name_server; - int result; TAO_TRY { - // Initialize and obtain reference to the Naming Context - if (orbmgr.init_child_poa (argc, argv,"Rob", TAO_TRY_ENV) == -1) + // Initialize and obtain reference to the Naming Context. + if (orbmgr.init_child_poa (argc, + argv, + "child", + TAO_TRY_ENV) == -1) ACE_ERROR_RETURN ((LM_ERROR, "failed to init ORB\n"), -1); @@ -46,16 +50,19 @@ main (int argc, char **argv) CORBA::ORB_var orb = orbmgr.orb (); child_poa = orbmgr.child_poa (); - result = my_name_server.init (orb, child_poa); + int result = my_name_server.init (orb, + child_poa); - if (result < 0) + if (result == -1) return result; CosNaming::Name context_name; - CosNaming::NamingContext_var ns_ctx; context_name.length (1); - context_name[0].id = CORBA::string_dup ("NameService"); - ns_ctx = my_name_server->bind_new_context (context_name, TAO_TRY_ENV); + context_name[0].id = + CORBA::string_dup ("NameService"); + CosNaming::NamingContext_var ns_ctx = + my_name_server->bind_new_context (context_name, + TAO_TRY_ENV); TAO_CHECK_ENV_RETURN (TAO_TRY_ENV, -1); @@ -66,43 +73,52 @@ main (int argc, char **argv) // Create a child context. CosNaming::Name test_context (1); - CosNaming::NamingContext_var my_context; test_context.length (1); test_context[0].id = CORBA::string_dup ("MyContext"); - my_context = my_name_server->bind_new_context (test_context, TAO_TRY_ENV); + CosNaming::NamingContext_var my_context = + my_name_server->bind_new_context (test_context, + TAO_TRY_ENV); TAO_CHECK_ENV_RETURN (TAO_TRY_ENV, -1); - cerr << "Created new context OK" << endl; + ACE_DEBUG ((LM_DEBUG, + "Created new context OK")); // Bind an object to a child context. CosNaming::Name test_name (2); test_name.length (2); - test_name[0].id = CORBA::string_dup ("MyContext"); - test_name[1].id = CORBA::string_dup ("MyName"); + test_name[0].id = + CORBA::string_dup ("MyContext"); + test_name[1].id = + CORBA::string_dup ("MyName"); my_name_server->bind (test_name, myObject_var.in (), TAO_TRY_ENV); TAO_CHECK_ENV; - cerr << "Bound compound name OK" << endl; + ACE_DEBUG ((LM_DEBUG, + "Bound compound name OK")); // Finally, try now to resolve the compound name. CosNaming::Name result_name (2); result_name.length (2); - result_name[0].id = CORBA::string_dup ("MyContext"); - result_name[1].id = CORBA::string_dup ("MyName"); + result_name[0].id = + CORBA::string_dup ("MyContext"); + result_name[1].id = + CORBA::string_dup ("MyName"); - CORBA::Object_var resolvedobj = my_name_server->resolve (result_name, - TAO_TRY_ENV); + CORBA::Object_var resolvedobj = + my_name_server->resolve (result_name, + TAO_TRY_ENV); TAO_CHECK_ENV; Test_Object_var resultObject = Test_Object::_narrow (resolvedobj.in (), TAO_TRY_ENV); - - cerr << "Resolved compound name OK" << endl; + TAO_CHECK_ENV; + ACE_DEBUG ((LM_DEBUG, + "Resolved compound name OK")); } TAO_CATCHANY { diff --git a/TAO/orbsvcs/tests/Simple_Naming/Makefile b/TAO/orbsvcs/tests/Simple_Naming/Makefile index d193b68a169..b4abb8e8ba5 100644 --- a/TAO/orbsvcs/tests/Simple_Naming/Makefile +++ b/TAO/orbsvcs/tests/Simple_Naming/Makefile @@ -8,17 +8,27 @@ # Local macros #---------------------------------------------------------------------------- +ifndef TAO_ROOT +TAO_ROOT = $(ACE_ROOT)/TAO +endif + LDLIBS = -lorbsvcs -lTAO -CLIENT_SRCS = client.cpp +IDL_SRC = test_objectC.cpp test_objectS.cpp +CLIENT_SRC = client.cpp + +LSRC = $(IDL_SRC) $(CLIENT_SRC) -LSRC = $(CLIENT_SRCS) +CLIENT_OBJS = $(IDL_SRC:.cpp=.o) $(CLIENT_SRC:.cpp=.o) -CLIENT_OBJS = $(CLIENT_SRCS:.cpp=.o) +TEST_OBJECT_OBJS = test_objectC.o \ + test_objectS.o \ + client.o BIN = client BUILD = $(BIN) VLDLIBS = $(LDLIBS:%=%$(VAR)) +VBIN = $(BIN:%=%$(VAR)) #---------------------------------------------------------------------------- # Include macros and targets @@ -26,18 +36,18 @@ VLDLIBS = $(LDLIBS:%=%$(VAR)) include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU include $(ACE_ROOT)/include/makeinclude/macros.GNU +include $(TAO_ROOT)/rules.tao.GNU include $(ACE_ROOT)/include/makeinclude/rules.common.GNU include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU -include $(ACE_ROOT)/include/makeinclude/rules.bin.GNU include $(ACE_ROOT)/include/makeinclude/rules.local.GNU +include $(TAO_ROOT)/taoconfig.mk -ifndef TAO_ROOT -TAO_ROOT = $(ACE_ROOT)/TAO -endif -TSS_ORB_FLAG = #-DTAO_HAS_TSS_ORBCORE LDFLAGS += -L$(TAO_ROOT)/orbsvcs/orbsvcs -L$(TAO_ROOT)/tao CPPFLAGS += -I$(TAO_ROOT)/orbsvcs -I$(TAO_ROOT) $(TSS_ORB_FLAG)#-H +client: $(addprefix $(VDIR),$(TEST_OBJECT_OBJS)) + $(LINK.cc) $(LDFLAGS) -o $@ $^ $(VLDLIBS) $(POSTLINK) + # DO NOT DELETE THIS LINE -- g++dep uses it. # DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. diff --git a/TAO/orbsvcs/tests/Simple_Naming/README b/TAO/orbsvcs/tests/Simple_Naming/README new file mode 100644 index 00000000000..9ab259bb0a1 --- /dev/null +++ b/TAO/orbsvcs/tests/Simple_Naming/README @@ -0,0 +1,13 @@ +// $Id$ + +This test application exercises basic features of TAO's Naming +Service. It behaves as follows: + + 1. It obtains an object reference to a remote Naming + Service (which currently must be handed started, + but will ultimately be run in by a perl script). + + 2. It binds(), resolves(), and unbinds() an object + reference into the Naming Context. + +We'll add more features to this test over time. diff --git a/TAO/orbsvcs/tests/Simple_Naming/client.cpp b/TAO/orbsvcs/tests/Simple_Naming/client.cpp index 8c9c884d90a..27d17a92929 100644 --- a/TAO/orbsvcs/tests/Simple_Naming/client.cpp +++ b/TAO/orbsvcs/tests/Simple_Naming/client.cpp @@ -19,6 +19,14 @@ #include "client.h" #include "ace/Get_Opt.h" +#include "test_objectS.h" + +class My_Test_Object : public POA_Test_Object +{ +public: + My_Test_Object (void) {}; + ~My_Test_Object (void) {}; +}; // constructor @@ -66,29 +74,58 @@ CosNaming_Client::parse_args (void) int CosNaming_Client::run (void) { - // Dummy object instantiation. - Test_Object_var myObject_var = - myObject._this (TAO_TRY_ENV); - TAO_CHECK_ENV; - - // Bind an object to the Naming Context. - CosNaming::Name test_name (1); - test_name.length (1); - test_name[0].id = - CORBA::string_dup ("Foo"); - - my_name_server->bind (test_name, - myObject_var.in (), - TAO_TRY_ENV); - - TAO_CHECK_ENV; - ACE_DEBUG ((LM_DEBUG, - "Bound name OK")); - - // @@ TODO, add some more interesting tests here, for instance - // creating some nested naming contexts and registering a number of - // objreferences in there. We could even use the Iterators and the - // TAO_Client_Naming abstraction to simply this. + TAO_TRY + { + My_Test_Object myObject; + + // Dummy object instantiation. + Test_Object_var myObject_var = + myObject._this (TAO_TRY_ENV); + TAO_CHECK_ENV; + + // Bind an object to the Naming Context. + CosNaming::Name test_name (1); + test_name.length (1); + test_name[0].id = + CORBA::string_dup ("Foo"); + + this->naming_client_->bind (test_name, + myObject_var.in (), + TAO_TRY_ENV); + TAO_CHECK_ENV; + + ACE_DEBUG ((LM_DEBUG, + "Bound name OK\n")); + + CORBA::Object_var resolvedobj = + this->naming_client_->resolve (test_name, + TAO_TRY_ENV); + TAO_CHECK_ENV; + + Test_Object_var resultObject = + Test_Object::_narrow (resolvedobj.in (), + TAO_TRY_ENV); + TAO_CHECK_ENV; + ACE_DEBUG ((LM_DEBUG, + "Resolved name OK\n")); + + this->naming_client_->unbind (test_name, + TAO_TRY_ENV); + TAO_CHECK_ENV; + + ACE_DEBUG ((LM_DEBUG, + "Unbound name OK\n")); + // @@ TODO, add some more interesting tests here, for instance + // creating some nested naming contexts and registering a number of + // objreferences in there. We could even use the Iterators and the + // TAO_Client_Naming abstraction to simply this. + } + TAO_CATCHANY + { + TAO_TRY_ENV.print_exception ("ns_tree"); + return -1; + } + TAO_ENDTRY; return 0; } @@ -111,11 +148,10 @@ CosNaming_Client::init (int argc, char **argv) // Initialize ORB. this->orbmgr_.init (argc, argv, - 0, TAO_TRY_ENV); TAO_CHECK_ENV; - return this->naming_client_.init (this->orbmgr_.orb ()) + return this->naming_client_.init (this->orbmgr_.orb ()); } TAO_CATCHANY { diff --git a/TAO/orbsvcs/tests/Simple_Naming/test_object.idl b/TAO/orbsvcs/tests/Simple_Naming/test_object.idl new file mode 100644 index 00000000000..42e5ee937bf --- /dev/null +++ b/TAO/orbsvcs/tests/Simple_Naming/test_object.idl @@ -0,0 +1,7 @@ +// $Id$ + +interface Test_Object +{ + // = TITLE + // This is a simple "no-op" interface to test the Naming Service. +}; |