summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Notify/Notify_StructuredPushSupplier.cpp
blob: a803241ee5eba1ae000694567b0ce777586f14f3 (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
// -*- C++ -*-
// $Id$
#include "Notify_StructuredPushSupplier.h"

// @@ Pradeep: the RCSID

TAO_Notify_StructuredPushSupplier::TAO_Notify_StructuredPushSupplier (void)
{
}

TAO_Notify_StructuredPushSupplier::~TAO_Notify_StructuredPushSupplier ()
{
}

void
TAO_Notify_StructuredPushSupplier::init (PortableServer::POA_ptr poa, CORBA::Environment & /*ACE_TRY_ENV*/)
{
  this->default_POA_ = PortableServer::POA::_duplicate (poa);
}

void
TAO_Notify_StructuredPushSupplier::connect (CosNotifyChannelAdmin::SupplierAdmin_ptr supplier_admin, CORBA::Environment &ACE_TRY_ENV)
{
  CosNotifyComm::StructuredPushSupplier_var objref =
    this->_this (ACE_TRY_ENV);
  ACE_CHECK;

  CosNotifyChannelAdmin::ProxyConsumer_var proxyconsumer =
    supplier_admin->obtain_notification_push_consumer (CosNotifyChannelAdmin::STRUCTURED_EVENT, my_id_, ACE_TRY_ENV);
  ACE_CHECK;

  ACE_ASSERT (!CORBA::is_nil (proxyconsumer.in ()));

  // narrow
  this->consumer_proxy_ =
    CosNotifyChannelAdmin::StructuredProxyPushConsumer::_narrow (proxyconsumer.in (), ACE_TRY_ENV);
  ACE_CHECK;

  ACE_ASSERT (!CORBA::is_nil (consumer_proxy_.in ()));

  consumer_proxy_->connect_structured_push_supplier (objref.in (),
                                                     ACE_TRY_ENV);
  ACE_CHECK;
}

void
TAO_Notify_StructuredPushSupplier::disconnect (CORBA::Environment &ACE_TRY_ENV)
{
  ACE_ASSERT (!CORBA::is_nil (this->consumer_proxy_.in ()));

  this->consumer_proxy_->disconnect_structured_push_consumer(ACE_TRY_ENV);
  ACE_CHECK;

  this->deactivate (ACE_TRY_ENV);
}

void
TAO_Notify_StructuredPushSupplier::subscription_change (
                                                        const CosNotification::EventTypeSeq & /*added*/,
                                                        const CosNotification::EventTypeSeq & /*removed */,
                                                        CORBA::Environment & //ACE_TRY_ENV
      )
      ACE_THROW_SPEC ((
        CORBA::SystemException,
        CosNotifyComm::InvalidEventType
      ))
{
  //No-Op.
}

PortableServer::POA_ptr
TAO_Notify_StructuredPushSupplier::_default_POA (CORBA::Environment& /* env */)
{
  return PortableServer::POA::_duplicate (this->default_POA_);
}

void
TAO_Notify_StructuredPushSupplier::deactivate (CORBA::Environment &ACE_TRY_ENV)
{
  PortableServer::ObjectId_var id =
    this->default_POA_->servant_to_id (this,
                                       ACE_TRY_ENV);
  ACE_CHECK;

  this->default_POA_->deactivate_object (id.in (),
                                         ACE_TRY_ENV);
  ACE_CHECK;

  // release all resources ...
  this->default_POA_ = PortableServer::POA::_nil ();

  this->consumer_proxy_ =
    CosNotifyChannelAdmin::StructuredProxyPushConsumer::_nil ();
}

void
TAO_Notify_StructuredPushSupplier::disconnect_structured_push_supplier (
        CORBA::Environment &ACE_TRY_ENV
      )
      ACE_THROW_SPEC ((
        CORBA::SystemException
      ))
{
  this->consumer_proxy_->disconnect_structured_push_consumer (ACE_TRY_ENV);
  ACE_CHECK;
  this->deactivate (ACE_TRY_ENV);
}

void
TAO_Notify_StructuredPushSupplier::send_event (const CosNotification::StructuredEvent& event, CORBA::Environment &ACE_TRY_ENV)
{
  ACE_ASSERT (!CORBA::is_nil (this->consumer_proxy_.in ()));

  consumer_proxy_->push_structured_event (event, ACE_TRY_ENV);
  ACE_CHECK;
}