summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Notify/Notify_ProxyPushSupplier_i.cpp
blob: ceb0cce022bbc525c0fda2f7589b15a363d202b5 (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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
//$Id$

#include "Notify_ProxyPushSupplier_i.h"
#include "Notify_Event_Manager.h"
#include "Notify_ConsumerAdmin_i.h"

ACE_RCSID(Notify, Notify_ProxyPushSupplier_i, "$Id$")

typedef ACE_Reverse_Lock<ACE_Lock> TAO_Notify_Unlock;

TAO_Notify_ProxyPushSupplier_i::TAO_Notify_ProxyPushSupplier_i (TAO_Notify_ConsumerAdmin_i* consumer_admin)
  :proxy_inherited (consumer_admin),
   notify_style_consumer_ (0)
{
}

// Implementation skeleton destructor
TAO_Notify_ProxyPushSupplier_i::~TAO_Notify_ProxyPushSupplier_i (void)
{
}

void
TAO_Notify_ProxyPushSupplier_i::dispatch_event_i (TAO_Notify_Event &event, CORBA::Environment &ACE_TRY_ENV)
{
  ACE_TRY
    {
      event.do_push (this->cosec_push_consumer_.in (), ACE_TRY_ENV);
      ACE_TRY_CHECK;
    }
  ACE_CATCHALL
    {
      ACE_DEBUG ((LM_DEBUG, "Exception dispatching any event\n"));
      // misbehaving client, ignore for now.
    }
  ACE_ENDTRY;
}

void
TAO_Notify_ProxyPushSupplier_i::dispatch_update_i (CosNotification::EventTypeSeq added, CosNotification::EventTypeSeq removed, CORBA::Environment &ACE_TRY_ENV)
{
  {
    ACE_GUARD (ACE_Lock, ace_mon, *this->lock_);
    if (this->notify_style_consumer_ == 0)
      return; // Our consumer doesn't support offer_change.
  }

  ACE_TRY
    {
      this->notify_push_consumer_->offer_change (added, removed, ACE_TRY_ENV);
      ACE_TRY_CHECK;
    }
  ACE_CATCHALL
    {
      // misbehaving client, ignore for now.
    }
  ACE_ENDTRY;
}

void
TAO_Notify_ProxyPushSupplier_i::connect_any_push_consumer (CosEventComm::PushConsumer_ptr push_consumer, CORBA::Environment &ACE_TRY_ENV)
  ACE_THROW_SPEC ((
                   CORBA::SystemException,
                   CosEventChannelAdmin::AlreadyConnected,
                   CosEventChannelAdmin::TypeError
  ))
{
  ACE_GUARD_THROW_EX (ACE_Lock, ace_mon, *this->lock_,
                      CORBA::INTERNAL ());
  ACE_CHECK;

  if (CORBA::is_nil (push_consumer))
    ACE_THROW (CosEventChannelAdmin::TypeError ());
  else if (this->is_connected_ == 1)
    ACE_THROW (CosEventChannelAdmin::AlreadyConnected ());
  else
    {
      this->cosec_push_consumer_ =
        CosEventComm::PushConsumer::_duplicate (push_consumer);

      this->notify_push_consumer_ =
        CosNotifyComm::PushConsumer::_narrow (push_consumer, ACE_TRY_ENV);
      ACE_CHECK;

      if (!CORBA::is_nil (this->notify_push_consumer_.in ()))
        {
          CosNotifyComm::PushConsumer::
            _duplicate (this->notify_push_consumer_.in ());
          this->notify_style_consumer_ = 1;
        }

      this->is_connected_ = 1;
    } // else

  ACE_TRY
    {
      TAO_Notify_Unlock reverse_lock (*this->lock_);

      {
        ACE_GUARD_THROW_EX (TAO_Notify_Unlock, ace_mon, reverse_lock,
                            CORBA::INTERNAL ());
        ACE_CHECK;

        this->on_connected (ACE_TRY_ENV);
        ACE_TRY_CHECK;
      }
    }
 ACE_CATCHALL
   {
     this->cosec_push_consumer_ = CosNotifyComm::PushConsumer::_nil ();
     this->notify_push_consumer_ = CosNotifyComm::PushConsumer::_nil ();

     this->is_connected_ = 0;
     ACE_RE_THROW;
   }
 ACE_ENDTRY;
}

void
TAO_Notify_ProxyPushSupplier_i::shutdown_i (CORBA::Environment &ACE_TRY_ENV)
{
  this->on_disconnected (ACE_TRY_ENV);
  ACE_CHECK;

  // ask our parent to deactivate us.
  this->consumer_admin_->
    deactivate_proxy_pushsupplier (this, ACE_TRY_ENV);
}

void
TAO_Notify_ProxyPushSupplier_i::disconnect_push_supplier (CORBA::Environment &ACE_TRY_ENV)
  ACE_THROW_SPEC ((
                   CORBA::SystemException
                   ))
{
  // unregister with CA
  this->consumer_admin_->unregister_listener (this, ACE_TRY_ENV);
  ACE_CHECK;

  this->shutdown_i (ACE_TRY_ENV);
}

void
TAO_Notify_ProxyPushSupplier_i::shutdown (CORBA::Environment &ACE_TRY_ENV)
{
  // Tell the consumer that we're going away ...
  // @@ Later, lookup a "notify_on_disconnect" option.

  {
    ACE_GUARD (ACE_Lock, ace_mon, *this->lock_);

    if (this->is_connected_ == 0)
      return;
  }

  this->shutdown_i (ACE_TRY_ENV);
  ACE_CHECK;

  ACE_TRY
    {
      this->cosec_push_consumer_->disconnect_push_consumer (ACE_TRY_ENV);
      ACE_TRY_CHECK;
    }
  ACE_CATCHALL
    {
      // ignore
    }
  ACE_ENDTRY;
}

// = TAO_Notify_CosEC_ProxyPushSupplier_i

TAO_Notify_CosEC_ProxyPushSupplier_i::TAO_Notify_CosEC_ProxyPushSupplier_i (TAO_Notify_ConsumerAdmin_i* consumer_admin)
  :notify_proxy_ (consumer_admin)
{
  // No-Op.
}

TAO_Notify_CosEC_ProxyPushSupplier_i::~TAO_Notify_CosEC_ProxyPushSupplier_i (void)
{
}

void
TAO_Notify_CosEC_ProxyPushSupplier_i::init (CORBA::Environment &ACE_TRY_ENV)
{
  this->notify_proxy_.init (0, ACE_TRY_ENV);
}

void
TAO_Notify_CosEC_ProxyPushSupplier_i::disconnect_push_supplier (CORBA::Environment &ACE_TRY_ENV)
  ACE_THROW_SPEC ((CORBA::SystemException))
{
  this->notify_proxy_.disconnect_push_supplier (ACE_TRY_ENV);
}

void
TAO_Notify_CosEC_ProxyPushSupplier_i::connect_push_consumer(CosEventComm::PushConsumer_ptr push_consumer, CORBA::Environment &ACE_TRY_ENV)
    ACE_THROW_SPEC ((CORBA::SystemException,
                     CosEventChannelAdmin::AlreadyConnected,
                     CosEventChannelAdmin::TypeError))
{
  this->notify_proxy_.connect_any_push_consumer (push_consumer, ACE_TRY_ENV);
}

#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)

template class TAO_Notify_ProxySupplier<POA_CosNotifyChannelAdmin::ProxyPushSupplier>;
template class TAO_Notify_Proxy<POA_CosNotifyChannelAdmin::ProxyPushSupplier>;

#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)

#pragma instantiate TAO_Notify_ProxySupplier<POA_CosNotifyChannelAdmin::ProxyPushSupplier>
#pragma instantiate TAO_Notify_Proxy<POA_CosNotifyChannelAdmin::ProxyPushSupplier>

#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */

#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)

template class ACE_Unbounded_Queue<TAO_Notify_Event*>;
template class ACE_Node<TAO_Notify_Event*>;
template class ACE_Unbounded_Queue_Iterator <TAO_Notify_Event*>;

#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)

#pragma instantiate ACE_Unbounded_Queue<TAO_Notify_Event*>
#pragma instantiate ACE_Node<TAO_Notify_Event*>
#pragma instantiate ACE_Unbounded_Queue_Iterator <TAO_Notify_Event*>

#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */