2 #include "ace/Service_Config.h"
3 #include "ace/Log_Msg.h"
7 #include "tao/PortableServer/PortableServer.h"
8 #include "orbsvcs/CosNotifyChannelAdminC.h"
9 #include "orbsvcs/Notify/CosNotify_Service.h"
13 ACE_TCHAR
const * const scpc_loadOrb
= ACE_DYNAMIC_VERSIONED_SERVICE_DIRECTIVE(
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(
25 "TAO_CosNotification_Serv",
27 "_make_TAO_CosNotify_Service",
28 "-UseSeparateDispatchingORB 1"
31 ACE_TCHAR
const * const scpc_unloadNotifyService
= ACE_REMOVE_SERVICE_DIRECTIVE("testNotifyService");
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")));
42 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("unloading NotifyService done.\n")));
47 loadNotify(ACE_Service_Config
& service_config
)
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")));
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(
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: ");
103 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("Unexpected C++ Exception\n")));
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")));
119 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("unloading ORB done.\n")));
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")));
131 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("Loading ORB done.\n")));
137 ACE_TMAIN(int, ACE_TCHAR
**argv
)
141 ACE_TCHAR signum
[64];
142 ACE_OS::sprintf(signum
, ACE_TEXT("%d"), SIGUSR1
);
146 args
.add(ACE_TEXT("-s"));
149 ACE_Service_Config
&serviceConfig
= *ACE_Service_Config::singleton ();
151 result
= serviceConfig
.open (args
.argc(),
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
160 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("serviceConfig.open failed\n")));
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
);
171 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("loadOrb failed\n")));
174 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("loadOrb done\n")));
176 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("loadNotify ...\n")));
177 result
= loadNotify(serviceConfig
);
180 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("loadNotify failed\n")));
183 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("loadNotify done\n")));
185 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("unloadNotify ...\n")));
186 result
= unloadNotify(serviceConfig
);
189 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("unloadNotify failed\n")));
192 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("unloadNotify done\n")));
194 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("unloadOrb ...\n")));
195 result
= unloadOrb(serviceConfig
);
198 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("unloadOrb failed\n")));
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();
208 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("serviceConfig.fini_svcs failed\n")));
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();
217 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("serviceConfig.close failed\n")));
220 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("serviceConfig.close done\n")));