blob: df08d623bd98223145df01df275dd7379d816af4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
//
// $Id$
//
#include "orbsvcs/CosNamingC.h"
#include "tao/corba.h"
int main (int argc, char *argv[])
{
ACE_TRY_NEW_ENV
{
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, "" TAO_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
CORBA::Object_var ns_obj =
orb->resolve_initial_references ("NameService" TAO_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
if (CORBA::is_nil (ns_obj.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
"Could not resolve Naming Service"),
1);
CosNaming::NamingContext_var inc =
CosNaming::NamingContext::_narrow (ns_obj.in ()
TAO_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
if (CORBA::is_nil (inc.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
"Could not resolve Naming Service"),
1);
CosNaming::Name name;
name.length (1);
name[0].id = CORBA::string_dup ("yourself");
inc->bind (name, ns_obj.in () TAO_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
ACE_DEBUG ((LM_DEBUG, "Test Successful\n"));
}
ACE_CATCHANY
{
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Test");
return 1;
}
ACE_ENDTRY;
return 0;
}
|