Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / orbsvcs / tests / Notify / Bug_3252_Regression / server.cpp
bloba766af31cb0ba19a5b296fce88ace26fe0415c3b
1 #include "ace/ARGV.h"
2 #include "ace/Service_Config.h"
3 #include "ace/Log_Msg.h"
5 #include "tao/corba.h"
6 #include "tao/ORB.h"
7 #include "tao/PortableServer/PortableServer.h"
8 #include "orbsvcs/CosNotifyChannelAdminC.h"
9 #include "orbsvcs/Notify/CosNotify_Service.h"
11 #include "DllOrb.h"
13 ACE_TCHAR const * const scpc_loadOrb = ACE_DYNAMIC_VERSIONED_SERVICE_DIRECTIVE(
14 "testDllOrb",
15 "Bug_3252",
16 TAO_VERSION,
17 "_make_DllOrb",
18 "testDllOrb -ORBDebugLevel 0 -ORBId testDllOrb -NumThreads 2 -ORBDottedDecimalAddresses 1 -ORBCollocationStrategy thru_poa"
21 ACE_TCHAR const * const scpc_unloadOrb = ACE_REMOVE_SERVICE_DIRECTIVE("testDllOrb");
23 ACE_TCHAR const * const scpc_loadNotifyService = ACE_DYNAMIC_VERSIONED_SERVICE_DIRECTIVE(
24 "testNotifyService",
25 "TAO_CosNotification_Serv",
26 TAO_VERSION,
27 "_make_TAO_CosNotify_Service",
28 "-UseSeparateDispatchingORB 1"
31 ACE_TCHAR const * const scpc_unloadNotifyService = ACE_REMOVE_SERVICE_DIRECTIVE("testNotifyService");
33 int
34 unloadNotify(ACE_Service_Config & service_config)
36 ACE_DEBUG ((LM_INFO, ACE_TEXT ("Unloading NotifyService ...\n")));
37 if(service_config.process_directive(scpc_unloadNotifyService) != 0)
39 ACE_ERROR ((LM_ERROR, ACE_TEXT ("Unloading NotifyService failed\n")));
40 return -1;
42 ACE_DEBUG ((LM_INFO, ACE_TEXT ("unloading NotifyService done.\n")));
43 return 0;
46 int
47 loadNotify(ACE_Service_Config & service_config)
49 try
51 DllOrb * p_orb = ACE_Dynamic_Service<DllOrb>::instance ("testDllOrb");
52 CORBA::ORB_var v_orb = p_orb->orb();
54 CORBA::Object_var v_poa = v_orb->resolve_initial_references("RootPOA");
55 PortableServer::POA_var v_rootPOA = PortableServer::POA::_narrow(v_poa.in ());
56 ACE_DEBUG ((LM_INFO, ACE_TEXT ("RootPOA OK.\n")));
58 ACE_DEBUG ((LM_INFO, ACE_TEXT ("Loading NotifyService ...\n")));
59 if(0 != service_config.process_directive(scpc_loadNotifyService))
61 ACE_ERROR ((LM_ERROR, ACE_TEXT ("Loading NotifyService failed\n")));
62 return -1;
64 ACE_DEBUG ((LM_INFO, ACE_TEXT ("Loading NotifyService done.\n")));
66 TAO_CosNotify_Service * p_notifyService =
67 ACE_Dynamic_Service<TAO_CosNotify_Service>::instance("testNotifyService");
69 p_notifyService->init_service(v_orb.in());
71 CosNotifyChannelAdmin::EventChannelFactory_var v_notifyFactory =
72 p_notifyService->create(v_rootPOA.in());
73 ACE_DEBUG ((LM_INFO, ACE_TEXT ("got EventChannelFactory\n")));
75 // create an event channel
76 CosNotifyChannelAdmin::ChannelID id;
78 CosNotification::QoSProperties initialQos;
79 CosNotification::AdminProperties initialAdmin;
81 CosNotifyChannelAdmin::EventChannel_var v_eventChannel =
82 v_notifyFactory->create_channel(
83 initialQos,
84 initialAdmin,
85 id);
86 ACE_DEBUG ((LM_INFO, ACE_TEXT ("got EventChannel\n")));
88 CosNotifyFilter::FilterFactory_var v_filterFactory =
89 v_eventChannel->default_filter_factory();
90 ACE_DEBUG ((LM_INFO, ACE_TEXT ("got FilterFactory\n")));
92 CosNotifyFilter::Filter_var v_filter =
93 v_filterFactory->create_filter("ETCL");
94 ACE_DEBUG ((LM_INFO, ACE_TEXT ("got Filter\n")));
96 catch(CORBA::Exception const & rc_ex)
98 rc_ex._tao_print_exception ("Unexpected CORBA Exception: ");
99 return -1;
101 catch(...)
103 ACE_ERROR ((LM_ERROR, ACE_TEXT ("Unexpected C++ Exception\n")));
104 return -1;
107 return 0;
111 int unloadOrb(ACE_Service_Config & service_config)
113 ACE_DEBUG ((LM_INFO, ACE_TEXT ("Unloading ORB ...\n")));
114 if(0 != service_config.process_directive(scpc_unloadOrb))
116 ACE_ERROR ((LM_ERROR, ACE_TEXT ("Unloading ORB failed\n")));
117 return -1;
119 ACE_DEBUG ((LM_INFO, ACE_TEXT ("unloading ORB done.\n")));
120 return 0;
123 int loadOrb(ACE_Service_Config & service_config)
125 ACE_DEBUG ((LM_INFO, ACE_TEXT ("Loading ORB ...\n")));
126 if(0 != service_config.process_directive(scpc_loadOrb))
128 ACE_ERROR ((LM_ERROR, ACE_TEXT ("Loading ORB failed\n")));
129 return -1;
131 ACE_DEBUG ((LM_INFO, ACE_TEXT ("Loading ORB done.\n")));
132 return 0;
137 ACE_TMAIN(int, ACE_TCHAR **argv)
139 int result = 0;
141 ACE_TCHAR signum[64];
142 ACE_OS::sprintf(signum, ACE_TEXT("%d"), SIGUSR1);
144 ACE_ARGV args;
145 args.add(argv[0]);
146 args.add(ACE_TEXT("-s"));
147 args.add(signum);
149 ACE_Service_Config &serviceConfig = *ACE_Service_Config::singleton ();
151 result = serviceConfig.open (args.argc(),
152 args.argv(),
153 ACE_DEFAULT_LOGGER_KEY,
154 true, // ignore_static_svcs = 1,
155 true, // ignore_default_svc_conf_file = 0,
156 false); // ignore_debug_flag = 0
158 if(0 != result)
160 ACE_ERROR ((LM_ERROR, ACE_TEXT ("serviceConfig.open failed\n")));
161 return result;
163 ACE_DEBUG ((LM_INFO, ACE_TEXT ("serviceConfig.open done\n")));
165 for(int i = 0; i < 5; ++i)
167 ACE_DEBUG ((LM_INFO, ACE_TEXT ("loadOrb ...\n")));
168 result = loadOrb(serviceConfig);
169 if(0 != result)
171 ACE_ERROR ((LM_ERROR, ACE_TEXT ("loadOrb failed\n")));
172 return result;
174 ACE_DEBUG ((LM_INFO, ACE_TEXT ("loadOrb done\n")));
176 ACE_DEBUG ((LM_INFO, ACE_TEXT ("loadNotify ...\n")));
177 result = loadNotify(serviceConfig);
178 if(0 != result)
180 ACE_ERROR ((LM_ERROR, ACE_TEXT ("loadNotify failed\n")));
181 return result;
183 ACE_DEBUG ((LM_INFO, ACE_TEXT ("loadNotify done\n")));
185 ACE_DEBUG ((LM_INFO, ACE_TEXT ("unloadNotify ...\n")));
186 result = unloadNotify(serviceConfig);
187 if(0 != result)
189 ACE_ERROR ((LM_ERROR, ACE_TEXT ("unloadNotify failed\n")));
190 return result;
192 ACE_DEBUG ((LM_INFO, ACE_TEXT ("unloadNotify done\n")));
194 ACE_DEBUG ((LM_INFO, ACE_TEXT ("unloadOrb ...\n")));
195 result = unloadOrb(serviceConfig);
196 if(0 != result)
198 ACE_ERROR ((LM_ERROR, ACE_TEXT ("unloadOrb failed\n")));
199 return result;
201 ACE_DEBUG ((LM_INFO, ACE_TEXT ("unloadOrb done\n")));
204 ACE_DEBUG ((LM_INFO, ACE_TEXT ("serviceConfig.fini_svcs ...\n")));
205 result = serviceConfig.fini_svcs();
206 if(0 != result)
208 ACE_ERROR ((LM_ERROR, ACE_TEXT ("serviceConfig.fini_svcs failed\n")));
209 return result;
211 ACE_DEBUG ((LM_INFO, ACE_TEXT ("serviceConfig.fini_svcs done\n")));
213 ACE_DEBUG ((LM_INFO, ACE_TEXT ("serviceConfig.close ...\n")));
214 result = serviceConfig.close();
215 if(0 != result)
217 ACE_ERROR ((LM_ERROR, ACE_TEXT ("serviceConfig.close failed\n")));
218 return result;
220 ACE_DEBUG ((LM_INFO, ACE_TEXT ("serviceConfig.close done\n")));
222 return 0;