2 #include "ace/OS_NS_unistd.h"
3 #include "ace/Thread.h"
6 #include "tao/IORManipulation/IORManip_Loader.h"
10 ACE_THR_FUNC_RETURN
RunFunc(void *)
12 ACE_DEBUG ((LM_DEBUG
, "running the _orb\n"));
14 ACE_DEBUG ((LM_DEBUG
, "done running _orb\n"));
18 int ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
23 _orb
= CORBA::ORB_init (argc
, argv
);
26 CORBA::Object_var obj
= _orb
->resolve_initial_references("RootPOA");
27 PortableServer::POA_var poa
= PortableServer::POA::_narrow(obj
.in ());
29 // activate its managers so it can handle incoming requests
30 poa
->the_POAManager()->activate();
32 // get a thread going to handle incoming requests
33 ACE_Thread::spawn(RunFunc
);
35 // we could also use the c_orbaloc syntax to get a reference to the
36 // object. This will cause the _orb to talk directly to the other
37 // _orb with no name service or common file involved.
38 obj
= _orb
->string_to_object("c_orbaloc::localhost:9999/Simple");
40 if (CORBA::is_nil(obj
.in ()))
42 ACE_ERROR ((LM_ERROR
, "could not get reference\n"));
46 // narrow the reference to the particular type we wish to deal with
47 Simple_var simple
= Simple::_narrow(obj
.in ());
48 if (CORBA::is_nil(simple
.in ()))
50 ACE_ERROR ((LM_ERROR
, "could not get reference\n"));
54 // create an object reference that has a bogus value for the first
56 obj
= _orb
->resolve_initial_references("IORManipulation");
57 TAO_IOP::TAO_IOR_Manipulation_var iorm
=
58 TAO_IOP::TAO_IOR_Manipulation::_narrow(obj
.in());
60 // Status: The following scenarios appear to work:
61 // - first profile invalid host name, second profile valid.
62 // - first profile invalid ip number, second profiel valid.
63 // - first profiel invalid port number, second profile valid.
65 // The following causes a core dump of the server:
66 // - first and second invalid
68 // Note that he iormanip is being used since it is not practical
69 // to have a test case that depends on a VPN being present.
71 CORBA::Object_var name1
=
72 _orb
->string_to_object ("c_orbaloc:iiop:10.0.2.3:6060/xyz");
73 CORBA::Object_var name2
=
74 _orb
->string_to_object ("c_orbaloc:iiop:daisnot:7070/xyz");
75 CORBA::String_var name1_ior
= _orb
->object_to_string(name1
.in());
76 CORBA::String_var name2_ior
= _orb
->object_to_string(name2
.in());
78 // create a callback object
79 Callee_i
* callee_i
= new Callee_i
;
80 // get the CORBA reference
81 PortableServer::ObjectId_var id
=
82 poa
->activate_object (callee_i
);
84 CORBA::Object_var object_act
= poa
->id_to_reference (id
.in ());
86 Callee_var callee
= Callee::_narrow (object_act
.in ());
88 if (CORBA::is_nil(callee
.in ()))
90 ACE_ERROR ((LM_ERROR
, "could not get callback object\n"));
95 CORBA::String_var str
= _orb
->object_to_string(callee
.in ());
96 FILE *output_file
= ACE_OS::fopen ("ior", "w");
98 ACE_ERROR_RETURN ((LM_ERROR
,
99 "Cannot open output file for writing IOR: ior\n"),
101 ACE_OS::fprintf (output_file
, "%s", str
.in ());
102 ACE_OS::fclose (output_file
);
105 // create a reference with two profiles with the first on being
106 // bogus. If things work as they should the callback should be
107 // succesful with the ORB trying the second profile.
108 TAO_IOP::TAO_IOR_Manipulation::IORList
iors (2);
113 CORBA::Object_var merged
= iorm
->merge_iors(iors
);
114 Callee_var doubleCallee
= Callee::_unchecked_narrow(merged
.in());
116 ACE_DEBUG ((LM_DEBUG
, "Profile count is %d\n",
117 iorm
->get_profile_count(merged
.in())));
119 simple
->registerCallee(doubleCallee
.in ());
123 ACE_DEBUG ((LM_DEBUG
, "done sleeping\n"));
127 catch (const ::CORBA::Exception
&ex
)
129 ex
._tao_print_exception("Caught unexpected CORBA exception :");