Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / orbsvcs / tests / Notify / Bug_1884_Regression / supplier.cpp
blob172a6306ad4d85a82fd7728104780e7fe68fb40d
1 #include "common.h"
3 namespace CosNotifyCommImpl{
4 class StructuredPushSupplier: public virtual POA_CosNotifyComm:: StructuredPushSupplier
6 public:
7 void disconnect_structured_push_supplier()
8 {};
9 void subscription_change( const CosNotification::EventTypeSeq&,
10 const CosNotification::EventTypeSeq&)
11 {};
16 int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
18 try
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();
31 /*Get event_channel*/
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;
47 return 1;
50 //Obtain a Proxy Consumer
51 CosNotifyChannelAdmin::ProxyID proxy_id;
52 CosNotifyChannelAdmin::ClientType ctype = CosNotifyChannelAdmin::STRUCTURED_EVENT;
54 CosNotifyChannelAdmin::ProxyConsumer_var proxyCon_obj;
55 try
57 proxyCon_obj = sa->obtain_notification_push_consumer(ctype, proxy_id);
59 catch(const CosNotifyChannelAdmin::AdminLimitExceeded&)
61 std::cerr << "CosNotifyChannelAdmin::AdminLimitExceeded Exception!" << std::endl;
62 throw;
65 CosNotifyChannelAdmin::StructuredProxyPushConsumer_var ppc =
66 CosNotifyChannelAdmin::StructuredProxyPushConsumer::_narrow(proxyCon_obj.in());
68 //Connecting a Supplier to a Proxy Consumer
69 try
71 ppc->connect_structured_push_supplier(sps.in());
73 catch (const CosEventChannelAdmin::AlreadyConnected&)
75 std::cerr << "CosEventChannelAdmin::AlreadyConnected" << std::endl;
76 throw;
78 catch (const CORBA::SystemException& se)
80 std::cerr << "System exception occurred during connect: " <<
81 se << std::endl;
82 throw;
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
102 << std::endl;
103 std::cout << "event.header.fixed_header.event_type.type_name = "
104 << event.header.fixed_header.event_type.type_name
105 << std::endl;
108 try{
109 ppc->push_structured_event(event);
111 catch (const CORBA::SystemException& se)
113 std::cerr << "System exception occurred during push: "
114 << se << std::endl;
115 throw;
117 catch (const CORBA::Exception&)
119 std::cerr << "Unknown exception occurred during push" << std::endl;
120 throw;
123 try{
124 ppc->disconnect_structured_push_consumer();
126 catch(CORBA::Exception&)
128 std::cerr << "Disconnect fail!" << std::endl;
131 orb->shutdown();
132 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Supplier done.\n")));
134 catch(...)
136 std::cerr << "Supplier: Some exceptions was caught!" << std::endl;
137 return 1;
141 return 0;