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 #if defined (__BORLANDC__) && (__BORLANDC__ >= 0x660) && (__BORLANDC__ <= 0x750)
14 # pragma option push -w-8057
17 ACE_TCHAR
const * const scpc_loadOrb
= ACE_DYNAMIC_VERSIONED_SERVICE_DIRECTIVE(
22 "testDllOrb -ORBDebugLevel 0 -ORBId testDllOrb -NumThreads 2 -ORBDottedDecimalAddresses 1 -ORBCollocationStrategy thru_poa"
25 ACE_TCHAR
const * const scpc_unloadOrb
= ACE_REMOVE_SERVICE_DIRECTIVE("testDllOrb");
27 ACE_TCHAR
const * const scpc_loadNotifyService
= ACE_DYNAMIC_VERSIONED_SERVICE_DIRECTIVE(
29 "TAO_CosNotification_Serv",
31 "_make_TAO_CosNotify_Service",
32 "-UseSeparateDispatchingORB 1"
35 ACE_TCHAR
const * const scpc_unloadNotifyService
= ACE_REMOVE_SERVICE_DIRECTIVE("testNotifyService");
38 unloadNotify(ACE_Service_Config
& service_config
)
40 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("Unloading NotifyService ...\n")));
41 if(service_config
.process_directive(scpc_unloadNotifyService
) != 0)
43 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("Unloading NotifyService failed\n")));
46 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("unloading NotifyService done.\n")));
51 loadNotify(ACE_Service_Config
& service_config
)
55 DllOrb
* p_orb
= ACE_Dynamic_Service
<DllOrb
>::instance ("testDllOrb");
56 CORBA::ORB_var v_orb
= p_orb
->orb();
58 CORBA::Object_var v_poa
= v_orb
->resolve_initial_references("RootPOA");
59 PortableServer::POA_var v_rootPOA
= PortableServer::POA::_narrow(v_poa
.in ());
60 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("RootPOA OK.\n")));
62 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("Loading NotifyService ...\n")));
63 if(0 != service_config
.process_directive(scpc_loadNotifyService
))
65 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("Loading NotifyService failed\n")));
68 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("Loading NotifyService done.\n")));
70 TAO_CosNotify_Service
* p_notifyService
=
71 ACE_Dynamic_Service
<TAO_CosNotify_Service
>::instance("testNotifyService");
73 p_notifyService
->init_service(v_orb
.in());
75 CosNotifyChannelAdmin::EventChannelFactory_var v_notifyFactory
=
76 p_notifyService
->create(
79 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("got EventChannelFactory\n")));
81 // create an event channel
82 CosNotifyChannelAdmin::ChannelID id
;
84 CosNotification::QoSProperties initialQos
;
85 CosNotification::AdminProperties initialAdmin
;
87 CosNotifyChannelAdmin::EventChannel_var v_eventChannel
=
88 v_notifyFactory
->create_channel(
93 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("got EventChannel\n")));
95 CosNotifyFilter::FilterFactory_var v_filterFactory
=
96 v_eventChannel
->default_filter_factory();
97 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("got FilterFactory\n")));
99 CosNotifyFilter::Filter_var v_filter
=
100 v_filterFactory
->create_filter("ETCL");
101 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("got Filter\n")));
103 catch(CORBA::Exception
const & rc_ex
)
105 rc_ex
._tao_print_exception ("Unexpected CORBA Exception: ");
110 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("Unexpected C++ Exception\n")));
118 int unloadOrb(ACE_Service_Config
& service_config
)
120 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("Unloading ORB ...\n")));
121 if(0 != service_config
.process_directive(scpc_unloadOrb
))
123 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("Unloading ORB failed\n")));
126 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("unloading ORB done.\n")));
130 int loadOrb(ACE_Service_Config
& service_config
)
132 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("Loading ORB ...\n")));
133 if(0 != service_config
.process_directive(scpc_loadOrb
))
135 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("Loading ORB failed\n")));
138 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("Loading ORB done.\n")));
145 ACE_TMAIN(int, ACE_TCHAR
**argv
)
149 ACE_TCHAR signum
[64];
150 ACE_OS::sprintf(signum
, ACE_TEXT("%d"), SIGUSR1
);
154 args
.add(ACE_TEXT("-s"));
157 ACE_Service_Config
&serviceConfig
= *ACE_Service_Config::singleton ();
159 result
= serviceConfig
.open (args
.argc(),
161 ACE_DEFAULT_LOGGER_KEY
,
162 true, // ignore_static_svcs = 1,
163 true, // ignore_default_svc_conf_file = 0,
164 false // ignore_debug_flag = 0
169 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("serviceConfig.open failed\n")));
172 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("serviceConfig.open done\n")));
174 for(int i
= 0; i
< 5; ++i
)
176 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("loadOrb ...\n")));
177 result
= loadOrb(serviceConfig
);
180 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("loadOrb failed\n")));
183 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("loadOrb done\n")));
185 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("loadNotify ...\n")));
186 result
= loadNotify(serviceConfig
);
189 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("loadNotify failed\n")));
192 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("loadNotify done\n")));
194 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("unloadNotify ...\n")));
195 result
= unloadNotify(serviceConfig
);
198 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("unloadNotify failed\n")));
201 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("unloadNotify done\n")));
203 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("unloadOrb ...\n")));
204 result
= unloadOrb(serviceConfig
);
207 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("unloadOrb failed\n")));
210 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("unloadOrb done\n")));
213 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("serviceConfig.fini_svcs ...\n")));
214 result
= serviceConfig
.fini_svcs();
217 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("serviceConfig.fini_svcs failed\n")));
220 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("serviceConfig.fini_svcs done\n")));
222 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("serviceConfig.close ...\n")));
223 result
= serviceConfig
.close();
226 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("serviceConfig.close failed\n")));
229 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("serviceConfig.close done\n")));
234 #if defined (__BORLANDC__) && (__BORLANDC__ >= 0x660) && (__BORLANDC__ <= 0x750)