2 #include "tao/IORTable/IORTable.h"
5 void advertise(CORBA::ORB_ptr orb
, CORBA::Object_ptr obj
)
7 // advertise our object in the IORTable so that it can be
8 // accessed by a client using the "cobaloc" syntax
9 CORBA::String_var str
= orb
->object_to_string(obj
);
10 CORBA::Object_var tmp
= orb
->resolve_initial_references("IORTable");
11 IORTable::Table_var iorTable
= IORTable::Table::_narrow(tmp
.in ());
12 if (CORBA::is_nil(iorTable
.in ()))
14 ACE_ERROR ((LM_ERROR
, "could not get the IORTable, will not register\n"));
18 iorTable
->rebind("Simple", str
.in());
19 ACE_DEBUG ((LM_DEBUG
, "regisered\n"));
21 // we could also advertise the object reference to a naming and/or
25 int ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
29 // Initialize the orb.
30 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
33 CORBA::Object_var obj
= orb
->resolve_initial_references("RootPOA");
34 PortableServer::POA_var poa
= PortableServer::POA::_narrow(obj
.in ());
36 // activate its managers so it can handle incoming requests
37 poa
->the_POAManager()->activate();
39 // Create a CORBA object that can be called by a client. Note that
40 // this does not create the CORBA object. It creates the object
41 // that does the real work behind the CORBA object.
42 Simple_i
* simple
= new Simple_i(orb
.in ());
44 // This call creates the CORBA object and returns a reference to
45 // it. It uses the "RootPOA" for dispatching its calls. There are
46 // a number of ways this can be done different. Refer to "Advanced
47 // CORBA Programming with C++" chapter 11 for more information.
48 PortableServer::ObjectId_var id
=
49 poa
->activate_object (simple
);
51 CORBA::Object_var object_act
= poa
->id_to_reference (id
.in ());
53 Simple_var simpleRef
= Simple::_narrow (object_act
.in ());
55 advertise(orb
.in(), simpleRef
.in());
57 // give the ORB control for only 30 seconds
58 ACE_DEBUG ((LM_DEBUG
, "run orb\n"));
59 for (int i
= 0; i
< 1000; ++i
) {
60 ACE_Time_Value
runTime(3);
62 for (int i
= 0; i
< 10000000; ++i
) {}
65 ACE_DEBUG ((LM_DEBUG
, "done running\n"));
71 catch (const CORBA::Exception
& ex
)
73 ex
._tao_print_exception ("Exception caught:");