2 #include "Stock_Consumer.h"
3 #include <orbsvcs/CosNamingC.h>
4 #include "ace/streams.h"
6 int ACE_TMAIN (int argc
, ACE_TCHAR
* argv
[])
9 // First initialize the ORB, that will remove some arguments...
11 CORBA::ORB_init (argc
, argv
);
12 CORBA::Object_var poa_object
=
13 orb
->resolve_initial_references ("RootPOA");
14 PortableServer::POA_var poa
=
15 PortableServer::POA::_narrow (poa_object
.in ());
16 PortableServer::POAManager_var poa_manager
=
17 poa
->the_POAManager ();
18 poa_manager
->activate ();
20 CORBA::Object_var naming_context_object
=
21 orb
->resolve_initial_references ("NameService");
22 CosNaming::NamingContext_var naming_context
=
23 CosNaming::NamingContext::_narrow (naming_context_object
.in ());
25 CosNaming::Name
name (1);
27 name
[0].id
= CORBA::string_dup ("CosEventService");
29 CORBA::Object_var ec_object
=
30 naming_context
->resolve (name
);
32 // Now downcast the object reference to the appropriate type
33 CosEventChannelAdmin::EventChannel_var ec
=
34 CosEventChannelAdmin::EventChannel::_narrow (ec_object
.in ());
36 Stock_Consumer stock_consumer_i
;
37 stock_consumer_i
.connect (ec
.in ());
41 stock_consumer_i
.disconnect ();
43 poa
->destroy (true, true);
46 catch (const CORBA::Exception
&) {
47 cerr
<< "CORBA exception raised!" << endl
;