Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / Bug_3547_Regression / Stock_Quoter_Server.cpp
blob83cc4f8df4d1f5bafe16c125dfadd96733a522ce
1 // Stock Quoter includes
2 #include "Stock_Quoter_i.h"
4 // UPDTest
5 #include "UDPTest_i.h"
7 // Advanced Resource Factory include
8 #include "tao/Strategies/advanced_resource.h"
10 // IORTable include
11 #include "tao/IORTable/IORTable.h"
12 #include "ace/streams.h"
14 int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
16 try
18 // Initialize the ORB
19 CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
21 // Get the POA from the ORB.
22 CORBA::Object_var poa_obj = orb->resolve_initial_references ("RootPOA");
24 // Narrow to the POA interface
25 PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_obj.in ());
27 // Create a Stock Quoter implementation object
28 Stock_Quoter_i* stock_quoter = new Stock_Quoter_i (orb.in ());
30 UDPTest_i* UDP = new UDPTest_i ();
32 // Activate the Stock Quoter in the RootPOA.
33 PortableServer::ObjectId_var oid = root_poa->activate_object (stock_quoter);
34 CORBA::Object_var sq_obj = root_poa->id_to_reference (oid.in());
36 PortableServer::ObjectId_var oid1 = root_poa->activate_object (UDP);
37 CORBA::Object_var udp_obj1 = root_poa->id_to_reference (oid1.in());
39 CORBA::String_var ior =
40 orb->object_to_string (udp_obj1.in ());
42 ACE_DEBUG ((LM_DEBUG, "Activated as <%C>\n", ior.in ()));
44 // Also make the Stock Quoter object available via corbaloc
45 // ObjectURL by binding it to a simple ObjectKey in the IORTable.
46 CORBA::Object_var table_obj = orb->resolve_initial_references ("IORTable");
47 IORTable::Table_var table = IORTable::Table::_narrow (table_obj.in());
48 CORBA::String_var quoter_ior_string = orb->object_to_string (sq_obj.in());
49 CORBA::String_var UDP_ior_string = orb->object_to_string (udp_obj1.in());
50 table->bind ("UDPTest", UDP_ior_string.in());
51 table->bind ("MyStockQuoter", quoter_ior_string.in());
53 // Activate the POA Manager
54 PortableServer::POAManager_var poa_mgr = root_poa->the_POAManager ();
55 poa_mgr->activate ();
57 cout << "Server ready" << endl;
58 orb->run ();
60 if (!UDP->received_send_)
62 ACE_ERROR_RETURN ((LM_ERROR, "Not received send\n"), 1);
65 catch (const CORBA::Exception& e)
67 e._tao_print_exception ("Exception caught:");
68 return 1;
71 return 0;