1 #include "Notify_Test_Client.h"
2 #define NOTIFY_FACTORY_NAME "NotifyEventChannelFactory"
3 #define NAMING_SERVICE_NAME "NameService"
5 Notify_Test_Client::Notify_Test_Client ()
9 // @@ Later: accept the inter filter operator as a param.
10 ifgop_
= CosNotifyChannelAdmin::OR_OP
;
13 Notify_Test_Client::~Notify_Test_Client ()
15 if (!CORBA::is_nil (root_poa_
.in ()) &&
16 !CORBA::is_nil (orb_
.in ()))
20 root_poa_
->destroy(true, true);
23 catch (const CORBA::Exception
& e
)
25 e
._tao_print_exception ("\nError: ");
31 Notify_Test_Client::init (int argc
, ACE_TCHAR
*argv
[])
33 int status
= this->init_ORB (argc
, argv
);
36 this->resolve_naming_service ();
37 this->resolve_Notify_factory ();
43 Notify_Test_Client::parse_args (int /*argc*/, ACE_TCHAR
*[] /*argv*/)
50 Notify_Test_Client::init_ORB (int argc
, ACE_TCHAR
*argv
[])
52 this->orb_
= CORBA::ORB_init (argc
, argv
);
54 if (this->parse_args (argc
, argv
) != 0)
59 CORBA::Object_var poa_object
=
60 this->orb_
->resolve_initial_references("RootPOA");
62 if (CORBA::is_nil (poa_object
.in ()))
65 " (%P|%t) Unable to initialize the POA.\n"));
69 PortableServer::POA::_narrow (poa_object
.in ());
71 PortableServer::POAManager_var poa_manager
=
72 root_poa_
->the_POAManager ();
74 poa_manager
->activate ();
80 Notify_Test_Client::resolve_naming_service ()
82 CORBA::Object_var naming_obj
=
83 this->orb_
->resolve_initial_references (NAMING_SERVICE_NAME
);
85 // Need to check return value for errors.
86 if (CORBA::is_nil (naming_obj
.in ()))
87 throw CORBA::UNKNOWN ();
89 this->naming_context_
=
90 CosNaming::NamingContext::_narrow (naming_obj
.in ());
94 Notify_Test_Client::resolve_Notify_factory ()
96 CosNaming::Name
name (1);
98 name
[0].id
= CORBA::string_dup (NOTIFY_FACTORY_NAME
);
100 CORBA::Object_var obj
=
101 this->naming_context_
->resolve (name
);
103 this->notify_factory_
=
104 CosNotifyChannelAdmin::EventChannelFactory::_narrow (obj
.in ());
108 Notify_Test_Client::ORB_run ()
112 ACE_Time_Value
tv(0, 10 * 1000);
116 ACE_DEBUG((LM_DEBUG
, "\nWaiting for stray events...\n"));
118 ACE_Time_Value
tv(2);
125 Notify_Test_Client::ORB_run (ACE_Time_Value
& tv
)
129 ACE_DEBUG((LM_DEBUG
, "\nWaiting for stray events...\n"));
131 ACE_Time_Value
tv2(2,0);
137 void Notify_Test_Client::consumer_start (TAO_Notify_Tests_Peer
*)
143 Notify_Test_Client::consumer_done (TAO_Notify_Tests_Peer
*)
145 int value
= --num_clients_
;
153 Notify_Test_Client::is_done () const
159 Notify_Test_Client::orb ()
161 return this->orb_
.in ();
165 PortableServer::POA_ptr
166 Notify_Test_Client::root_poa ()
168 return this->root_poa_
.in ();
171 CosNaming::NamingContext_ptr
172 Notify_Test_Client::naming_context ()
174 return this->naming_context_
.in ();
177 CosNotifyChannelAdmin::EventChannelFactory_ptr
178 Notify_Test_Client::notify_factory ()
180 return this->notify_factory_
.in ();
183 CosNotifyChannelAdmin::EventChannel_ptr
184 Notify_Test_Client::create_event_channel (const char* cname
, bool resolve
)
186 CosNotifyChannelAdmin::EventChannel_var ec
;
187 CosNaming::Name
name (1);
189 name
[0].id
= CORBA::string_dup (cname
);
193 CORBA::Object_var obj
= naming_context_
->resolve (name
);
194 ec
= CosNotifyChannelAdmin::EventChannel::_narrow (obj
.in ());
198 if (CORBA::is_nil (this->notify_factory_
.in ()))
200 return CosNotifyChannelAdmin::EventChannel::_nil ();
203 CosNotifyChannelAdmin::ChannelID id
;
204 CosNotification::QoSProperties initial_qos
;
205 CosNotification::AdminProperties initial_admin
;
207 ec
= notify_factory_
->create_channel (initial_qos
,
211 naming_context_
->rebind(name
, ec
.in());