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"
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"
14 # define LOAD_ORB_DIRECTIVE "testDllOrb -ORBDebugLevel 0 -ORBId testDllOrb -ORBDottedDecimalAddresses 1 -ORBInitRef NameService=iioploc://%s:%s/NameService"
17 ACE_TCHAR scpc_loadOrb
[max_length
] = ACE_DYNAMIC_VERSIONED_SERVICE_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"
30 # define LOAD_NOTIFYSVC_DIRECTIVE "-Channel -ChannelName Channel1 -ChannelName Channel2 -RunThreads 0 -ORBInitRef NameService=iioploc://%s:%s/NameService -IORoutput %s"
33 ACE_TCHAR scpc_loadNotifyService
[max_length
] = ACE_DYNAMIC_VERSIONED_SERVICE_DIRECTIVE(
37 "_make_TAO_Notify_Service_Driver",
38 LOAD_NOTIFYSVC_DIRECTIVE
41 ACE_TCHAR
const * const scpc_unloadNotifyService
= ACE_REMOVE_SERVICE_DIRECTIVE("testNotifyService");
44 parse_args (int argc
, ACE_TCHAR
*argv
[])
46 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("h:p:o:"));
49 ACE_TCHAR
*hostname
= 0;
51 ACE_TCHAR
*ior_file
= 0;
53 while ((c
= get_opts ()) != -1)
57 hostname
= get_opts
.opt_arg ();
60 port
= get_opts
.opt_arg ();
63 ior_file
= get_opts
.opt_arg ();
68 ACE_ERROR_RETURN ((LM_ERROR
,
76 // Indicates successful parsing of the command line
77 if ( hostname
== 0 || port
== 0 || ior_file
== 0){
78 ACE_ERROR_RETURN ((LM_ERROR
,
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
);
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"),
110 ACE_Dynamic_Service
<DllORB
>::instance("testDllOrb");
112 CORBA::ORB_var v_orb
= p_orb
->orb();
114 ACE_TEXT ("(%P|%t) loadunloadcycle - v_orb OK\n")));
116 CORBA::Object_var v_poa
=
117 v_orb
->resolve_initial_references("RootPOA");
119 ACE_TEXT ("(%P|%t) loadunloadcycle - v_poa OK\n")));
121 PortableServer::POA_var v_rootPOA
=
122 PortableServer::POA::_narrow(v_poa
.in ());
124 ACE_TEXT ("(%P|%t) loadunloadcycle - v_rootPOA OK\n")
127 result
= ACE_Service_Config::process_directive(scpc_loadNotifyService
);
129 ACE_TEXT ("(%P|%t) loadunloadcycle - ")
130 ACE_TEXT ("loading NotifyService done. Result: <%d>\n"),
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")));
143 p_notifyService
->run ();
147 ACE_TEXT ("(%P|%t) loadunloadcycle - unloading\n")));
150 ACE_TEXT ("(%P|%t) loadunloadcycle - unloading NotifyService ...\n")));
151 result
= ACE_Service_Config::process_directive(scpc_unloadNotifyService
);
153 ACE_TEXT ("(%P|%t) loadunloadcycle - unloading NotifyService done. Result: <%d>\n"),
157 ACE_TEXT ("(%P|%t) loadunloadcycle - unloading ORB ...\n")));
158 result
= ACE_Service_Config::process_directive(scpc_unloadOrb
);
160 ACE_TEXT ("(%P|%t) loadunloadcycle - unloading ORB done. Result: <%d>\n"),
164 int ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
167 ACE_TEXT ("(%P|%t) main - entered\n")));
169 if (parse_args (argc
, argv
) != 0)
172 for (int cnt
= 0, max
= 2; cnt
< max
; ++cnt
)
174 ACE_DEBUG ((LM_DEBUG
,
175 ACE_TEXT ("(%P|%t) main - cycle %d ...\n"),
179 ACE_DEBUG ((LM_DEBUG
,
180 ACE_TEXT ("(%P|%t) main - cycle %d done\n"),
184 ACE_DEBUG ((LM_DEBUG
,
185 ACE_TEXT ("(%P|%t) main - leaving\n")));