3 namespace CosNotifyCommImpl
{
4 class StructuredPushSupplier
: public virtual POA_CosNotifyComm:: StructuredPushSupplier
7 void disconnect_structured_push_supplier()
9 void subscription_change( const CosNotification::EventTypeSeq
&,
10 const CosNotification::EventTypeSeq
&)
16 int ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
20 PortableServer::POAManager_var poa_manager
;
22 CORBA::ORB_var orb
= CORBA::ORB_init(argc
, argv
);
24 CORBA::Object_var poa_obj
= orb
->resolve_initial_references("RootPOA");
25 PortableServer::POA_var root_poa
= PortableServer::POA::_narrow(poa_obj
.in());
27 poa_manager
= root_poa
->the_POAManager();
29 poa_manager
->activate();
32 std::cout
<< "Create event_channel now" << std::endl
;
33 CosNotifyChannelAdmin::EventChannel_var ec
= get_event_channel(orb
.in());
35 //Instanciating the Supplier
36 CosNotifyComm::StructuredPushSupplier_var sps
=
37 CosNotifyComm::StructuredPushSupplier::_nil();
40 CosNotifyCommImpl::StructuredPushSupplier
*pImpl_sps
= new CosNotifyCommImpl::StructuredPushSupplier
;
41 sps
= pImpl_sps
->_this();
43 //Obtain a Supplier Admin
44 CosNotifyChannelAdmin::SupplierAdmin_var sa
= ec
->default_supplier_admin();
45 if( sa
.in() == CosNotifyChannelAdmin::SupplierAdmin::_nil() ){
46 std::cerr
<< "sa is nil!" << std::endl
;
50 //Obtain a Proxy Consumer
51 CosNotifyChannelAdmin::ProxyID proxy_id
;
52 CosNotifyChannelAdmin::ClientType ctype
= CosNotifyChannelAdmin::STRUCTURED_EVENT
;
54 CosNotifyChannelAdmin::ProxyConsumer_var proxyCon_obj
;
57 proxyCon_obj
= sa
->obtain_notification_push_consumer(ctype
, proxy_id
);
59 catch(const CosNotifyChannelAdmin::AdminLimitExceeded
&)
61 std::cerr
<< "CosNotifyChannelAdmin::AdminLimitExceeded Exception!" << std::endl
;
65 CosNotifyChannelAdmin::StructuredProxyPushConsumer_var ppc
=
66 CosNotifyChannelAdmin::StructuredProxyPushConsumer::_narrow(proxyCon_obj
.in());
68 //Connecting a Supplier to a Proxy Consumer
71 ppc
->connect_structured_push_supplier(sps
.in());
73 catch (const CosEventChannelAdmin::AlreadyConnected
&)
75 std::cerr
<< "CosEventChannelAdmin::AlreadyConnected" << std::endl
;
78 catch (const CORBA::SystemException
& se
)
80 std::cerr
<< "System exception occurred during connect: " <<
86 //Demo::demo_send_heart_beat(ppc);
87 //Send a Demo Notification
89 CosNotification::StructuredEvent event
;
91 event
.header
.fixed_header
.event_type
.domain_name
=
92 CORBA::string_dup("Test_domain");
93 event
.header
.fixed_header
.event_type
.type_name
=
94 CORBA::string_dup("Test_type_name");
96 event
.header
.variable_header
.length(0);
97 event
.remainder_of_body
<<= "";
99 std::cout
<< "Sending a demo event...," << std::endl
;
100 std::cout
<< "event.header.fixed_header.event_type.domain_name = "
101 << event
.header
.fixed_header
.event_type
.domain_name
103 std::cout
<< "event.header.fixed_header.event_type.type_name = "
104 << event
.header
.fixed_header
.event_type
.type_name
109 ppc
->push_structured_event(event
);
111 catch (const CORBA::SystemException
& se
)
113 std::cerr
<< "System exception occurred during push: "
117 catch (const CORBA::Exception
&)
119 std::cerr
<< "Unknown exception occurred during push" << std::endl
;
124 ppc
->disconnect_structured_push_consumer();
126 catch(CORBA::Exception
&)
128 std::cerr
<< "Disconnect fail!" << std::endl
;
132 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("Supplier done.\n")));
136 std::cerr
<< "Supplier: Some exceptions was caught!" << std::endl
;