1 #include "tao/Strategies/advanced_resource.h"
4 #include "Stock_QuoterC.h"
6 #include "ace/streams.h"
9 class OrbTask
: public ACE_Task_Base
12 OrbTask(const CORBA::ORB_ptr orb
)
13 : orb_(CORBA::ORB::_duplicate(orb
))
23 catch (const CORBA::Exception
&)
33 static int n_threads
= 1;
35 unsigned char Msg
[1000] = { 0 } ;
37 int ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
42 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
44 // Use a simple ObjectKey to access the Stock Quoter.
45 // (Client ORB must be initialized with
46 // -ORBInitRef MyStockQuoter=corbaloc:...)
47 CORBA::Object_var udp_obj
=
48 orb
->resolve_initial_references ("UDPTest");
50 CORBA::Object_var stock_quoter_obj
=
51 orb
->resolve_initial_references ("MyStockQuoter");
53 OrbTask
task(orb
.in());
55 if (task
.activate (THR_NEW_LWP
| THR_JOINABLE
,
57 ACE_ERROR_RETURN ((LM_ERROR
,
58 "Cannot activate threads\n"),
61 UDPTestI_var server
= UDPTestI::_narrow (udp_obj
.in ());
63 Stock_Quoter_var quoter
= Stock_Quoter::_narrow (stock_quoter_obj
.in());
65 memset( Msg
, 1, 1000 ) ;
72 CORBA::Float current_stock_price
= quoter
->get_quote ("BA");
73 cout
<< "Stock Id: BA, Price = " << current_stock_price
<< endl
;
75 catch (Bad_Ticker_Symbol
& e
)
77 cerr
<< "Caught a bad ticker symbol exception: "
87 catch (const CORBA::Exception
& e
)
89 e
._tao_print_exception ("Exception caught:");