summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Event/EC_Event_Channel.cpp
blob: 053b2054fc1b59c18a07ea90f9bacb959fcada8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
// $Id$

#include "EC_Event_Channel.h"
#include "EC_Factory.h"
#include "EC_Dispatching.h"
#include "EC_ConsumerAdmin.h"
#include "EC_SupplierAdmin.h"
#include "EC_Timeout_Generator.h"
#include "EC_ObserverStrategy.h"

#if ! defined (__ACE_INLINE__)
#include "EC_Event_Channel.i"
#endif /* __ACE_INLINE__ */

ACE_RCSID(Event, EC_Event_Channel, "$Id$")

TAO_EC_Event_Channel::TAO_EC_Event_Channel (TAO_EC_Factory* factory)
  : factory_ (factory)
{
  ACE_ASSERT (this->factory_ != 0);

  this->dispatching_ =
    this->factory_->create_dispatching (this);
  this->filter_builder_ =
    this->factory_->create_filter_builder (this);
  this->consumer_admin_ =
    this->factory_->create_consumer_admin (this);
  this->supplier_admin_ =
    this->factory_->create_supplier_admin (this);
  this->timeout_generator_ =
    this->factory_->create_timeout_generator (this);
  this->observer_strategy_ =
    this->factory_->create_observer_strategy (this);
}

TAO_EC_Event_Channel::~TAO_EC_Event_Channel (void)
{
  this->factory_->destroy_dispatching (this->dispatching_);
  this->dispatching_ = 0;
  this->factory_->destroy_filter_builder (this->filter_builder_);
  this->filter_builder_ = 0;
  this->factory_->destroy_consumer_admin (this->consumer_admin_);
  this->consumer_admin_ = 0;
  this->factory_->destroy_supplier_admin (this->supplier_admin_);
  this->supplier_admin_ = 0;
  this->factory_->destroy_timeout_generator (this->timeout_generator_);
  this->timeout_generator_ = 0;
  this->factory_->destroy_observer_strategy (this->observer_strategy_);
  this->observer_strategy_ = 0;
}

void
TAO_EC_Event_Channel::activate (CORBA::Environment& ACE_TRY_ENV)
{
  this->dispatching_->activate ();
  this->timeout_generator_->activate ();

  PortableServer::POA_var supplier_poa =
    this->factory_->supplier_poa (ACE_TRY_ENV);
  ACE_CHECK;
  this->supplier_admin_->set_default_POA (supplier_poa.in ());

  PortableServer::POA_var consumer_poa =
    this->factory_->consumer_poa (ACE_TRY_ENV);
  ACE_CHECK;
  this->consumer_admin_->set_default_POA (consumer_poa.in ());
}

void
TAO_EC_Event_Channel::shutdown (CORBA::Environment& ACE_TRY_ENV)
{
  this->dispatching_->shutdown ();
  this->timeout_generator_->shutdown ();

  PortableServer::POA_var consumer_poa =
    this->consumer_admin_->_default_POA (ACE_TRY_ENV);
  ACE_CHECK;
  PortableServer::ObjectId_var consumer_id =
    consumer_poa->servant_to_id (this->consumer_admin_, ACE_TRY_ENV);
  ACE_CHECK;
  consumer_poa->deactivate_object (consumer_id.in (), ACE_TRY_ENV);
  ACE_CHECK;

  PortableServer::POA_var supplier_poa =
    this->supplier_admin_->_default_POA (ACE_TRY_ENV);
  ACE_CHECK;
  PortableServer::ObjectId_var supplier_id =
    supplier_poa->servant_to_id (this->supplier_admin_, ACE_TRY_ENV);
  ACE_CHECK;
  supplier_poa->deactivate_object (supplier_id.in (), ACE_TRY_ENV);
  ACE_CHECK;
}

void
TAO_EC_Event_Channel::connected (TAO_EC_ProxyPushConsumer* consumer,
                                 CORBA::Environment &ACE_TRY_ENV)
{
  this->consumer_admin_->connected (consumer, ACE_TRY_ENV);
  ACE_CHECK;
  this->supplier_admin_->connected (consumer, ACE_TRY_ENV);
  ACE_CHECK;
  this->observer_strategy_->connected (consumer, ACE_TRY_ENV);
  ACE_CHECK;
}

void
TAO_EC_Event_Channel::disconnected (TAO_EC_ProxyPushConsumer* consumer,
                                    CORBA::Environment &ACE_TRY_ENV)
{
  this->consumer_admin_->disconnected (consumer, ACE_TRY_ENV);
  ACE_CHECK;
  this->supplier_admin_->disconnected (consumer, ACE_TRY_ENV);
  ACE_CHECK;
  this->observer_strategy_->disconnected (consumer, ACE_TRY_ENV);
  ACE_CHECK;
}

void
TAO_EC_Event_Channel::connected (TAO_EC_ProxyPushSupplier* supplier,
                                 CORBA::Environment &ACE_TRY_ENV)
{
  this->supplier_admin_->connected (supplier, ACE_TRY_ENV);
  ACE_CHECK;
  this->consumer_admin_->connected (supplier, ACE_TRY_ENV);
  ACE_CHECK;
  this->observer_strategy_->connected (supplier, ACE_TRY_ENV);
  ACE_CHECK;
}

void
TAO_EC_Event_Channel::disconnected (TAO_EC_ProxyPushSupplier* supplier,
                                    CORBA::Environment &ACE_TRY_ENV)
{
  this->supplier_admin_->disconnected (supplier, ACE_TRY_ENV);
  ACE_CHECK;
  this->consumer_admin_->disconnected (supplier, ACE_TRY_ENV);
  ACE_CHECK;
  this->observer_strategy_->disconnected (supplier, ACE_TRY_ENV);
  ACE_CHECK;
}

RtecEventChannelAdmin::ConsumerAdmin_ptr
TAO_EC_Event_Channel::for_consumers (CORBA::Environment& ACE_TRY_ENV)
{
  return this->consumer_admin_->_this (ACE_TRY_ENV);
}

RtecEventChannelAdmin::SupplierAdmin_ptr
TAO_EC_Event_Channel::for_suppliers (CORBA::Environment& ACE_TRY_ENV)
{
  return this->supplier_admin_->_this (ACE_TRY_ENV);
}

void
TAO_EC_Event_Channel::destroy (CORBA::Environment &TAO_TRY_ENV)
{
  this->shutdown (TAO_TRY_ENV);
}

RtecEventChannelAdmin::Observer_Handle
TAO_EC_Event_Channel::append_observer (
       RtecEventChannelAdmin::Observer_ptr observer,
       CORBA::Environment &ACE_IN_ENV)
    TAO_THROW_SPEC ((CORBA::SystemException,
                     RtecEventChannel::EventChannel::SYNCHRONIZATION_ERROR,
                     RtecEventChannel::EventChannel::CANT_APPEND_OBSERVER))
{
  return this->observer_strategy_->append_observer (observer, ACE_IN_ENV);
}

void
TAO_EC_Event_Channel::remove_observer (
       RtecEventChannelAdmin::Observer_Handle handle,
       CORBA::Environment &ACE_IN_ENV)
    TAO_THROW_SPEC ((CORBA::SystemException,
                     RtecEventChannel::EventChannel::SYNCHRONIZATION_ERROR,
                     RtecEventChannel::EventChannel::CANT_REMOVE_OBSERVER))
{
  this->observer_strategy_->remove_observer (handle, ACE_IN_ENV);
}