1 #include "Counting_Consumer.h"
2 #include "Counting_Supplier.h"
3 #include "orbsvcs/CosEvent/CEC_EventChannel.h"
4 #include "orbsvcs/CosEvent/CEC_Default_Factory.h"
6 static void run_test (PortableServer::POA_ptr poa
,
10 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
12 TAO_CEC_Default_Factory::init_svcs ();
16 // ORB initialization boiler plate...
18 CORBA::ORB_init (argc
, argv
);
20 CORBA::Object_var object
=
21 orb
->resolve_initial_references ("RootPOA");
22 PortableServer::POA_var poa
=
23 PortableServer::POA::_narrow (object
.in ());
24 PortableServer::POAManager_var poa_manager
=
25 poa
->the_POAManager ();
26 poa_manager
->activate ();
28 // ****************************************************************
30 run_test (poa
.in (), 0);
32 run_test (poa
.in (), 1);
34 // ****************************************************************
36 poa
->destroy (true, true);
40 catch (const CORBA::Exception
& ex
)
42 ex
._tao_print_exception ("Service");
49 deactivate_servant (PortableServer::Servant servant
)
51 PortableServer::POA_var poa
=
52 servant
->_default_POA ();
53 PortableServer::ObjectId_var id
=
54 poa
->servant_to_id (servant
);
55 poa
->deactivate_object (id
.in ());
59 run_test (PortableServer::POA_ptr poa
,
62 TAO_CEC_EventChannel_Attributes
attributes (poa
,
64 attributes
.disconnect_callbacks
= with_callbacks
;
66 TAO_CEC_EventChannel
ec_impl (attributes
);
69 CosEventChannelAdmin::EventChannel_var event_channel
=
72 // ****************************************************************
74 // Obtain the consumer admin..
75 CosEventChannelAdmin::ConsumerAdmin_var consumer_admin
=
76 event_channel
->for_consumers ();
78 // Obtain the supplier admin..
79 CosEventChannelAdmin::SupplierAdmin_var supplier_admin
=
80 event_channel
->for_suppliers ();
82 // ****************************************************************
84 CEC_Counting_Consumer
**consumer
= 0;
85 CEC_Counting_Supplier
**supplier
= 0;
88 ACE_NEW (consumer
, CEC_Counting_Consumer
*[n
]);
89 ACE_NEW (supplier
, CEC_Counting_Supplier
*[n
]);
92 for (i
= 0; i
!= n
; ++i
)
94 char consumer_name
[64];
95 ACE_OS::sprintf (consumer_name
, "Consumer/%4.4d", i
);
97 CEC_Counting_Consumer (consumer_name
));
99 ACE_NEW (supplier
[i
], CEC_Counting_Supplier ());
102 for (i
= 0; i
!= n
; ++i
)
104 consumer
[i
]->connect (consumer_admin
.in ());
106 supplier
[i
]->connect (supplier_admin
.in ());
109 // ****************************************************************
111 // Destroy the event channel, *before* disconnecting the
113 event_channel
->destroy ();
115 // ****************************************************************
117 for (i
= 0; i
!= n
; ++i
)
119 if (consumer
[i
]->disconnect_count
!= 1)
120 ACE_DEBUG ((LM_DEBUG
,
122 "disconnect count (%d) in Consumer/%04.4d\n",
123 consumer
[i
]->disconnect_count
,
126 if (supplier
[i
]->disconnect_count
!= 1)
127 ACE_DEBUG ((LM_DEBUG
,
129 "disconnect count (%d) in Supplier/%04.4d\n",
130 supplier
[i
]->disconnect_count
,
134 // ****************************************************************
136 for (i
= 0; i
!= n
; ++i
)
138 deactivate_servant (supplier
[i
]);
141 deactivate_servant (consumer
[i
]);
147 deactivate_servant (&ec_impl
);