2 * A simple "Hello World" example that uses the POA
6 #ifdef HAVE_ANSI_CPLUSPLUS_HEADERS
16 * Hello World implementation inherits the POA skeleton class
19 class HelloWorld_impl : virtual public POA_HelloWorld
26 HelloWorld_impl::hello ()
28 cout << "Hello World" << endl;
32 main (int argc, char *argv[])
38 CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
41 * Obtain a reference to the RootPOA and its Manager
44 CORBA::Object_var poaobj = orb->resolve_initial_references ("RootPOA");
45 PortableServer::POA_var poa = PortableServer::POA::_narrow (poaobj);
46 PortableServer::POAManager_var mgr = poa->the_POAManager();
49 * Create a Hello World object
52 HelloWorld_impl * hello = new HelloWorld_impl;
55 * Activate the Servant
58 PortableServer::ObjectId_var oid = poa->activate_object (hello);
61 * Write reference to file
64 ofstream of ("hello.ref");
65 CORBA::Object_var ref = poa->id_to_reference (oid.in());
66 CORBA::String_var str = orb->object_to_string (ref.in());
67 of << str.in() << endl;
71 * Activate the POA and start serving requests
74 cout << "Running." << endl;
80 * Shutdown (never reached)
83 poa->destroy (TRUE, TRUE);