=default for generated implementation copy ctor
[ACE_TAO.git] / TAO / examples / Content_Server / AMI_Observer / server.cpp
blob4230647087041cd178fdcb3190acee6227c8a5d9
1 // -*- C++ -*-
2 // Ossama Othman <ossama@uci.edu>
4 #include "orbsvcs/CosNamingC.h"
5 #include "Push_Web_ServerS.h"
6 #include "Push_Iterator_Factory_i.h"
8 int
9 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
11 try
13 // Initialize the ORB.
14 CORBA::ORB_var orb = CORBA::ORB_init (argc,
15 argv,
16 "Mighty ORB");
18 // Get the Root POA.
19 CORBA::Object_var obj =
20 orb->resolve_initial_references ("RootPOA");
22 PortableServer::POA_var poa =
23 PortableServer::POA::_narrow (obj.in ());
25 // Activate the POA manager.
26 PortableServer::POAManager_var mgr = poa->the_POAManager ();
27 mgr->activate ();
29 // Create the Iterator_Factory servant and object.
30 Push_Iterator_Factory_i factory_servant;
31 Web_Server::Iterator_Factory_var factory =
32 factory_servant._this ();
34 // Get a reference to the Name Service.
35 obj = orb->resolve_initial_references ("NameService");
37 // Narrow to a Naming Context
38 CosNaming::NamingContext_var nc =
39 CosNaming::NamingContext::_narrow (obj.in ());
41 // Create a name.
42 CosNaming::Name name;
43 name.length (1);
44 name[0].id = CORBA::string_dup ("Push_Iterator_Factory");
45 name[0].kind = CORBA::string_dup ("");
47 nc->bind (name, factory.in ());
49 // Some debugging output.
50 CORBA::String_var IOR = orb->object_to_string (factory.in ());
51 ACE_DEBUG ((LM_DEBUG,
52 ACE_TEXT ("Bound <%s> to <%s> in Name Service.\n"),
53 name[0].id.in (),
54 IOR.in ()));
56 ACE_DEBUG ((LM_INFO,
57 ACE_TEXT ("Accepting requests.\n")));
59 // Accept requests.
60 orb->run ();
62 catch (const CORBA::Exception& ex)
64 ex._tao_print_exception (ACE_TEXT ("Caught unexpected exception:"));
66 return -1;
69 return 0;