00001
00002
00003 #include "orbsvcs/CosEvent/CEC_EventChannel.h"
00004 #include "orbsvcs/CosEvent/CEC_Dispatching.h"
00005 #include "orbsvcs/CosEvent/CEC_Pulling_Strategy.h"
00006 #include "orbsvcs/CosEvent/CEC_ConsumerAdmin.h"
00007 #include "orbsvcs/CosEvent/CEC_SupplierAdmin.h"
00008 #include "orbsvcs/CosEvent/CEC_ConsumerControl.h"
00009 #include "orbsvcs/CosEvent/CEC_SupplierControl.h"
00010 #include "ace/Dynamic_Service.h"
00011
00012 #if ! defined (__ACE_INLINE__)
00013 #include "orbsvcs/CosEvent/CEC_EventChannel.inl"
00014 #endif
00015
00016 ACE_RCSID(CosEvent, CEC_EventChannel, "$Id: CEC_EventChannel.cpp 77001 2007-02-12 07:54:49Z johnnyw $")
00017
00018 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00019
00020 TAO_CEC_EventChannel::
00021 TAO_CEC_EventChannel (const TAO_CEC_EventChannel_Attributes& attr,
00022 TAO_CEC_Factory* factory,
00023 int own_factory)
00024 : supplier_poa_ (PortableServer::POA::_duplicate (attr.supplier_poa)),
00025 consumer_poa_ (PortableServer::POA::_duplicate (attr.consumer_poa)),
00026 factory_ (factory),
00027 own_factory_ (own_factory),
00028 consumer_reconnect_ (attr.consumer_reconnect),
00029 supplier_reconnect_ (attr.supplier_reconnect),
00030 disconnect_callbacks_ (attr.disconnect_callbacks)
00031 {
00032 if (this->factory_ == 0)
00033 {
00034 this->factory_ =
00035 ACE_Dynamic_Service<TAO_CEC_Factory>::instance ("CEC_Factory");
00036 this->own_factory_ = 0;
00037 ACE_ASSERT (this->factory_ != 0);
00038 }
00039
00040 this->dispatching_ =
00041 this->factory_->create_dispatching (this);
00042 this->pulling_strategy_ =
00043 this->factory_->create_pulling_strategy (this);
00044 this->consumer_admin_ =
00045 this->factory_->create_consumer_admin (this);
00046 this->supplier_admin_ =
00047 this->factory_->create_supplier_admin (this);
00048 this->consumer_control_ =
00049 this->factory_->create_consumer_control (this);
00050 this->supplier_control_ =
00051 this->factory_->create_supplier_control (this);
00052 }
00053
00054 TAO_CEC_EventChannel::~TAO_CEC_EventChannel (void)
00055 {
00056 this->factory_->destroy_dispatching (this->dispatching_);
00057 this->dispatching_ = 0;
00058
00059 this->factory_->destroy_pulling_strategy (this->pulling_strategy_);
00060 this->pulling_strategy_ = 0;
00061
00062 this->factory_->destroy_consumer_admin (this->consumer_admin_);
00063 this->consumer_admin_ = 0;
00064 this->factory_->destroy_supplier_admin (this->supplier_admin_);
00065 this->supplier_admin_ = 0;
00066
00067 this->factory_->destroy_consumer_control (this->consumer_control_);
00068 this->consumer_control_ = 0;
00069 this->factory_->destroy_supplier_control (this->supplier_control_);
00070 this->supplier_control_ = 0;
00071
00072 if (this->own_factory_)
00073 delete this->factory_;
00074 }
00075
00076 void
00077 TAO_CEC_EventChannel::activate (void)
00078 {
00079 this->dispatching_->activate ();
00080 this->pulling_strategy_->activate ();
00081 this->consumer_control_->activate ();
00082 this->supplier_control_->activate ();
00083 }
00084
00085 void
00086 TAO_CEC_EventChannel::shutdown (void)
00087 {
00088 this->dispatching_->shutdown ();
00089 this->pulling_strategy_->shutdown ();
00090 this->supplier_control_->shutdown ();
00091 this->consumer_control_->shutdown ();
00092
00093 PortableServer::POA_var consumer_poa =
00094 this->consumer_admin_->_default_POA ();
00095 PortableServer::ObjectId_var consumer_id =
00096 consumer_poa->servant_to_id (this->consumer_admin_);
00097 consumer_poa->deactivate_object (consumer_id.in ());
00098
00099 PortableServer::POA_var supplier_poa =
00100 this->supplier_admin_->_default_POA ();
00101 PortableServer::ObjectId_var supplier_id =
00102 supplier_poa->servant_to_id (this->supplier_admin_);
00103 supplier_poa->deactivate_object (supplier_id.in ());
00104
00105 this->supplier_admin_->shutdown ();
00106
00107 this->consumer_admin_->shutdown ();
00108 }
00109
00110 void
00111 TAO_CEC_EventChannel::connected (TAO_CEC_ProxyPushConsumer* consumer)
00112 {
00113 this->supplier_admin_->connected (consumer);
00114 }
00115
00116 void
00117 TAO_CEC_EventChannel::reconnected (TAO_CEC_ProxyPushConsumer* consumer)
00118 {
00119 this->supplier_admin_->reconnected (consumer);
00120 }
00121
00122 void
00123 TAO_CEC_EventChannel::disconnected (TAO_CEC_ProxyPushConsumer* consumer)
00124 {
00125 this->supplier_admin_->disconnected (consumer);
00126 }
00127
00128 void
00129 TAO_CEC_EventChannel::connected (TAO_CEC_ProxyPullConsumer* consumer)
00130 {
00131 this->supplier_admin_->connected (consumer);
00132 }
00133
00134 void
00135 TAO_CEC_EventChannel::reconnected (TAO_CEC_ProxyPullConsumer* consumer)
00136 {
00137 this->supplier_admin_->reconnected (consumer);
00138 }
00139
00140 void
00141 TAO_CEC_EventChannel::disconnected (TAO_CEC_ProxyPullConsumer* consumer)
00142 {
00143 this->supplier_admin_->disconnected (consumer);
00144 }
00145
00146 void
00147 TAO_CEC_EventChannel::connected (TAO_CEC_ProxyPushSupplier* supplier)
00148 {
00149 this->consumer_admin_->connected (supplier);
00150 }
00151
00152 void
00153 TAO_CEC_EventChannel::reconnected (TAO_CEC_ProxyPushSupplier* supplier)
00154 {
00155 this->consumer_admin_->reconnected (supplier);
00156 }
00157
00158 void
00159 TAO_CEC_EventChannel::disconnected (TAO_CEC_ProxyPushSupplier* supplier)
00160 {
00161 this->consumer_admin_->disconnected (supplier);
00162 }
00163
00164 void
00165 TAO_CEC_EventChannel::connected (TAO_CEC_ProxyPullSupplier* supplier)
00166 {
00167 this->consumer_admin_->connected (supplier);
00168 }
00169
00170 void
00171 TAO_CEC_EventChannel::reconnected (TAO_CEC_ProxyPullSupplier* supplier)
00172 {
00173 this->consumer_admin_->reconnected (supplier);
00174 }
00175
00176 void
00177 TAO_CEC_EventChannel::disconnected (TAO_CEC_ProxyPullSupplier* supplier)
00178 {
00179 this->consumer_admin_->disconnected (supplier);
00180 }
00181
00182 CosEventChannelAdmin::ConsumerAdmin_ptr
00183 TAO_CEC_EventChannel::for_consumers (void)
00184 {
00185 return this->consumer_admin_->_this ();
00186 }
00187
00188 CosEventChannelAdmin::SupplierAdmin_ptr
00189 TAO_CEC_EventChannel::for_suppliers (void)
00190 {
00191 return this->supplier_admin_->_this ();
00192 }
00193
00194 void
00195 TAO_CEC_EventChannel::destroy (void)
00196 {
00197 this->shutdown ();
00198 }
00199
00200 CORBA::Policy_ptr TAO_CEC_EventChannel::create_roundtrip_timeout_policy
00201 (const ACE_Time_Value &timeout)
00202 {
00203 return this->factory_->create_roundtrip_timeout_policy (timeout);
00204 }
00205
00206 TAO_END_VERSIONED_NAMESPACE_DECL