Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / orbsvcs / tests / Notify / Bug_3688b_Regression / server.cpp
blob2f61282b07dbd2b956313e88f0f1e4e0866eaeee
1 #include "ace/Service_Config.h"
2 #include "orbsvcs/Notify_Service/Notify_Service.h"
3 #include "orbsvcs/CosNotifyChannelAdminC.h"
4 #include "orbsvcs/CosNamingC.h"
6 #include "DllORB.h"
7 #include "TestListener.h"
8 #include "TestBroadcaster.h"
10 ACE_TCHAR const * const scpc_loadOrb = ACE_DYNAMIC_VERSIONED_SERVICE_DIRECTIVE(
11 "testDllOrb",
12 "bug3688",
13 TAO_VERSION,
14 "_make_DllORB",
15 "testDllOrb -ORBDebugLevel 0 -ORBId testDllOrb -ORBDottedDecimalAddresses 1 -ORBInitRef NameService=file://naming.ior"
18 ACE_TCHAR const * const scpc_unloadOrb = ACE_REMOVE_SERVICE_DIRECTIVE("testDllOrb");
20 ACE_TCHAR const * const scpc_loadNameService = ACE_DYNAMIC_VERSIONED_SERVICE_DIRECTIVE(
21 "testNamingService",
22 "TAO_CosNaming_Serv",
23 TAO_VERSION,
24 "_make_TAO_Naming_Loader",
25 "testNameService testNameService -ORBId testDllOrb -m 0 -o naming.ior"
28 ACE_TCHAR const * const scpc_unloadNameService = ACE_REMOVE_SERVICE_DIRECTIVE("testNamingService");
31 ACE_TCHAR const * const scpc_loadNotifyService = ACE_DYNAMIC_VERSIONED_SERVICE_DIRECTIVE(
32 "testNotifyService",
33 "TAO_Notify_Service",
34 TAO_VERSION,
35 "_make_TAO_Notify_Service_Driver",
36 "-Channel -ChannelName Channel1 -ChannelName Channel2 -RunThreads 1 -ORBInitRef NameService=file://naming.ior -IORoutput notify.ior"
39 ACE_TCHAR const * const scpc_unloadNotifyService = ACE_REMOVE_SERVICE_DIRECTIVE("testNotifyService");
42 int publish()
44 int result = 0;
46 ACE_DEBUG((
47 LM_INFO,
48 ACE_TEXT ("(%P|%t) publish ...\n")
49 ));
51 DllORB * p_orb = ACE_Dynamic_Service<DllORB>::instance ("testDllOrb");
52 CORBA::ORB_var v_orb = p_orb->orb();
54 TestBroadcaster testBroadcaster;
56 testBroadcaster.connect(
57 v_orb.in(),
58 "corbaname:rir:#Channel1");
60 TestListener testListener(
61 v_orb.in(),
62 "corbaname:rir:#Channel1",
63 "$data == 1 or "
64 "$data == 2 or "
65 "$data == 4"
68 testBroadcaster.sendData();
71 ACE_DEBUG((
72 LM_INFO,
73 ACE_TEXT ("(%P|%t) testListener.m_receivedData.size()=%d\n"),
74 testListener.m_receivedData.size()
75 ));
77 result = testListener.m_receivedData.size() == 3 ? 0 : testListener.m_receivedData.size();
79 ACE_DEBUG((
80 LM_INFO,
81 ACE_TEXT ("(%P|%t) publish done\n")
82 ));
84 return result;
87 int loadunloadcycle()
89 int publish_result = 0;
91 ACE_DEBUG((
92 LM_DEBUG,
93 ACE_TEXT ("(%P|%t) loadunloadcycle - loading\n")
94 ));
96 int result = ACE_Service_Config::process_directive(scpc_loadOrb);
97 ACE_DEBUG((
98 LM_DEBUG,
99 ACE_TEXT ("(%P|%t) loadunloadcycle - loading ORB done. Result: <%d>\n"),
100 result
103 DllORB * p_orb =
104 ACE_Dynamic_Service<DllORB>::instance("testDllOrb");
106 CORBA::ORB_var v_orb = p_orb->orb();
107 ACE_DEBUG((
108 LM_DEBUG,
109 ACE_TEXT ("(%P|%t) loadunloadcycle - v_orb OK\n")
112 CORBA::Object_var v_poa =
113 v_orb->resolve_initial_references("RootPOA");
114 ACE_DEBUG((
115 LM_DEBUG,
116 ACE_TEXT ("(%P|%t) loadunloadcycle - v_poa OK\n")
119 PortableServer::POA_var v_rootPOA =
120 PortableServer::POA::_narrow(v_poa.in ());
121 ACE_DEBUG((
122 LM_DEBUG,
123 ACE_TEXT ("(%P|%t) loadunloadcycle - v_rootPOA OK\n")
126 result = ACE_Service_Config::process_directive(scpc_loadNameService);
127 ACE_DEBUG((
128 LM_DEBUG,
129 ACE_TEXT ("(%P|%t) loadunloadcycle - loading NamingService done. Result: <%d>\n"),
130 result
133 result = ACE_Service_Config::process_directive(scpc_loadNotifyService);
134 ACE_DEBUG((
135 LM_DEBUG,
136 ACE_TEXT ("(%P|%t) loadunloadcycle - loading NotifyService done. Result: <%d>\n"),
137 result
140 publish_result = publish();
142 ACE_DEBUG((
143 LM_DEBUG,
144 ACE_TEXT ("(%P|%t) loadunloadcycle - unloading\n")
147 ACE_DEBUG((
148 LM_DEBUG,
149 ACE_TEXT ("(%P|%t) loadunloadcycle - unloading NotifyService ...\n")
151 result = ACE_Service_Config::process_directive(scpc_unloadNotifyService);
152 ACE_DEBUG((
153 LM_DEBUG,
154 ACE_TEXT ("(%P|%t) loadunloadcycle - unloading NotifyService done. Result: <%d>\n"),
155 result
158 ACE_DEBUG((
159 LM_DEBUG,
160 ACE_TEXT ("(%P|%t) loadunloadcycle - unloading NameService ...\n")
162 result = ACE_Service_Config::process_directive(scpc_unloadNameService);
163 ACE_DEBUG((
164 LM_DEBUG,
165 ACE_TEXT ("(%P|%t) loadunloadcycle - unloading NameService done. Result: <%d>\n"),
166 result
169 ACE_DEBUG((
170 LM_DEBUG,
171 ACE_TEXT ("(%P|%t) loadunloadcycle - unloading ORB ...\n")
173 result = ACE_Service_Config::process_directive(scpc_unloadOrb);
174 ACE_DEBUG((
175 LM_DEBUG,
176 ACE_TEXT ("(%P|%t) loadunloadcycle - unloading ORB done. Result: <%d>\n"),
177 result
180 return publish_result;
183 int ACE_TMAIN (int , ACE_TCHAR **)
185 ACE_DEBUG((
186 LM_DEBUG,
187 ACE_TEXT ("(%P|%t) main - entered\n")
190 ACE_DEBUG((
191 LM_DEBUG,
192 ACE_TEXT ("(%P|%t) main - cycle ...\n")
195 int result = loadunloadcycle();
197 ACE_DEBUG((
198 LM_DEBUG,
199 ACE_TEXT ("(%P|%t) main - cycle done\n")
202 ACE_DEBUG((
203 LM_DEBUG,
204 ACE_TEXT ("(%P|%t) main - leaving\n")
207 return result;