1
// EC_Event_Channel_Base.cpp,v 1.4 2003/08/13 09:03:45 jwillemsen Exp
3
#include "EC_Event_Channel_Base.h"
4
#include "EC_Dispatching.h"
5
#include "EC_ConsumerAdmin.h"
6
#include "EC_SupplierAdmin.h"
7
#include "EC_Timeout_Generator.h"
8
#include "EC_ObserverStrategy.h"
9
#include "EC_ConsumerControl.h"
10
#include "EC_SupplierControl.h"
11
#include "ace/Dynamic_Service.h"
13
#if ! defined (__ACE_INLINE__)
14
#include "EC_Event_Channel_Base.i"
15
#endif /* __ACE_INLINE__ */
17
ACE_RCSID(Event, EC_Event_Channel_Base, "EC_Event_Channel_Base.cpp,v 1.4 2003/08/13 09:03:45 jwillemsen Exp")
19
TAO_EC_Event_Channel_Base::
20
TAO_EC_Event_Channel_Base (const TAO_EC_Event_Channel_Attributes& attr,
21
TAO_EC_Factory* factory,
23
: supplier_poa_ (PortableServer::POA::_duplicate (attr.supplier_poa)),
24
consumer_poa_ (PortableServer::POA::_duplicate (attr.consumer_poa)),
26
own_factory_ (own_factory),
29
supplier_filter_builder_ (0),
32
timeout_generator_ (0),
33
observer_strategy_ (0),
34
scheduling_strategy_(0),
35
consumer_reconnect_ (attr.consumer_reconnect),
36
supplier_reconnect_ (attr.supplier_reconnect),
37
disconnect_callbacks_ (attr.disconnect_callbacks),
38
consumer_control_ (0),
39
supplier_control_ (0),
43
CORBA::Object::_duplicate (attr.scheduler);
46
TAO_EC_Event_Channel_Base::~TAO_EC_Event_Channel_Base (void)
48
// Destroy Strategies in the reverse order of creation, they
49
// refere to each other during destruction and thus need to be
50
// cleaned up properly.
51
this->factory_->destroy_supplier_control (this->supplier_control_);
52
this->supplier_control_ = 0;
53
this->factory_->destroy_consumer_control (this->consumer_control_);
54
this->consumer_control_ = 0;
56
this->factory_->destroy_scheduling_strategy (this->scheduling_strategy_);
57
this->scheduling_strategy_ = 0;
59
this->factory_->destroy_observer_strategy (this->observer_strategy_);
60
this->observer_strategy_ = 0;
62
this->factory_->destroy_timeout_generator (this->timeout_generator_);
63
this->timeout_generator_ = 0;
65
this->factory_->destroy_supplier_admin (this->supplier_admin_);
66
this->supplier_admin_ = 0;
67
this->factory_->destroy_consumer_admin (this->consumer_admin_);
68
this->consumer_admin_ = 0;
70
this->factory_->destroy_supplier_filter_builder (this->supplier_filter_builder_);
71
this->supplier_filter_builder_ = 0;
73
this->factory_->destroy_filter_builder (this->filter_builder_);
74
this->filter_builder_ = 0;
76
this->factory_->destroy_dispatching (this->dispatching_);
77
this->dispatching_ = 0;
83
TAO_EC_Event_Channel_Base::create_strategies (void)
86
this->factory_->create_dispatching (this);
87
this->filter_builder_ =
88
this->factory_->create_filter_builder (this);
89
this->supplier_filter_builder_ =
90
this->factory_->create_supplier_filter_builder (this);
91
this->consumer_admin_ =
92
this->factory_->create_consumer_admin (this);
93
this->supplier_admin_ =
94
this->factory_->create_supplier_admin (this);
95
this->timeout_generator_ =
96
this->factory_->create_timeout_generator (this);
97
this->observer_strategy_ =
98
this->factory_->create_observer_strategy (this);
100
this->scheduling_strategy_ =
101
this->factory_->create_scheduling_strategy (this);
103
this->consumer_control_ =
104
this->factory_->create_consumer_control (this);
105
this->supplier_control_ =
106
this->factory_->create_supplier_control (this);
110
TAO_EC_Event_Channel_Base::activate (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
113
// First check if the EC is idle, if it is not then we need to
114
// return right away...
115
ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_);
116
if (this->status_ != EC_S_IDLE)
118
this->status_ = EC_S_ACTIVATING;
120
this->dispatching_->activate ();
121
this->timeout_generator_->activate ();
122
this->consumer_control_->activate ();
123
this->supplier_control_->activate ();
125
// Only when all the operations complete successfully we can mark
126
// the EC as active...
127
ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_);
128
ACE_ASSERT (this->status_ == EC_S_ACTIVATING);
129
this->status_ = EC_S_ACTIVE;
134
TAO_EC_Event_Channel_Base::shutdown (ACE_ENV_SINGLE_ARG_DECL)
137
// First check if the EC is already active, if it is not then we
138
// need to return right away...
139
ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_);
140
if (this->status_ != EC_S_ACTIVE)
142
this->status_ = EC_S_DESTROYING;
144
this->dispatching_->shutdown ();
145
this->timeout_generator_->shutdown ();
146
this->supplier_control_->shutdown ();
147
this->consumer_control_->shutdown ();
149
this->deactivate_supplier_admin ();
150
this->deactivate_consumer_admin ();
152
this->supplier_admin_->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
155
this->consumer_admin_->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
159
// Wait until all the shutdown() operations return before marking
160
// the EC as destroyed...
161
ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_);
162
ACE_ASSERT (this->status_ == EC_S_DESTROYING);
163
this->status_ = EC_S_DESTROYED;
168
TAO_EC_Event_Channel_Base::deactivate_supplier_admin (void)
170
ACE_DECLARE_NEW_CORBA_ENV;
173
PortableServer::POA_var supplier_poa =
174
this->supplier_admin_->_default_POA (ACE_ENV_SINGLE_ARG_PARAMETER);
176
PortableServer::ObjectId_var supplier_id =
177
supplier_poa->servant_to_id (this->supplier_admin_ ACE_ENV_ARG_PARAMETER);
179
supplier_poa->deactivate_object (supplier_id.in () ACE_ENV_ARG_PARAMETER);
184
// The deactivation can throw...
190
TAO_EC_Event_Channel_Base::deactivate_consumer_admin (void)
194
PortableServer::POA_var consumer_poa =
195
this->consumer_admin_->_default_POA (ACE_ENV_SINGLE_ARG_PARAMETER);
197
PortableServer::ObjectId_var consumer_id =
198
consumer_poa->servant_to_id (this->consumer_admin_ ACE_ENV_ARG_PARAMETER);
200
consumer_poa->deactivate_object (consumer_id.in () ACE_ENV_ARG_PARAMETER);
205
// The deactivation can throw...
211
TAO_EC_Event_Channel_Base::connected (TAO_EC_ProxyPushConsumer* consumer
214
this->consumer_admin_->peer_connected (consumer ACE_ENV_ARG_PARAMETER);
216
this->supplier_admin_->connected (consumer ACE_ENV_ARG_PARAMETER);
218
this->observer_strategy_->connected (consumer ACE_ENV_ARG_PARAMETER);
223
TAO_EC_Event_Channel_Base::reconnected (TAO_EC_ProxyPushConsumer* consumer
226
this->consumer_admin_->peer_reconnected (consumer ACE_ENV_ARG_PARAMETER);
228
this->supplier_admin_->reconnected (consumer ACE_ENV_ARG_PARAMETER);
230
this->observer_strategy_->connected (consumer ACE_ENV_ARG_PARAMETER);
235
TAO_EC_Event_Channel_Base::disconnected (TAO_EC_ProxyPushConsumer* consumer
238
this->consumer_admin_->peer_disconnected (consumer ACE_ENV_ARG_PARAMETER);
240
this->supplier_admin_->disconnected (consumer ACE_ENV_ARG_PARAMETER);
242
this->observer_strategy_->disconnected (consumer ACE_ENV_ARG_PARAMETER);
247
TAO_EC_Event_Channel_Base::connected (TAO_EC_ProxyPushSupplier* supplier
250
this->supplier_admin_->peer_connected (supplier ACE_ENV_ARG_PARAMETER);
252
this->consumer_admin_->connected (supplier ACE_ENV_ARG_PARAMETER);
254
this->observer_strategy_->connected (supplier ACE_ENV_ARG_PARAMETER);
259
TAO_EC_Event_Channel_Base::reconnected (TAO_EC_ProxyPushSupplier* supplier
262
this->supplier_admin_->peer_reconnected (supplier ACE_ENV_ARG_PARAMETER);
264
this->consumer_admin_->reconnected (supplier ACE_ENV_ARG_PARAMETER);
266
this->observer_strategy_->connected (supplier ACE_ENV_ARG_PARAMETER);
271
TAO_EC_Event_Channel_Base::disconnected (TAO_EC_ProxyPushSupplier* supplier
274
this->supplier_admin_->peer_disconnected (supplier ACE_ENV_ARG_PARAMETER);
276
this->consumer_admin_->disconnected (supplier ACE_ENV_ARG_PARAMETER);
278
this->observer_strategy_->disconnected (supplier ACE_ENV_ARG_PARAMETER);
282
RtecEventChannelAdmin::ConsumerAdmin_ptr
283
TAO_EC_Event_Channel_Base::for_consumers (ACE_ENV_SINGLE_ARG_DECL)
284
ACE_THROW_SPEC ((CORBA::SystemException))
286
return this->consumer_admin_->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
289
RtecEventChannelAdmin::SupplierAdmin_ptr
290
TAO_EC_Event_Channel_Base::for_suppliers (ACE_ENV_SINGLE_ARG_DECL)
291
ACE_THROW_SPEC ((CORBA::SystemException))
293
return this->supplier_admin_->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
297
TAO_EC_Event_Channel_Base::destroy (ACE_ENV_SINGLE_ARG_DECL)
298
ACE_THROW_SPEC ((CORBA::SystemException))
300
this->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
303
RtecEventChannelAdmin::Observer_Handle
304
TAO_EC_Event_Channel_Base::append_observer (
305
RtecEventChannelAdmin::Observer_ptr observer
308
CORBA::SystemException,
309
RtecEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR,
310
RtecEventChannelAdmin::EventChannel::CANT_APPEND_OBSERVER))
312
return this->observer_strategy_->append_observer (observer
313
ACE_ENV_ARG_PARAMETER);
317
TAO_EC_Event_Channel_Base::remove_observer (
318
RtecEventChannelAdmin::Observer_Handle handle
321
CORBA::SystemException,
322
RtecEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR,
323
RtecEventChannelAdmin::EventChannel::CANT_REMOVE_OBSERVER))
325
this->observer_strategy_->remove_observer (handle
326
ACE_ENV_ARG_PARAMETER);
330
TAO_EC_Event_Channel_Base::for_each_consumer (
331
TAO_ESF_Worker<TAO_EC_ProxyPushSupplier> *worker
333
ACE_THROW_SPEC ((CORBA::SystemException))
335
this->consumer_admin_->for_each (worker
336
ACE_ENV_ARG_PARAMETER);
341
TAO_EC_Event_Channel_Base::for_each_supplier (
342
TAO_ESF_Worker<TAO_EC_ProxyPushConsumer> *worker
344
ACE_THROW_SPEC ((CORBA::SystemException))
346
this->supplier_admin_->for_each (worker
347
ACE_ENV_ARG_PARAMETER);