summaryrefslogtreecommitdiff
path: root/TAO/tests/Cubit/TAO/IDL_Cubit
diff options
context:
space:
mode:
authornaga <naga@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-02-16 23:24:25 +0000
committernaga <naga@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-02-16 23:24:25 +0000
commit22d3f12f8cddb4439c52f75c0e1c9f54596a71ad (patch)
tree5a010729656a1868f01b88f61857d0cda8f899ba /TAO/tests/Cubit/TAO/IDL_Cubit
parentf6cd83de32519d81e2412fd503c6b4765ebb7b14 (diff)
downloadATCD-22d3f12f8cddb4439c52f75c0e1c9f54596a71ad.tar.gz
*** empty log message ***
Diffstat (limited to 'TAO/tests/Cubit/TAO/IDL_Cubit')
-rw-r--r--TAO/tests/Cubit/TAO/IDL_Cubit/clnt.cpp86
-rw-r--r--TAO/tests/Cubit/TAO/IDL_Cubit/svr.cpp29
2 files changed, 91 insertions, 24 deletions
diff --git a/TAO/tests/Cubit/TAO/IDL_Cubit/clnt.cpp b/TAO/tests/Cubit/TAO/IDL_Cubit/clnt.cpp
index 4686c6833b7..f48b2c9a580 100644
--- a/TAO/tests/Cubit/TAO/IDL_Cubit/clnt.cpp
+++ b/TAO/tests/Cubit/TAO/IDL_Cubit/clnt.cpp
@@ -22,12 +22,14 @@
#include "ace/Profile_Timer.h"
#include "ace/Env_Value_T.h"
#include "clnt.h"
+#include "orbsvcs/CosNamingC.h"
+
-// Constructor.
#define quote(x) #x
#define MAX_IOR_SIZE 512
+// Constructor.
Cubit_Client::Cubit_Client (void)
: cubit_factory_key_ (0),
cubit_key_ (ACE_OS::strdup ("key0")),
@@ -36,7 +38,8 @@ Cubit_Client::Cubit_Client (void)
cubit_ (Cubit::_nil ()),
call_count_ (0),
error_count_ (0),
- cubit_factory_ior_file_ (0)
+ cubit_factory_ior_file_ (0),
+ use_naming_service (0)
{
}
@@ -54,7 +57,7 @@ Cubit_Client::func (u_int i)
int
Cubit_Client::parse_args (void)
{
- ACE_Get_Opt get_opts (argc_, argv_, "dn:f:k:x");
+ ACE_Get_Opt get_opts (argc_, argv_, "dn:f:k:x:s");
int c;
char temp_buf[MAX_IOR_SIZE];
char *result = 0;
@@ -88,6 +91,9 @@ Cubit_Client::parse_args (void)
case 'x':
this->exit_later_++;
break;
+ case 's':
+ use_naming_service = 1;
+ break;
case '?':
default:
ACE_ERROR_RETURN ((LM_ERROR,
@@ -97,6 +103,7 @@ Cubit_Client::parse_args (void)
" [-f cubit_factory-obj-ref-key-file]"
" [-k cubit-obj-ref-key]"
" [-x]"
+ " [-s]"
"\n",
this->argv_ [0]),
-1);
@@ -701,28 +708,59 @@ Cubit_Client::init (int argc, char **argv)
if (this->parse_args () == -1)
return -1;
- if (this->cubit_factory_key_ == 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- "%s: no cubit factory key specified\n",
- this->argv_[0]),
- -1);
-
-
- CORBA::Object_var factory_object =
- this->orb_->string_to_object (this->cubit_factory_key_,
- TAO_TRY_ENV);
- TAO_CHECK_ENV;
-
- this->factory_ =
- Cubit_Factory::_narrow (factory_object.in(), TAO_TRY_ENV);
- TAO_CHECK_ENV;
-
- if (CORBA::is_nil (this->factory_.in ()))
+ if ( use_naming_service )
{
- ACE_ERROR_RETURN ((LM_ERROR,
- "invalid factory key <%s>\n",
- this->cubit_factory_key_),
- -1);
+ CORBA::Object_var naming_obj =
+ this->orb_->resolve_initial_references ("NameService");
+ if (CORBA::is_nil (naming_obj.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ " (%P|%t) Unable to resolve the Name Service.\n"),
+ -1);
+ CosNaming::NamingContext_var naming_context =
+ CosNaming::NamingContext::_narrow (naming_obj.in (), TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
+ CosNaming::Name cubit_factory_name (2);
+ cubit_factory_name.length (2);
+ cubit_factory_name[0].id = CORBA::string_dup ("IDL_Cubit");
+ cubit_factory_name[1].id = CORBA::string_dup ("cubit_factory");
+ CORBA::Object_var factory_obj = naming_context->resolve (cubit_factory_name,TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
+ this->factory_ =
+ Cubit_Factory::_narrow (factory_obj.in (),TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
+ if (CORBA::is_nil (this->factory_.in ()))
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ " could not resolve cubit factory in Naming service <%s>\n"),
+ -1);
+ }
+ } else {
+ if (this->cubit_factory_key_ == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%s: no cubit factory key specified\n",
+ this->argv_[0]),
+ -1);
+
+
+ CORBA::Object_var factory_object =
+ this->orb_->string_to_object (this->cubit_factory_key_,
+ TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
+ this->factory_ =
+ Cubit_Factory::_narrow (factory_object.in(), TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
+ if (CORBA::is_nil (this->factory_.in ()))
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "invalid factory key <%s>\n",
+ this->cubit_factory_key_),
+ -1);
+ }
}
ACE_DEBUG ((LM_DEBUG, "Factory received OK\n"));
diff --git a/TAO/tests/Cubit/TAO/IDL_Cubit/svr.cpp b/TAO/tests/Cubit/TAO/IDL_Cubit/svr.cpp
index ba13a335c34..aa9f021cdc2 100644
--- a/TAO/tests/Cubit/TAO/IDL_Cubit/svr.cpp
+++ b/TAO/tests/Cubit/TAO/IDL_Cubit/svr.cpp
@@ -16,6 +16,7 @@
#include "ace/Get_Opt.h"
#include "ace/Log_Msg.h"
#include "tao/corba.h"
+#include "orbsvcs/CosNamingC.h"
#include "cubit_i.h"
// Global Variables
@@ -105,6 +106,18 @@ main (int argc, char *argv[])
TAO_TRY_ENV);
TAO_CHECK_ENV;
+ //Resolve the Naming Service context
+ 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 resolve the Name Service.\n"),
+ 2);
+
+ CosNaming::NamingContext_var naming_context =
+ CosNaming::NamingContext::_narrow (naming_obj.in (), TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
// Parse remaining command line and verify parameters.
parse_args (argc, argv);
@@ -135,6 +148,22 @@ main (int argc, char *argv[])
ACE_OS::fprintf (ior_output_file, "%s", str.in());
ACE_OS::fclose (ior_output_file);
}
+
+ // Bind a new IDL_Cubit Name context
+ CosNaming::Name cubit_context_name (1);
+ cubit_context_name.length (1);
+ cubit_context_name[0].id = CORBA::string_dup ("IDL_Cubit");
+ CosNaming::NamingContext_var cubit_context =
+ naming_context->bind_new_context (cubit_context_name,TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
+ //Register the cubit_factory name with the IDL_Cubit Naming Context...
+ CosNaming::Name factory_name (1);
+ factory_name.length (1);
+ factory_name[0].id = CORBA::string_dup ("cubit_factory");
+ cubit_context->bind (factory_name,obj.in (), TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
poa_manager->activate (TAO_TRY_ENV);
TAO_CHECK_ENV;