Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / orbsvcs / tests / Notify / Bug_3646c_Regression / server.cpp
blob3909d532eaa833b2cb13ce8d63df2f01f5f0ac9a
1 #include "ace/Service_Config.h"
2 #include "orbsvcs/Notify_Service/Notify_Service.h"
3 #include "orbsvcs/CosNotifyChannelAdminC.h"
4 #include "orbsvcs/CosNamingC.h"
5 #include "ace/Get_Opt.h"
7 #include "DllORB.h"
9 const int max_length = 1000;
11 #if defined (ACE_USES_WCHAR)
12 # define LOAD_ORB_DIRECTIVE "testDllOrb -ORBDebugLevel 0 -ORBId testDllOrb -ORBDottedDecimalAddresses 1 -ORBInitRef NameService=iioploc://%ls:%ls/NameService"
13 #else
14 # define LOAD_ORB_DIRECTIVE "testDllOrb -ORBDebugLevel 0 -ORBId testDllOrb -ORBDottedDecimalAddresses 1 -ORBInitRef NameService=iioploc://%s:%s/NameService"
15 #endif
17 ACE_TCHAR scpc_loadOrb[max_length] = ACE_DYNAMIC_VERSIONED_SERVICE_DIRECTIVE(
18 "testDllOrb",
19 "bug3646c",
20 TAO_VERSION,
21 "_make_DllORB",
22 LOAD_ORB_DIRECTIVE
25 ACE_TCHAR const * const scpc_unloadOrb = ACE_REMOVE_SERVICE_DIRECTIVE("testDllOrb");
27 #if defined (ACE_USES_WCHAR)
28 # define LOAD_NOTIFYSVC_DIRECTIVE "-Channel -ChannelName Channel1 -ChannelName Channel2 -RunThreads 0 -ORBInitRef NameService=iioploc://%ls:%ls/NameService -IORoutput %ls"
29 #else
30 # define LOAD_NOTIFYSVC_DIRECTIVE "-Channel -ChannelName Channel1 -ChannelName Channel2 -RunThreads 0 -ORBInitRef NameService=iioploc://%s:%s/NameService -IORoutput %s"
31 #endif
33 ACE_TCHAR scpc_loadNotifyService[max_length] = ACE_DYNAMIC_VERSIONED_SERVICE_DIRECTIVE(
34 "testNotifyService",
35 "TAO_Notify_Service",
36 TAO_VERSION,
37 "_make_TAO_Notify_Service_Driver",
38 LOAD_NOTIFYSVC_DIRECTIVE
41 ACE_TCHAR const * const scpc_unloadNotifyService = ACE_REMOVE_SERVICE_DIRECTIVE("testNotifyService");
43 int
44 parse_args (int argc, ACE_TCHAR *argv[])
46 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("h:p:o:"));
47 int c;
49 ACE_TCHAR *hostname = 0;
50 ACE_TCHAR *port = 0;
51 ACE_TCHAR *ior_file = 0;
53 while ((c = get_opts ()) != -1)
54 switch (c)
56 case 'h':
57 hostname = get_opts.opt_arg ();
58 break;
59 case 'p':
60 port = get_opts.opt_arg ();
61 break;
62 case 'o':
63 ior_file = get_opts.opt_arg ();
64 break;
66 case '?':
67 default:
68 ACE_ERROR_RETURN ((LM_ERROR,
69 "usage: %s "
70 "-h <hostname> "
71 "-p <port> "
72 "-o <ior> "
73 "\n",
74 argv [0]),-1);
76 // Indicates successful parsing of the command line
77 if ( hostname == 0 || port == 0 || ior_file == 0){
78 ACE_ERROR_RETURN ((LM_ERROR,
79 "usage: %s "
80 "-h <hostname> "
81 "-p <port> "
82 "-o <ior> "
83 "\n",
84 argv [0]),-1);
87 ACE_TCHAR str[max_length];
89 ACE_OS::strcpy(str, scpc_loadNotifyService);
90 ACE_OS::sprintf(scpc_loadNotifyService, str, hostname, port, ior_file);
92 ACE_OS::strcpy(str, scpc_loadOrb);
93 ACE_OS::sprintf(scpc_loadOrb, str, hostname, port);
95 return 0;
99 void loadunloadcycle()
101 ACE_DEBUG ((LM_DEBUG,
102 ACE_TEXT ("(%P|%t) loadunloadcycle - loading\n")));
104 int result = ACE_Service_Config::process_directive(scpc_loadOrb);
105 ACE_DEBUG(( LM_DEBUG,
106 ACE_TEXT ("(%P|%t) loadunloadcycle - loading ORB done. Result: <%d>\n"),
107 result));
109 DllORB * p_orb =
110 ACE_Dynamic_Service<DllORB>::instance("testDllOrb");
112 CORBA::ORB_var v_orb = p_orb->orb();
113 ACE_DEBUG((LM_DEBUG,
114 ACE_TEXT ("(%P|%t) loadunloadcycle - v_orb OK\n")));
116 CORBA::Object_var v_poa =
117 v_orb->resolve_initial_references("RootPOA");
118 ACE_DEBUG((LM_DEBUG,
119 ACE_TEXT ("(%P|%t) loadunloadcycle - v_poa OK\n")));
121 PortableServer::POA_var v_rootPOA =
122 PortableServer::POA::_narrow(v_poa.in ());
123 ACE_DEBUG((LM_DEBUG,
124 ACE_TEXT ("(%P|%t) loadunloadcycle - v_rootPOA OK\n")
127 result = ACE_Service_Config::process_directive(scpc_loadNotifyService);
128 ACE_DEBUG((LM_DEBUG,
129 ACE_TEXT ("(%P|%t) loadunloadcycle - ")
130 ACE_TEXT ("loading NotifyService done. Result: <%d>\n"),
131 result));
133 TAO_Notify_Service_Driver * p_notifyService =
134 ACE_Dynamic_Service<TAO_Notify_Service_Driver>::instance("testNotifyService");
136 if (p_notifyService == 0)
138 ACE_DEBUG ((LM_DEBUG,
139 ACE_TEXT ("(%P|%t) Could not resolve testNotifyService\n")));
141 else
143 p_notifyService->run ();
146 ACE_DEBUG((LM_DEBUG,
147 ACE_TEXT ("(%P|%t) loadunloadcycle - unloading\n")));
149 ACE_DEBUG((LM_DEBUG,
150 ACE_TEXT ("(%P|%t) loadunloadcycle - unloading NotifyService ...\n")));
151 result = ACE_Service_Config::process_directive(scpc_unloadNotifyService);
152 ACE_DEBUG((LM_DEBUG,
153 ACE_TEXT ("(%P|%t) loadunloadcycle - unloading NotifyService done. Result: <%d>\n"),
154 result));
156 ACE_DEBUG((LM_DEBUG,
157 ACE_TEXT ("(%P|%t) loadunloadcycle - unloading ORB ...\n")));
158 result = ACE_Service_Config::process_directive(scpc_unloadOrb);
159 ACE_DEBUG((LM_DEBUG,
160 ACE_TEXT ("(%P|%t) loadunloadcycle - unloading ORB done. Result: <%d>\n"),
161 result));
164 int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
166 ACE_DEBUG((LM_DEBUG,
167 ACE_TEXT ("(%P|%t) main - entered\n")));
169 if (parse_args (argc, argv) != 0)
170 return 1;
172 for (int cnt = 0, max = 2; cnt < max; ++cnt)
174 ACE_DEBUG ((LM_DEBUG,
175 ACE_TEXT ("(%P|%t) main - cycle %d ...\n"),
176 cnt));
177 loadunloadcycle();
179 ACE_DEBUG ((LM_DEBUG,
180 ACE_TEXT ("(%P|%t) main - cycle %d done\n"),
181 cnt));
184 ACE_DEBUG ((LM_DEBUG,
185 ACE_TEXT ("(%P|%t) main - leaving\n")));
187 return 0;