diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-05-07 21:41:29 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-05-07 21:41:29 +0000 |
commit | 919d3b8c15afb2db862edbb26eaadff65d47a095 (patch) | |
tree | 35920aa88b85357eaa21459f956afacadcd7837d /TAO/orbsvcs | |
parent | 70e114b2752617f6a245e95500c890e331254eb5 (diff) | |
download | ATCD-919d3b8c15afb2db862edbb26eaadff65d47a095.tar.gz |
*** empty log message ***
Diffstat (limited to 'TAO/orbsvcs')
-rw-r--r-- | TAO/orbsvcs/tests/Naming/ns_tree.cpp | 58 |
1 files changed, 27 insertions, 31 deletions
diff --git a/TAO/orbsvcs/tests/Naming/ns_tree.cpp b/TAO/orbsvcs/tests/Naming/ns_tree.cpp index 6bf979212f7..e14f06c2070 100644 --- a/TAO/orbsvcs/tests/Naming/ns_tree.cpp +++ b/TAO/orbsvcs/tests/Naming/ns_tree.cpp @@ -17,6 +17,7 @@ #include "tao/TAO.h" #include "orbsvcs/CosNamingC.h" #include "test_objectS.h" +#include "orbsvcs/Naming/Naming_Utils.h" class Test_Object_impl : public POA_Test_Object { @@ -30,29 +31,34 @@ main (int argc, char **argv) { TAO_ORB_Manager orbmgr; Test_Object_impl myObject; + TAO_Naming_Server my_name_server; + int result; TAO_TRY { // Initialize and obtain reference to the Naming Context - if (orbmgr.init (argc, argv, TAO_TRY_ENV) == -1) + if (orbmgr.init_child_poa (argc, argv,"Rob", TAO_TRY_ENV) == -1) ACE_ERROR_RETURN ((LM_ERROR, "failed to init ORB\n"), -1); TAO_CHECK_ENV; - CORBA::ORB_var orb = orbmgr.orb (); - CORBA::Object_var ns_obj = - orb->resolve_initial_references ("NameService"); + PortableServer::POA_var child_poa; + CORBA::ORB_var orb = orbmgr.orb (); - if (CORBA::is_nil (ns_obj)) - ACE_ERROR_RETURN ((LM_ERROR, - "failed to resolve Name Service\n"), - -1); + child_poa = orbmgr.child_poa (); + result = my_name_server.init (orb, child_poa); - CosNaming::NamingContext_var ns_ctx = - CosNaming::NamingContext::_narrow (ns_obj.in (), - TAO_TRY_ENV); - TAO_CHECK_ENV; + if (result < 0) + 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); + + TAO_CHECK_ENV_RETURN (TAO_TRY_ENV, -1); // Dummy object instantiation. Test_Object_var myObject_var = @@ -62,24 +68,14 @@ 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); - CORBA::Object_var mycontext = - ns_ctx->bind_new_context (test_context, - TAO_TRY_ENV); - TAO_CHECK_ENV; + TAO_CHECK_ENV_RETURN (TAO_TRY_ENV, -1); - if (CORBA::is_nil (mycontext)) - ACE_ERROR_RETURN ((LM_ERROR, - "unabled to create new naming context \"MyContext\"\n"), - -1); - - CosNaming::NamingContext_var my_context = - CosNaming::NamingContext::_narrow (mycontext.in (), - TAO_TRY_ENV); - TAO_CHECK_ENV; cerr << "Created new context OK" << endl; // bind an object to a child context @@ -88,9 +84,9 @@ main (int argc, char **argv) test_name[0].id = CORBA::string_dup ("MyContext"); test_name[1].id = CORBA::string_dup ("MyName"); - ns_ctx->bind (test_name, - myObject_var.in (), - TAO_TRY_ENV); + my_name_server->bind (test_name, + myObject_var.in (), + TAO_TRY_ENV); TAO_CHECK_ENV; cerr << "Bound compound name OK" << endl; @@ -100,12 +96,12 @@ main (int argc, char **argv) result_name[0].id = CORBA::string_dup ("MyContext"); result_name[1].id = CORBA::string_dup ("MyName"); - CORBA::Object_var resolvedobj = ns_ctx->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 (), + Test_Object::_narrow (resolvedobj.in (), TAO_TRY_ENV); cerr << "Resolved compound name OK" << endl; |