2 //=============================================================================
4 * @file CC_naming_service.cpp
6 * This class implements the naming services necessary to test the
9 * @author Torben Worm <tworm@cs.wustl.edu>
11 //=============================================================================
14 #include "CC_naming_service.h"
15 #include "ace/OS_NS_string.h"
16 #include "ace/Log_Msg.h"
20 CC_naming_service::CC_naming_service (CORBA::ORB_var orb
)
21 : cc_factory_key_ (0),
30 CC_naming_service::CC_naming_service(void)
31 : cc_factory_key_ (0),
38 CC_naming_service::Init(CORBA::ORB_var orb
)
42 int success
= init_naming_service ();
44 throw CORBA::INTERNAL ();
47 CC_naming_service::~CC_naming_service (void)
51 // @TAO somthing went wrong when these lines were uncommented
55 CC_naming_service::Instance(void)
59 instance_
= new CC_naming_service();
65 CC_naming_service::get_obj_from_name (const char *c_name
,
68 ACE_DEBUG ((LM_DEBUG
, "C: %s, N: %s\n", c_name
, name
));
69 CORBA::Object_var obj
;
73 if (ACE_OS::strlen (c_name
) == 0)
75 CosNaming::Name
ns_name (1);
77 ns_name
[0].id
= CORBA::string_dup (name
);
78 obj
= my_name_client_
->resolve (ns_name
);
82 CosNaming::Name
ns_name (2);
84 ns_name
[0].id
= CORBA::string_dup (c_name
);
85 ns_name
[1].id
= CORBA::string_dup (name
);
86 obj
= my_name_client_
->resolve (ns_name
);
88 if (CORBA::is_nil (obj
.in ()) )
90 "OBJ was nill (aieee)\n"));
92 catch (const CORBA::Exception
& ex
)
94 ex
._tao_print_exception ("CC_Client::get_obj_from_name (...)");
102 CC_naming_service::bind_name (const char *n
,
103 CORBA::Object_ptr obj
)
105 ACE_DEBUG ((LM_DEBUG
, "CC_Client::bind_name\n"));
109 CosNaming::Name
ns_name (1);
111 ns_name
[0].id
= CORBA::string_dup (n
);
112 my_name_client_
->bind (ns_name
,
115 catch (const CORBA::Exception
& ex
)
117 ex
._tao_print_exception ("CC_Client::bind_name (...)");
121 CosConcurrencyControl::LockSetFactory_var
122 CC_naming_service::get_lock_set_factory (void)
124 return this->factory_
;
128 CC_naming_service::init_naming_service (void)
132 // Initialize the naming services
133 if (my_name_client_
.init (orb_
.in ()) != 0)
134 ACE_ERROR_RETURN ((LM_ERROR
,
135 " (%P|%t) Unable to initialize "
136 "the TAO_Naming_Client.\n"),
139 CORBA::Object_var factory_obj
= get_obj_from_name ("CosConcurrency",
143 CosConcurrencyControl::LockSetFactory::_narrow
146 if (CORBA::is_nil (this->factory_
.in ()))
147 ACE_ERROR_RETURN ((LM_ERROR
,
148 " could not resolve lock set factory in Naming service\n"),
151 catch (const CORBA::Exception
& ex
)
153 ex
._tao_print_exception ("CC_Client::init_naming_service");
160 CC_naming_service
* CC_naming_service::instance_
= 0;